@pisell/pisellos 2.2.187 → 2.2.188
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/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -4
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +11 -4
- package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
- package/dist/modules/Order/index.d.ts +4 -0
- package/dist/modules/Order/index.js +143 -47
- package/dist/modules/Rules/index.js +32 -21
- package/dist/solution/BaseSales/index.js +21 -20
- package/dist/solution/BaseSales/utils/cartPromotion.js +31 -11
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +18 -4
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +4 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +56 -0
- package/lib/modules/Order/index.d.ts +4 -0
- package/lib/modules/Order/index.js +90 -10
- package/lib/modules/Rules/index.js +88 -78
- package/lib/solution/BaseSales/index.js +1 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +22 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +19 -2
- package/package.json +1 -1
|
@@ -206,6 +206,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
206
206
|
isFormSubject,
|
|
207
207
|
orderTotalAmount
|
|
208
208
|
}, options) {
|
|
209
|
+
var _a;
|
|
209
210
|
const isEditModeAddNewProduct = productList.find((n) => n.booking_id) && productList.find((n) => !n.booking_id);
|
|
210
211
|
const editModeDiscount = [];
|
|
211
212
|
const addModeDiscount = [];
|
|
@@ -218,8 +219,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
218
219
|
});
|
|
219
220
|
const editModeOrderLevelProductIds = /* @__PURE__ */ new Set();
|
|
220
221
|
editModeDiscount.forEach((discount) => {
|
|
221
|
-
var
|
|
222
|
-
if (((
|
|
222
|
+
var _a2, _b;
|
|
223
|
+
if (((_a2 = discount.discount) == null ? void 0 : _a2.discount_calculation_mode) === "order_level") {
|
|
223
224
|
editModeOrderLevelProductIds.add((_b = discount == null ? void 0 : discount.discount) == null ? void 0 : _b.discount_product_id);
|
|
224
225
|
}
|
|
225
226
|
});
|
|
@@ -233,6 +234,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
233
234
|
const filteredDiscountList = addModeDiscount.filter((discount) => {
|
|
234
235
|
return !discount.isManualSelect;
|
|
235
236
|
});
|
|
237
|
+
const hasDiscountInput = editModeDiscount.length > 0 || addModeDiscount.length > 0 || Boolean(options == null ? void 0 : options.discountId) || Boolean((_a = options == null ? void 0 : options.selectedList) == null ? void 0 : _a.length) || Boolean(options == null ? void 0 : options.scan);
|
|
238
|
+
if (!hasDiscountInput) {
|
|
239
|
+
return {
|
|
240
|
+
discountList,
|
|
241
|
+
productList
|
|
242
|
+
};
|
|
243
|
+
}
|
|
236
244
|
const flattenProductsWithBundle = (productList2) => {
|
|
237
245
|
const flattened = [];
|
|
238
246
|
productList2.forEach((originProduct) => {
|
|
@@ -278,17 +286,17 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
278
286
|
};
|
|
279
287
|
const sortedDiscountList = [...filteredDiscountList].sort((a, b) => {
|
|
280
288
|
const isHolderDiscount = (discount) => {
|
|
281
|
-
var
|
|
282
|
-
return ((_b = (
|
|
289
|
+
var _a2, _b;
|
|
290
|
+
return ((_b = (_a2 = discount.metadata) == null ? void 0 : _a2.holder) == null ? void 0 : _b.type) === "custom";
|
|
283
291
|
};
|
|
284
292
|
const isGoodPass = (discount) => discount.tag === "good_pass";
|
|
285
293
|
const isOrderLevelDiscount = (discount) => {
|
|
286
|
-
var
|
|
287
|
-
return discount.tag === "product_discount_card" && ((
|
|
294
|
+
var _a2;
|
|
295
|
+
return discount.tag === "product_discount_card" && ((_a2 = discount.metadata) == null ? void 0 : _a2.discount_calculation_mode) === "order_level";
|
|
288
296
|
};
|
|
289
297
|
const isItemLevelDiscount = (discount) => {
|
|
290
|
-
var
|
|
291
|
-
return discount.tag === "product_discount_card" && ((
|
|
298
|
+
var _a2;
|
|
299
|
+
return discount.tag === "product_discount_card" && ((_a2 = discount.metadata) == null ? void 0 : _a2.discount_calculation_mode) !== "order_level";
|
|
292
300
|
};
|
|
293
301
|
const getPriority = (discount) => {
|
|
294
302
|
const isHolder = isHolderDiscount(discount);
|
|
@@ -318,8 +326,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
318
326
|
return itemA.expire_time ? -1 : itemB.expire_time ? 1 : 0;
|
|
319
327
|
}
|
|
320
328
|
function compareDiscountCardValue(itemA, itemB) {
|
|
321
|
-
var
|
|
322
|
-
const typeA = ((
|
|
329
|
+
var _a2, _b;
|
|
330
|
+
const typeA = ((_a2 = itemA.metadata) == null ? void 0 : _a2.discount_card_type) || "percent";
|
|
323
331
|
const typeB = ((_b = itemB.metadata) == null ? void 0 : _b.discount_card_type) || "percent";
|
|
324
332
|
if (typeA === "fixed_amount" && typeB === "percent")
|
|
325
333
|
return -1;
|
|
@@ -359,7 +367,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
359
367
|
});
|
|
360
368
|
const flattenedList = flattenProductsWithBundle(productList);
|
|
361
369
|
const sortedFlattenedList = flattenedList.sort((a, b) => {
|
|
362
|
-
var
|
|
370
|
+
var _a2, _b;
|
|
363
371
|
const priceA = new import_decimal.default(
|
|
364
372
|
a.type === "bundle" ? a.original_price ?? a.price ?? "0" : a.price || "0"
|
|
365
373
|
);
|
|
@@ -372,7 +380,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
372
380
|
}
|
|
373
381
|
if (a.type === "main" && b.type === "main") {
|
|
374
382
|
if (a.product.quantity === b.product.quantity) {
|
|
375
|
-
return (((
|
|
383
|
+
return (((_a2 = b.product.discount_list) == null ? void 0 : _a2.length) || 0) - (((_b = a.product.discount_list) == null ? void 0 : _b.length) || 0);
|
|
376
384
|
}
|
|
377
385
|
return a.product.quantity - b.product.quantity;
|
|
378
386
|
}
|
|
@@ -385,7 +393,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
385
393
|
const evaluator = this.getWalletPassEvaluator();
|
|
386
394
|
if (evaluator) {
|
|
387
395
|
addModeDiscount.forEach((discount) => {
|
|
388
|
-
var
|
|
396
|
+
var _a2, _b;
|
|
389
397
|
const discountType = discount.tag || discount.type;
|
|
390
398
|
if (["good_pass", "discount_card", "product_discount_card"].includes(
|
|
391
399
|
discountType
|
|
@@ -397,17 +405,17 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
397
405
|
type: discountType,
|
|
398
406
|
product_id: discount.product_id,
|
|
399
407
|
unified_available_status: 1,
|
|
400
|
-
available_product_type: (
|
|
408
|
+
available_product_type: (_a2 = discount.limited_relation_product_data) == null ? void 0 : _a2.type,
|
|
401
409
|
available_product_ids: (_b = discount.limited_relation_product_data) == null ? void 0 : _b.product_ids
|
|
402
410
|
};
|
|
403
411
|
const productsForEvaluate = sortedFlattenedList.map((item) => {
|
|
404
|
-
var
|
|
412
|
+
var _a3;
|
|
405
413
|
return {
|
|
406
414
|
product_id: item.id,
|
|
407
415
|
price: item.price || 0,
|
|
408
416
|
quantity: item.quantity || item.num || 1,
|
|
409
417
|
selling_price: item.price || 0,
|
|
410
|
-
product_options: item.type === "main" ? (
|
|
418
|
+
product_options: item.type === "main" ? (_a3 = item.product) == null ? void 0 : _a3.options : void 0
|
|
411
419
|
};
|
|
412
420
|
});
|
|
413
421
|
const result = evaluator.checkVoucherAvailability({
|
|
@@ -440,7 +448,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
440
448
|
const orderLevelDiscountApplicableItems = /* @__PURE__ */ new Map();
|
|
441
449
|
const itemApplicableDiscounts = /* @__PURE__ */ new Map();
|
|
442
450
|
const checkItemApplicableForDiscount = (flatItem, discount) => {
|
|
443
|
-
var
|
|
451
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
444
452
|
let product;
|
|
445
453
|
if (flatItem.type === "main") {
|
|
446
454
|
product = flatItem.product;
|
|
@@ -453,7 +461,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
453
461
|
num: flatItem.num,
|
|
454
462
|
booking_id: flatItem.booking_id,
|
|
455
463
|
discount_list: flatItem.discount_list || [],
|
|
456
|
-
startDate: (
|
|
464
|
+
startDate: (_a2 = flatItem.parentProduct) == null ? void 0 : _a2.startDate
|
|
457
465
|
};
|
|
458
466
|
}
|
|
459
467
|
const isAvailableProduct = flatItem.type === "main" ? !((product == null ? void 0 : product.booking_id) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.length) && ((_c = product == null ? void 0 : product.discount_list) == null ? void 0 : _c.every((d) => d.id && ["good_pass", "discount_card", "product_discount_card"].includes(d.tag || d.type)))) : !((flatItem == null ? void 0 : flatItem.booking_id) && !!((_e = (_d = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _d.discount_list) == null ? void 0 : _e.length) && ((_g = (_f = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _f.discount_list) == null ? void 0 : _g.every((d) => d.id)));
|
|
@@ -521,7 +529,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
521
529
|
}
|
|
522
530
|
const applicableProducts = [];
|
|
523
531
|
sortedFlattenedList.forEach((flatItem) => {
|
|
524
|
-
var
|
|
532
|
+
var _a2, _b, _c;
|
|
525
533
|
const occupyingDiscountId = occupiedItems.get(flatItem._id);
|
|
526
534
|
if (occupyingDiscountId !== void 0 && occupyingDiscountId !== discount.id) {
|
|
527
535
|
return;
|
|
@@ -541,7 +549,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
541
549
|
num: flatItem.num
|
|
542
550
|
};
|
|
543
551
|
}
|
|
544
|
-
const quantity = flatItem.type === "main" ? product.num || product.quantity || 1 : (product.num || product.quantity || 1) * (((
|
|
552
|
+
const quantity = flatItem.type === "main" ? product.num || product.quantity || 1 : (product.num || product.quantity || 1) * (((_a2 = flatItem.parentProduct) == null ? void 0 : _a2.num) || ((_b = flatItem.parentProduct) == null ? void 0 : _b.quantity) || 1);
|
|
545
553
|
const originalAmount = flatItem.type === "main" ? Number(product.price ?? 0) : Number(flatItem.original_price ?? flatItem.price ?? 0);
|
|
546
554
|
const productData = {
|
|
547
555
|
productId: flatItem._id,
|
|
@@ -561,7 +569,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
561
569
|
const processedProductsMap = /* @__PURE__ */ new Map();
|
|
562
570
|
const appliedDiscountProducts = /* @__PURE__ */ new Map();
|
|
563
571
|
sortedFlattenedList.forEach((flatItem) => {
|
|
564
|
-
var
|
|
572
|
+
var _a2;
|
|
565
573
|
let product, originProduct;
|
|
566
574
|
if (flatItem.type === "main") {
|
|
567
575
|
product = flatItem.product;
|
|
@@ -577,12 +585,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
577
585
|
origin_total: flatItem.origin_total,
|
|
578
586
|
booking_id: flatItem.booking_id,
|
|
579
587
|
discount_list: flatItem.discount_list || [],
|
|
580
|
-
startDate: (
|
|
588
|
+
startDate: (_a2 = flatItem.parentProduct) == null ? void 0 : _a2.startDate
|
|
581
589
|
};
|
|
582
590
|
originProduct = flatItem.originProduct;
|
|
583
591
|
}
|
|
584
592
|
addModeDiscount.forEach((discount) => {
|
|
585
|
-
var
|
|
593
|
+
var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
586
594
|
const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
|
|
587
595
|
const _tempVar = (flatItem == null ? void 0 : flatItem.type) === "bundle" ? flatItem == null ? void 0 : flatItem.parentProduct : flatItem == null ? void 0 : flatItem.product;
|
|
588
596
|
const isHolderMatch = this.checkHolderMatch(
|
|
@@ -596,7 +604,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
596
604
|
let timeLimit = true;
|
|
597
605
|
timeLimit = !!(0, import_utils.filterDiscountListByBookingTime)([discount], ((product == null ? void 0 : product.startDate) || (0, import_dayjs.default)()).format("YYYY-MM-DD HH:mm:ss")).length;
|
|
598
606
|
const isLimitedProduct = (limitedData.type === "product_all" && limitedData.filter !== 1 || limitedData.type === "product_all" && limitedData.filter === 1 && !limitedData.exclude_product_ids.includes(product.id) || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
|
|
599
|
-
const isAvailableProduct = flatItem.type === "main" ? !((product == null ? void 0 : product.booking_id) && ((
|
|
607
|
+
const isAvailableProduct = flatItem.type === "main" ? !((product == null ? void 0 : product.booking_id) && ((_a3 = product == null ? void 0 : product.discount_list) == null ? void 0 : _a3.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every(
|
|
600
608
|
(discount2) => discount2.id && [
|
|
601
609
|
"good_pass",
|
|
602
610
|
"discount_card",
|
|
@@ -680,7 +688,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
680
688
|
}, 0);
|
|
681
689
|
};
|
|
682
690
|
sortedFlattenedList.forEach((flatItem, index) => {
|
|
683
|
-
var
|
|
691
|
+
var _a2, _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, _C, _D, _E, _F, _G, _H, _I;
|
|
684
692
|
let product, originProduct;
|
|
685
693
|
if (flatItem.type === "main") {
|
|
686
694
|
product = flatItem.product;
|
|
@@ -693,7 +701,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
693
701
|
quantity: flatItem.quantity,
|
|
694
702
|
num: flatItem.num,
|
|
695
703
|
total: flatItem.total,
|
|
696
|
-
original_price: (
|
|
704
|
+
original_price: (_a2 = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _a2.original_price,
|
|
697
705
|
origin_total: (_b = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _b.original_price,
|
|
698
706
|
booking_id: flatItem.booking_id,
|
|
699
707
|
discount_list: ((_c = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _c.discount_list) || [],
|
|
@@ -703,8 +711,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
703
711
|
}
|
|
704
712
|
const isPersistedProduct = (product == null ? void 0 : product.booking_id) || (originProduct == null ? void 0 : originProduct.order_detail_id) || (originProduct == null ? void 0 : originProduct.orderDetailId) || (originProduct == null ? void 0 : originProduct.booking_id);
|
|
705
713
|
const hasExistingWalletDiscount = ((_e = product.discount_list) == null ? void 0 : _e.length) && ((_f = product == null ? void 0 : product.discount_list) == null ? void 0 : _f.every((discount) => {
|
|
706
|
-
var
|
|
707
|
-
const discountIdentity = discount.id ?? ((
|
|
714
|
+
var _a3;
|
|
715
|
+
const discountIdentity = discount.id ?? ((_a3 = discount.discount) == null ? void 0 : _a3.resource_id);
|
|
708
716
|
const discountType = discount.tag || discount.type;
|
|
709
717
|
return Boolean(
|
|
710
718
|
discountIdentity && ["good_pass", "discount_card", "product_discount_card"].includes(
|
|
@@ -726,20 +734,20 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
726
734
|
return;
|
|
727
735
|
}
|
|
728
736
|
const applicableDiscounts = sortedDiscountList.filter((discount) => {
|
|
729
|
-
var
|
|
737
|
+
var _a3, _b2, _c2, _d2;
|
|
730
738
|
const discountType = discount.tag || discount.type;
|
|
731
739
|
if (["good_pass", "discount_card", "product_discount_card"].includes(
|
|
732
740
|
discountType
|
|
733
741
|
)) {
|
|
734
|
-
if (discount.config === void 0 || !((
|
|
742
|
+
if (discount.config === void 0 || !((_a3 = discount == null ? void 0 : discount.config) == null ? void 0 : _a3.isAvailable)) {
|
|
735
743
|
return false;
|
|
736
744
|
}
|
|
737
745
|
}
|
|
738
746
|
if ((Number(product.price) <= 0 || !product.price) && !((_b2 = product.discount_list) == null ? void 0 : _b2.length) && (discount.tag || discount.type) === "good_pass")
|
|
739
747
|
return false;
|
|
740
748
|
if ((Number(product.price) <= 0 || !product.price) && !((_c2 = product.discount_list) == null ? void 0 : _c2.find((n) => {
|
|
741
|
-
var
|
|
742
|
-
return ((
|
|
749
|
+
var _a4;
|
|
750
|
+
return ((_a4 = n.discount) == null ? void 0 : _a4.resource_id) === discount.id;
|
|
743
751
|
})) && (discount.tag || discount.type) !== "good_pass")
|
|
744
752
|
return false;
|
|
745
753
|
const targetUsedDiscounts = usedDiscounts.get(discount.id);
|
|
@@ -795,8 +803,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
795
803
|
if (flatItem.type === "main") {
|
|
796
804
|
isManualDiscount = typeof product.isManualDiscount === "boolean" ? product.isManualDiscount : ((_g = product.discount_list) == null ? void 0 : _g.some((item) => item.type === "product")) || product.total != product.origin_total && (product.bundle || []).every(
|
|
797
805
|
(item) => {
|
|
798
|
-
var
|
|
799
|
-
return !((
|
|
806
|
+
var _a3;
|
|
807
|
+
return !((_a3 = item.discount_list || []) == null ? void 0 : _a3.length);
|
|
800
808
|
}
|
|
801
809
|
) && (!((_h = product.discount_list) == null ? void 0 : _h.length) || ((_j = (_i = product == null ? void 0 : product.discount_list) == null ? void 0 : _i.every) == null ? void 0 : _j.call(
|
|
802
810
|
_i,
|
|
@@ -810,8 +818,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
810
818
|
if (parentProduct) {
|
|
811
819
|
isManualDiscount = typeof parentProduct.isManualDiscount === "boolean" ? parentProduct.isManualDiscount : ((_k = parentProduct.discount_list) == null ? void 0 : _k.some((item) => item.type === "product")) || parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(
|
|
812
820
|
(item) => {
|
|
813
|
-
var
|
|
814
|
-
return !((
|
|
821
|
+
var _a3;
|
|
822
|
+
return !((_a3 = item.discount_list || []) == null ? void 0 : _a3.length);
|
|
815
823
|
}
|
|
816
824
|
) && (!((_l = parentProduct.discount_list) == null ? void 0 : _l.length) || ((_n = (_m = parentProduct == null ? void 0 : parentProduct.discount_list) == null ? void 0 : _m.every) == null ? void 0 : _n.call(
|
|
817
825
|
_m,
|
|
@@ -822,8 +830,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
822
830
|
if (options == null ? void 0 : options.discountId) {
|
|
823
831
|
if (flatItem.type === "main" && ((_o = product.discount_list) == null ? void 0 : _o.some(
|
|
824
832
|
(item) => {
|
|
825
|
-
var
|
|
826
|
-
return ((
|
|
833
|
+
var _a3;
|
|
834
|
+
return ((_a3 = item.discount) == null ? void 0 : _a3.resource_id) === options.discountId;
|
|
827
835
|
}
|
|
828
836
|
))) {
|
|
829
837
|
isManualDiscount = false;
|
|
@@ -831,13 +839,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
831
839
|
if (flatItem.type === "bundle") {
|
|
832
840
|
if (((_p = product.discount_list) == null ? void 0 : _p.some(
|
|
833
841
|
(item) => {
|
|
834
|
-
var
|
|
835
|
-
return ((
|
|
842
|
+
var _a3;
|
|
843
|
+
return ((_a3 = item.discount) == null ? void 0 : _a3.resource_id) === options.discountId;
|
|
836
844
|
}
|
|
837
845
|
)) || ((_r = (_q = flatItem.parentProduct) == null ? void 0 : _q.discount_list) == null ? void 0 : _r.some(
|
|
838
846
|
(item) => {
|
|
839
|
-
var
|
|
840
|
-
return ((
|
|
847
|
+
var _a3;
|
|
848
|
+
return ((_a3 = item.discount) == null ? void 0 : _a3.resource_id) === options.discountId;
|
|
841
849
|
}
|
|
842
850
|
))) {
|
|
843
851
|
isManualDiscount = false;
|
|
@@ -847,11 +855,11 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
847
855
|
if (options == null ? void 0 : options.selectedList) {
|
|
848
856
|
if (flatItem.type === "main" && ((_s = product.discount_list) == null ? void 0 : _s.some(
|
|
849
857
|
(item) => {
|
|
850
|
-
var
|
|
851
|
-
return (
|
|
858
|
+
var _a3;
|
|
859
|
+
return (_a3 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a3.some(
|
|
852
860
|
(n) => {
|
|
853
|
-
var
|
|
854
|
-
return n.discountId === ((
|
|
861
|
+
var _a4;
|
|
862
|
+
return n.discountId === ((_a4 = item.discount) == null ? void 0 : _a4.resource_id);
|
|
855
863
|
}
|
|
856
864
|
);
|
|
857
865
|
}
|
|
@@ -861,21 +869,21 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
861
869
|
if (flatItem.type === "bundle") {
|
|
862
870
|
if (((_t = product.discount_list) == null ? void 0 : _t.some(
|
|
863
871
|
(item) => {
|
|
864
|
-
var
|
|
865
|
-
return (
|
|
872
|
+
var _a3;
|
|
873
|
+
return (_a3 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a3.some(
|
|
866
874
|
(n) => {
|
|
867
|
-
var
|
|
868
|
-
return n.discountId === ((
|
|
875
|
+
var _a4;
|
|
876
|
+
return n.discountId === ((_a4 = item.discount) == null ? void 0 : _a4.resource_id);
|
|
869
877
|
}
|
|
870
878
|
);
|
|
871
879
|
}
|
|
872
880
|
)) || ((_v = (_u = flatItem.parentProduct) == null ? void 0 : _u.discount_list) == null ? void 0 : _v.some(
|
|
873
881
|
(item) => {
|
|
874
|
-
var
|
|
875
|
-
return (
|
|
882
|
+
var _a3;
|
|
883
|
+
return (_a3 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a3.some(
|
|
876
884
|
(n) => {
|
|
877
|
-
var
|
|
878
|
-
return n.discountId === ((
|
|
885
|
+
var _a4;
|
|
886
|
+
return n.discountId === ((_a4 = item.discount) == null ? void 0 : _a4.resource_id);
|
|
879
887
|
}
|
|
880
888
|
);
|
|
881
889
|
}
|
|
@@ -1284,8 +1292,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1284
1292
|
bundleProcessingInfo.set(bundleIndex, processedBundleItems);
|
|
1285
1293
|
const hasGoodPass = processedBundleItems.some(
|
|
1286
1294
|
(item) => {
|
|
1287
|
-
var
|
|
1288
|
-
return (
|
|
1295
|
+
var _a2;
|
|
1296
|
+
return (_a2 = item.discount_list) == null ? void 0 : _a2.some(
|
|
1289
1297
|
(discount) => discount.type === "good_pass" || discount.tag === "good_pass"
|
|
1290
1298
|
);
|
|
1291
1299
|
}
|
|
@@ -1309,13 +1317,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1309
1317
|
if (processedItems.length > 1) {
|
|
1310
1318
|
processedItems.forEach((item) => {
|
|
1311
1319
|
const updatedDiscountList2 = (item.discount_list || []).map((discount) => {
|
|
1312
|
-
var
|
|
1320
|
+
var _a2;
|
|
1313
1321
|
return {
|
|
1314
1322
|
...discount,
|
|
1315
1323
|
metadata: {
|
|
1316
1324
|
...discount.metadata,
|
|
1317
1325
|
num: item.num,
|
|
1318
|
-
custom_product_bundle_map_id: (
|
|
1326
|
+
custom_product_bundle_map_id: (_a2 = item.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id
|
|
1319
1327
|
}
|
|
1320
1328
|
// num: item.num, // 使用拆分后的 num
|
|
1321
1329
|
};
|
|
@@ -1333,13 +1341,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1333
1341
|
const item = processedItems[0];
|
|
1334
1342
|
if (item.processed) {
|
|
1335
1343
|
const updatedDiscountList2 = (item.discount_list || []).map((discount) => {
|
|
1336
|
-
var
|
|
1344
|
+
var _a2;
|
|
1337
1345
|
return {
|
|
1338
1346
|
...discount,
|
|
1339
1347
|
metadata: {
|
|
1340
1348
|
...discount.metadata,
|
|
1341
1349
|
num: item.num,
|
|
1342
|
-
custom_product_bundle_map_id: (
|
|
1350
|
+
custom_product_bundle_map_id: (_a2 = item.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id
|
|
1343
1351
|
}
|
|
1344
1352
|
// num: item.num, // 使用当前的 num
|
|
1345
1353
|
};
|
|
@@ -1363,8 +1371,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1363
1371
|
mainProductData.original_price || mainProductData.price || 0
|
|
1364
1372
|
);
|
|
1365
1373
|
const updatedMainDiscountList = mainProductData.discount_list.map((discount) => {
|
|
1366
|
-
var
|
|
1367
|
-
if ((
|
|
1374
|
+
var _a2, _b;
|
|
1375
|
+
if ((_a2 = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id) {
|
|
1368
1376
|
return discount;
|
|
1369
1377
|
}
|
|
1370
1378
|
return {
|
|
@@ -1379,8 +1387,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1379
1387
|
});
|
|
1380
1388
|
const mainDiscountList = updatedMainDiscountList.filter(
|
|
1381
1389
|
(item) => {
|
|
1382
|
-
var
|
|
1383
|
-
return !((
|
|
1390
|
+
var _a2;
|
|
1391
|
+
return !((_a2 = item == null ? void 0 : item.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id);
|
|
1384
1392
|
}
|
|
1385
1393
|
);
|
|
1386
1394
|
if (mainDiscountList && mainDiscountList.length > 0) {
|
|
@@ -1393,8 +1401,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1393
1401
|
newTotalWithDiscount += Number(item.price) * Number(item.num);
|
|
1394
1402
|
});
|
|
1395
1403
|
newBundleWithDiscount.forEach((item) => {
|
|
1396
|
-
var
|
|
1397
|
-
const originalPrice = ((_c = (_b = (
|
|
1404
|
+
var _a2, _b, _c;
|
|
1405
|
+
const originalPrice = ((_c = (_b = (_a2 = item.discount_list) == null ? void 0 : _a2[0]) == null ? void 0 : _b.discount) == null ? void 0 : _c.original_amount) || item.price;
|
|
1398
1406
|
newOriginTotalWithDiscount += Number(originalPrice) * Number(item.num);
|
|
1399
1407
|
});
|
|
1400
1408
|
}
|
|
@@ -1431,8 +1439,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1431
1439
|
mainProductData.original_price || mainProductData.price || 0
|
|
1432
1440
|
);
|
|
1433
1441
|
const updatedMainDiscountListOriginal = mainProductData.discount_list.map((discount) => {
|
|
1434
|
-
var
|
|
1435
|
-
if ((
|
|
1442
|
+
var _a2, _b;
|
|
1443
|
+
if ((_a2 = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id) {
|
|
1436
1444
|
return discount;
|
|
1437
1445
|
}
|
|
1438
1446
|
return {
|
|
@@ -1447,8 +1455,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1447
1455
|
});
|
|
1448
1456
|
const mainDiscountListOriginal = updatedMainDiscountListOriginal.filter(
|
|
1449
1457
|
(item) => {
|
|
1450
|
-
var
|
|
1451
|
-
return !((
|
|
1458
|
+
var _a2;
|
|
1459
|
+
return !((_a2 = item == null ? void 0 : item.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id);
|
|
1452
1460
|
}
|
|
1453
1461
|
);
|
|
1454
1462
|
if (mainDiscountListOriginal && mainDiscountListOriginal.length > 0) {
|
|
@@ -1487,7 +1495,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1487
1495
|
}
|
|
1488
1496
|
} else {
|
|
1489
1497
|
mainProductArr.forEach((mainProduct) => {
|
|
1490
|
-
var
|
|
1498
|
+
var _a2, _b, _c;
|
|
1491
1499
|
const mainProductData = this.hooks.getProduct(mainProduct);
|
|
1492
1500
|
const newBundle = [];
|
|
1493
1501
|
if (product.bundle && Array.isArray(product.bundle)) {
|
|
@@ -1498,14 +1506,16 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1498
1506
|
newBundle.push(bundleItem);
|
|
1499
1507
|
} else {
|
|
1500
1508
|
processedBundleItems.forEach((item) => {
|
|
1509
|
+
const nextBundlePrice = item.price ?? bundleItem.price;
|
|
1510
|
+
const nextBundleSellingPrice = item.bundle_selling_price ?? item.price ?? bundleItem.bundle_selling_price;
|
|
1501
1511
|
const updatedDiscountList2 = (item.discount_list || []).map((discount) => {
|
|
1502
|
-
var
|
|
1512
|
+
var _a3;
|
|
1503
1513
|
return {
|
|
1504
1514
|
...discount,
|
|
1505
1515
|
metadata: {
|
|
1506
1516
|
...discount.metadata,
|
|
1507
1517
|
num: item.num,
|
|
1508
|
-
custom_product_bundle_map_id: (
|
|
1518
|
+
custom_product_bundle_map_id: (_a3 = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a3.custom_product_bundle_map_id
|
|
1509
1519
|
}
|
|
1510
1520
|
// num: item.num, // 使用拆分后的 num
|
|
1511
1521
|
};
|
|
@@ -1514,10 +1524,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1514
1524
|
...bundleItem,
|
|
1515
1525
|
_id: item._id,
|
|
1516
1526
|
product_id: bundleItem.product_id,
|
|
1517
|
-
price:
|
|
1527
|
+
price: nextBundlePrice,
|
|
1518
1528
|
num: item.num,
|
|
1519
1529
|
discount_list: updatedDiscountList2,
|
|
1520
|
-
bundle_selling_price: bundleItem.bundle_selling_price !== void 0 ?
|
|
1530
|
+
bundle_selling_price: bundleItem.bundle_selling_price !== void 0 ? nextBundleSellingPrice : void 0
|
|
1521
1531
|
});
|
|
1522
1532
|
});
|
|
1523
1533
|
}
|
|
@@ -1526,7 +1536,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1526
1536
|
const mainSellingPrice = mainProductData.main_product_selling_price ?? mainProductData.price ?? 0;
|
|
1527
1537
|
let newTotal = Number(mainSellingPrice || 0);
|
|
1528
1538
|
let newOriginTotal = Number(mainProductData.original_price || mainProductData.price || 0);
|
|
1529
|
-
const isManualDiscount = typeof mainProductData.isManualDiscount === "boolean" ? mainProductData.isManualDiscount : mainProductData.total != mainProductData.origin_total && (!((
|
|
1539
|
+
const isManualDiscount = typeof mainProductData.isManualDiscount === "boolean" ? mainProductData.isManualDiscount : mainProductData.total != mainProductData.origin_total && (!((_a2 = mainProductData.discount_list) == null ? void 0 : _a2.length) || ((_c = (_b = mainProductData == null ? void 0 : mainProductData.discount_list) == null ? void 0 : _b.every) == null ? void 0 : _c.call(_b, (item) => item.type === "product")));
|
|
1530
1540
|
if (isManualDiscount) {
|
|
1531
1541
|
newTotal = mainProductData.total ?? newTotal;
|
|
1532
1542
|
newOriginTotal = mainProductData.origin_total ?? newOriginTotal;
|
|
@@ -1537,8 +1547,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1537
1547
|
newTotal += Number(bundleSellingPrice) * Number(item.num);
|
|
1538
1548
|
});
|
|
1539
1549
|
newBundle.forEach((item) => {
|
|
1540
|
-
var
|
|
1541
|
-
const originalPrice = ((_c2 = (_b2 = (
|
|
1550
|
+
var _a3, _b2, _c2;
|
|
1551
|
+
const originalPrice = ((_c2 = (_b2 = (_a3 = item.discount_list) == null ? void 0 : _a3[0]) == null ? void 0 : _b2.discount) == null ? void 0 : _c2.original_amount) || item.price;
|
|
1542
1552
|
newOriginTotal += Number(originalPrice) * Number(item.num);
|
|
1543
1553
|
});
|
|
1544
1554
|
}
|
|
@@ -432,6 +432,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
432
432
|
const externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
433
433
|
if (!params.forceRemote) {
|
|
434
434
|
const localRecord = params.orderId !== void 0 ? await this.store.order.getLocalOrderByOrderId(params.orderId) : externalSaleNumber ? await this.store.order.getLocalOrderByExternalSaleNumber(externalSaleNumber) : params.orderNumber ? await this.store.order.getLocalOrderByOrderNumber(params.orderNumber) : null;
|
|
435
|
+
debugger;
|
|
435
436
|
if (localRecord) {
|
|
436
437
|
const sales2 = await this.store.order.hydrateTempOrderFromRecord(localRecord, { recalcOnHydrate: false });
|
|
437
438
|
this.currentSalesDetail = sales2;
|
|
@@ -179,11 +179,13 @@ function mergeIdenticalPromotionCartLines(products) {
|
|
|
179
179
|
promotion.finalPrice ?? ((_c = line.metadata) == null ? void 0 : _c.main_product_selling_price) ?? ""
|
|
180
180
|
);
|
|
181
181
|
const bookingUid = (line == null ? void 0 : line.booking_uid) ?? ((_d = line == null ? void 0 : line.metadata) == null ? void 0 : _d.booking_uid);
|
|
182
|
+
const orderDetailId = (line == null ? void 0 : line.order_detail_id) ?? (line == null ? void 0 : line.orderDetailId);
|
|
182
183
|
const mergeKey = [
|
|
183
184
|
line.product_id,
|
|
184
185
|
line.product_variant_id ?? 0,
|
|
185
186
|
fingerprint,
|
|
186
187
|
bookingUid ? String(bookingUid) : "",
|
|
188
|
+
orderDetailId !== void 0 && orderDetailId !== null && orderDetailId !== "" ? String(orderDetailId) : "",
|
|
187
189
|
promotion.strategyId,
|
|
188
190
|
unitPrice,
|
|
189
191
|
promoUnitPrice
|
|
@@ -315,6 +317,14 @@ function getGiftInfo(product) {
|
|
|
315
317
|
var _a;
|
|
316
318
|
return ((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a._giftInfo) || (product == null ? void 0 : product._giftInfo) || null;
|
|
317
319
|
}
|
|
320
|
+
function isPersistedGeneratedVoucher(product) {
|
|
321
|
+
const orderDetailId = (product == null ? void 0 : product.order_detail_id) ?? (product == null ? void 0 : product.orderDetailId);
|
|
322
|
+
if (orderDetailId === void 0 || orderDetailId === null || orderDetailId === "") {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
const metadata = (product == null ? void 0 : product.metadata) || {};
|
|
326
|
+
return (product == null ? void 0 : product.extension_type) === "product_voucher" || metadata.parent_order_detail_id !== void 0 || metadata.gift_card_type !== void 0;
|
|
327
|
+
}
|
|
318
328
|
function getProductBundleForEvaluator(product) {
|
|
319
329
|
const bundles = Array.isArray(product == null ? void 0 : product.product_bundle) ? product.product_bundle : [];
|
|
320
330
|
return bundles.map((b) => ({
|
|
@@ -334,6 +344,15 @@ function buildConsolidateKeyForPromotion(item) {
|
|
|
334
344
|
item.product_bundle
|
|
335
345
|
);
|
|
336
346
|
const bookingUid = (item == null ? void 0 : item.booking_uid) ?? ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.booking_uid);
|
|
347
|
+
const orderDetailId = (item == null ? void 0 : item.order_detail_id) ?? (item == null ? void 0 : item.orderDetailId);
|
|
348
|
+
if (orderDetailId !== void 0 && orderDetailId !== null && orderDetailId !== "") {
|
|
349
|
+
return [
|
|
350
|
+
item.product_id,
|
|
351
|
+
item.product_variant_id ?? 0,
|
|
352
|
+
fingerprint,
|
|
353
|
+
String(orderDetailId)
|
|
354
|
+
].join("#");
|
|
355
|
+
}
|
|
337
356
|
if (bookingUid !== void 0 && bookingUid !== null && String(bookingUid) !== "") {
|
|
338
357
|
return [
|
|
339
358
|
item.product_id,
|
|
@@ -639,7 +658,9 @@ function processCartPromotion(list, evaluator, options) {
|
|
|
639
658
|
for (let i = 0; i < list.length; i++) {
|
|
640
659
|
const item = list[i];
|
|
641
660
|
const giftInfo = getGiftInfo(item);
|
|
642
|
-
if (
|
|
661
|
+
if (isPersistedGeneratedVoucher(item)) {
|
|
662
|
+
editProductsWithIndex.push({ item, originalListIndex: i });
|
|
663
|
+
} else if (giftInfo) {
|
|
643
664
|
existingGiftsWithIndex.push({ item, originalListIndex: i });
|
|
644
665
|
} else if ((item == null ? void 0 : item.booking_id) !== void 0 && (item == null ? void 0 : item.booking_id) !== null && item.booking_id !== 0 && item.booking_id !== "0") {
|
|
645
666
|
editProductsWithIndex.push({ item, originalListIndex: i });
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 1 | 2 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 3 | 5 | 4 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -45,8 +45,23 @@ var import_cartView = require("./utils/cartView");
|
|
|
45
45
|
var import_addProductDecision = require("./utils/addProductDecision");
|
|
46
46
|
var import_buildCacheItemFromOrderLine = require("../../modules/BookingContext/utils/buildCacheItemFromOrderLine");
|
|
47
47
|
var import_buildNormalProductCacheItemFromOrderLine = require("../../modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine");
|
|
48
|
+
var import_orderLineDisplay = require("../../modules/BookingContext/utils/orderLineDisplay");
|
|
48
49
|
var import_bookingStatus = require("./utils/bookingStatus");
|
|
49
50
|
__reExport(BookingTicket_exports, require("./types"), module.exports);
|
|
51
|
+
function withProductOptionString(cacheItem) {
|
|
52
|
+
var _a;
|
|
53
|
+
const productOptionString = (0, import_orderLineDisplay.buildProductOptionStringFromOrderLine)(cacheItem);
|
|
54
|
+
if (!productOptionString)
|
|
55
|
+
return cacheItem;
|
|
56
|
+
return {
|
|
57
|
+
...cacheItem,
|
|
58
|
+
product_option_string: (cacheItem == null ? void 0 : cacheItem.product_option_string) || productOptionString,
|
|
59
|
+
_extend: {
|
|
60
|
+
...(cacheItem == null ? void 0 : cacheItem._extend) || {},
|
|
61
|
+
product_option_string: ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.product_option_string) || productOptionString
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
50
65
|
var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
51
66
|
constructor() {
|
|
52
67
|
super(...arguments);
|
|
@@ -909,10 +924,12 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
909
924
|
* 拼装 cacheItem 的 _extend / _data(资源 / 容量 / timeObj),与 info2 `getProductExtend` 等价。
|
|
910
925
|
*/
|
|
911
926
|
getProductExtend(cacheItem, extra) {
|
|
912
|
-
|
|
913
|
-
|
|
927
|
+
const preparedCacheItem = withProductOptionString(cacheItem);
|
|
928
|
+
const result = (0, import_BookingContext.getProductExtend)({
|
|
929
|
+
cacheItem: preparedCacheItem,
|
|
914
930
|
ctx: this.buildBookingCalcContext(extra)
|
|
915
931
|
});
|
|
932
|
+
return result;
|
|
916
933
|
}
|
|
917
934
|
/**
|
|
918
935
|
* 取资源不可用原因列表(结构化 enum + params,i18n 文案由 UI 渲染)。
|