联合支付功能测试

This commit is contained in:
2026-03-24 18:34:38 +08:00
parent c4a6101a7b
commit fcea0d785d
5 changed files with 87 additions and 47 deletions
@@ -255,40 +255,72 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
binding.ivImg.load(imgUrl)
}
/**
* 联合支付-即放即取模式
*/
private fun loadJFJQBySettlement(weight: Int) {
//即放即取+联合支付人脸查询订单完成
if (presentation!!.jointPaymentQueryFinish) {
if (weight > WEIGHT_RESET_RECOGNIZE) {
//已识别完成人脸并查询到订单数据,增加重量不再重新识别
return
}
//重量小于等于5克时改为识别中页面
isAnalyzing = false
presentation?.step1FoodRecognizing()
return
}
if (weight <= WEIGHT_RESET_RECOGNIZE) {
//秤上重量过下,显示识别中页面
presentation?.step1FoodRecognizing()
return
}
// val isWeightChange = abs(weight - lastWeight) > 0.02
val isWeightChange = weight - lastWeight > WEIGHT_CHANGE_VALUE
if (weight != lastWeight) {
log("recognizeByWeight---00001,weight=$weight,lastWeight=$lastWeight,isWeightChange=$isWeightChange")
}
recognizeByWeight(weight, isWeightChange)
}
/**
* 联合支付-余量计量模式
*/
private fun loadYLJLBySettlement(weight: Int) {
if (weight <= WEIGHT_RESET_RECOGNIZE) {
//秤上重量过小,显示识别中页面
presentation?.step1FoodRecognizing()
return
}
//余量计量+联合支付人脸查询订单完成
if (presentation!!.jointPaymentQueryFinish) {
presentation?.updateWeight(weight)
return
}
val isWeightChange = weight - lastWeight > WEIGHT_CHANGE_VALUE
recognizeByWeight(weight, isWeightChange)
}
private fun readWeight(weight: Int) {
log("registerDataChange weight = $weight")
//runOnUiThread { binding.tvShowWeight.text="${weight*1000}克" }
runOnUiThread {
binding.tvShowWeight.let {
if (it.text.toString() == weight.toString()) return@runOnUiThread
it.text = "$weight"
}
}
if (settlementMode == 0) {
//联合支付-------------------------------------------
//0-即放即取,1-余量计量
val mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
if (mealPickupMode == 1) {
loadYLJLBySettlement(weight)
return
}
//即放即取+联合支付人脸查询订单完成
if (presentation!!.jointPaymentQueryFinish) {
if (weight > WEIGHT_RESET_RECOGNIZE) {
//已识别完成人脸并查询到订单数据,增加重量不再重新识别
return
}
//重量小于等于5克时改为识别中页面
isAnalyzing = false
presentation?.step1FoodRecognizing()
return
}
if (weight <= WEIGHT_RESET_RECOGNIZE) {
//秤上重量过下,显示识别中页面
presentation?.step1FoodRecognizing()
return
}
// val isWeightChange = abs(weight - lastWeight) > 0.02
val isWeightChange = weight - lastWeight > WEIGHT_CHANGE_VALUE
if (weight != lastWeight) {
log("recognizeByWeight---00001,weight=$weight,lastWeight=$lastWeight,isWeightChange=$isWeightChange")
}
recognizeByWeight(weight, isWeightChange)
loadJFJQBySettlement(weight)
return
}
//独立支付-------------------------------------------
if (lastWeight - weight > 5) {
//及放及取,从秤上拿走超过5克
@@ -305,11 +337,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
}
return
}
// val isWeightChange = abs(weight - lastWeight) > 0.02
val isWeightChange = weight - lastWeight > WEIGHT_CHANGE_VALUE
if (weight != lastWeight) {
log("recognizeByWeight---00001,weight=$weight,lastWeight=$lastWeight,isWeightChange=$isWeightChange")
}
recognizeByWeight(weight, isWeightChange)
}
@@ -321,6 +349,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
}
private fun recognizeByWeight(weight: Int, isWeightChange: Boolean, block: () -> Unit = {}) {
if (weight != lastWeight) {
val payTypeDesc = if (settlementMode == 0) "联合支付" else "独立支付"
log("readWeight-${payTypeDesc},weight=$weight,lastWeight=$lastWeight,isWeightChange=$isWeightChange")
}
presentation?.updateWeight(weight)
if (weight <= WEIGHT_RESET_RECOGNIZE) {
@@ -642,6 +674,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
//已显示副屏,则进行更新
val weight = lastWeight
lastWeight = 0
presentation?.pauseCamera()
presentation?.hideRecImage()
presentation?.step1FoodRecognizing()
@@ -690,10 +723,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
lastTouchTime = System.currentTimeMillis()
}
fun joinPayment() {
}
fun createOrder(
foodInfo: FoodInfo,
foodWeight: Int,