联机超时查询
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 b238e97..33632de 100644
--- a/app/src/main/java/com/supwisdom/activities/consume/ConsumeActivity.kt
+++ b/app/src/main/java/com/supwisdom/activities/consume/ConsumeActivity.kt
@@ -48,6 +48,7 @@
private lateinit var vLinkLogo: ImageView
private lateinit var vLastResult: TextView
private lateinit var vLastPayamt: TextView
+ private lateinit var vLastCardno: TextView
private lateinit var vLastPayway: TextView
private lateinit var vLastPaytime: TextView
private lateinit var vLastPayFailreason: TextView
@@ -85,6 +86,7 @@
override fun callback(isManualCancel: Boolean) {
presenter.clickNoPay()
amountTxt.text = ""
+ AuxScreenController.getInstance().refreshContent(Arrays.asList(" 欢迎光临!", " 请刷卡..."))
}
override fun callback(code: String) {
@@ -128,7 +130,8 @@
vCardstatus = this.findViewById<TextView>(R.id.tv_cardstatus)
vTime = this.findViewById<TextView>(R.id.tv_nowtime)
vLastResult = this.findViewById<TextView>(R.id.tv_last_pay_result)
- vLastPayamt = this.findViewById<TextView>(R.id.consume_last_payamt)
+ vLastCardno = this.findViewById<TextView>(R.id.tv_last_cardno)
+ vLastPayamt = this.findViewById<TextView>(R.id.tv_last_payamt)
vLastPayway = this.findViewById<TextView>(R.id.tv_last_payway)
vLastPaytime = this.findViewById<TextView>(R.id.tv_last_paytime)
vLastPayFailreason = this.findViewById<TextView>(R.id.tv_last_failreason)
@@ -345,6 +348,11 @@
AuxScreenController.getInstance().refreshContent(Arrays.asList(hint, amountStr))
}
+ override fun showConsumeQuery(hint: String) {
+ dialogPurchase!!.showProcess(hint, "请耐心等待")
+ AuxScreenController.getInstance().refreshContent(Arrays.asList(hint, "请耐心等待"))
+ }
+
override fun showConsumeFail(info: CardUserInfoBean) {
dialogPurchase!!.showPayFail(info)
SoundUtil.playMusic(applicationContext, R.raw.consume_fail)
@@ -370,12 +378,20 @@
private var lastShowRecentTime: String? = null
private fun refreshRecentDtl(info: CardUserInfoBean?) {
if (info != null) {
+ val showtime: Long = 30 * 1000
lastPayInfo = info
//已显示过不在显示
if (lastShowRecentTime == info.transtime) {
return
}
lastShowRecentTime = info.transtime
+ if (info.transtime != null) {
+ val paytime = DateUtil.timeFormatConvertToLong(info.transtime!!)
+ val nowtime = DateUtil.timeFormatConvertToLong(DateUtil.getNowTimeNoFormat())
+ if (nowtime - paytime > showtime) {
+ return
+ }
+ }
if (info.status == PayStatus.SUC) {
when {
@@ -398,7 +414,7 @@
vLastPayamtll.visibility = View.GONE
vLastPayFailreason.text = info.retmsg
}
-
+ vLastCardno.text = info.cardno
vLastPayway.text = if (info.payway == "code") {
"二维码"
} else {
@@ -409,7 +425,7 @@
.append(info.transtime?.substring(2, 4)).append(":")
.append(info.transtime?.substring(4))
vLastPaytime.text = sb.toString()
- resetPayShowCounter(30 * 1000)
+ resetPayShowCounter(showtime)
}
}
@@ -480,6 +496,7 @@
private fun clearLastPayResult() {
vLastResult.text = null
+ vLastCardno.text = null
vLastPayamt.text = null
vLastPayway.text = null
vLastPaytime.text = null
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 4d48b61..fd4a90d 100644
--- a/app/src/main/java/com/supwisdom/activities/consume/ConsumePresenter.kt
+++ b/app/src/main/java/com/supwisdom/activities/consume/ConsumePresenter.kt
@@ -42,6 +42,7 @@
PublicDef.MSG_CARD_PAY_SUC -> iConsumeView.showConsumeSuc(msg.obj as CardUserInfoBean)
PublicDef.MSG_CARD_PAYING,
PublicDef.MSG_CARD_READ_AGAIN -> iConsumeView.showConsumeHint(msg.obj as String)
+ PublicDef.MSG_CARD_PAY_QUERY -> iConsumeView.showConsumeQuery(msg.obj as String)
PublicDef.MSG_CARD_PAY_FAIL -> {
val ret = msg.obj as CardUserInfoBean
LogUtil.d(TAG, "pay fail,reason=${ret.retmsg}")
diff --git a/app/src/main/java/com/supwisdom/activities/consume/IConsumeView.kt b/app/src/main/java/com/supwisdom/activities/consume/IConsumeView.kt
index b633d51..64249c9 100644
--- a/app/src/main/java/com/supwisdom/activities/consume/IConsumeView.kt
+++ b/app/src/main/java/com/supwisdom/activities/consume/IConsumeView.kt
@@ -17,6 +17,8 @@
fun showConsumeHint(hint: String)
+ fun showConsumeQuery(hint: String)
+
fun showConsumeFail(info: CardUserInfoBean)
fun showReverseSuc(info: CardUserInfoBean)
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 2bfb60f..af02d37 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
@@ -328,6 +328,9 @@
}
resp = consumeApi.payConfirm(onlRecord)
result = parseConfirmResult(resp)
+ if (!result) {
+ result = doOnlineConsumeQuery()
+ }
updateTransdtlOnline(result)
if (result) {
showOnlSucInfo()
@@ -335,6 +338,33 @@
return result
}
+ private fun doOnlineConsumeQuery(): Boolean {
+ var queryCnt = 1
+ sleepWithCancel(1000)
+ while (clickStat == ClickStat.PAY) {
+ sendMsg(PublicDef.MSG_CARD_PAY_QUERY, "消费确认中[$queryCnt]")
+ val resp = consumeApi.payQuery(onlRecord)
+ val result = parseConfirmResult(resp)
+ if (result) {
+ return result
+ }
+ queryCnt += 1
+ sleepWithCancel(3000)
+ }
+ return false
+ }
+
+ private fun sleepWithCancel(ms: Long) {
+ var time = 0
+ while (clickStat == ClickStat.PAY) {
+ CommonUtil.doSleep(20)
+ time += 20
+ if (time > ms) {
+ return
+ }
+ }
+ }
+
private fun parseInitResult(resp: TransResp?): Boolean {
if (resp == null || resp.retcode != HttpStatus.SC_OK) {
SPApplication.getInstance().setEpayLinking(false)
@@ -349,6 +379,7 @@
throw CardPayFailError(retBean.getErrorMsg())
}
onlRecord.billno = retBean.billno
+ onlRecord.username = retBean.username
return true
}
@@ -366,8 +397,7 @@
throw CardPayFailError(retBean.getErrorMsg())
}
if (retBean.require_query) {
- //TODO
- throw CardPayFailError("查询未实现")
+ return false
}
onlRecord.payamt = retBean.amount
onlRecord.extraamt = retBean.extraamt
@@ -509,7 +539,7 @@
}
private fun showRvsOnlSucInfo() {
- val info = CardUserInfoBean(PublicDef.SUCCESS, "消费成功")
+ val info = CardUserInfoBean(PublicDef.SUCCESS, "冲正成功")
info.showtime = pos.getSysPara()!!.sucShowtime
info.amount = onlRvsRecord.payamt
info.payamt = onlRvsRecord.payamt
@@ -524,7 +554,7 @@
}
private fun showRvsOffSucInfo() {
- val info = CardUserInfoBean(PublicDef.SUCCESS, "消费成功")
+ val info = CardUserInfoBean(PublicDef.SUCCESS, "冲正成功")
info.showtime = pos.getSysPara()!!.sucShowtime
info.amount = offRvsRecord.payamt
info.payamt = offRvsRecord.payamt
diff --git a/app/src/main/java/com/supwisdom/utils/DateUtil.kt b/app/src/main/java/com/supwisdom/utils/DateUtil.kt
index 6ce7a41..a65a9ce 100644
--- a/app/src/main/java/com/supwisdom/utils/DateUtil.kt
+++ b/app/src/main/java/com/supwisdom/utils/DateUtil.kt
@@ -218,6 +218,19 @@
}
/**
+ * @param time HHmmss
+ * @return ms
+ * @desc 将时间格式的字符串转换为长整型
+ */
+ fun timeFormatConvertToLong(time: String): Long {
+ return try {
+ FORMAT_HHmmss.parse(time).time
+ } catch (ex: ParseException) {
+ 0L
+ }
+ }
+
+ /**
* @param time ms
* @return yyyyMMddHHmmss
* @desc 将长整型数字转换为日期格式的字符串
diff --git a/app/src/main/res/layout/activity_consume.xml b/app/src/main/res/layout/activity_consume.xml
index d453add..a1bf974 100644
--- a/app/src/main/res/layout/activity_consume.xml
+++ b/app/src/main/res/layout/activity_consume.xml
@@ -320,7 +320,31 @@
android:textSize="@dimen/consume_text_size2"
android:textStyle="bold"/>
</LinearLayout>
+ <LinearLayout
+ android:id="@+id/ll_consume_cardno"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:paddingLeft="10dp"
+ android:paddingTop="5dp">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:text="支付卡号: "
+ android:textColor="@color/black"
+ android:textSize="@dimen/consume_text_size2"/>
+
+ <TextView
+ android:id="@+id/tv_last_cardno"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:maxLines="1"
+ android:text=""
+ android:textColor="@color/blue"
+ android:textSize="@dimen/consume_text_size2"
+ android:textStyle="bold"/>
+ </LinearLayout>
<LinearLayout
android:id="@+id/ll_consume_last_payamt"
android:layout_width="match_parent"
@@ -337,7 +361,7 @@
android:textSize="@dimen/consume_text_size2"/>
<TextView
- android:id="@+id/consume_last_payamt"
+ android:id="@+id/tv_last_payamt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:maxLines="1"