波段定时消费功能
diff --git a/app/src/main/java/com/supwisdom/activities/consume/ConsumeActivity.kt b/app/src/main/java/com/supwisdom/activities/consume/ConsumeActivity.kt
index 3a336af..e945e80 100644
--- a/app/src/main/java/com/supwisdom/activities/consume/ConsumeActivity.kt
+++ b/app/src/main/java/com/supwisdom/activities/consume/ConsumeActivity.kt
@@ -20,6 +20,7 @@
 import com.supwisdom.activities.transdtl.TransdtlActivity
 import com.supwisdom.auxscreen.AuxScreenController
 import com.supwisdom.entity.PayStatus
+import com.supwisdom.entity.PeriodFixPayRecord
 import com.supwisdom.entity.ReversalFlag
 import com.supwisdom.entity.TransdtlUnionRecord
 import com.supwisdom.utils.CommonUtil
@@ -55,6 +56,7 @@
     private lateinit var vLastPayFailreason: TextView
     private lateinit var vLastPayFailll: LinearLayout
     private lateinit var vLastPayamtll: LinearLayout
+    private val pos = SPApplication.getInstance().getPos()
     private var beepManager: BeepManager? = null
     private val scanLock = ReentrantLock()
     @Volatile
@@ -73,6 +75,8 @@
     private var counter: LastPayShowTimer? = null
     private var lastPayInfo: CardUserInfoBean? = null
     private var dialogPurchase: DialogPurchase? = null
