Merge branch 'hotfix/1.0.8'
diff --git a/app/src/main/java/com/supwisdom/activities/YktSession.kt b/app/src/main/java/com/supwisdom/activities/YktSession.kt
index 0d01687..2767df0 100644
--- a/app/src/main/java/com/supwisdom/activities/YktSession.kt
+++ b/app/src/main/java/com/supwisdom/activities/YktSession.kt
@@ -39,7 +39,13 @@
 
 
     // 设置通信参数
-    fun setWebAPISession(epayIP: String, epayPort: Int, uri: String, termid: String, commTime: Int) {
+    fun setWebAPISession(
+        epayIP: String,
+        epayPort: Int,
+        uri: String,
+        tenantId: String,
+        commTime: Int
+    ) {
         val sb = StringBuilder()
         if (epayIP.startsWith("http")) {
             sb.append(epayIP)
@@ -50,6 +56,7 @@
 
         mSession!!.setEpayurl(sb.toString())
         NetworkHandler.getInstance().setCommTime(commTime)
+        NetworkHandler.getInstance().setTenantId(tenantId)
     }
 
     // post
diff --git a/app/src/main/java/com/supwisdom/activities/communicate/CommunicateActivity.kt b/app/src/main/java/com/supwisdom/activities/communicate/CommunicateActivity.kt
index e511752..a591170 100644
--- a/app/src/main/java/com/supwisdom/activities/communicate/CommunicateActivity.kt
+++ b/app/src/main/java/com/supwisdom/activities/communicate/CommunicateActivity.kt
@@ -20,6 +20,7 @@
  **/
 class CommunicateActivity : BaseActivity() {
     private val pos = SPApplication.getInstance().getPos()
+    private lateinit var vTenantid: TextView
     private lateinit var vDevphyid: TextView
     private lateinit var vEpayUrl: EditText
     private lateinit var vEpayUri: EditText
@@ -33,6 +34,7 @@
     }
 
     private fun initView() {
+        vTenantid = findViewById<View>(R.id.comm_tenantid) as TextView
         vDevphyid = findViewById<View>(R.id.comm_devphyid) as TextView
         vEpayUrl = findViewById<View>(R.id.comm_epay_url) as EditText
         vEpayUri = findViewById<View>(R.id.comm_epay_uri) as EditText
@@ -83,7 +85,8 @@
 
     private fun initData() {
         val record = pos.getConfigPara()
-        vDevphyid.text = record!!.devphyid
+        vTenantid.text = record!!.tenantId
+        vDevphyid.text = record.devphyid
         vEpayUrl.setText(record.epayIP)
         vEpayUri.setText(record.epayUri)
         vEpayPort.setText(record.epayPort.toString())
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 e7a96e8..5ae2b1a 100644
--- a/app/src/main/java/com/supwisdom/activities/consume/ConsumeActivity.kt
+++ b/app/src/main/java/com/supwisdom/activities/consume/ConsumeActivity.kt
@@ -103,7 +103,8 @@
                         else -> {
                             presenter.clickNoPay()
                             amountTxt.text = ""
-                            AuxScreenController.getInstance().refreshContent(Arrays.asList(" 欢迎光临!", " 请刷卡..."))
+                            AuxScreenController.getInstance()
+                                .refreshContent(Arrays.asList(" 欢迎光临!", " 请刷卡..."))
                         }
                     }
                 }
@@ -292,7 +293,8 @@
                 if (amount > 0) {
                     checkAmtToPay(amount)
                 } else {
-                    AuxScreenController.getInstance().refreshContent(Arrays.asList("请先输入金额:", "金额不能为0"))
+                    AuxScreenController.getInstance()
+                        .refreshContent(Arrays.asList("请先输入金额:", "金额不能为0"))
                 }
             }
         }
