From a8ade1605821166bc02e147b5c5554ca3d3f9fb8 Mon Sep 17 00:00:00 2001 From: mazengfei <331023091@qq.com> Date: Tue, 28 Jul 2026 09:18:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(MainScreenPresentation):=20=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E5=8F=96=E9=A4=90=E9=87=8D=E9=87=8F=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 去除净重计算,改以实际重量做后续份数、价格、总重量计算 - 修正计价和取餐份数计算中使用的重量参数 - 调整本地数据订单中数量赋值,使用实际重量替代净重 - 在营养计算和柱状图绘制中扣减餐具重量,确保显示净重 - 保持取餐模式余量计量逻辑兼容,优化逻辑判断条件 --- .../presentation/MainScreenPresentation.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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!!)