联合支付余量计量模式订单显示当前取餐信息
This commit is contained in:
@@ -670,12 +670,63 @@ class MainScreenPresentation(
|
||||
// }
|
||||
}
|
||||
|
||||
private var lastAddWeight = 0
|
||||
private fun addFoodToOrder(weight: Int, foodInfo: FoodInfo) {
|
||||
if (weight == lastAddWeight) return
|
||||
lastAddWeight = weight
|
||||
if (weight <= 10) {
|
||||
if (foodOrderList.isNotEmpty()) {
|
||||
val last = foodOrderList.last()
|
||||
if (last.isLocalData) {
|
||||
foodOrderList.remove(last)
|
||||
foodOrderAdapter.submitList(foodOrderList)
|
||||
//foodOrderAdapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
val foodPrice = if (isMember) foodInfo.vipPrice else foodInfo.specPrice
|
||||
val eatNum = activity.getEatNum(weight.toDouble(), foodInfo.specWeight)
|
||||
val price = eatNum * (foodPrice?:0.0)
|
||||
if (foodOrderList.isNotEmpty()) {
|
||||
val last = foodOrderList.last()
|
||||
if (last.isLocalData) {
|
||||
last.eatNum = eatNum
|
||||
last.num = weight
|
||||
last.price = price
|
||||
foodOrderAdapter.submitList(foodOrderList)
|
||||
//foodOrderAdapter.notifyItemChanged(foodOrderList.lastIndex)
|
||||
return
|
||||
}
|
||||
}
|
||||
foodOrderList.add(FoodItem(
|
||||
id = System.currentTimeMillis().toString(),
|
||||
foodId = foodInfo.foodId,
|
||||
foodName = foodInfo.foodName,
|
||||
price = price,
|
||||
specId = foodInfo.specId,
|
||||
foodMaterialId = foodInfo.foodMaterialId,
|
||||
specWeight = foodInfo.specWeight?.toInt() ?: 0,
|
||||
orderFrom = 2,
|
||||
num = weight,
|
||||
eatNum = eatNum,
|
||||
isLocalData = true
|
||||
))
|
||||
foodOrderAdapter.submitList(foodOrderList)
|
||||
//foodOrderAdapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun calculateNutrition(value: Int) {
|
||||
if (currentFood == null || userNutrition == null) {
|
||||
return
|
||||
}
|
||||
var weight = value
|
||||
if (weight < 0) weight = 0
|
||||
if (activity.settlementMode == 0) {
|
||||
activity.runOnUiThread {
|
||||
addFoodToOrder(weight, currentFood!!)
|
||||
}
|
||||
}
|
||||
debouncer.debounce {
|
||||
Timber.tag(TAG)
|
||||
.d("calculateNutrition weight = $weight, recognitionWeight = $recognitionWeight")
|
||||
@@ -1341,7 +1392,7 @@ class MainScreenPresentation(
|
||||
it.root.updateLayoutParams {
|
||||
height = activity.screenSize[1] / 2 + 120.dp
|
||||
}
|
||||
it.tvFoodList.run {
|
||||
it.rvFoodList.run {
|
||||
if (adapter == null) {
|
||||
layoutManager =
|
||||
LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false)
|
||||
@@ -1349,16 +1400,17 @@ class MainScreenPresentation(
|
||||
}
|
||||
}
|
||||
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
|
||||
activity.runOnUiThread {
|
||||
if (model == null) return@runOnUiThread
|
||||
foodOrderList.clear()
|
||||
foodOrderList.addAll(model.list?:emptyList())
|
||||
foodOrderAdapter.submitList(foodOrderList)
|
||||
//foodOrderAdapter.notifyDataSetChanged()
|
||||
binding.detailInclude.tvTotalWeight.text = "总重量:${model.eatWeightSum}克"
|
||||
binding.detailInclude.tvTotalCalorie.text =
|
||||
"总热量:${model.calorie.roundToInt()}千卡"
|
||||
jointPaymentQueryFinish = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user