@@ -390,24 +392,30 @@
         periodFixPayEnable = false
         dialogPurchase?.dismiss()
         pos.getControlPara(PublicDef.CONTROL_FIXAMT)?.also { mode ->
-            when {
-                mode.paraval == PayMode.HOTKEY.desc -> {
+            when (mode.paraval) {
+                PayMode.HOTKEY.desc -> {
                     presenter.setFixMode(false)
                     payMode = PayMode.HOTKEY
                     hotkeyPayMap.clear()
                     hotkeyPayList.clear()
                     pos.getHotkeyPay()?.forEach {
                         hotkeyPayMap[it.key] = it.amount
-                        hotkeyPayList.add(String.format("按键%d - %.02f元", it.key, it.amount / 100.0f))
+                        hotkeyPayList.add(
+                            String.format(
+                                "按键%d - %.02f元",
+                                it.key,
+                                it.amount / 100.0f
+                            )
+                        )
                     }
                     AuxScreenController.getInstance().refreshContent(hotkeyPayList)
                 }
-                mode.paraval == PayMode.PERIODFIX.desc -> {
+                PayMode.PERIODFIX.desc -> {
                     periodFixPayEnable = true
                     periodFixPayList = pos.getPeriodFixPay()
                     parsePeriodFixPay()
                 }
-                mode.paraval == PayMode.NORMAL.desc -> {
+                PayMode.NORMAL.desc -> {
                     doNormalPay()
                 }
                 else -> {
@@ -503,7 +511,8 @@
 
     override fun showConsumeFail(info: CardUserInfoBean) {
         dialogPurchase!!.showPayFail(info)
-        AuxScreenController.getInstance().refreshContent(Arrays.asList<String>("消费失败", "原因:", info.retmsg))
+        AuxScreenController.getInstance()
+            .refreshContent(Arrays.asList<String>("消费失败", "原因:", info.retmsg))
         SoundUtil.playMusic(applicationContext, R.raw.consume_fail)
         refreshRecentDtl(info)
     }
@@ -511,14 +520,20 @@
     override fun showReverseSuc(info: CardUserInfoBean) {
         dialogPurchase!!.showReverseSuccess(info)
         AuxScreenController.getInstance()
-            .refreshContent(Arrays.asList<String>(info.retmsg, CommonUtil.showFormatAmount("金额", info.payamt)))
+            .refreshContent(
+                Arrays.asList<String>(
+                    info.retmsg,
+                    CommonUtil.showFormatAmount("金额", info.payamt)
+                )
+            )
         SoundUtil.playMusic(applicationContext, R.raw.reversal_suc)
         refreshRecentDtl(info)
     }
 
     override fun showReverseFail(info: CardUserInfoBean) {
         dialogPurchase!!.showReverseFail(info)
-        AuxScreenController.getInstance().refreshContent(Arrays.asList<String>("冲正失败", "原因:", info.retmsg))
+        AuxScreenController.getInstance()
+            .refreshContent(Arrays.asList<String>("冲正失败", "原因:", info.retmsg))
         SoundUtil.playMusic(applicationContext, R.raw.reversal_fail)
         refreshRecentDtl(info)
     }
@@ -614,17 +629,32 @@
         when (payMode) {
             PayMode.FIXPAY -> {
                 AuxScreenController.getInstance()
-                    .refreshContent(Arrays.asList("定额付款", CommonUtil.showFormatAmount("金额", inputAmt)))
+                    .refreshContent(
+                        Arrays.asList(
+                            "定额付款",
+                            CommonUtil.showFormatAmount("金额", inputAmt)
+                        )
+                    )
                 showDialogPay(true)
             }
             PayMode.HOTKEY -> {
                 AuxScreenController.getInstance()
-                    .refreshContent(Arrays.asList("热键付款", CommonUtil.showFormatAmount("金额", inputAmt)))
+                    .refreshContent(
+                        Arrays.asList(
+                            "热键付款",
+                            CommonUtil.showFormatAmount("金额", inputAmt)
+                        )
+                    )
                 showDialogPay(false)
             }
             else -> {
                 AuxScreenController.getInstance()
-                    .refreshContent(Arrays.asList("等待付款", CommonUtil.showFormatAmount("金额", inputAmt)))
+                    .refreshContent(
+                        Arrays.asList(
+                            "等待付款",
+                            CommonUtil.showFormatAmount("金额", inputAmt)
+                        )
+                    )
                 showDialogPay(false)
             }
         }
@@ -683,7 +713,8 @@
                 )
             )
         } else {
-            AuxScreenController.getInstance().refreshContent(Arrays.asList("输入金额:", amountTxt.text.toString()))
+            AuxScreenController.getInstance()
+                .refreshContent(Arrays.asList("输入金额:", amountTxt.text.toString()))
         }
     }
 
diff --git a/app/src/main/java/com/supwisdom/activities/init/InitActivity.kt b/app/src/main/java/com/supwisdom/activities/init/InitActivity.kt
index 1d773f5..1c83abd 100644
--- a/app/src/main/java/com/supwisdom/activities/init/InitActivity.kt
+++ b/app/src/main/java/com/supwisdom/activities/init/InitActivity.kt
@@ -35,6 +35,7 @@
 class InitActivity : BaseActivity(), IInitView {
     private lateinit var presenter: InitPresenter
     private lateinit var vDevphyid: EditText
+    private lateinit var vTenantId: EditText
     private lateinit var vServerIp: EditText
     private lateinit var vUri: EditText
     private lateinit var vPort: EditText
@@ -63,6 +64,7 @@
         if (record == null) {
             record = ConfigParaRecord()
             record.mode = 0
+            record.tenantId = "schema"
             record.devphyid = "12345678"
             record.epayIP = "127.0.0.1"
             record.epayPort = 8080
@@ -79,7 +81,8 @@
 //            cfgRecord.mode == PublicDef.TERMINAL_THIRD_LOGIN_MODE -> vRadioThirdLoginMode.isChecked = true
 //            else -> vRadioPayMode.isChecked = true
 //        }
-        vDevphyid.setText(cfgRecord!!.devphyid)
+        vTenantId.setText(cfgRecord!!.tenantId)
+        vDevphyid.setText(cfgRecord.devphyid)
         vServerIp.setText(cfgRecord.epayIP)
         vUri.setText(cfgRecord.epayUri)
         vPort.setText(cfgRecord.epayPort.toString())
@@ -101,19 +104,12 @@
 
     private fun initView() {
         this.findViewById<Button>(R.id.tv_settings).setOnClickListener {
-            //            CommonUtil.sendBroadcast(applicationContext, false)
             CommonUtil.startNetSetting(this@InitActivity)
         }
         this.findViewById<TextView>(R.id.btn_save).setOnClickListener {
-            //            val mode = when {
-//                vRadioDepositMode.isChecked -> PublicDef.TERMINAL_DEPOSIT_MODE
-//                vRadioThirdPayMode.isChecked -> PublicDef.TERMINAL_THIRD_PAY_MODE
-//                vRadioThirdLoginMode.isChecked -> PublicDef.TERMINAL_THIRD_LOGIN_MODE
-//                vRadioGateMode.isChecked -> PublicDef.TERMINAL_GATE_MODE
-//                else -> PublicDef.TERMINAL_PAY_MODE
-//            }
             presenter.saveConfigParam(
                 0,
+                CommonUtil.getEditView(vTenantId),
                 CommonUtil.getEditView(vDevphyid), CommonUtil.getEditView(vServerIp),
                 CommonUtil.getEditView(vUri), CommonUtil.getEditView(vPort)
             )
@@ -130,6 +126,7 @@
         vRadioDepositMode = this.findViewById(R.id.rb_deposit_mode) as RadioButton
         vRadioThirdPayMode = this.findViewById(R.id.rb_third_pay_mode) as RadioButton
         vRadioThirdLoginMode = this.findViewById(R.id.rb_third_login_mode) as RadioButton
+        vTenantId = this.findViewById(R.id.tv_tenantid) as EditText
         vDevphyid = this.findViewById(R.id.tv_devphyid) as EditText
         vServerIp = this.findViewById(R.id.tv_server_ip) as EditText
         vUri = this.findViewById(R.id.tv_uri_root) as EditText
@@ -150,7 +147,8 @@
     private fun refresh() {
         AuxScreenController.getInstance().refreshTitle("通讯参数设置")
         AuxScreenController.getInstance().refreshBottom(DateUtil.getNowDateTime())
-        AuxScreenController.getInstance().refreshContent(Arrays.asList("设备第一次使用", "请联系管理员", "在大屏配置参数"))
+        AuxScreenController.getInstance()
+            .refreshContent(Arrays.asList("设备第一次使用", "请联系管理员", "在大屏配置参数"))
     }
 
     private fun asyncGetConfigName() {
@@ -170,16 +168,19 @@
                         vNsdResult.setTextColor(resources.getColor(R.color.light_blue2))
                         if (dialogNsdConfig == null) {
                             dialogNsdConfig = BigSwDialog(this, PublicDef.DIALOG_TYPE_NSD_CONFIG)
-                            val vConfigList = dialogNsdConfig!!.findViewById(R.id.rv_config_list) as RecyclerView
+                            val vConfigList =
+                                dialogNsdConfig!!.findViewById(R.id.rv_config_list) as RecyclerView
                             vConfigList.layoutManager = LinearLayoutManager(this)
                             vConfigList.addItemDecoration(NsdServerConfigAdapter.ItemDecoration(10))
                             nsdConfigAdapter =
-                                NsdServerConfigAdapter(this, object : NsdServerConfigAdapter.ConfigNameListener {
-                                    override fun callback(configName: String) {
-                                        asyncGetConfigFromNsdServer(configName)
-                                        dialogNsdConfig!!.dismiss()
-                                    }
-                                })
+                                NsdServerConfigAdapter(
+                                    this,
+                                    object : NsdServerConfigAdapter.ConfigNameListener {
+                                        override fun callback(configName: String) {
+                                            asyncGetConfigFromNsdServer(configName)
+                                            dialogNsdConfig!!.dismiss()
+                                        }
+                                    })
                             vConfigList.adapter = nsdConfigAdapter
                         }
                         nsdConfigAdapter!!.setList(ret.list)
@@ -201,7 +202,8 @@
     private fun asyncGetConfigFromNsdServer(configName: String) {
         ThreadPool.getShortPool().execute(Runnable {
             try {
-                val ret = NsdClientApi(nsdServiceIp!!, nsdServicePort).getEcardConfigParam(configName)
+                val ret =
+                    NsdClientApi(nsdServiceIp!!, nsdServicePort).getEcardConfigParam(configName)
                 NtpClient().startCalibrateTime(ret.systime)
                 runOnUiThread {
                     vNsdResult.text = ret.retmsg
diff --git a/app/src/main/java/com/supwisdom/activities/init/InitPresenter.kt b/app/src/main/java/com/supwisdom/activities/init/InitPresenter.kt
index 0b46818..dd3b83a 100644
--- a/app/src/main/java/com/supwisdom/activities/init/InitPresenter.kt
+++ b/app/src/main/java/com/supwisdom/activities/init/InitPresenter.kt
@@ -17,10 +17,21 @@
     private val iInitView = iInitView
     private val pos = SPApplication.getInstance().getPos()
 
-    fun saveConfigParam(mode: Int, devphyid: String, serverip: String, uri: String, port: String) {
+    fun saveConfigParam(
+        mode: Int,
+        tenantId: String,
+        devphyid: String,
+        serverip: String,
+        uri: String,
+        port: String
+    ) {
         val record = pos.getConfigPara() ?: ConfigParaRecord()
         record.mode = mode
-        record.devphyid = devphyid
+        if (TextUtils.isEmpty(tenantId)) {
+            iInitView.showSWToastInfo("租户名不能为空!", PublicDef.TOAST_SHOW_DOUBT)
+            return
+        }
+        record.tenantId = tenantId
         if (TextUtils.isEmpty(devphyid)) {
             iInitView.showSWToastInfo("终端机编号不能为空!", PublicDef.TOAST_SHOW_DOUBT)
             return
@@ -68,7 +79,7 @@
             record.epayIP!!,
             record.epayPort,
             record.epayUri!!,
-            record.devphyid!!,
+            record.tenantId!!,
             CommonUtil.getCommunicateTime()
         )
         iInitView.jumpToNextActivity()
diff --git a/app/src/main/java/com/supwisdom/activities/load/LoadPresenter.kt b/app/src/main/java/com/supwisdom/activities/load/LoadPresenter.kt
index 77ba654..823c8ca 100644
--- a/app/src/main/java/com/supwisdom/activities/load/LoadPresenter.kt
+++ b/app/src/main/java/com/supwisdom/activities/load/LoadPresenter.kt
@@ -48,7 +48,7 @@
             cfgRecord!!.epayIP!!,
             cfgRecord.epayPort,
             cfgRecord.epayUri!!,
-            cfgRecord.devphyid!!,
+            cfgRecord.tenantId!!,
             CommonUtil.getCommunicateTime()
         )
 
diff --git a/app/src/main/java/com/supwisdom/activities/syspara/SysparaActivity.kt b/app/src/main/java/com/supwisdom/activities/syspara/SysparaActivity.kt
index 29a5ef9..82d0bf8 100644
--- a/app/src/main/java/com/supwisdom/activities/syspara/SysparaActivity.kt
+++ b/app/src/main/java/com/supwisdom/activities/syspara/SysparaActivity.kt
@@ -40,7 +40,8 @@
         val cfgRecord = pos.getConfigPara()
         val sysRecord = pos.getSysPara()
         val dyRecord = pos.getDynamicPara()
-        kvMap[index++] = ControlParaRecord("物理编号>>", cfgRecord!!.devphyid!!)
+        kvMap[index++] = ControlParaRecord("租户名>>", cfgRecord!!.tenantId!!)
+        kvMap[index++] = ControlParaRecord("物理编号>>", cfgRecord.devphyid!!)
         kvMap[index++] = ControlParaRecord("服务器地址>>", cfgRecord.epayIP!!)
         kvMap[index++] = ControlParaRecord("服务器标识>>", cfgRecord.epayUri!!)
         kvMap[index++] = ControlParaRecord("服务器端口>>", "" + cfgRecord.epayPort)
diff --git a/app/src/main/java/com/supwisdom/db/BeanPropEnum.kt b/app/src/main/java/com/supwisdom/db/BeanPropEnum.kt
index 0112dfc..66047bc 100644
--- a/app/src/main/java/com/supwisdom/db/BeanPropEnum.kt
+++ b/app/src/main/java/com/supwisdom/db/BeanPropEnum.kt
@@ -22,6 +22,7 @@
     enum class ConfigPara {
         id,
         mode,
+        tenantid,
         devphyid,
         psamno,
         epayIP,
diff --git a/app/src/main/java/com/supwisdom/db/ConfigParaDao.kt b/app/src/main/java/com/supwisdom/db/ConfigParaDao.kt
index cce42b8..1b7df2d 100644
--- a/app/src/main/java/com/supwisdom/db/ConfigParaDao.kt
+++ b/app/src/main/java/com/supwisdom/db/ConfigParaDao.kt
@@ -75,6 +75,7 @@
     private fun getRecord(cursor: Cursor): ConfigParaRecord {
         val record = ConfigParaRecord()
         record.mode = cursor.getInt(cursor.getColumnIndex(BeanPropEnum.ConfigPara.mode.toString()))
+        record.tenantId = cursor.getString(cursor.getColumnIndex(BeanPropEnum.ConfigPara.tenantid.toString()))
         record.devphyid = cursor.getString(cursor.getColumnIndex(BeanPropEnum.ConfigPara.devphyid.toString()))
         record.epayIP = cursor.getString(cursor.getColumnIndex(BeanPropEnum.ConfigPara.epayIP.toString()))
         record.epayPort = cursor.getInt(cursor.getColumnIndex(BeanPropEnum.ConfigPara.epayPort.toString()))
@@ -103,6 +104,7 @@
         val values = ContentValues()
         values.put(BeanPropEnum.ConfigPara.id.toString(), INDEX)
         values.put(BeanPropEnum.ConfigPara.mode.toString(), record.mode)
+        values.put(BeanPropEnum.ConfigPara.tenantid.toString(), record.tenantId)
         values.put(BeanPropEnum.ConfigPara.devphyid.toString(), record.devphyid)
         values.put(BeanPropEnum.ConfigPara.epayIP.toString(), record.epayIP)
         values.put(BeanPropEnum.ConfigPara.epayPort.toString(), record.epayPort)
diff --git a/app/src/main/java/com/supwisdom/db/DBLocalHelper.kt b/app/src/main/java/com/supwisdom/db/DBLocalHelper.kt
index a57dc71..6b11ddf 100644
--- a/app/src/main/java/com/supwisdom/db/DBLocalHelper.kt
+++ b/app/src/main/java/com/supwisdom/db/DBLocalHelper.kt
@@ -10,10 +10,11 @@
  ** create by zzq on 2019/7/31
  ** @desc 本地配置文件
  **/
-class DBLocalHelper private constructor(context: Context) : SQLiteOpenHelper(context, DB_NAME, null, VERSION) {
+class DBLocalHelper private constructor(context: Context) :
+    SQLiteOpenHelper(context, DB_NAME, null, VERSION) {
     companion object {
         private val DB_NAME = "db_local_config"
-        private val VERSION = 1
+        private val VERSION = 2
         private var instance: DBLocalHelper? = null
 
         const val TABLE_NAME_CONFIGPARA = "tb_configpara"
@@ -37,12 +38,13 @@
             + TABLE_NAME_CONFIGPARA + " ( "
             + BeanPropEnum.ConfigPara.id + " long primary key, "
             + BeanPropEnum.ConfigPara.mode + " integer, "
-            + BeanPropEnum.ConfigPara.devphyid + " char(8), "
-            + BeanPropEnum.ConfigPara.psamno + " char(12), "
+            + BeanPropEnum.ConfigPara.tenantid + " varchar(64), "
+            + BeanPropEnum.ConfigPara.devphyid + " varchar(8), "
+            + BeanPropEnum.ConfigPara.psamno + " varchar(12), "
             + BeanPropEnum.ConfigPara.epayIP + " varchar(128), "
             + BeanPropEnum.ConfigPara.epayPort + " integer, "
             + BeanPropEnum.ConfigPara.epayUri + " varchar(128), "
-            + BeanPropEnum.ConfigPara.managePwd + " char(6),"
+            + BeanPropEnum.ConfigPara.managePwd + " varchar(6),"
             + BeanPropEnum.ConfigPara.initOK + " integer ) ")
     private val DROP_TABLE_NAME_CONFIGPARA = "DROP TABLE IF EXISTS $TABLE_NAME_CONFIGPARA"
 
@@ -57,6 +59,9 @@
 
     override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
         if (oldVersion < newVersion) {
+            if (2 <= newVersion && oldVersion < 2) {
+                db.execSQL("alter table $TABLE_NAME_CONFIGPARA add column ${BeanPropEnum.ConfigPara.tenantid} varchar(64)")
+            }
         }
     }
 }
\ No newline at end of file
diff --git a/app/src/main/java/com/supwisdom/entity/ConfigParaRecord.kt b/app/src/main/java/com/supwisdom/entity/ConfigParaRecord.kt
index 4b536ac..27b777b 100644
--- a/app/src/main/java/com/supwisdom/entity/ConfigParaRecord.kt
+++ b/app/src/main/java/com/supwisdom/entity/ConfigParaRecord.kt
@@ -6,6 +6,7 @@
  **/
 class ConfigParaRecord {
     var mode: Int = 0//
+    var tenantId: String? = null //租户名
     var devphyid: String? = null
     var epayIP: String? = null
     var epayPort: Int = 0
diff --git a/app/src/main/java/com/supwisdom/okhttp/NetworkHandler.kt b/app/src/main/java/com/supwisdom/okhttp/NetworkHandler.kt
index 008eeaf..74594cc 100644
--- a/app/src/main/java/com/supwisdom/okhttp/NetworkHandler.kt
+++ b/app/src/main/java/com/supwisdom/okhttp/NetworkHandler.kt
@@ -5,9 +5,10 @@
 import okhttp3.MediaType.Companion.toMediaTypeOrNull
 import java.io.IOException
 import java.io.UnsupportedEncodingException
-import java.security.*
-import java.security.cert.CertificateException
-import java.security.cert.X509Certificate
+import java.security.KeyManagementException
+import java.security.KeyStore
+import java.security.KeyStoreException
+import java.security.NoSuchAlgorithmException
 import java.util.*
 import java.util.concurrent.TimeUnit
 import javax.net.ssl.*
@@ -37,7 +38,7 @@
     private val JSON = "application/json; charset=utf-8".toMediaTypeOrNull()
     private val FORM_ENCODE = "application/x-www-form-urlencoded;charset=utf-8".toMediaTypeOrNull()
     private var commTime = 5
-    private var clientId: String? = null
+    private var tenantId: String? = null
     private var jwt: String? = null
     private var sslSocketFactory: SSLSocketFactory? = null
     private var trustManager: X509TrustManager? = null
@@ -69,19 +70,23 @@
 
         client = OkHttpClient()
             .newBuilder()
+            .followRedirects(true)
+            .followSslRedirects(true)
             .retryOnConnectionFailure(false)
             .readTimeout(commTime.toLong(), TimeUnit.SECONDS)
             .writeTimeout(1, TimeUnit.SECONDS)
-            .connectTimeout(commTime.toLong(), TimeUnit.SECONDS)
+            .connectTimeout(1, TimeUnit.SECONDS)
             .hostnameVerifier(TrustAllHostnameVerifier())
             .sslSocketFactory(sslSocketFactory!!, trustManager!!)
             .build()
         clientLong = OkHttpClient()
             .newBuilder()
+            .followRedirects(true)
+            .followSslRedirects(true)
             .retryOnConnectionFailure(false)
-            .readTimeout(35, TimeUnit.SECONDS)
+            .readTimeout(60, TimeUnit.SECONDS)
             .writeTimeout(1, TimeUnit.SECONDS)
-            .connectTimeout(3, TimeUnit.SECONDS)
+            .connectTimeout(1, TimeUnit.SECONDS)
             .hostnameVerifier(TrustAllHostnameVerifier())
             .sslSocketFactory(sslSocketFactory!!, trustManager!!)
             .build()
@@ -93,18 +98,20 @@
             this.commTime = communicateTime
             client = OkHttpClient()
                 .newBuilder()
+                .followRedirects(true)
+                .followSslRedirects(true)
                 .retryOnConnectionFailure(false)
                 .readTimeout(commTime.toLong(), TimeUnit.SECONDS)
                 .writeTimeout(1, TimeUnit.SECONDS)
-                .connectTimeout(commTime.toLong(), TimeUnit.SECONDS)
+                .connectTimeout(1, TimeUnit.SECONDS)
                 .hostnameVerifier(TrustAllHostnameVerifier())
                 .sslSocketFactory(sslSocketFactory!!, trustManager!!)
                 .build()
         }
     }
 
-    fun setClientId(clientId: String?) {
-        this.clientId = clientId
+    fun setTenantId(tenantId: String) {
+        this.tenantId = tenantId
     }
 
     fun setJwt(jwt: String?) {
@@ -124,8 +131,8 @@
     private fun addExtentHeader(request: Request.Builder): Request.Builder {
         request.addHeader("Accept", "application/json; q=0.5")
             .addHeader("Connection", "close")
-        if (!TextUtils.isEmpty(clientId)) {
-            request.addHeader("X-TENANT-ID", clientId!!)
+        if (!TextUtils.isEmpty(tenantId)) {
+            request.addHeader("X-TENANT-ID", tenantId!!)
         }
         if (!TextUtils.isEmpty(jwt)) {
             request.addHeader("Authorization", jwt!!)
diff --git a/app/src/main/java/com/supwisdom/service/AuthEpay.kt b/app/src/main/java/com/supwisdom/service/AuthEpay.kt
index 6fe9a3e..1059227 100644
--- a/app/src/main/java/com/supwisdom/service/AuthEpay.kt
+++ b/app/src/main/java/com/supwisdom/service/AuthEpay.kt
@@ -57,8 +57,6 @@
             .append("/api/auth/gettoken/").append(record.devphyid).append("?")
         val params = WebParams()
         params.setParameter("appid", pos.getDynamicPara()!!.appid)
-
-        NetworkHandler.getInstance().setClientId(record.devphyid!!)
         NetworkHandler.getInstance().setJwt(null)
 
         val resp = NetworkHandler.getInstance().get(url.toString(), params)
diff --git a/app/src/main/java/com/supwisdom/view/DialogPurchase.kt b/app/src/main/java/com/supwisdom/view/DialogPurchase.kt
index 44d3c74..d368f60 100644
--- a/app/src/main/java/com/supwisdom/view/DialogPurchase.kt
+++ b/app/src/main/java/com/supwisdom/view/DialogPurchase.kt
@@ -22,9 +22,9 @@
  ** @desc 消费弹窗
  **/
 @Suppress("DEPRECATION")
-class DialogPurchase constructor(context: Context, callBack: ICallBack) : DialogBase(context), IDecoderAcquirer {
+class DialogPurchase constructor(context: Context, private val callBack: ICallBack) :
+    DialogBase(context), IDecoderAcquirer {
     private val TAG = "DialogPurchase"
-    private val callBack = callBack
     private var vCount: TextView
     private var vPayhint: TextView
     private var vPayamt: TextView
@@ -90,7 +90,7 @@
     fun show(hint: String, amount: String) {
         vPayhint.text = hint
         vPayhint.setTextColor(context.resources.getColor(R.color.blue))
-        vPayamt.text = amount
+        vPayamt.text = null//amount
         vPayamt.visibility = View.VISIBLE
 
         vUsername.visibility = View.GONE
@@ -181,7 +181,7 @@
         } else {
             val time = System.currentTimeMillis()
             if (time < lastFixpayDecoderOpenTime ||
-                time - lastFixpayDecoderOpenTime > 120000
+                time - lastFixpayDecoderOpenTime > 60000
             ) {
                 lastFixpayDecoderOpenTime = time
                 try {
@@ -236,7 +236,8 @@
      * @param countDownInterval The interval along the way to receive
      * [.onTick] callbacks.
      */
-        (millisInFuture: Long, countDownInterval: Long) : CountDownTimer(millisInFuture, countDownInterval) {
+        (millisInFuture: Long, countDownInterval: Long) :
+        CountDownTimer(millisInFuture, countDownInterval) {
 
         override fun onTick(millisUntilFinished: Long) {
             vCount.text = "${millisUntilFinished / 1000}s"
diff --git a/app/src/main/res/layout/activity_communicate.xml b/app/src/main/res/layout/activity_communicate.xml
index d66e4ca..f8af3c8 100644
--- a/app/src/main/res/layout/activity_communicate.xml
+++ b/app/src/main/res/layout/activity_communicate.xml
@@ -57,7 +57,25 @@
                                 android:visibility="gone"/>
                     </RadioGroup>
                 </LinearLayout>
+                <LinearLayout style="@style/comm_ll_para_style">
 
+                    <TextView
+                            android:layout_width="wrap_content"
+                            android:layout_height="wrap_content"
+                            android:gravity="start|center"
+                            android:text="租户名"
+                            android:textColor="@color/light_blue2"
+                            android:textSize="@dimen/enable_devphyid_font_size"/>
+
+                    <TextView
+                            android:id="@+id/comm_tenantid"
+                            android:layout_width="match_parent"
+                            android:layout_height="wrap_content"
+                            android:gravity="start|center"
+                            android:text="schema"
+                            android:textColor="@color/light_blue2"
+                            android:textSize="@dimen/enable_devphyid_font_size"/>
+                </LinearLayout>
                 <LinearLayout style="@style/comm_ll_para_style">
 
                     <TextView
diff --git a/app/src/main/res/layout/activity_init.xml b/app/src/main/res/layout/activity_init.xml
index 24c9d45..f1290ae 100644
--- a/app/src/main/res/layout/activity_init.xml
+++ b/app/src/main/res/layout/activity_init.xml
@@ -92,7 +92,14 @@
                             android:visibility="gone"
                             android:text="闸机(入)模式(点击切换)"/>
                 </RadioGroup>
+                <TextView
+                        style="@style/init_param_name_style"
+                        android:text="租户名"/>
 
+                <EditText
+                        android:id="@+id/tv_tenantid"
+                        style="@style/init_param_name_style"
+                        android:text="schema"/>
                 <TextView
                         style="@style/init_param_name_style"
                         android:text="终端物理ID"/>