fix(MainScreenPresentation): 修正取餐重量计算逻辑
- 去除净重计算,改以实际重量做后续份数、价格、总重量计算 - 修正计价和取餐份数计算中使用的重量参数 - 调整本地数据订单中数量赋值,使用实际重量替代净重 - 在营养计算和柱状图绘制中扣减餐具重量,确保显示净重 - 保持取餐模式余量计量逻辑兼容,优化逻辑判断条件
This commit is contained in:
@@ -689,9 +689,7 @@ class MainScreenPresentation(
|
|||||||
Timber.tag(TAG) .d("addFoodToOrder: ${weight == lastAddWeight}")
|
Timber.tag(TAG) .d("addFoodToOrder: ${weight == lastAddWeight}")
|
||||||
// if (weight == lastAddWeight) return
|
// if (weight == lastAddWeight) return
|
||||||
lastAddWeight = weight
|
lastAddWeight = weight
|
||||||
// 扣减餐具重量,后续份数、价格、总重量均以净重计算
|
if (weight <= 10) {
|
||||||
val netWeight = (weight - activity.getDishWeight()).coerceAtLeast(0)
|
|
||||||
if (netWeight <= 10) {
|
|
||||||
//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 (foodOrderList.isNotEmpty() && mealPickupMode == 1) {
|
if (foodOrderList.isNotEmpty() && mealPickupMode == 1) {
|
||||||
@@ -706,13 +704,13 @@ class MainScreenPresentation(
|
|||||||
}
|
}
|
||||||
//val foodPrice = if (isMember) foodInfo.vipPrice else foodInfo.specPrice
|
//val foodPrice = if (isMember) foodInfo.vipPrice else foodInfo.specPrice
|
||||||
val foodPrice = (foodInfo.specPrice ?: 0.0) * memberDiscount
|
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
|
val price = eatNum * foodPrice
|
||||||
if (foodOrderList.isNotEmpty() && mealPickupMode == 1) {
|
if (foodOrderList.isNotEmpty() && mealPickupMode == 1) {
|
||||||
val last = foodOrderList.last()
|
val last = foodOrderList.last()
|
||||||
if (last.isLocalData) {
|
if (last.isLocalData) {
|
||||||
last.eatNum = eatNum
|
last.eatNum = eatNum
|
||||||
last.num = netWeight
|
last.num = weight
|
||||||
last.price = price
|
last.price = price
|
||||||
// foodOrderAdapter.submitList(foodOrderList)
|
// foodOrderAdapter.submitList(foodOrderList)
|
||||||
foodOrderAdapter.notifyItemChanged(foodOrderList.lastIndex)
|
foodOrderAdapter.notifyItemChanged(foodOrderList.lastIndex)
|
||||||
@@ -729,7 +727,7 @@ class MainScreenPresentation(
|
|||||||
foodMaterialId = foodInfo.foodMaterialId,
|
foodMaterialId = foodInfo.foodMaterialId,
|
||||||
specWeight = foodInfo.specWeight?.toInt() ?: 0,
|
specWeight = foodInfo.specWeight?.toInt() ?: 0,
|
||||||
orderFrom = 2,
|
orderFrom = 2,
|
||||||
num = netWeight,
|
num = weight,
|
||||||
eatNum = eatNum,
|
eatNum = eatNum,
|
||||||
isLocalData = true
|
isLocalData = true
|
||||||
)
|
)
|
||||||
@@ -755,6 +753,8 @@ class MainScreenPresentation(
|
|||||||
}
|
}
|
||||||
var weight = value
|
var weight = value
|
||||||
if (weight < 0) weight = 0
|
if (weight < 0) weight = 0
|
||||||
|
// 扣减餐具重量,后续营养计算、柱图绘制、取餐明细均以净重为准
|
||||||
|
weight = (weight - activity.getDishWeight()).coerceAtLeast(0)
|
||||||
if (activity.settlementMode == 0) {
|
if (activity.settlementMode == 0) {
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
addFoodToOrder(weight, currentFood!!)
|
addFoodToOrder(weight, currentFood!!)
|
||||||
|
|||||||
Reference in New Issue
Block a user