diff --git a/app/src/main/java/com/sw/dualscreen/presentation/MainScreenPresentation.kt b/app/src/main/java/com/sw/dualscreen/presentation/MainScreenPresentation.kt index 9c4ac6b..3f311d5 100644 --- a/app/src/main/java/com/sw/dualscreen/presentation/MainScreenPresentation.kt +++ b/app/src/main/java/com/sw/dualscreen/presentation/MainScreenPresentation.kt @@ -689,9 +689,7 @@ class MainScreenPresentation( Timber.tag(TAG) .d("addFoodToOrder: ${weight == lastAddWeight}") // if (weight == lastAddWeight) return lastAddWeight = weight - // 扣减餐具重量,后续份数、价格、总重量均以净重计算 - val netWeight = (weight - activity.getDishWeight()).coerceAtLeast(0) - if (netWeight <= 10) { + if (weight <= 10) { //0-即放即取,1-余量计量 mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0 if (foodOrderList.isNotEmpty() && mealPickupMode == 1) { @@ -706,13 +704,13 @@ class MainScreenPresentation( } //val foodPrice = if (isMember) foodInfo.vipPrice else foodInfo.specPrice val foodPrice = (foodInfo.specPrice ?: 0.0) * memberDiscount - val eatNum = activity.getEatNum(netWeight.toDouble(), foodInfo.specWeight) + val eatNum = activity.getEatNum(weight.toDouble(), foodInfo.specWeight) val price = eatNum * foodPrice if (foodOrderList.isNotEmpty() && mealPickupMode == 1) { val last = foodOrderList.last() if (last.isLocalData) { last.eatNum = eatNum - last.num = netWeight + last.num = weight last.price = price // foodOrderAdapter.submitList(foodOrderList) foodOrderAdapter.notifyItemChanged(foodOrderList.lastIndex) @@ -729,7 +727,7 @@ class MainScreenPresentation( foodMaterialId = foodInfo.foodMaterialId, specWeight = foodInfo.specWeight?.toInt() ?: 0, orderFrom = 2, - num = netWeight, + num = weight, eatNum = eatNum, isLocalData = true ) @@ -755,6 +753,8 @@ class MainScreenPresentation( } var weight = value if (weight < 0) weight = 0 + // 扣减餐具重量,后续营养计算、柱图绘制、取餐明细均以净重为准 + weight = (weight - activity.getDishWeight()).coerceAtLeast(0) if (activity.settlementMode == 0) { activity.runOnUiThread { addFoodToOrder(weight, currentFood!!)