+    private var periodFixPayList: List<PeriodFixPayRecord>? = null
+    private var periodFixPayEnable = false
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
@@ -316,22 +320,23 @@
 
     private var lastshowtime: String? = null
     override fun clearUserInfo(datetime: String) {
-        if (!isBackRunning) {
-            vCitizenName.text = null
-            vCitizenCardno.text = null
-            vCardstatus.text = null
-            val tmptime = datetime.substring(0, 16)
-            if (lastshowtime != tmptime) {
-                lastshowtime = tmptime
-                vTime.text = tmptime
-                AuxScreenController.getInstance().refreshBottom(tmptime)
+        vCitizenName.text = null
+        vCitizenCardno.text = null
+        vCardstatus.text = null
+        val tmptime = datetime.substring(0, 16)
+        if (lastshowtime != tmptime) {
+            lastshowtime = tmptime
+            vTime.text = tmptime
+            AuxScreenController.getInstance().refreshBottom(tmptime)
+            if (periodFixPayEnable) {
+                parsePeriodFixPay()
             }
-            if (dialogPurchase!!.isShowing &&
-                !dialogPurchase!!.isFixPay &&
-                payStatusEnable
-            ) {
-                beepManager!!.playBeepSoundAndVibrate()
-            }
+        }
+        if (dialogPurchase!!.isShowing &&
+            !dialogPurchase!!.isFixPay &&
+            payStatusEnable
+        ) {
+            beepManager!!.playBeepSoundAndVibrate()
         }
     }
 
@@ -366,7 +371,7 @@
     private fun refresh() {
         addAmount = 0
         amountTxt.text = "0"
-        var shopname = SPApplication.getInstance().getPos().getDynamicPara()!!.shopname
+        var shopname = pos.getDynamicPara()!!.shopname
         if (shopname == null || shopname.length < 9) {
             vShopname.textSize = resources.getDimension(R.dimen.consume_shopname_text_size_normal)
         } else {
@@ -382,28 +387,31 @@
         AuxScreenController.getInstance().refreshBottom(DateUtil.getNowDateTime().substring(0, 16))
         AuxScreenController.getInstance().refreshContent(Arrays.asList(" 欢迎光临!", " 请刷卡..."))
 
-        SPApplication.getInstance().getPos().getControlPara(PublicDef.CONTROL_FIXAMT)?.also { mode ->
+        periodFixPayEnable = false
+        pos.getControlPara(PublicDef.CONTROL_FIXAMT)?.also { mode ->
             when {
                 mode.paraval == PayMode.HOTKEY.desc -> {
                     presenter.setFixMode(false)
                     payMode = PayMode.HOTKEY
                     hotkeyPayMap.clear()
                     hotkeyPayList.clear()
-                    SPApplication.getInstance().getPos().getHotkeyPay()?.forEach {
+                    pos.getHotkeyPay()?.forEach {
                         hotkeyPayMap[it.key] = it.amount
                         hotkeyPayList.add(String.format("按键%d - %.02f元", it.key, it.amount / 100.0f))
                     }
                     AuxScreenController.getInstance().refreshContent(hotkeyPayList)
                 }
+                mode.paraval == PayMode.PERIODFIX.desc -> {
+                    periodFixPayEnable = true
+                    periodFixPayList = pos.getPeriodFixPay()
+                    parsePeriodFixPay()
+                }
                 mode.paraval == PayMode.NORMAL.desc -> {
-                    presenter.setFixMode(false)
-                    payMode = PayMode.NORMAL
+                    doNormalPay()
                 }
                 else -> {
-                    presenter.setFixMode(true)
-                    payMode = PayMode.FIXPAY
                     try {
-                        checkAmtToPay(Integer.parseInt(mode.paraval))
+                        doFixPay(Integer.parseInt(mode.paraval))
                     } catch (ex: Exception) {
                         ex.printStackTrace()
                     }
@@ -412,6 +420,33 @@
         }
     }
 
+    private fun parsePeriodFixPay() {
+        val nowtime = DateUtil.getNowTimeNoFormat().substring(0, 4)
+        periodFixPayList?.forEach {
+            if (it.beginTime!! <= nowtime && nowtime < it.endTime!!) {
+                if (payMode != PayMode.FIXPAY) {
+                    doFixPay(it.amount)
+                }
+                return
+            }
+        }
+        if (payMode != PayMode.NORMAL) {
+            doNormalPay()
+        }
+    }
+
+    private fun doFixPay(fixamt: Int) {
+        presenter.setFixMode(true)
+        payMode = PayMode.FIXPAY
+        checkAmtToPay(fixamt)
+    }
+
+    private fun doNormalPay() {
+		amount = 0
+        presenter.setFixMode(false)
+        payMode = PayMode.NORMAL
+    }
+
     override fun refreshLinkStatus(isOnline: Boolean) {
         if (isOnline) {
             vLinkLogo.setImageDrawable(getDrawable(R.drawable.wireless_on))
diff --git a/app/src/main/java/com/supwisdom/activities/consume/ConsumePresenter.kt b/app/src/main/java/com/supwisdom/activities/consume/ConsumePresenter.kt
index 4c8340c..4be4346 100644
--- a/app/src/main/java/com/supwisdom/activities/consume/ConsumePresenter.kt
+++ b/app/src/main/java/com/supwisdom/activities/consume/ConsumePresenter.kt
@@ -137,5 +137,6 @@
 enum class PayMode(val desc: String) {
     NORMAL("none"),
     FIXPAY("fixpay"),
-    HOTKEY("hotkey")
+    HOTKEY("hotkey"),
+    PERIODFIX("periodfix")
 }
\ No newline at end of file
diff --git a/app/src/main/java/com/supwisdom/activities/consume/mode/CardPayService.kt b/app/src/main/java/com/supwisdom/activities/consume/mode/CardPayService.kt
index 5266df9..11f8580 100644
--- a/app/src/main/java/com/supwisdom/activities/consume/mode/CardPayService.kt
+++ b/app/src/main/java/com/supwisdom/activities/consume/mode/CardPayService.kt
@@ -113,6 +113,7 @@
                         readCard()
                         cardBean!!.cardphyid = cardphyid
                         oldcardphyid = cardphyid
+                        operation = true
                     }
                     when (clickStat) {
                         ClickStat.PAY -> {
diff --git a/app/src/main/java/com/supwisdom/activities/consumeMode/ConsumeModeActivity.kt b/app/src/main/java/com/supwisdom/activities/consumeMode/ConsumeModeActivity.kt
index 3daaf82..eaf5482 100644
--- a/app/src/main/java/com/supwisdom/activities/consumeMode/ConsumeModeActivity.kt
+++ b/app/src/main/java/com/supwisdom/activities/consumeMode/ConsumeModeActivity.kt
@@ -3,12 +3,10 @@
 import android.annotation.SuppressLint
 import android.os.Bundle
 import android.os.CountDownTimer
+import android.text.TextUtils
 import android.view.KeyEvent
 import android.view.View
-import android.widget.EditText
-import android.widget.LinearLayout
-import android.widget.RadioButton
-import android.widget.TextView
+import android.widget.*
 import com.supwisdom.R
 import com.supwisdom.activities.BaseActivity
 import com.supwisdom.activities.SPApplication
@@ -16,6 +14,7 @@
 import com.supwisdom.activities.menu.MenuActivity
 import com.supwisdom.auxscreen.AuxScreenController
 import com.supwisdom.entity.HotKeyPayRecord
+import com.supwisdom.entity.PeriodFixPayRecord
 import com.supwisdom.utils.CommonUtil
 import com.supwisdom.utils.DateUtil
 import com.supwisdom.utils.PublicDef
@@ -29,17 +28,20 @@
  **/
 class ConsumeModeActivity : BaseActivity() {
     private lateinit var vPayamt: TextView
-    private lateinit var vNormalMode: TextView
-    private lateinit var vFixMode: TextView
-    private lateinit var vHotkeyMode: TextView
-    private lateinit var llHotList: LinearLayout
+    private lateinit var vSpecialDesc: TextView
+    private lateinit var rbHotkeyMode: RadioButton
+    private lateinit var rbPeriodMode: RadioButton
+    private lateinit var rgSpecialMode: RadioGroup
+    private lateinit var llSpecialList: LinearLayout
     private lateinit var llFixMode: LinearLayout
-    private lateinit var llHotMode: LinearLayout
+    private lateinit var llSpecialMode: LinearLayout
     private val pos = SPApplication.getInstance().getPos()
     private var keyActive = true
     private var shoppwdPass = false
-    private var hotkey = false
+    private var specialMode = false
     private var tmpPwd = ""
+    private var configMode = ConfigMode.NORMAL_FIX
+
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
@@ -49,83 +51,183 @@
     }
 
     private fun initData() {
-        pos.getHotkeyPay()?.forEach {
-            val item = View.inflate(this, R.layout.item_hotkey_pay, null)
-            item.findViewById<TextView>(R.id.tv_hot_del).setOnClickListener {
-                llHotList.removeView(item)
-                for (loop in 0 until llHotList.childCount) {
-                    val item = llHotList.getChildAt(loop)
-                    val key = item.findViewById<TextView>(R.id.tv_hot_key)
-                    key.text = "${(loop + 1)}"
-                }
-            }
-            val key = item.findViewById<TextView>(R.id.tv_hot_key)
-            key.text = "${llHotList.childCount + 1}"
-            val amt = item.findViewById<TextView>(R.id.tv_hot_amount)
-            amt.text = String.format("%.02f", it.amount / 100.0f)
-            llHotList.addView(item)
-        }
+
     }
 
     private fun initView() {
         vPayamt = findViewById<TextView>(R.id.tv_consume_mode_payamt)
-        llHotList = findViewById<LinearLayout>(R.id.ll_hot_list)
+        llSpecialList = findViewById<LinearLayout>(R.id.ll_special_list)
         this.findViewById<TextView>(R.id.tv_hot_add).setOnClickListener {
-            if (llHotList.childCount >= 9) {
+            if (llSpecialList.childCount >= 9) {
                 return@setOnClickListener
             }
+            if (configMode == ConfigMode.PERIOD_FIX) {
+                addPeriodFixRule()
+            } else {
+                addHotkeyRule()
+            }
+        }
+        this.findViewById<TextView>(R.id.tv_hot_save).setOnClickListener {
+            if (llSpecialList.childCount == 0) {
+                SWToast.show(applicationContext, "请先添加规则", PublicDef.TOAST_SHOW_DOUBT)
+                return@setOnClickListener
+            }
+            if (configMode == ConfigMode.PERIOD_FIX) {
+                if (!savePeriodFixRule()) {
+                    return@setOnClickListener
+                }
+            } else {
+                if (!saveHotkeyRule()) {
+                    return@setOnClickListener
+                }
+            }
+            finish()
+        }
+        this.findViewById<TextView>(R.id.tv_return).setOnClickListener {
+            showCurrentMode(ConfigMode.NORMAL_FIX)
+            refreshToSetAmount()
+        }
+        rgSpecialMode = this.findViewById<RadioGroup>(R.id.rg_special_mode)
+        rgSpecialMode.setOnCheckedChangeListener { _, checkedId ->
+            when (checkedId) {
+                R.id.rb_hot_mode -> showCurrentMode(ConfigMode.HOT_KEY)
+                R.id.rb_period_fix_mode -> showCurrentMode(ConfigMode.PERIOD_FIX)
+            }
+        }
+        rbPeriodMode = this.findViewById<RadioButton>(R.id.rb_period_fix_mode)
+        rbHotkeyMode = this.findViewById<RadioButton>(R.id.rb_hot_mode)
+
+        llFixMode = this.findViewById<LinearLayout>(R.id.ll_fix_mode)
+        llSpecialMode = this.findViewById<LinearLayout>(R.id.ll_hot_mode)
+
+        vSpecialDesc = this.findViewById<TextView>(R.id.tv_special_desc)
+    }
+
+    private fun addHotkeyRule() {
+        val item = View.inflate(this, R.layout.item_hotkey_pay, null)
+        item.findViewById<TextView>(R.id.tv_hot_del).setOnClickListener {
+            llSpecialList.removeView(item)
+            for (loop in 0 until llSpecialList.childCount) {
+                val item = llSpecialList.getChildAt(loop)
+                val key = item.findViewById<TextView>(R.id.tv_hot_key)
+                key.text = "${(loop + 1)}"
+            }
+        }
+        val key = item.findViewById<TextView>(R.id.tv_hot_key)
+        key.text = "${llSpecialList.childCount + 1}"
+        llSpecialList.addView(item)
+    }
+
+    private fun addPeriodFixRule() {
+        val item = View.inflate(this, R.layout.item_period_fix_pay, null)
+        item.findViewById<TextView>(R.id.tv_del).setOnClickListener {
+            llSpecialList.removeView(item)
+            for (loop in 0 until llSpecialList.childCount) {
+                val item = llSpecialList.getChildAt(loop)
+                val key = item.findViewById<TextView>(R.id.tv_config)
+                key.text = "规则${(loop + 1)}:"
+            }
+        }
+        val key = item.findViewById<TextView>(R.id.tv_config)
+        key.text = "规则${llSpecialList.childCount + 1}:"
+        llSpecialList.addView(item)
+    }
+
+    private fun saveHotkeyRule(): Boolean {
+        val list = ArrayList<HotKeyPayRecord>()
+        for (loop in 0 until llSpecialList.childCount) {
+            val record = HotKeyPayRecord()
+            val item = llSpecialList.getChildAt(loop)
+            var temp = item.findViewById<TextView>(R.id.tv_hot_key)
+            record.key = Integer.parseInt(temp.text.toString())
+            temp = item.findViewById<EditText>(R.id.tv_hot_amount)
+            record.amount = CommonUtil.YuanToFen(java.lang.Double.parseDouble(CommonUtil.getEditView(temp)))
+            list.add(record)
+        }
+        pos.replaceControlPara(PublicDef.CONTROL_FIXAMT, PayMode.HOTKEY.desc)
+        if (!pos.saveHotkeyPay(list)) {
+            SWToast.show(applicationContext, "保持配置失败", PublicDef.TOAST_SHOW_CRY)
+            return false
+        }
+        return true
+    }
+
+    private fun savePeriodFixRule(): Boolean {
+        val list = ArrayList<PeriodFixPayRecord>()
+        for (loop in 0 until llSpecialList.childCount) {
+            val record = PeriodFixPayRecord()
+            val item = llSpecialList.getChildAt(loop)
+            record.beginTime = CommonUtil.getEditView(item.findViewById<EditText>(R.id.tv_period_start))
+            record.endTime = CommonUtil.getEditView(item.findViewById<EditText>(R.id.tv_period_end))
+            val temp = item.findViewById<EditText>(R.id.tv_amount)
+            record.amount = CommonUtil.YuanToFen(java.lang.Double.parseDouble(CommonUtil.getEditView(temp)))
+            if (TextUtils.isEmpty(record.beginTime) || TextUtils.isEmpty(record.endTime)) {
+                SWToast.show(applicationContext, "时间段不为空", PublicDef.TOAST_SHOW_CRY)
+                return false
+            }
+            if (record.beginTime!!.length != 4 || record.endTime!!.length != 4) {
+                SWToast.show(applicationContext, "时间段长度不对", PublicDef.TOAST_SHOW_CRY)
+                return false
+            }
+            if (!("0000" <= record.beginTime!! && record.beginTime!! < record.endTime!! && record.endTime!! <= "2400")) {
+                SWToast.show(applicationContext, "时间段不合法", PublicDef.TOAST_SHOW_CRY)
+                return false
+            }
+            list.add(record)
+        }
+        pos.replaceControlPara(PublicDef.CONTROL_FIXAMT, PayMode.PERIODFIX.desc)
+        if (!pos.savePeriodFixPay(list)) {
+            SWToast.show(applicationContext, "保持配置失败", PublicDef.TOAST_SHOW_CRY)
+            return false
+        }
+        return true
+    }
+
+    private fun loadHotkeyRule() {
+        llSpecialList.removeAllViews()
+        pos.getHotkeyPay()?.forEach {
             val item = View.inflate(this, R.layout.item_hotkey_pay, null)
             item.findViewById<TextView>(R.id.tv_hot_del).setOnClickListener {
-                llHotList.removeView(item)
-                for (loop in 0 until llHotList.childCount) {
-                    val item = llHotList.getChildAt(loop)
+                llSpecialList.removeView(item)
+                for (loop in 0 until llSpecialList.childCount) {
+                    val item = llSpecialList.getChildAt(loop)
                     val key = item.findViewById<TextView>(R.id.tv_hot_key)
                     key.text = "${(loop + 1)}"
                 }
             }
             val key = item.findViewById<TextView>(R.id.tv_hot_key)
-            key.text = "${llHotList.childCount + 1}"
-            llHotList.addView(item)
+            key.text = "${llSpecialList.childCount + 1}"
+            val amt = item.findViewById<TextView>(R.id.tv_hot_amount)
+            amt.text = String.format("%.02f", it.amount / 100.0f)
+            llSpecialList.addView(item)
         }
-        this.findViewById<TextView>(R.id.tv_hot_save).setOnClickListener {
-            if (llHotList.childCount == 0) {
-                SWToast.show(applicationContext, "请先添加热键", PublicDef.TOAST_SHOW_DOUBT)
-                return@setOnClickListener
-            }
-            val list = ArrayList<HotKeyPayRecord>()
-            for (loop in 0 until llHotList.childCount) {
-                val item = llHotList.getChildAt(loop)
-                val key = item.findViewById<TextView>(R.id.tv_hot_key)
-                val keyboard = key.text.toString()
-                val amt = item.findViewById<EditText>(R.id.tv_hot_amount)
-                val hotamt = CommonUtil.getEditView(amt)
-
-                val record = HotKeyPayRecord()
-                record.key = Integer.parseInt(keyboard)
-                record.amount = CommonUtil.YuanToFen(java.lang.Double.parseDouble(hotamt))
-                list.add(record)
-            }
-            pos.replaceControlPara(PublicDef.CONTROL_FIXAMT, PayMode.HOTKEY.desc)
-            if (!pos.saveHotkeyPay(list)) {
-                SWToast.show(applicationContext, "保持热键失败", PublicDef.TOAST_SHOW_CRY)
-                return@setOnClickListener
-            }
-            finish()
-        }
-        this.findViewById<TextView>(R.id.tv_return).setOnClickListener {
-            hotkey = false
-            llHotMode.visibility = View.GONE
-            llFixMode.visibility = View.VISIBLE
-            refreshToSetAmount()
-        }
-        vNormalMode = this.findViewById<RadioButton>(R.id.rb_normal_mode)
-        vFixMode = this.findViewById<RadioButton>(R.id.rb_fix_mode)
-        vHotkeyMode = this.findViewById<RadioButton>(R.id.rb_hot_mode)
-
-        llFixMode = this.findViewById<LinearLayout>(R.id.ll_fix_mode)
-        llHotMode = this.findViewById<LinearLayout>(R.id.ll_hot_mode)
     }
 
+    private fun loadPeriodFixRule() {
+        llSpecialList.removeAllViews()
+        pos.getPeriodFixPay()?.forEach {
+            val item = View.inflate(this, R.layout.item_period_fix_pay, null)
+            item.findViewById<TextView>(R.id.tv_del).setOnClickListener {
+                llSpecialList.removeView(item)
+                for (loop in 0 until llSpecialList.childCount) {
+                    val item = llSpecialList.getChildAt(loop)
+                    val key = item.findViewById<TextView>(R.id.tv_config)
+                    key.text = "规则${(loop + 1)}:"
+                }
+            }
+            val beginTime = item.findViewById<EditText>(R.id.tv_period_start)
+            beginTime.setText(it.beginTime)
+            val endTime = item.findViewById<EditText>(R.id.tv_period_end)
+            endTime.setText(it.endTime)
+            val amt = item.findViewById<EditText>(R.id.tv_amount)
+            amt.setText(String.format("%.02f", it.amount / 100.0f))
+            val key = item.findViewById<TextView>(R.id.tv_config)
+            key.text = "规则${llSpecialList.childCount + 1}:"
+            llSpecialList.addView(item)
+        }
+    }
+
+
     @SuppressLint("SetTextI18n")
     override fun dispatchKeyEvent(event: KeyEvent): Boolean {
         if (event.action == KeyEvent.ACTION_DOWN) {
@@ -145,13 +247,41 @@
     override fun onResume() {
         super.onResume()
         shoppwdPass = false
-        hotkey = false
         keyActive = true
-        llFixMode.visibility = View.VISIBLE
-        llHotMode.visibility = View.GONE
+        showCurrentMode(ConfigMode.NORMAL_FIX)
         refreshToCheckPasswd()
     }
 
+    private fun showCurrentMode(mode: ConfigMode) {
+        configMode = mode
+        when (mode) {
+            ConfigMode.HOT_KEY -> {
+                specialMode = true
+                rgSpecialMode.visibility = View.VISIBLE
+                rbHotkeyMode.isChecked = true
+                llFixMode.visibility = View.GONE
+                llSpecialMode.visibility = View.VISIBLE
+                vSpecialDesc.text = "设置快捷按键(单位:元)"
+                loadHotkeyRule()
+            }
+            ConfigMode.PERIOD_FIX -> {
+                specialMode = true
+                rbPeriodMode.isChecked = true
+                rgSpecialMode.visibility = View.VISIBLE
+                llFixMode.visibility = View.GONE
+                llSpecialMode.visibility = View.VISIBLE
+                vSpecialDesc.text = "设置波段定额(单位:元)"
+                loadPeriodFixRule()
+            }
+            else -> {
+                rgSpecialMode.visibility = View.GONE
+                llSpecialMode.visibility = View.GONE
+                llFixMode.visibility = View.VISIBLE
+                specialMode = false
+            }
+        }
+    }
+
     private fun checkShopPwd(keyCode: Int) {
         when (keyCode) {
             KeyEvent.KEYCODE_0,
@@ -203,7 +333,7 @@
     }
 
     private fun setFixAmount(keyCode: Int) {
-        if (hotkey) {
+        if (specialMode) {
             AuxScreenController.getInstance().refreshContent(Arrays.asList<String>("请到大屏设置"))
             return
         }
@@ -227,9 +357,7 @@
             }
             KeyEvent.KEYCODE_DPAD_LEFT -> {
                 //F1
-                hotkey = true
-                llHotMode.visibility = View.VISIBLE
-                llFixMode.visibility = View.GONE
+                showCurrentMode(ConfigMode.HOT_KEY)
                 AuxScreenController.getInstance().refreshContent(Arrays.asList<String>("请到大屏设置"))
             }
         }
@@ -244,11 +372,23 @@
     private fun refreshToSetAmount() {
         vPayamt.text = PayMode.NORMAL.desc
         pos.getControlPara(PublicDef.CONTROL_FIXAMT)?.also {
-            if (PayMode.FIXPAY.desc == it.paraval) {
-                vPayamt.text = String.format("%.02f", Integer.parseInt(it.paraval) / 100.0f)
+            when {
+                PayMode.FIXPAY.desc == it.paraval -> {
+                    vPayamt.text = String.format("%.02f", Integer.parseInt(it.paraval) / 100.0f)
+                    screenShowAmt()
+                }
+                PayMode.HOTKEY.desc == it.paraval -> {
+                    showCurrentMode(ConfigMode.HOT_KEY)
+                    AuxScreenController.getInstance().refreshContent(Arrays.asList<String>("请到大屏设置"))
+                    return
+                }
+                PayMode.PERIODFIX.desc == it.paraval -> {
+                    showCurrentMode(ConfigMode.PERIOD_FIX)
+                    AuxScreenController.getInstance().refreshContent(Arrays.asList<String>("请到大屏设置"))
+                    return
+                }
             }
-        }
-        screenShowAmt()
+        } ?: screenShowAmt()
     }
 
     private fun getFixAmount(): String {
@@ -306,7 +446,7 @@
     }
 
     private fun screenShowAmt() {
-        AuxScreenController.getInstance().refreshTitle("消费模式设置       F1-热键模式")
+        AuxScreenController.getInstance().refreshTitle("消费模式设置       F1-特殊模式")
         AuxScreenController.getInstance().refreshBottom(DateUtil.getNowDateTime())
         AuxScreenController.getInstance().refreshContent(
             Arrays.asList<String>(
@@ -317,10 +457,6 @@
         )
     }
 
-    override fun onDestroy() {
-        super.onDestroy()
-    }
-
     private var counter: ContinuePressTimer? = null
 
     private fun resetCounter(timems: Long) {
@@ -343,4 +479,10 @@
             keyActive = true
         }
     }
+}
+
+enum class ConfigMode {
+    NORMAL_FIX,
+    HOT_KEY,
+    PERIOD_FIX,
 }
\ No newline at end of file
diff --git a/app/src/main/java/com/supwisdom/activities/upgrade/mode/EpayUpgradeApi.kt b/app/src/main/java/com/supwisdom/activities/upgrade/mode/EpayUpgradeApi.kt
index 304a6a7..110f204 100644
--- a/app/src/main/java/com/supwisdom/activities/upgrade/mode/EpayUpgradeApi.kt
+++ b/app/src/main/java/com/supwisdom/activities/upgrade/mode/EpayUpgradeApi.kt
@@ -18,9 +18,8 @@
  * @date 2019/4/9
  * @desc 在线升级
  */
-class EpayUpgradeApi constructor(callbackInterface: CallbackInterface) {
+class EpayUpgradeApi constructor(private val callback: CallbackInterface) {
     private val TIMEOUT = 5 * 1000// 超时
-    private val callback = callbackInterface
     private val POSID = "posa711dali"
 
     fun upgrade(devphyid: String, version: String) {
diff --git a/app/src/main/java/com/supwisdom/db/BeanPropEnum.kt b/app/src/main/java/com/supwisdom/db/BeanPropEnum.kt
index 1c90e59..0112dfc 100644
--- a/app/src/main/java/com/supwisdom/db/BeanPropEnum.kt
+++ b/app/src/main/java/com/supwisdom/db/BeanPropEnum.kt
@@ -114,4 +114,10 @@
         key,
         amount
     }
+    enum class PeriodFixPay{
+        id,
+        begintime,
+        endtime,
+        amount
+    }
 }
\ No newline at end of file
diff --git a/app/src/main/java/com/supwisdom/db/DBParaHelper.kt b/app/src/main/java/com/supwisdom/db/DBParaHelper.kt
index 4862731..8a0f51d 100644
--- a/app/src/main/java/com/supwisdom/db/DBParaHelper.kt
+++ b/app/src/main/java/com/supwisdom/db/DBParaHelper.kt
@@ -13,13 +13,14 @@
 class DBParaHelper private constructor(context: Context) : SQLiteOpenHelper(context, DB_NAME, null, VERSION) {
     companion object {
         private val DB_NAME = "db_para"
-        private val VERSION = 1
+        private val VERSION = 2
 
         val TABLE_NAME_SYSPARA = "tb_syspara"
         val TABLE_NAME_DYNAMICPARA = "tb_dynamicpara"
         val TABLE_NAME_CONTROLPARA = "tb_controlpara"
         val TABLE_NAME_WHITELIST = "tb_whitelist"
         val TABLE_NAME_HOTKEY = "tb_hotkey"
+        val TABLE_NAME_PERIOD_FIX = "tb_period_fix"
 
         private var instance: DBParaHelper? = null
         fun getInstance(context: Context): DBParaHelper {
@@ -38,9 +39,15 @@
     /**
      * SQL for create table
      */
+    private val CREATE_TABLE_NAME_PERIOD_FIX = ("create table IF NOT EXISTS "
+            + TABLE_NAME_PERIOD_FIX + " ( "
+            + BeanPropEnum.PeriodFixPay.id + " integer primary key autoincrement,"
+            + BeanPropEnum.PeriodFixPay.begintime + " varchar(4),"
+            + BeanPropEnum.PeriodFixPay.endtime + " varchar(4),"
+            + BeanPropEnum.PeriodFixPay.amount + " integer )")
     private val CREATE_TABLE_NAME_HOTKEY = ("create table IF NOT EXISTS "
             + TABLE_NAME_HOTKEY + " ( "
-            + BeanPropEnum.HotkeyPay.key + " integer primary key,"
+            + BeanPropEnum.HotkeyPay.key + " long primary key,"
             + BeanPropEnum.HotkeyPay.amount + " integer)")
     private val CREATE_TABLE_NAME_WHITELIST = ("create table IF NOT EXISTS "
             + TABLE_NAME_WHITELIST + " ( "
@@ -99,12 +106,13 @@
         db.execSQL(CREATE_TABLE_NAME_CONTROLPARA)
         db.execSQL(CREATE_TABLE_NAME_WHITELIST)
         db.execSQL(CREATE_TABLE_NAME_HOTKEY)
+        db.execSQL(CREATE_TABLE_NAME_PERIOD_FIX)
     }
 
     override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
         if (oldVersion < newVersion) {
             if (oldVersion < 2 && newVersion >= 2) {
-//                db.execSQL("alter table $TABLE_NAME_SYSPARA add column ${BeanPropEnum.Syspara.maxDayOfflineAmt} integer")
+                db.execSQL(CREATE_TABLE_NAME_PERIOD_FIX)
             }
         }
     }
diff --git a/app/src/main/java/com/supwisdom/db/PeriodFixPayDao.kt b/app/src/main/java/com/supwisdom/db/PeriodFixPayDao.kt
new file mode 100644
index 0000000..dce63c0
--- /dev/null
+++ b/app/src/main/java/com/supwisdom/db/PeriodFixPayDao.kt
@@ -0,0 +1,100 @@
+package com.supwisdom.db
+
+import android.content.ContentValues
+import android.content.Context
+import android.database.Cursor
+import com.supwisdom.entity.PeriodFixPayRecord
+import java.util.concurrent.locks.Lock
+
+/**
+ ** create by zzq on 2019/11/20
+ ** @desc
+ **/
+class PeriodFixPayDao constructor(context: Context) {
+    private val dbHelper = DBParaHelper.getInstance(context)
+    private val TABLE = DBParaHelper.TABLE_NAME_PERIOD_FIX
+
+    fun getLock(): Lock {
+        return dbHelper.getLock()
+    }
+
+    fun replace(record: PeriodFixPayRecord): Boolean {
+        val db = dbHelper.readableDatabase
+        val values = getContentValues(record)
+        try {
+            db.beginTransaction()
+            if (db.replace(TABLE, null, values) > 0) {
+                db.setTransactionSuccessful()
+                return true
+            }
+        } finally {
+            db.endTransaction()
+        }
+        return false
+    }
+
+    fun save(list: List<PeriodFixPayRecord>): Boolean {
+        val db = dbHelper.writableDatabase
+        try {
+            db.beginTransaction()
+            if (db.delete(TABLE, null, null) < 0) {
+                return false
+            }
+            list.forEach {
+                val values = getContentValues(it)
+                if (db.insert(TABLE, null, values) <= 0) {
+                    return false
+                }
+            }
+            db.setTransactionSuccessful()
+            return true
+        } finally {
+            db.endTransaction()
+        }
+    }
+
+    fun get(): List<PeriodFixPayRecord>? {
+        val db = dbHelper.readableDatabase
+        var cursor: Cursor? = null
+        try {
+            cursor = db.query(TABLE, null, null, null, null, null, null)
+            val list = ArrayList<PeriodFixPayRecord>()
+            while (cursor != null && cursor.moveToNext()) {
+                list.add(getRecord(cursor))
+            }
+            return list
+        } finally {
+            cursor?.close()
+        }
+    }
+
+    fun clear(): Boolean {
+        val db = dbHelper.writableDatabase
+        try {
+            db.beginTransaction()
+            if (db.delete(TABLE, null, null) < 0) {
+                return false
+            }
+            db.setTransactionSuccessful()
+            return true
+        } finally {
+            db.endTransaction()
+        }
+    }
+
+    private fun getRecord(cursor: Cursor): PeriodFixPayRecord {
+        val record = PeriodFixPayRecord()
+        record.beginTime = cursor.getString(cursor.getColumnIndex(BeanPropEnum.PeriodFixPay.begintime.toString()))
+        record.endTime = cursor.getString(cursor.getColumnIndex(BeanPropEnum.PeriodFixPay.endtime.toString()))
+        record.amount = cursor.getInt(cursor.getColumnIndex(BeanPropEnum.PeriodFixPay.amount.toString()))
+        return record
+    }
+
+    private fun getContentValues(record: PeriodFixPayRecord): ContentValues {
+        val values = ContentValues()
+        values.put(BeanPropEnum.PeriodFixPay.begintime.toString(), record.beginTime)
+        values.put(BeanPropEnum.PeriodFixPay.endtime.toString(), record.endTime)
+        values.put(BeanPropEnum.PeriodFixPay.amount.toString(), record.amount)
+        return values
+    }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/supwisdom/db/Pos.kt b/app/src/main/java/com/supwisdom/db/Pos.kt
index 00ae522..9972af0 100644
--- a/app/src/main/java/com/supwisdom/db/Pos.kt
+++ b/app/src/main/java/com/supwisdom/db/Pos.kt
@@ -18,6 +18,7 @@
     private val controlParaDao = ControlParaDao(context)
     private val whiteListDao = WhiteListDao(context)
     private val hotkeyPayDao = HotkeyPayDao(context)
+    private val periodFixPayDao = PeriodFixPayDao(context)
     private val transdtlOnlineDao = TransdtlOnlineDao(sdContext)
     private val transdtlOfflineDao = TransdtlOfflineDao(sdContext)
     private val transdtlUnionDao = TransdtlUnionDao(sdContext)
@@ -73,6 +74,24 @@
         }
     }
 
+    fun savePeriodFixPay(list: List<PeriodFixPayRecord>): Boolean {
+        try {
+            periodFixPayDao.getLock().lock()
+            return periodFixPayDao.save(list)
+        } finally {
+            periodFixPayDao.getLock().unlock()
+        }
+    }
+
+    fun getPeriodFixPay(): List<PeriodFixPayRecord>? {
+        try {
+            periodFixPayDao.getLock().lock()
+            return periodFixPayDao.get()
+        } finally {
+            periodFixPayDao.getLock().unlock()
+        }
+    }
+
     fun replaceControlPara(record: ControlParaRecord): Boolean {
         try {
             controlParaDao.getLock().lock()
diff --git a/app/src/main/java/com/supwisdom/entity/HotKeyPayRecord.kt b/app/src/main/java/com/supwisdom/entity/HotKeyPayRecord.kt
index 4d8bb24..e3ae7aa 100644
--- a/app/src/main/java/com/supwisdom/entity/HotKeyPayRecord.kt
+++ b/app/src/main/java/com/supwisdom/entity/HotKeyPayRecord.kt
@@ -7,5 +7,4 @@
 class HotKeyPayRecord {
     var key: Int = 0
     var amount: Int = 0
-
 }
\ No newline at end of file
diff --git a/app/src/main/java/com/supwisdom/entity/PeriodFixPayRecord.kt b/app/src/main/java/com/supwisdom/entity/PeriodFixPayRecord.kt
new file mode 100644
index 0000000..abb736f
--- /dev/null
+++ b/app/src/main/java/com/supwisdom/entity/PeriodFixPayRecord.kt
@@ -0,0 +1,11 @@
+package com.supwisdom.entity
+
+/**
+ ** create by zzq on 2019/11/19
+ ** @desc
+ **/
+class PeriodFixPayRecord {
+    var beginTime: String? = null //hhmm
+    var endTime: String? = null //hhmm
+    var amount: Int = 0
+}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_consume_mode.xml b/app/src/main/res/layout/activity_consume_mode.xml
index 653add6..befd0cf 100644
--- a/app/src/main/res/layout/activity_consume_mode.xml
+++ b/app/src/main/res/layout/activity_consume_mode.xml
@@ -8,22 +8,19 @@
                 style="@style/head_title_text_style"
                 android:text="消费模式"/>
         <RadioGroup
+                android:id="@+id/rg_special_mode"
                 android:visibility="gone"
                 android:layout_height="wrap_content"
+                android:weightSum="2"
                 android:layout_width="match_parent"
-                android:orientation="vertical">
-            <RadioButton
-                    android:id="@+id/rb_normal_mode"
-                    android:text="普通消费"
-                    style="@style/consume_mode_rb_style"
-                    android:checked="true"/>
-            <RadioButton
-                    android:id="@+id/rb_fix_mode"
-                    android:text="定额消费"
-                    style="@style/consume_mode_rb_style"/>
+                android:orientation="horizontal">
             <RadioButton
                     android:id="@+id/rb_hot_mode"
-                    android:text="快捷消费"
+                    android:text="按键便捷消费"
+                    style="@style/consume_mode_rb_style"/>
+            <RadioButton
+                    android:id="@+id/rb_period_fix_mode"
+                    android:text="波段定额消费"
                     style="@style/consume_mode_rb_style"/>
         </RadioGroup>
         <LinearLayout
@@ -91,7 +88,7 @@
                 <TextView
                         android:id="@+id/tv_hot_save"
                         android:textSize="25sp"
-                        android:layout_marginLeft="50dp"
+                        android:layout_marginStart="50dp"
                         android:text="保存"
                         android:background="@drawable/corner_bg_blue"
                         android:padding="10dp"
@@ -102,7 +99,7 @@
                         android:id="@+id/tv_hot_add"
                         android:textSize="25sp"
                         android:text="添加"
-                        android:layout_marginLeft="50dp"
+                        android:layout_marginStart="50dp"
                         android:background="@drawable/corner_bg_blue"
                         android:padding="10dp"
                         android:textColor="@color/white"
@@ -110,6 +107,7 @@
                         android:layout_height="wrap_content"/>
             </LinearLayout>
             <TextView
+                    android:id="@+id/tv_special_desc"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:text="快捷消费(单位:元)"
@@ -117,11 +115,10 @@
                     android:textColor="@color/light_blue2"
                     android:textSize="20sp"/>
             <LinearLayout
-                    android:id="@+id/ll_hot_list"
+                    android:id="@+id/ll_special_list"
                     android:layout_width="match_parent"
                     android:orientation="vertical"
                     android:layout_height="match_parent"/>
-
         </LinearLayout>
     </LinearLayout>
 </LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/item_period_fix_pay.xml b/app/src/main/res/layout/item_period_fix_pay.xml
new file mode 100644
index 0000000..0f3f609
--- /dev/null
+++ b/app/src/main/res/layout/item_period_fix_pay.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:orientation="horizontal"
+              android:background="@color/white"
+              android:layout_width="match_parent"
+              android:weightSum="7"
+              android:padding="5dp"
+              android:layout_marginTop="10dp"
+              android:layout_height="match_parent">
+    <TextView
+            android:id="@+id/tv_config"
+            android:layout_height="wrap_content"
+            android:layout_width="0dp"
+            android:layout_weight="1"
+            android:text="规则 1:"
+            android:visibility="gone"
+            android:textColor="@color/light_blue2"
+            android:textSize="25sp"/>
+    <EditText
+            android:id="@+id/tv_period_start"
+            android:layout_height="wrap_content"
+            android:layout_width="0dp"
+            android:inputType="numberDecimal"
+            android:layout_weight="2"
+            android:maxLines="1"
+            android:text="1000"
+            android:textColor="@color/light_blue2"
+            android:textSize="25sp"/>
+    <EditText
+            android:id="@+id/tv_period_end"
+            android:layout_height="wrap_content"
+            android:layout_width="0dp"
+            android:inputType="numberDecimal"
+            android:layout_weight="2"
+            android:maxLines="1"
+            android:text="1430"
+            android:textColor="@color/light_blue2"
+            android:textSize="25sp"/>
+    <EditText
+            android:id="@+id/tv_amount"
+            android:layout_height="wrap_content"
+            android:layout_width="0dp"
+            android:inputType="numberDecimal"
+            android:layout_weight="2"
+            android:maxLines="1"
+            android:text="0"
+            android:textColor="@color/light_blue2"
+            android:textSize="25sp"/>
+    <TextView
+            android:id="@+id/tv_del"
+            android:layout_height="wrap_content"
+            android:layout_width="0dp"
+            android:layout_weight="1"
+            android:text="删除"
+            android:layout_marginStart="10dp"
+            android:gravity="center"
+            android:padding="10dp"
+            android:background="@drawable/corner_bg_blue"
+            android:textColor="@color/white"
+            android:textSize="25sp"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index d85e0af..a1088c5 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -428,7 +428,8 @@
     </style>
     <style name="consume_mode_rb_style">
         <item name="android:layout_height">wrap_content</item>
-        <item name="android:layout_width">match_parent</item>
+        <item name="android:layout_width">0dp</item>
+        <item name="android:layout_weight">1</item>
         <item name="android:textSize">25sp</item>
         <item name="android:textColor">@color/light_blue2</item>
     </style>