联合支付功能调试

This commit is contained in:
2026-03-20 18:06:22 +08:00
parent 549e8d303f
commit bf8444e5d5
15 changed files with 320 additions and 61 deletions
+2 -2
View File
@@ -4,10 +4,10 @@
<selectionStates> <selectionStates>
<SelectionState runConfigName="app"> <SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2026-03-10T03:02:12.156794100Z"> <DropdownSelection timestamp="2026-03-20T06:04:19.673022300Z">
<Target type="DEFAULT_BOOT"> <Target type="DEFAULT_BOOT">
<handle> <handle>
<DeviceId pluginId="Default" identifier="serial=192.168.1.211:5555;connection=7435869e" /> <DeviceId pluginId="Default" identifier="serial=192.168.1.16:5555;connection=571832d0" />
</handle> </handle>
</Target> </Target>
</DropdownSelection> </DropdownSelection>
+4 -2
View File
@@ -51,8 +51,10 @@ android {
kotlinOptions { kotlinOptions {
jvmTarget = "11" jvmTarget = "11"
} }
viewBinding {
enable = true buildFeatures {
viewBinding = true
buildConfig = true
} }
} }
@@ -140,6 +140,11 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
private var isStartRecognize = false private var isStartRecognize = false
//0-联合支付,1-独立支付
val settlementMode by lazy {
SPUtil.getInstance().get(GlobalKey.KEY_SETTLEMENT_MODE, 1)
}
override fun getViewModel(): BaseViewModel { override fun getViewModel(): BaseViewModel {
return viewModel return viewModel
} }
@@ -245,6 +250,18 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
SensorScaleUtils.addWeightListener { weight -> SensorScaleUtils.addWeightListener { weight ->
log("registerDataChange weight = $weight") log("registerDataChange weight = $weight")
//runOnUiThread { binding.tvShowWeight.text="${weight*1000}克" } //runOnUiThread { binding.tvShowWeight.text="${weight*1000}克" }
if (presentation?.jointPaymentQueryFinish == true) {
//0-即放即取,1-余量计量
val mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
if (mealPickupMode == 0 && weight <= 0.005) {
isAnalyzing = false
presentation?.step1FoodRecognizing()
} else {
return@addWeightListener
}
}
//if (presentation?.currentFood == null) return@addWeightListener
if (lastWeight - weight > 0.005) { if (lastWeight - weight > 0.005) {
//及放及取,从秤上拿走超过5克 //及放及取,从秤上拿走超过5克
if (presentation?.mealPickupMode == 0) { if (presentation?.mealPickupMode == 0) {
@@ -295,8 +312,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
} else { } else {
block() block()
} }
//0-联合支付,1-独立支付
val settlementMode = SPUtil.getInstance().get(GlobalKey.KEY_SETTLEMENT_MODE, 1)
if (presentation?.mealPickupMode == 1 || settlementMode == 0) { if (presentation?.mealPickupMode == 1 || settlementMode == 0) {
lastWeight = weight lastWeight = weight
} }
@@ -602,8 +617,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
binding.btnPay.run { binding.btnPay.run {
//0-计费,1-不计费 //0-计费,1-不计费
val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0) val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
//0-联合支付,1-独立支付
val settlementMode = SPUtil.getInstance().get(GlobalKey.KEY_SETTLEMENT_MODE, 1)
if (settlementMode == 1 && chargeMode == 0) visible() else gone() if (settlementMode == 1 && chargeMode == 0) visible() else gone()
} }
} }
@@ -651,11 +664,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
userId: String?, userId: String?,
isMember:Boolean, isMember:Boolean,
notEnoughOneBlock: () -> Unit = {}, notEnoughOneBlock: () -> Unit = {},
block: () -> Unit successBlock: () -> Unit
) { ) {
log("foodWeight=$foodWeight,eatWeight=$eatWeight") log("foodWeight=$foodWeight,eatWeight=$eatWeight")
//0-联合支付,1-独立支付
val settlementMode = SPUtil.getInstance().get(GlobalKey.KEY_SETTLEMENT_MODE, 1)
//0-计费,1-不计费 //0-计费,1-不计费
val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0) val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
//0-即放即取,1-余量计量 //0-即放即取,1-余量计量
@@ -693,10 +704,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
paymentFrom = if (settlementMode == 0) 1 else 2, paymentFrom = if (settlementMode == 0) 1 else 2,
member = isMember member = isMember
) )
submitOrder(order, block) submitOrder(order, successBlock)
} }
private fun submitOrder(order: FoodOrder, block: () -> Unit) { private fun submitOrder(order: FoodOrder, successBlock: () -> Unit) {
viewModel.createOrder(order) { orderId -> viewModel.createOrder(order) { orderId ->
runOnUiThread { runOnUiThread {
binding.root.postDelayed({ binding.root.postDelayed({
@@ -706,7 +717,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
return@postDelayed return@postDelayed
} }
foodOrderId = orderId foodOrderId = orderId
block() successBlock()
if (checkedItem!!.isFromSearch == true) { if (checkedItem!!.isFromSearch == true) {
//当前菜名为手动搜索选择,非识别结果,保存向量数据 //当前菜名为手动搜索选择,非识别结果,保存向量数据
@@ -1055,8 +1066,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
log("registerDataChange photoUri 识别数据名称:$foodName") log("registerDataChange photoUri 识别数据名称:$foodName")
runOnUiThread { runOnUiThread {
binding.flPay.run { binding.flPay.run {
//0-联合支付,1-独立支付
val settlementMode = SPUtil.getInstance().get(GlobalKey.KEY_SETTLEMENT_MODE, 1)
//0-计费,1-不计费 //0-计费,1-不计费
val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0) val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
//独立支付+计费模式才显示“去结算”按钮,否则使用人脸识别 //独立支付+计费模式才显示“去结算”按钮,否则使用人脸识别
@@ -0,0 +1,51 @@
package com.sw.dualscreen.adapter
import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.TextView
import androidx.core.graphics.toColorInt
import androidx.core.view.updateLayoutParams
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import com.sw.dualscreen.databinding.LayoutFoodListHeaderBinding
import com.sw.dualscreen.ext.dp
import com.sw.dualscreen.ext.format2String
import com.sw.dualscreen.model.response.FoodItem
class FoodOrderAdapter(var list: MutableList<FoodItem>) :
BaseQuickAdapter<FoodItem, FoodOrderAdapter.VH>(list) {
inner class VH(var binding: LayoutFoodListHeaderBinding) : QuickViewHolder(binding.root)
override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
val inflater = LayoutInflater.from(context)
val binding = LayoutFoodListHeaderBinding.inflate(inflater, parent, false)
return VH(binding)
}
@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: VH, position: Int, item: FoodItem?) {
val binding = holder.binding
item?.let {
binding.tvFoodName.text = it.foodName
binding.tvPriceNorm.text = it.foodPrice.format2String(2)
binding.tvWeight.text = "${it.num}"
binding.tvAmount.text = it.price.format2String(2)
}
setTextColor(binding.tvFoodName, binding.tvPriceNorm, binding.tvWeight, binding.tvAmount)
binding.root.updateLayoutParams<RecyclerView.LayoutParams> {
topMargin = 2.dp
bottomMargin = 2.dp
}
}
fun setTextColor(vararg tvList: TextView) {
tvList.forEach {
it.setTextColor("#FF33446A".toColorInt())
}
}
}
@@ -7,8 +7,10 @@ import android.graphics.BitmapFactory
import android.graphics.ImageFormat import android.graphics.ImageFormat
import android.graphics.Rect import android.graphics.Rect
import android.graphics.YuvImage import android.graphics.YuvImage
import android.util.DisplayMetrics
import android.util.TypedValue import android.util.TypedValue
import android.view.View import android.view.View
import android.view.WindowManager
import android.view.inputmethod.EditorInfo import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import android.widget.EditText import android.widget.EditText
@@ -159,3 +161,14 @@ fun View.invisible() {
fun View.gone() { fun View.gone() {
visibility = View.GONE visibility = View.GONE
} }
val Context.screenSize: IntArray
get() {
val windowManager = getSystemService(Context.WINDOW_SERVICE) as WindowManager
val displayMetrics = DisplayMetrics()
windowManager.defaultDisplay.getMetrics(displayMetrics)
return intArrayOf(
displayMetrics.widthPixels,
displayMetrics.heightPixels
)
}
@@ -127,7 +127,7 @@ data class RespCodeMsg(
data class PostEvent(var name: String = "") data class PostEvent(var name: String = "")
data class UpdateRefreshEvent(var name:String = "") data class UpdateRefreshEvent(var name: String = "")
data class PaySuccessEvent( data class PaySuccessEvent(
var name: String = "" var name: String = ""
) )
@@ -163,3 +163,28 @@ data class WeightRecord(
var lastWeight: Int = 0, var lastWeight: Int = 0,
var currentWeight: Int = 0 var currentWeight: Int = 0
) )
data class FoodItem(
val id: String? = null,
val foodId: String? = null,
val foodName: String? = null,
val foodMaterialId: String? = null,
val specId: String? = null,
val num: Int = 0,
val eatNum: Int = 0,
val price: Double = 0.0,
val foodPrice: Double = 0.0,
val discount: Double = 0.0,
val income: Double = 0.0,
val foodDifferenceId: Long = 0,
val createTime: String? = null
)
data class FoodOrderModel(
val calorie: Double = 0.0,
val incomeSum: Double = 0.0,
val discountSum: Double = 0.0,
val eatWeightSum: Int = 0,
val orderNo: String? = null,
val list: List<FoodItem>? = null
)
@@ -1,5 +1,6 @@
package com.sw.dualscreen.network package com.sw.dualscreen.network
import com.sw.dualscreen.BuildConfig
import com.sw.dualscreen.MyApp import com.sw.dualscreen.MyApp
import com.sw.dualscreen.network.api.ApiService import com.sw.dualscreen.network.api.ApiService
import com.sw.dualscreen.network.interceptor.RequestInterceptor import com.sw.dualscreen.network.interceptor.RequestInterceptor
@@ -22,7 +23,7 @@ object ApiClient {
.addNetworkInterceptor(HttpLoggingInterceptor(logger = { .addNetworkInterceptor(HttpLoggingInterceptor(logger = {
Timber.d("okhttp logger ==>${it}") Timber.d("okhttp logger ==>${it}")
}).apply { }).apply {
level = if (MyApp.DEBUG) { level = if (BuildConfig.DEBUG) {
HttpLoggingInterceptor.Level.BODY HttpLoggingInterceptor.Level.BODY
} else { } else {
HttpLoggingInterceptor.Level.NONE HttpLoggingInterceptor.Level.NONE
@@ -8,6 +8,7 @@ import com.sw.dualscreen.model.response.DinnerType
import com.sw.dualscreen.model.response.FaceData import com.sw.dualscreen.model.response.FaceData
import com.sw.dualscreen.model.response.FoodInfo import com.sw.dualscreen.model.response.FoodInfo
import com.sw.dualscreen.model.response.FoodOrder import com.sw.dualscreen.model.response.FoodOrder
import com.sw.dualscreen.model.response.FoodOrderModel
import com.sw.dualscreen.model.response.FoodSearchReq import com.sw.dualscreen.model.response.FoodSearchReq
import com.sw.dualscreen.model.response.FoodVector import com.sw.dualscreen.model.response.FoodVector
import com.sw.dualscreen.model.response.MemberInfo import com.sw.dualscreen.model.response.MemberInfo
@@ -311,4 +312,13 @@ interface ApiService {
@Url url: String = "${GlobalData.appBaseUrl}/terminal/neglect/boothMachine/app/deleteBoothMachineCollection", @Url url: String = "${GlobalData.appBaseUrl}/terminal/neglect/boothMachine/app/deleteBoothMachineCollection",
@QueryMap param: MutableMap<String, String?> @QueryMap param: MutableMap<String, String?>
): ApiResponse<Any?> ): ApiResponse<Any?>
/**
* 档口机向量数据分页查询
*/
@GET
suspend fun getFoodOrderList(
@Url url: String = "${GlobalData.appBaseUrl}/terminal/neglect/settlement/terminal/app/getFoodInfoBySettlement",
@Query("userId") userId: String
): ApiResponse<FoodOrderModel?>
} }
@@ -19,6 +19,7 @@ package com.sw.dualscreen.objbox
import android.content.Context import android.content.Context
import android.os.Environment import android.os.Environment
import android.util.Log import android.util.Log
import com.sw.dualscreen.BuildConfig
import com.sw.plate.App import com.sw.plate.App
import io.objectbox.Box import io.objectbox.Box
import io.objectbox.BoxStore import io.objectbox.BoxStore
@@ -91,14 +92,14 @@ object ObjectBox {
} }
} }
// if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
val syncAvailable = if (Sync.isAvailable()) "available" else "unavailable" val syncAvailable = if (Sync.isAvailable()) "available" else "unavailable"
Timber.tag(TAG) Timber.tag(TAG)
.d("Using ObjectBox ${BoxStore.getVersion()} (${BoxStore.getVersionNative()}, sync $syncAvailable)") .d("Using ObjectBox ${BoxStore.getVersion()} (${BoxStore.getVersionNative()}, sync $syncAvailable)")
// Enable ObjectBox Admin on debug builds. // Enable ObjectBox Admin on debug builds.
// https://docs.objectbox.io/data-browser // https://docs.objectbox.io/data-browser
Admin(boxStore).start(context.applicationContext) Admin(boxStore).start(context.applicationContext)
// } }
} }
@@ -1,6 +1,7 @@
package com.sw.dualscreen.presentation package com.sw.dualscreen.presentation
import android.Manifest import android.Manifest
import android.annotation.SuppressLint
import android.app.Presentation import android.app.Presentation
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.graphics.Bitmap import android.graphics.Bitmap
@@ -21,14 +22,18 @@ import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.view.isInvisible import androidx.core.view.isInvisible
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.core.view.postDelayed
import androidx.core.view.updateLayoutParams import androidx.core.view.updateLayoutParams
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.arcsoft.face.ErrorInfo import com.arcsoft.face.ErrorInfo
import com.sw.dualscreen.BuildConfig
import com.sw.dualscreen.GlobalKey import com.sw.dualscreen.GlobalKey
import com.sw.dualscreen.MyApp import com.sw.dualscreen.MyApp
import com.sw.dualscreen.R import com.sw.dualscreen.R
import com.sw.dualscreen.activity.MainActivity import com.sw.dualscreen.activity.MainActivity
import com.sw.dualscreen.adapter.FoodOrderAdapter
import com.sw.dualscreen.databinding.PresentationMainScreenBinding import com.sw.dualscreen.databinding.PresentationMainScreenBinding
import com.sw.dualscreen.ext.dp import com.sw.dualscreen.ext.dp
import com.sw.dualscreen.ext.format2String 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.load
import com.sw.dualscreen.ext.maskName import com.sw.dualscreen.ext.maskName
import com.sw.dualscreen.ext.roundedDecimalPlace import com.sw.dualscreen.ext.roundedDecimalPlace
import com.sw.dualscreen.ext.screenSize
import com.sw.dualscreen.ext.visible import com.sw.dualscreen.ext.visible
import com.sw.dualscreen.model.response.DinnerType import com.sw.dualscreen.model.response.DinnerType
import com.sw.dualscreen.model.response.FoodInfo 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.UserEnergy
import com.sw.dualscreen.model.response.UserNutrition import com.sw.dualscreen.model.response.UserNutrition
import com.sw.dualscreen.utils.Debouncer import com.sw.dualscreen.utils.Debouncer
@@ -128,9 +135,7 @@ class MainScreenPresentation(
initView() initView()
//0-计费,1-不计费 //0-计费,1-不计费
val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0) val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
//0-联合支付,1-独立支付 if (activity.settlementMode == 0 || chargeMode == 1) {
val settlementMode = SPUtil.getInstance().get(GlobalKey.KEY_SETTLEMENT_MODE, 1)
if (settlementMode == 0 || chargeMode == 1) {
setupArcCamera() setupArcCamera()
} }
registerDataChange() registerDataChange()
@@ -291,6 +296,9 @@ class MainScreenPresentation(
LightManager.openGreenLight() LightManager.openGreenLight()
currentStep = 3 currentStep = 3
stepChangeCallback(currentStep) stepChangeCallback(currentStep)
binding.llTopInfo.visible()
binding.flFoodDetail.gone()
//根据接口数据更新热量数据-------------------------- //根据接口数据更新热量数据--------------------------
userViewModel.getUserNutritionData(userId = userId) { nutrition -> userViewModel.getUserNutritionData(userId = userId) { nutrition ->
activity.runOnUiThread { activity.runOnUiThread {
@@ -312,6 +320,11 @@ class MainScreenPresentation(
activity.hideWaitingDialog() activity.hideWaitingDialog()
} }
} }
// TODO: 判断是联合支付调用接口查询就餐信息------------------------
if (activity.settlementMode == 0) {
loadOrderList(userId)
}
} }
private fun initView() { private fun initView() {
@@ -472,12 +485,15 @@ class MainScreenPresentation(
private var isFirstOpen = true private var isFirstOpen = true
var startTime = 0L var startTime = 0L
var jointPaymentQueryFinish = false
/** /**
* 餐品识别中 * 餐品识别中
*/ */
fun step1FoodRecognizing() { fun step1FoodRecognizing() {
Timber.tag(TAG).d("main,step1,耗时:${System.currentTimeMillis() - startTime}") Timber.tag(TAG).d("main,step1,耗时:${System.currentTimeMillis() - startTime}")
startTime = System.currentTimeMillis() startTime = System.currentTimeMillis()
jointPaymentQueryFinish = false
hideStandbyScreen() hideStandbyScreen()
activity.resetTouchTime() activity.resetTouchTime()
if (isFirstOpen.not()) { if (isFirstOpen.not()) {
@@ -501,6 +517,9 @@ class MainScreenPresentation(
stepChangeCallback(currentStep) stepChangeCallback(currentStep)
binding.llTopInfo.visible()
binding.flFoodDetail.gone()
binding.calorieInclude.root.gone() binding.calorieInclude.root.gone()
binding.nutritionInclude.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?) { fun updateFood(foodInfo: FoodInfo?) {
//if (isLoadUnbilledMode) return //if (isLoadUnbilledMode) return
Timber.tag(TAG).d("main,updateFood,耗时:${System.currentTimeMillis() - startTime}") Timber.tag(TAG).d("main,updateFood,耗时:${System.currentTimeMillis() - startTime}")
@@ -594,8 +613,6 @@ class MainScreenPresentation(
binding.tvFoodName.text = foodInfo.foodName binding.tvFoodName.text = foodInfo.foodName
binding.ivPreviewImage.gone() binding.ivPreviewImage.gone()
binding.ivFrame.gone() binding.ivFrame.gone()
//0-联合支付,1-独立支付
val settlementMode = SPUtil.getInstance().get(GlobalKey.KEY_SETTLEMENT_MODE, 1)
//0-计费,1-不计费 //0-计费,1-不计费
val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0) val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
if (chargeMode == 0) { if (chargeMode == 0) {
@@ -609,12 +626,12 @@ class MainScreenPresentation(
binding.ivRecImage.gone() binding.ivRecImage.gone()
} }
//独立支付+计费模式,使用人脸识别 //独立支付+计费模式,使用人脸识别
if (settlementMode == 1 && chargeMode == 0) { if (activity.settlementMode == 1 && chargeMode == 0) {
//计费,查询营养信息、价格信息------------------------ //计费,查询营养信息、价格信息------------------------
loadBilledMode() loadBilledMode()
} else { } else {
//联合支付,进行人脸识别 //联合支付,进行人脸识别
if (settlementMode == 0) { if (activity.settlementMode == 0) {
step2FaceRecognizing(foodInfo) step2FaceRecognizing(foodInfo)
} else { } else {
//不计费,开启人脸识别 //不计费,开启人脸识别
@@ -1169,28 +1186,37 @@ class MainScreenPresentation(
return return
} }
createOrder(notEnoughOneBlock = { createOrder(notEnoughOneBlock = {
if (activity.settlementMode == 0) {
binding.flFoodDetail.gone()
binding.llTopInfo.visible()
}
// if (mealPickupMode == 0) { // if (mealPickupMode == 0) {
currentStep = 2 currentStep = 2
step2FaceRecognizing(currentFood!!) step2FaceRecognizing(currentFood!!)
// } // }
}) { }, successBlock = {
// TODO: 测试人脸识别问题-------------------- // TODO: 测试人脸识别问题--------------------
//recognizeViewModel.updateRegisterStatus(REGISTER_STATUS_READY) //recognizeViewModel.updateRegisterStatus(REGISTER_STATUS_READY)
if (MyApp.DEBUG) { if (BuildConfig.DEBUG) {
ToastUtils.showToast("订单已生成") ToastUtils.showToast("订单已生成")
} }
currentUserId = null currentUserId = null
isMember = false isMember = false
//ToastUtils.showToast("isKeepFaceState=$isKeepFaceState,mealPickupMode=$mealPickupMode") //ToastUtils.showToast("isKeepFaceState=$isKeepFaceState,mealPickupMode=$mealPickupMode")
//|| isKeepFaceState //|| isKeepFaceState
if (mealPickupMode == 1) { if (activity.settlementMode == 0) {
step2FaceRecognizing(currentFood!!)
isKeepFaceState = false
} else {
activity.isAnalyzing = false activity.isAnalyzing = false
step1FoodRecognizing() 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) { fun createOrder(notEnoughOneBlock: () -> Unit = {}, successBlock: () -> Unit) {
////0-联合支付,1-独立支付
//val settlementMode = SPUtil.getInstance().get(GlobalKey.KEY_SETTLEMENT_MODE, 1)
//0-即放即取,1-余量计量 //0-即放即取,1-余量计量
mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0 mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
//if (settlementMode == 0) { //if (settlementMode == 0) {
@@ -1231,9 +1255,9 @@ class MainScreenPresentation(
userId = currentUserId, userId = currentUserId,
isMember = isMember , isMember = isMember ,
notEnoughOneBlock = notEnoughOneBlock, notEnoughOneBlock = notEnoughOneBlock,
block = { successBlock = {
activity.runOnUiThread { 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
}
}
}
} }
@@ -9,6 +9,7 @@ import com.sw.dualscreen.model.response.FaceData
import com.sw.dualscreen.model.response.FoodInfo import com.sw.dualscreen.model.response.FoodInfo
import com.sw.dualscreen.model.response.FoodSearchReq import com.sw.dualscreen.model.response.FoodSearchReq
import com.sw.dualscreen.model.response.FoodOrder import com.sw.dualscreen.model.response.FoodOrder
import com.sw.dualscreen.model.response.FoodOrderModel
import com.sw.dualscreen.model.response.FoodVector import com.sw.dualscreen.model.response.FoodVector
import com.sw.dualscreen.model.response.MemberInfo import com.sw.dualscreen.model.response.MemberInfo
import com.sw.dualscreen.model.response.UserFaceModel import com.sw.dualscreen.model.response.UserFaceModel
@@ -352,4 +353,10 @@ class RemoteRepository constructor(
) )
} }
} }
suspend fun getFoodOrderList(userId: String): ApiResponse<FoodOrderModel?> {
return safeApiCall {
apiService.getFoodOrderList(userId = userId)
}
}
} }
@@ -10,6 +10,7 @@ import com.sw.dualscreen.model.response.DeviceConfig
import com.sw.dualscreen.model.response.DinnerType import com.sw.dualscreen.model.response.DinnerType
import com.sw.dualscreen.model.response.FoodInfo import com.sw.dualscreen.model.response.FoodInfo
import com.sw.dualscreen.model.response.FoodOrder import com.sw.dualscreen.model.response.FoodOrder
import com.sw.dualscreen.model.response.FoodOrderModel
import com.sw.dualscreen.model.response.FoodVector import com.sw.dualscreen.model.response.FoodVector
import com.sw.dualscreen.model.response.MemberInfo import com.sw.dualscreen.model.response.MemberInfo
import com.sw.dualscreen.model.response.UserFaceModel import com.sw.dualscreen.model.response.UserFaceModel
@@ -620,4 +621,16 @@ class UserViewModel : BaseViewModel() {
} }
} }
} }
fun getFoodOrderList(userId: String, block: (FoodOrderModel?) -> Unit) {
Timber.tag(TAG).d("getFoodOrderList")
launchWithLoading {
val response = repository.getFoodOrderList(userId)
if (parseResponse(response)) {
block(response.data)
} else {
block(null)
}
}
}
} }
@@ -4,7 +4,8 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical"
tools:ignore="HardcodedText,UseCompatTextViewDrawableXml">
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -19,7 +20,7 @@
android:textSize="30sp" android:textSize="30sp"
android:textStyle="bold" android:textStyle="bold"
android:drawablePadding="17dp" android:drawablePadding="17dp"
app:drawableStartCompat="@drawable/ic_take_food" /> android:drawableStart="@drawable/ic_take_food" />
<TextView <TextView
android:id="@+id/tvUserName" android:id="@+id/tvUserName"
@@ -49,6 +50,7 @@
android:background="#FFDDE5F0" /> android:background="#FFDDE5F0" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/tvFoodList"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
@@ -69,7 +71,7 @@
android:textSize="26sp" android:textSize="26sp"
tools:text="总重量:680克" tools:text="总重量:680克"
android:drawablePadding="17dp" android:drawablePadding="17dp"
app:drawableStartCompat="@drawable/ic_flag_weight" /> android:drawableStart="@drawable/ic_flag_weight" />
<Space <Space
android:layout_width="0dp" android:layout_width="0dp"
@@ -84,7 +86,7 @@
android:textSize="26sp" android:textSize="26sp"
tools:text="总热量:793千卡" tools:text="总热量:793千卡"
android:drawablePadding="17dp" android:drawablePadding="17dp"
app:drawableStartCompat="@drawable/ic_flag_calorie" /> android:drawableStart="@drawable/ic_flag_calorie" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:gravity="center_vertical">
<!-- 菜品名称列,权重2.5 -->
<TextView
android:id="@+id/tvFoodName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.5"
android:text="菜品名称"
android:textColor="#FF889AC2"
android:textSize="26sp"
android:paddingHorizontal="5dp"
android:singleLine="true"
android:gravity="center_vertical|start" />
<!-- 规格列,权重1.0 -->
<TextView
android:id="@+id/tvPriceNorm"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:text="规格"
android:textColor="#FF889AC2"
android:textSize="26sp"
android:paddingHorizontal="5dp"
android:singleLine="true"
android:gravity="center" />
<!-- 重量列,权重1.0 -->
<TextView
android:id="@+id/tvWeight"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:text="重量(克)"
android:textColor="#FF889AC2"
android:textSize="26sp"
android:paddingHorizontal="5dp"
android:singleLine="true"
android:gravity="center" />
<!-- 小计列,权重1.0 -->
<TextView
android:id="@+id/tvAmount"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:text="小计(元)"
android:textColor="#FF889AC2"
android:textSize="26sp"
android:paddingHorizontal="5dp"
android:singleLine="true"
android:gravity="center" />
</LinearLayout>
@@ -13,13 +13,13 @@
android:padding="28dp"> android:padding="28dp">
<LinearLayout <LinearLayout
android:id="@+id/llSignlePage" android:id="@+id/llTopInfo"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/setting_border" android:background="@drawable/setting_border"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="26dp" android:paddingBottom="26dp"
android:visibility="gone"> android:visibility="visible">
<TextView <TextView
android:id="@+id/tvFoodName" android:id="@+id/tvFoodName"
@@ -32,10 +32,10 @@
android:textSize="40sp" android:textSize="40sp"
android:textStyle="bold" /> android:textStyle="bold" />
<!-- android:layout_width="300dp"--> <!--android:layout_width="300dp"-->
<!-- android:layout_height="450dp"--> <!--android:layout_height="450dp"-->
<!-- android:layout_width="330dp"--> <!--android:layout_width="330dp"-->
<!-- android:layout_height="495dp"--> <!--android:layout_height="495dp"-->
<FrameLayout <FrameLayout
android:id="@+id/flCameraView" android:id="@+id/flCameraView"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -189,14 +189,19 @@
</LinearLayout> </LinearLayout>
<include <FrameLayout
android:id="@+id/detailInclude" android:id="@+id/flFoodDetail"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/setting_border" android:background="@drawable/setting_border"
android:orientation="vertical" android:paddingHorizontal="15dp"
android:paddingBottom="26dp" android:visibility="gone">
layout="@layout/layout_eat_detail"/>
<include
android:id="@+id/detailInclude"
layout="@layout/layout_eat_detail"/>
</FrameLayout>
<FrameLayout <FrameLayout
android:id="@+id/flBottomView" android:id="@+id/flBottomView"