feat:bug修改
This commit is contained in:
1 parent
3729e3b896
commit
48c1ee8cb2
8 files changed
+143
-85
No files matched your search
@@ -39,6 +39,9 @@ class DiscountsTool {
|
||||
required List<ShopCardEntity> shopCardList,
|
||||
required String hourType,
|
||||
}) async {
|
||||
if (ObjectUtil.isEmpty(shopCardList)) {
|
||||
return 0;
|
||||
}
|
||||
var discountsItems = await updateUserDiscountsList(userId: userId);
|
||||
discountsItems = discountsItems
|
||||
?.where((element) => element.hourType?.code == hourType)
|
||||
@@ -51,23 +54,10 @@ class DiscountsTool {
|
||||
final extraPer = item.extraPer;
|
||||
final specialDishEnable = item.specialDishEnable;
|
||||
if (extraPer == null || extraPer <= 1.0) continue;
|
||||
// 计算总价
|
||||
int totalPrice = 0;
|
||||
// 特色菜不额外收费
|
||||
if (!specialDishEnable) {
|
||||
totalPrice = shopCardList
|
||||
.where((item) => item.isPriceIncreased)
|
||||
.map((item) => item.totalPrice)
|
||||
.reduce((value, element) => value + element);
|
||||
extraPrice += item.computedDiscountsExtraPrice(totalPrice);
|
||||
}
|
||||
// 特色菜额外收费
|
||||
if (specialDishEnable) {
|
||||
totalPrice = shopCardList
|
||||
.map((item) => item.totalPrice)
|
||||
.reduce((value, element) => value + element);
|
||||
extraPrice += item.computedDiscountsExtraPrice(totalPrice);
|
||||
}
|
||||
final iterable = specialDishEnable
|
||||
? shopCardList
|
||||
: shopCardList.where((e) => e.isPriceIncreased);
|
||||
final totalPrice = iterable.fold<int>(0, (sum, e) => sum + e.totalPrice);
|
||||
extraPrice += item.computedDiscountsExtraPrice(totalPrice);
|
||||
}
|
||||
return extraPrice;
|
||||
|
||||
Reference in new issue
Block a user