@pisell/pisellos 0.0.394 → 0.0.396
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Discount/types.d.ts +2 -0
- package/dist/modules/Rules/index.js +49 -18
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/ShopDiscount/utils.js +2 -1
- package/lib/modules/Discount/types.d.ts +2 -0
- package/lib/modules/Rules/index.js +32 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.js +1 -1
- package/package.json +1 -1
|
@@ -98,7 +98,9 @@ export interface Discount {
|
|
|
98
98
|
isEditMode?: boolean;
|
|
99
99
|
isScan?: boolean;
|
|
100
100
|
discount?: {
|
|
101
|
+
discount_product_id: number;
|
|
101
102
|
resource_id: number;
|
|
103
|
+
discount_calculation_mode: 'item_level' | 'order_level';
|
|
102
104
|
};
|
|
103
105
|
isManualSelect?: boolean;
|
|
104
106
|
isDisabled?: boolean;
|
|
@@ -227,6 +227,25 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
227
227
|
}
|
|
228
228
|
});
|
|
229
229
|
|
|
230
|
+
// 🔥 检查 editModeDiscount 中是否有订单级别的折扣,如果有则禁用 addModeDiscount 中相同 product_id 的折扣卡
|
|
231
|
+
var editModeOrderLevelProductIds = new Set();
|
|
232
|
+
editModeDiscount.forEach(function (discount) {
|
|
233
|
+
var _discount$discount2;
|
|
234
|
+
if (((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.discount_calculation_mode) === 'order_level') {
|
|
235
|
+
var _discount$discount3;
|
|
236
|
+
editModeOrderLevelProductIds.add(discount === null || discount === void 0 || (_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.discount_product_id);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// 如果存在订单级别的编辑模式折扣,禁用 addModeDiscount 中相同 product_id 的折扣卡
|
|
241
|
+
if (editModeOrderLevelProductIds.size > 0) {
|
|
242
|
+
addModeDiscount.forEach(function (discount) {
|
|
243
|
+
if (editModeOrderLevelProductIds.has(discount.product_id)) {
|
|
244
|
+
discount.isDisabled = true;
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
230
249
|
// 过滤掉手动取消false的优惠券,但仅用于应用优惠逻辑
|
|
231
250
|
var filteredDiscountList = addModeDiscount.filter(function (discount) {
|
|
232
251
|
return !discount.isManualSelect;
|
|
@@ -412,8 +431,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
412
431
|
|
|
413
432
|
// 对扁平化后的列表按价格降序排序(用于应用优惠券时优先选择高价商品)
|
|
414
433
|
var sortedFlattenedList = flattenedList.sort(function (a, b) {
|
|
415
|
-
var
|
|
416
|
-
|
|
434
|
+
var _ref3, _a$original_price, _ref4, _b$original_price;
|
|
435
|
+
// 子商品优先使用 original_price,主商品使用 price
|
|
436
|
+
var priceA = new Decimal(a.type === 'bundle' ? (_ref3 = (_a$original_price = a.original_price) !== null && _a$original_price !== void 0 ? _a$original_price : a.price) !== null && _ref3 !== void 0 ? _ref3 : '0' : a.price || '0');
|
|
437
|
+
var priceB = new Decimal(b.type === 'bundle' ? (_ref4 = (_b$original_price = b.original_price) !== null && _b$original_price !== void 0 ? _b$original_price : b.price) !== null && _ref4 !== void 0 ? _ref4 : '0' : b.price || '0');
|
|
417
438
|
if (priceA.equals(priceB)) {
|
|
418
439
|
// 价格相同时,主商品优先
|
|
419
440
|
if (a.type !== b.type) {
|
|
@@ -560,6 +581,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
560
581
|
return;
|
|
561
582
|
}
|
|
562
583
|
|
|
584
|
+
// 🔥 vouchersApplicable 为 false 的商品不参与订单级别折扣均摊
|
|
585
|
+
if (isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
|
|
563
589
|
// 商品价格为0时不可用
|
|
564
590
|
if (Number(product.price) <= 0 || !product.price) {
|
|
565
591
|
return;
|
|
@@ -660,7 +686,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
660
686
|
|
|
661
687
|
// 判断优惠券是否适用于该商品
|
|
662
688
|
if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
|
|
663
|
-
var _discountApplicabilit, _discount$metadata4;
|
|
689
|
+
var _discountApplicabilit, _discount$metadata4, _discount$metadata5;
|
|
664
690
|
// 记录此优惠券适用的商品
|
|
665
691
|
(_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
|
|
666
692
|
|
|
@@ -678,6 +704,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
678
704
|
discount: {
|
|
679
705
|
discount_card_type: discount === null || discount === void 0 || (_discount$metadata4 = discount.metadata) === null || _discount$metadata4 === void 0 ? void 0 : _discount$metadata4.discount_card_type,
|
|
680
706
|
fixed_amount: product.price,
|
|
707
|
+
discount_calculation_mode: discount === null || discount === void 0 || (_discount$metadata5 = discount.metadata) === null || _discount$metadata5 === void 0 ? void 0 : _discount$metadata5.discount_calculation_mode,
|
|
681
708
|
resource_id: discount.id,
|
|
682
709
|
title: discount.format_title,
|
|
683
710
|
original_amount: product.price || product.origin_total,
|
|
@@ -826,8 +853,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
826
853
|
var _product$discount_lis5, _product11, _product11$every;
|
|
827
854
|
// 主商品:判断自身是否手动折扣
|
|
828
855
|
isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && (product.bundle || []).every(function (item) {
|
|
829
|
-
var
|
|
830
|
-
return !((
|
|
856
|
+
var _ref5;
|
|
857
|
+
return !((_ref5 = item.discount_list || []) !== null && _ref5 !== void 0 && _ref5.length);
|
|
831
858
|
}) && (!((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length) || ((_product11 = product) === null || _product11 === void 0 || (_product11 = _product11.discount_list) === null || _product11 === void 0 || (_product11$every = _product11.every) === null || _product11$every === void 0 ? void 0 : _product11$every.call(_product11, function (item) {
|
|
832
859
|
return item.type === 'product';
|
|
833
860
|
})));
|
|
@@ -837,8 +864,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
837
864
|
if (parentProduct) {
|
|
838
865
|
var _parentProduct$discou, _parentProduct$discou2, _parentProduct$discou3;
|
|
839
866
|
isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
|
|
840
|
-
var
|
|
841
|
-
return !((
|
|
867
|
+
var _ref6;
|
|
868
|
+
return !((_ref6 = item.discount_list || []) !== null && _ref6 !== void 0 && _ref6.length);
|
|
842
869
|
}) && (!((_parentProduct$discou = parentProduct.discount_list) !== null && _parentProduct$discou !== void 0 && _parentProduct$discou.length) || (parentProduct === null || parentProduct === void 0 || (_parentProduct$discou2 = parentProduct.discount_list) === null || _parentProduct$discou2 === void 0 || (_parentProduct$discou3 = _parentProduct$discou2.every) === null || _parentProduct$discou3 === void 0 ? void 0 : _parentProduct$discou3.call(_parentProduct$discou2, function (item) {
|
|
843
870
|
return item.type === 'product';
|
|
844
871
|
})));
|
|
@@ -984,7 +1011,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
984
1011
|
}));
|
|
985
1012
|
}
|
|
986
1013
|
for (var i = 0; i < splitCount; i++) {
|
|
987
|
-
var _product$discount_lis10, _originProduct, _selectedDiscount$met;
|
|
1014
|
+
var _product$discount_lis10, _originProduct, _selectedDiscount$met, _selectedDiscount$met2;
|
|
988
1015
|
// 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
|
|
989
1016
|
var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
|
|
990
1017
|
// 标记优惠券为已使用
|
|
@@ -1038,6 +1065,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1038
1065
|
discount: {
|
|
1039
1066
|
discount_card_type: _selectedDiscount === null || _selectedDiscount === void 0 || (_selectedDiscount$met = _selectedDiscount.metadata) === null || _selectedDiscount$met === void 0 ? void 0 : _selectedDiscount$met.discount_card_type,
|
|
1040
1067
|
fixed_amount: actualDiscountAmount,
|
|
1068
|
+
discount_calculation_mode: _selectedDiscount === null || _selectedDiscount === void 0 || (_selectedDiscount$met2 = _selectedDiscount.metadata) === null || _selectedDiscount$met2 === void 0 ? void 0 : _selectedDiscount$met2.discount_calculation_mode,
|
|
1041
1069
|
resource_id: _selectedDiscount.id,
|
|
1042
1070
|
title: _selectedDiscount.format_title,
|
|
1043
1071
|
original_amount: product.price,
|
|
@@ -1107,6 +1135,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1107
1135
|
|
|
1108
1136
|
// 生成有折扣的商品(每张商品券对应 num: 1)
|
|
1109
1137
|
for (var _i = 0; _i < discountNum; _i++) {
|
|
1138
|
+
var _selectedDiscount2$me;
|
|
1110
1139
|
var _selectedDiscount2 = applicableDiscounts[_i];
|
|
1111
1140
|
usedDiscounts.set(_selectedDiscount2.id, true);
|
|
1112
1141
|
// 🔥 更新 product_id 使用计数
|
|
@@ -1126,6 +1155,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1126
1155
|
type: 'good_pass',
|
|
1127
1156
|
discount: {
|
|
1128
1157
|
fixed_amount: product.origin_total,
|
|
1158
|
+
discount_calculation_mode: _selectedDiscount2 === null || _selectedDiscount2 === void 0 || (_selectedDiscount2$me = _selectedDiscount2.metadata) === null || _selectedDiscount2$me === void 0 ? void 0 : _selectedDiscount2$me.discount_calculation_mode,
|
|
1129
1159
|
resource_id: _selectedDiscount2.id,
|
|
1130
1160
|
title: _selectedDiscount2.format_title,
|
|
1131
1161
|
original_amount: product.origin_total,
|
|
@@ -1171,7 +1201,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1171
1201
|
}));
|
|
1172
1202
|
}
|
|
1173
1203
|
} else {
|
|
1174
|
-
var _selectedDiscount3$me, _flatItem$parentProdu8;
|
|
1204
|
+
var _selectedDiscount3$me, _selectedDiscount3$me2, _flatItem$parentProdu8;
|
|
1175
1205
|
// 折扣卡:不拆分数量,直接应用
|
|
1176
1206
|
var _selectedDiscount3 = selectedDiscountCard || applicableDiscounts[0];
|
|
1177
1207
|
usedDiscounts.set(_selectedDiscount3.id, true);
|
|
@@ -1199,7 +1229,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1199
1229
|
_targetProductTotal = getDiscountAmount(_selectedDiscount3, _productOriginTotal, _productOriginTotal);
|
|
1200
1230
|
fixedAmountPerItem = new Decimal(_productOriginTotal).minus(_targetProductTotal).toNumber();
|
|
1201
1231
|
}
|
|
1202
|
-
|
|
1232
|
+
debugger;
|
|
1203
1233
|
// 🔥 使用当前的 _id 作为唯一标识
|
|
1204
1234
|
var _uniqueId = flatItem._id;
|
|
1205
1235
|
var _discountDetail2 = {
|
|
@@ -1208,6 +1238,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1208
1238
|
discount: {
|
|
1209
1239
|
discount_card_type: _selectedDiscount3 === null || _selectedDiscount3 === void 0 || (_selectedDiscount3$me = _selectedDiscount3.metadata) === null || _selectedDiscount3$me === void 0 ? void 0 : _selectedDiscount3$me.discount_card_type,
|
|
1210
1240
|
fixed_amount: fixedAmountPerItem,
|
|
1241
|
+
discount_calculation_mode: _selectedDiscount3 === null || _selectedDiscount3 === void 0 || (_selectedDiscount3$me2 = _selectedDiscount3.metadata) === null || _selectedDiscount3$me2 === void 0 ? void 0 : _selectedDiscount3$me2.discount_calculation_mode,
|
|
1211
1242
|
resource_id: _selectedDiscount3.id,
|
|
1212
1243
|
title: _selectedDiscount3.format_title,
|
|
1213
1244
|
original_amount: product.original_price,
|
|
@@ -1391,8 +1422,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1391
1422
|
|
|
1392
1423
|
// 🔥 更新主商品自己的 discount_list 中的 num(quantity=1)
|
|
1393
1424
|
var updatedMainDiscountList = mainProductData.discount_list.map(function (discount) {
|
|
1394
|
-
var _discount$
|
|
1395
|
-
if (discount !== null && discount !== void 0 && (_discount$
|
|
1425
|
+
var _discount$metadata6, _discount$metadata7;
|
|
1426
|
+
if (discount !== null && discount !== void 0 && (_discount$metadata6 = discount.metadata) !== null && _discount$metadata6 !== void 0 && _discount$metadata6.custom_product_bundle_map_id) {
|
|
1396
1427
|
// bundle的discount_list保持不变
|
|
1397
1428
|
return discount;
|
|
1398
1429
|
}
|
|
@@ -1400,7 +1431,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1400
1431
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1401
1432
|
// num: 1,
|
|
1402
1433
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1403
|
-
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$
|
|
1434
|
+
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$metadata7 = discount.metadata) === null || _discount$metadata7 === void 0 ? void 0 : _discount$metadata7.custom_product_bundle_map_id,
|
|
1404
1435
|
num: 1
|
|
1405
1436
|
})
|
|
1406
1437
|
});
|
|
@@ -1465,8 +1496,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1465
1496
|
|
|
1466
1497
|
// 🔥 更新主商品自己的 discount_list 中的 num(quantity=原quantity-1)
|
|
1467
1498
|
var updatedMainDiscountListOriginal = mainProductData.discount_list.map(function (discount) {
|
|
1468
|
-
var _discount$
|
|
1469
|
-
if (discount !== null && discount !== void 0 && (_discount$
|
|
1499
|
+
var _discount$metadata8, _discount$metadata9;
|
|
1500
|
+
if (discount !== null && discount !== void 0 && (_discount$metadata8 = discount.metadata) !== null && _discount$metadata8 !== void 0 && _discount$metadata8.custom_product_bundle_map_id) {
|
|
1470
1501
|
// bundle的discount_list保持不变
|
|
1471
1502
|
return discount;
|
|
1472
1503
|
}
|
|
@@ -1474,7 +1505,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1474
1505
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1475
1506
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1476
1507
|
num: mainProductQuantity - 1,
|
|
1477
|
-
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$
|
|
1508
|
+
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$metadata9 = discount.metadata) === null || _discount$metadata9 === void 0 ? void 0 : _discount$metadata9.custom_product_bundle_map_id
|
|
1478
1509
|
})
|
|
1479
1510
|
// num: mainProductQuantity - 1,
|
|
1480
1511
|
});
|
|
@@ -1539,11 +1570,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1539
1570
|
processedBundleItems.forEach(function (item) {
|
|
1540
1571
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
1541
1572
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1542
|
-
var _discount$
|
|
1573
|
+
var _discount$metadata10;
|
|
1543
1574
|
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1544
1575
|
metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
|
|
1545
1576
|
num: item.num,
|
|
1546
|
-
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$
|
|
1577
|
+
custom_product_bundle_map_id: discount === null || discount === void 0 || (_discount$metadata10 = discount.metadata) === null || _discount$metadata10 === void 0 ? void 0 : _discount$metadata10.custom_product_bundle_map_id
|
|
1547
1578
|
})
|
|
1548
1579
|
// num: item.num, // 使用拆分后的 num
|
|
1549
1580
|
});
|
|
@@ -308,7 +308,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
308
308
|
date: string;
|
|
309
309
|
status: string;
|
|
310
310
|
week: string;
|
|
311
|
-
weekNum: 0 |
|
|
311
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
312
312
|
}[]>;
|
|
313
313
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
314
314
|
private getScheduleDataByIds;
|
|
@@ -52,7 +52,8 @@ export var getDiscountAmount = function getDiscountAmount(discount, total, price
|
|
|
52
52
|
|
|
53
53
|
// 固定金额 小于0时返回0
|
|
54
54
|
if (isFixedAmount) {
|
|
55
|
-
|
|
55
|
+
var _discount$amount;
|
|
56
|
+
discountedPrice = Math.max(new Decimal(price).minus(new Decimal(((_discount$amount = discount.amount) !== null && _discount$amount !== void 0 ? _discount$amount : discount.par_value) || 0)).toNumber(), 0);
|
|
56
57
|
} else {
|
|
57
58
|
// 百分比:根据折扣卡金额计算
|
|
58
59
|
discountedPrice = new Decimal(100).minus(discount.par_value || 0).div(100).mul(new Decimal(price)).toNumber();
|
|
@@ -98,7 +98,9 @@ export interface Discount {
|
|
|
98
98
|
isEditMode?: boolean;
|
|
99
99
|
isScan?: boolean;
|
|
100
100
|
discount?: {
|
|
101
|
+
discount_product_id: number;
|
|
101
102
|
resource_id: number;
|
|
103
|
+
discount_calculation_mode: 'item_level' | 'order_level';
|
|
102
104
|
};
|
|
103
105
|
isManualSelect?: boolean;
|
|
104
106
|
isDisabled?: boolean;
|
|
@@ -164,6 +164,20 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
164
164
|
addModeDiscount.push(discount);
|
|
165
165
|
}
|
|
166
166
|
});
|
|
167
|
+
const editModeOrderLevelProductIds = /* @__PURE__ */ new Set();
|
|
168
|
+
editModeDiscount.forEach((discount) => {
|
|
169
|
+
var _a, _b;
|
|
170
|
+
if (((_a = discount.discount) == null ? void 0 : _a.discount_calculation_mode) === "order_level") {
|
|
171
|
+
editModeOrderLevelProductIds.add((_b = discount == null ? void 0 : discount.discount) == null ? void 0 : _b.discount_product_id);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
if (editModeOrderLevelProductIds.size > 0) {
|
|
175
|
+
addModeDiscount.forEach((discount) => {
|
|
176
|
+
if (editModeOrderLevelProductIds.has(discount.product_id)) {
|
|
177
|
+
discount.isDisabled = true;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
167
181
|
const filteredDiscountList = addModeDiscount.filter((discount) => {
|
|
168
182
|
return !discount.isManualSelect;
|
|
169
183
|
});
|
|
@@ -294,8 +308,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
294
308
|
const flattenedList = flattenProductsWithBundle(productList);
|
|
295
309
|
const sortedFlattenedList = flattenedList.sort((a, b) => {
|
|
296
310
|
var _a, _b;
|
|
297
|
-
const priceA = new import_decimal.default(
|
|
298
|
-
|
|
311
|
+
const priceA = new import_decimal.default(
|
|
312
|
+
a.type === "bundle" ? a.original_price ?? a.price ?? "0" : a.price || "0"
|
|
313
|
+
);
|
|
314
|
+
const priceB = new import_decimal.default(
|
|
315
|
+
b.type === "bundle" ? b.original_price ?? b.price ?? "0" : b.price || "0"
|
|
316
|
+
);
|
|
299
317
|
if (priceA.equals(priceB)) {
|
|
300
318
|
if (a.type !== b.type) {
|
|
301
319
|
return a.type === "main" ? -1 : 1;
|
|
@@ -389,6 +407,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
389
407
|
if (!isAvailableProduct) {
|
|
390
408
|
return;
|
|
391
409
|
}
|
|
410
|
+
if ((0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
392
413
|
if (Number(product.price) <= 0 || !product.price) {
|
|
393
414
|
return;
|
|
394
415
|
}
|
|
@@ -441,7 +462,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
441
462
|
originProduct = flatItem.originProduct;
|
|
442
463
|
}
|
|
443
464
|
addModeDiscount.forEach((discount) => {
|
|
444
|
-
var _a2, _b, _c, _d, _e, _f, _g;
|
|
465
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
445
466
|
const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
|
|
446
467
|
const _tempVar = (flatItem == null ? void 0 : flatItem.type) === "bundle" ? flatItem == null ? void 0 : flatItem.parentProduct : flatItem == null ? void 0 : flatItem.product;
|
|
447
468
|
const isHolderMatch = this.checkHolderMatch(
|
|
@@ -476,6 +497,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
476
497
|
discount: {
|
|
477
498
|
discount_card_type: (_g = discount == null ? void 0 : discount.metadata) == null ? void 0 : _g.discount_card_type,
|
|
478
499
|
fixed_amount: product.price,
|
|
500
|
+
discount_calculation_mode: (_h = discount == null ? void 0 : discount.metadata) == null ? void 0 : _h.discount_calculation_mode,
|
|
479
501
|
resource_id: discount.id,
|
|
480
502
|
title: discount.format_title,
|
|
481
503
|
original_amount: product.price || product.origin_total,
|
|
@@ -494,7 +516,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
494
516
|
});
|
|
495
517
|
const processedFlatItemsMap = /* @__PURE__ */ new Map();
|
|
496
518
|
sortedFlattenedList.forEach((flatItem, index) => {
|
|
497
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
519
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
|
|
498
520
|
let product, originProduct;
|
|
499
521
|
if (flatItem.type === "main") {
|
|
500
522
|
product = flatItem.product;
|
|
@@ -807,6 +829,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
807
829
|
discount: {
|
|
808
830
|
discount_card_type: (_w = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _w.discount_card_type,
|
|
809
831
|
fixed_amount: actualDiscountAmount,
|
|
832
|
+
discount_calculation_mode: (_x = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _x.discount_calculation_mode,
|
|
810
833
|
resource_id: selectedDiscount2.id,
|
|
811
834
|
title: selectedDiscount2.format_title,
|
|
812
835
|
original_amount: product.price,
|
|
@@ -887,6 +910,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
887
910
|
type: "good_pass",
|
|
888
911
|
discount: {
|
|
889
912
|
fixed_amount: product.origin_total,
|
|
913
|
+
discount_calculation_mode: (_y = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _y.discount_calculation_mode,
|
|
890
914
|
resource_id: selectedDiscount2.id,
|
|
891
915
|
title: selectedDiscount2.format_title,
|
|
892
916
|
original_amount: product.origin_total,
|
|
@@ -955,13 +979,15 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
955
979
|
);
|
|
956
980
|
fixedAmountPerItem = new import_decimal.default(productOriginTotal).minus(targetProductTotal).toNumber();
|
|
957
981
|
}
|
|
982
|
+
debugger;
|
|
958
983
|
const uniqueId = flatItem._id;
|
|
959
984
|
const discountDetail = {
|
|
960
985
|
amount: fixedAmountPerItem * (product.num || 1),
|
|
961
986
|
type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag,
|
|
962
987
|
discount: {
|
|
963
|
-
discount_card_type: (
|
|
988
|
+
discount_card_type: (_z = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _z.discount_card_type,
|
|
964
989
|
fixed_amount: fixedAmountPerItem,
|
|
990
|
+
discount_calculation_mode: (_A = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _A.discount_calculation_mode,
|
|
965
991
|
resource_id: selectedDiscount2.id,
|
|
966
992
|
title: selectedDiscount2.format_title,
|
|
967
993
|
original_amount: product.original_price,
|
|
@@ -977,7 +1003,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
977
1003
|
...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference }
|
|
978
1004
|
},
|
|
979
1005
|
config: selectedDiscount2 == null ? void 0 : selectedDiscount2.config,
|
|
980
|
-
_num: (product.num || 1) * (((
|
|
1006
|
+
_num: (product.num || 1) * (((_B = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _B.num) || 1)
|
|
981
1007
|
};
|
|
982
1008
|
const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
|
|
983
1009
|
appliedProducts.push(discountDetail);
|
|
@@ -308,7 +308,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
308
308
|
date: string;
|
|
309
309
|
status: string;
|
|
310
310
|
week: string;
|
|
311
|
-
weekNum: 0 |
|
|
311
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
312
312
|
}[]>;
|
|
313
313
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
314
314
|
private getScheduleDataByIds;
|
|
@@ -62,7 +62,7 @@ var getDiscountAmount = (discount, total, price) => {
|
|
|
62
62
|
} else {
|
|
63
63
|
const isFixedAmount = ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.discount_card_type) === "fixed_amount";
|
|
64
64
|
if (isFixedAmount) {
|
|
65
|
-
discountedPrice = Math.max(new import_decimal.default(price).minus(new import_decimal.default(discount.amount || 0)).toNumber(), 0);
|
|
65
|
+
discountedPrice = Math.max(new import_decimal.default(price).minus(new import_decimal.default((discount.amount ?? discount.par_value) || 0)).toNumber(), 0);
|
|
66
66
|
} else {
|
|
67
67
|
discountedPrice = new import_decimal.default(100).minus(discount.par_value || 0).div(100).mul(new import_decimal.default(price)).toNumber();
|
|
68
68
|
}
|