联合支付功能调试
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.sw.dualscreen.presentation
|
||||
|
||||
import android.Manifest
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Presentation
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Bitmap
|
||||
@@ -21,14 +22,18 @@ import androidx.annotation.RequiresApi
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.postDelayed
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.arcsoft.face.ErrorInfo
|
||||
import com.sw.dualscreen.BuildConfig
|
||||
import com.sw.dualscreen.GlobalKey
|
||||
import com.sw.dualscreen.MyApp
|
||||
import com.sw.dualscreen.R
|
||||
import com.sw.dualscreen.activity.MainActivity
|
||||
import com.sw.dualscreen.adapter.FoodOrderAdapter
|
||||
import com.sw.dualscreen.databinding.PresentationMainScreenBinding
|
||||
import com.sw.dualscreen.ext.dp
|
||||
import com.sw.dualscreen.ext.format2String
|
||||
@@ -36,9 +41,11 @@ import com.sw.dualscreen.ext.gone
|
||||
import com.sw.dualscreen.ext.load
|
||||
import com.sw.dualscreen.ext.maskName
|
||||
import com.sw.dualscreen.ext.roundedDecimalPlace
|
||||
import com.sw.dualscreen.ext.screenSize
|
||||
import com.sw.dualscreen.ext.visible
|
||||
import com.sw.dualscreen.model.response.DinnerType
|
||||
import com.sw.dualscreen.model.response.FoodInfo
|
||||
import com.sw.dualscreen.model.response.FoodItem
|
||||
import com.sw.dualscreen.model.response.UserEnergy
|
||||
import com.sw.dualscreen.model.response.UserNutrition
|
||||
import com.sw.dualscreen.utils.Debouncer
|
||||
@@ -128,9 +135,7 @@ class MainScreenPresentation(
|
||||
initView()
|
||||
//0-计费,1-不计费
|
||||
val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
|
||||
//0-联合支付,1-独立支付
|
||||
val settlementMode = SPUtil.getInstance().get(GlobalKey.KEY_SETTLEMENT_MODE, 1)
|
||||
if (settlementMode == 0 || chargeMode == 1) {
|
||||
if (activity.settlementMode == 0 || chargeMode == 1) {
|
||||
setupArcCamera()
|
||||
}
|
||||
registerDataChange()
|
||||
@@ -291,6 +296,9 @@ class MainScreenPresentation(
|
||||
LightManager.openGreenLight()
|
||||
currentStep = 3
|
||||
stepChangeCallback(currentStep)
|
||||
|
||||
binding.llTopInfo.visible()
|
||||
binding.flFoodDetail.gone()
|
||||
//根据接口数据更新热量数据--------------------------
|
||||
userViewModel.getUserNutritionData(userId = userId) { nutrition ->
|
||||
activity.runOnUiThread {
|
||||
@@ -312,6 +320,11 @@ class MainScreenPresentation(
|
||||
activity.hideWaitingDialog()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: 判断是联合支付调用接口查询就餐信息------------------------
|
||||
if (activity.settlementMode == 0) {
|
||||
loadOrderList(userId)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
@@ -472,12 +485,15 @@ class MainScreenPresentation(
|
||||
private var isFirstOpen = true
|
||||
var startTime = 0L
|
||||
|
||||
var jointPaymentQueryFinish = false
|
||||
|
||||
/**
|
||||
* 餐品识别中
|
||||
*/
|
||||
fun step1FoodRecognizing() {
|
||||
Timber.tag(TAG).d("main,step1,耗时:${System.currentTimeMillis() - startTime}")
|
||||
startTime = System.currentTimeMillis()
|
||||
jointPaymentQueryFinish = false
|
||||
hideStandbyScreen()
|
||||
activity.resetTouchTime()
|
||||
if (isFirstOpen.not()) {
|
||||
@@ -501,6 +517,9 @@ class MainScreenPresentation(
|
||||
|
||||
stepChangeCallback(currentStep)
|
||||
|
||||
binding.llTopInfo.visible()
|
||||
binding.flFoodDetail.gone()
|
||||
|
||||
binding.calorieInclude.root.gone()
|
||||
binding.nutritionInclude.root.gone()
|
||||
|
||||
@@ -582,7 +601,7 @@ class MainScreenPresentation(
|
||||
}
|
||||
|
||||
// 当前食物信息
|
||||
private var currentFood: FoodInfo? = null
|
||||
var currentFood: FoodInfo? = null
|
||||
fun updateFood(foodInfo: FoodInfo?) {
|
||||
//if (isLoadUnbilledMode) return
|
||||
Timber.tag(TAG).d("main,updateFood,耗时:${System.currentTimeMillis() - startTime}")
|
||||
@@ -594,8 +613,6 @@ class MainScreenPresentation(
|
||||
binding.tvFoodName.text = foodInfo.foodName
|
||||
binding.ivPreviewImage.gone()
|
||||
binding.ivFrame.gone()
|
||||
//0-联合支付,1-独立支付
|
||||
val settlementMode = SPUtil.getInstance().get(GlobalKey.KEY_SETTLEMENT_MODE, 1)
|
||||
//0-计费,1-不计费
|
||||
val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
|
||||
if (chargeMode == 0) {
|
||||
@@ -609,12 +626,12 @@ class MainScreenPresentation(
|
||||
binding.ivRecImage.gone()
|
||||
}
|
||||
//独立支付+计费模式,使用人脸识别
|
||||
if (settlementMode == 1 && chargeMode == 0) {
|
||||
if (activity.settlementMode == 1 && chargeMode == 0) {
|
||||
//计费,查询营养信息、价格信息------------------------
|
||||
loadBilledMode()
|
||||
} else {
|
||||
//联合支付,进行人脸识别
|
||||
if (settlementMode == 0) {
|
||||
if (activity.settlementMode == 0) {
|
||||
step2FaceRecognizing(foodInfo)
|
||||
} else {
|
||||
//不计费,开启人脸识别
|
||||
@@ -1169,28 +1186,37 @@ class MainScreenPresentation(
|
||||
return
|
||||
}
|
||||
createOrder(notEnoughOneBlock = {
|
||||
if (activity.settlementMode == 0) {
|
||||
binding.flFoodDetail.gone()
|
||||
binding.llTopInfo.visible()
|
||||
}
|
||||
// if (mealPickupMode == 0) {
|
||||
currentStep = 2
|
||||
step2FaceRecognizing(currentFood!!)
|
||||
// }
|
||||
}) {
|
||||
}, successBlock = {
|
||||
// TODO: 测试人脸识别问题--------------------
|
||||
//recognizeViewModel.updateRegisterStatus(REGISTER_STATUS_READY)
|
||||
if (MyApp.DEBUG) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
ToastUtils.showToast("订单已生成")
|
||||
}
|
||||
currentUserId = null
|
||||
isMember = false
|
||||
//ToastUtils.showToast("isKeepFaceState=$isKeepFaceState,mealPickupMode=$mealPickupMode")
|
||||
//|| isKeepFaceState
|
||||
if (mealPickupMode == 1) {
|
||||
step2FaceRecognizing(currentFood!!)
|
||||
isKeepFaceState = false
|
||||
} else {
|
||||
if (activity.settlementMode == 0) {
|
||||
activity.isAnalyzing = false
|
||||
step1FoodRecognizing()
|
||||
} else {
|
||||
if (mealPickupMode == 1) {
|
||||
step2FaceRecognizing(currentFood!!)
|
||||
isKeepFaceState = false
|
||||
} else {
|
||||
activity.isAnalyzing = false
|
||||
step1FoodRecognizing()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1198,9 +1224,7 @@ class MainScreenPresentation(
|
||||
/**
|
||||
* 人脸离开后调用创建订单接口
|
||||
*/
|
||||
fun createOrder(notEnoughOneBlock: () -> Unit = {}, block: () -> Unit) {
|
||||
////0-联合支付,1-独立支付
|
||||
//val settlementMode = SPUtil.getInstance().get(GlobalKey.KEY_SETTLEMENT_MODE, 1)
|
||||
fun createOrder(notEnoughOneBlock: () -> Unit = {}, successBlock: () -> Unit) {
|
||||
//0-即放即取,1-余量计量
|
||||
mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
|
||||
//if (settlementMode == 0) {
|
||||
@@ -1231,9 +1255,9 @@ class MainScreenPresentation(
|
||||
userId = currentUserId,
|
||||
isMember = isMember ,
|
||||
notEnoughOneBlock = notEnoughOneBlock,
|
||||
block = {
|
||||
successBlock = {
|
||||
activity.runOnUiThread {
|
||||
block()
|
||||
successBlock()
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -1278,4 +1302,40 @@ class MainScreenPresentation(
|
||||
// }
|
||||
}
|
||||
|
||||
private var foodOrderList = mutableListOf<FoodItem>()
|
||||
private val foodOrderAdapter by lazy {
|
||||
FoodOrderAdapter(foodOrderList)
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载订单列表
|
||||
*/
|
||||
@SuppressLint("NotifyDataSetChanged", "SetTextI18n")
|
||||
private fun loadOrderList(userId: String) {
|
||||
binding.llTopInfo.gone()
|
||||
binding.flFoodDetail.visible()
|
||||
binding.detailInclude.let {
|
||||
it.root.updateLayoutParams {
|
||||
height = activity.screenSize[1]/2
|
||||
}
|
||||
it.tvFoodList.run {
|
||||
if (adapter == null) {
|
||||
layoutManager = LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false)
|
||||
adapter = foodOrderAdapter
|
||||
}
|
||||
}
|
||||
userViewModel.getFoodOrderList(userId) { model ->
|
||||
if (model == null) return@getFoodOrderList
|
||||
foodOrderList.clear()
|
||||
model.list?.let {
|
||||
foodOrderList.addAll(model.list)
|
||||
}
|
||||
foodOrderAdapter.notifyDataSetChanged()
|
||||
binding.detailInclude.tvTotalWeight.text = "总重量:${model.eatWeightSum}克"
|
||||
binding.detailInclude.tvTotalCalorie.text = "总热量:${model.calorie.roundToInt()}千卡"
|
||||
jointPaymentQueryFinish = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user