@pisell/pisellos 2.2.261 → 2.2.262

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.
Files changed (134) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  6. package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
  7. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  8. package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
  9. package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  10. package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
  11. package/dist/model/strategy/adapter/index.d.ts +4 -0
  12. package/dist/model/strategy/adapter/index.js +5 -1
  13. package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  14. package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
  15. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  16. package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
  17. package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
  18. package/dist/model/strategy/adapter/promotion/examples.js +0 -99
  19. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  20. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  21. package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
  22. package/dist/model/strategy/adapter/promotion/type.js +0 -45
  23. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
  24. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  25. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  26. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
  27. package/dist/modules/Discount/index.d.ts +5 -2
  28. package/dist/modules/Discount/index.js +30 -7
  29. package/dist/modules/Discount/types.d.ts +4 -0
  30. package/dist/modules/Order/index.d.ts +14 -2
  31. package/dist/modules/Order/index.js +1035 -736
  32. package/dist/modules/Order/types.d.ts +16 -0
  33. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  34. package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
  35. package/dist/modules/Order/utils.d.ts +4 -3
  36. package/dist/modules/Order/utils.js +54 -61
  37. package/dist/modules/Product/types.d.ts +22 -0
  38. package/dist/modules/ProductList/index.d.ts +1 -1
  39. package/dist/modules/ProductList/index.js +4 -2
  40. package/dist/modules/ProductList/types.d.ts +2 -0
  41. package/dist/modules/Rules/index.d.ts +2 -9
  42. package/dist/modules/Rules/index.js +69 -43
  43. package/dist/modules/Rules/types.d.ts +10 -1
  44. package/dist/server/index.d.ts +55 -0
  45. package/dist/server/index.js +1161 -742
  46. package/dist/server/modules/order/index.d.ts +10 -4
  47. package/dist/server/modules/order/index.js +404 -399
  48. package/dist/server/modules/order/types.d.ts +4 -0
  49. package/dist/server/modules/products/index.d.ts +31 -8
  50. package/dist/server/modules/products/index.js +549 -390
  51. package/dist/server/modules/products/types.d.ts +18 -0
  52. package/dist/solution/BaseSales/index.d.ts +21 -1
  53. package/dist/solution/BaseSales/index.js +1136 -789
  54. package/dist/solution/BaseSales/types.d.ts +6 -1
  55. package/dist/solution/BaseSales/types.js +1 -1
  56. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  57. package/dist/solution/BaseSales/utils/cartPromotion.js +48 -81
  58. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  59. package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
  60. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
  61. package/dist/solution/BookingByStep/index.d.ts +1 -1
  62. package/dist/solution/BookingTicket/index.d.ts +1 -1
  63. package/dist/solution/BookingTicket/index.js +59 -25
  64. package/dist/solution/BookingTicket/types.d.ts +2 -0
  65. package/dist/solution/ScanOrder/index.js +20 -31
  66. package/dist/solution/ShopDiscount/index.js +15 -14
  67. package/dist/solution/VenueBooking/index.js +19 -30
  68. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  69. package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
  70. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  71. package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
  72. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  73. package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
  74. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  75. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  76. package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  77. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  78. package/lib/model/strategy/adapter/index.d.ts +4 -0
  79. package/lib/model/strategy/adapter/index.js +13 -2
  80. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  81. package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
  82. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  83. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
  84. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
  85. package/lib/model/strategy/adapter/promotion/examples.js +0 -91
  86. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  87. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  88. package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
  89. package/lib/model/strategy/adapter/promotion/type.js +0 -2
  90. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
  91. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
  92. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  93. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
  94. package/lib/modules/Discount/index.d.ts +5 -2
  95. package/lib/modules/Discount/index.js +23 -3
  96. package/lib/modules/Discount/types.d.ts +4 -0
  97. package/lib/modules/Order/index.d.ts +14 -2
  98. package/lib/modules/Order/index.js +326 -60
  99. package/lib/modules/Order/types.d.ts +16 -0
  100. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  101. package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
  102. package/lib/modules/Order/utils.d.ts +4 -3
  103. package/lib/modules/Order/utils.js +22 -23
  104. package/lib/modules/Product/types.d.ts +22 -0
  105. package/lib/modules/ProductList/index.d.ts +1 -1
  106. package/lib/modules/ProductList/index.js +4 -2
  107. package/lib/modules/ProductList/types.d.ts +2 -0
  108. package/lib/modules/Rules/index.d.ts +2 -9
  109. package/lib/modules/Rules/index.js +61 -29
  110. package/lib/modules/Rules/types.d.ts +10 -1
  111. package/lib/server/index.d.ts +55 -0
  112. package/lib/server/index.js +327 -31
  113. package/lib/server/modules/order/index.d.ts +10 -4
  114. package/lib/server/modules/order/index.js +198 -139
  115. package/lib/server/modules/order/types.d.ts +4 -0
  116. package/lib/server/modules/products/index.d.ts +31 -8
  117. package/lib/server/modules/products/index.js +134 -35
  118. package/lib/server/modules/products/types.d.ts +18 -0
  119. package/lib/solution/BaseSales/index.d.ts +21 -1
  120. package/lib/solution/BaseSales/index.js +313 -72
  121. package/lib/solution/BaseSales/types.d.ts +6 -1
  122. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  123. package/lib/solution/BaseSales/utils/cartPromotion.js +29 -60
  124. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  125. package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
  126. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
  127. package/lib/solution/BookingByStep/index.d.ts +1 -1
  128. package/lib/solution/BookingTicket/index.d.ts +1 -1
  129. package/lib/solution/BookingTicket/index.js +33 -8
  130. package/lib/solution/BookingTicket/types.d.ts +2 -0
  131. package/lib/solution/ScanOrder/index.js +0 -8
  132. package/lib/solution/ShopDiscount/index.js +2 -1
  133. package/lib/solution/VenueBooking/index.js +0 -8
  134. package/package.json +1 -1
@@ -77,34 +77,19 @@ function getOrderProductOriginalPriceForPromotion(product) {
77
77
  }
78
78
  return getOrderProductBasePrice(product);
79
79
  }
80
- var X_ITEMS_FOR_Y_PRICE = "X_ITEMS_FOR_Y_PRICE";
81
- var ITEM_REWARD = "ITEM_REWARD";
82
- function isManagedPromotionDiscountItem(item) {
83
- var _a, _b;
84
- if ((item == null ? void 0 : item.type) === "promotion")
85
- return true;
86
- return (item == null ? void 0 : item.type) === "product" && ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = item == null ? void 0 : item.metadata) == null ? void 0 : _b.actionType) === ITEM_REWARD;
87
- }
88
- function updatePromotionDiscountList(item, promotionDiscount, options) {
80
+ function updatePromotionDiscountList(item, promotionDiscount) {
89
81
  let discountList = Array.isArray(item.discount_list) ? [...item.discount_list] : [];
90
- discountList = discountList.filter((d) => !isManagedPromotionDiscountItem(d));
82
+ discountList = discountList.filter((d) => (d == null ? void 0 : d.type) !== "promotion");
91
83
  if (promotionDiscount) {
92
- const discountType = (options == null ? void 0 : options.discountType) || "promotion";
93
84
  discountList.push({
94
- type: discountType,
85
+ type: "promotion",
95
86
  amount: promotionDiscount.amount,
96
87
  discount: {
97
88
  original_amount: promotionDiscount.original_amount,
98
89
  fixed_amount: promotionDiscount.fixed_amount,
99
90
  title: promotionDiscount.title,
100
91
  resource_id: ""
101
- },
102
- ...discountType === "product" ? {
103
- metadata: {
104
- source: "promotion",
105
- actionType: (options == null ? void 0 : options.actionType) || ITEM_REWARD
106
- }
107
- } : {}
92
+ }
108
93
  });
109
94
  }
110
95
  if (discountList.length > 0) {
@@ -113,15 +98,7 @@ function updatePromotionDiscountList(item, promotionDiscount, options) {
113
98
  delete item.discount_list;
114
99
  }
115
100
  }
116
- function evaluatorHasActionType(evaluator, actionType) {
117
- var _a;
118
- const configs = (_a = evaluator == null ? void 0 : evaluator.getStrategyConfigs) == null ? void 0 : _a.call(evaluator);
119
- if (!Array.isArray(configs))
120
- return false;
121
- return configs.some(
122
- (config) => ((config == null ? void 0 : config.actions) || []).some((action) => (action == null ? void 0 : action.type) === actionType)
123
- );
124
- }
101
+ var X_ITEMS_FOR_Y_PRICE = "X_ITEMS_FOR_Y_PRICE";
125
102
  function applyPromoUnitPriceToLine(item, input) {
126
103
  const metadata = item.metadata || (item.metadata = {});
127
104
  const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(item)).toNumber();
@@ -148,9 +125,6 @@ function applyPromoUnitPriceToLine(item, input) {
148
125
  amount: discountAmount,
149
126
  original_amount: catalogSource,
150
127
  fixed_amount: discountAmount
151
- }, {
152
- actionType: input.actionType,
153
- discountType: input.actionType === ITEM_REWARD ? "product" : "promotion"
154
128
  });
155
129
  } else {
156
130
  updatePromotionDiscountList(item, null);
@@ -205,6 +179,7 @@ function mergeIdenticalPromotionCartLines(products) {
205
179
  promotion.finalPrice ?? ((_c = line.metadata) == null ? void 0 : _c.main_product_selling_price) ?? ""
206
180
  );
207
181
  const noteSignature = getProductLineNoteSignature(line);
182
+ const lineMergeBoundary = getPromotionLineMergeBoundary(line);
208
183
  const bookingUid = (line == null ? void 0 : line.booking_uid) ?? ((_d = line == null ? void 0 : line.metadata) == null ? void 0 : _d.booking_uid);
209
184
  const orderDetailId = (line == null ? void 0 : line.order_detail_id) ?? (line == null ? void 0 : line.orderDetailId);
210
185
  const mergeKey = [
@@ -212,6 +187,7 @@ function mergeIdenticalPromotionCartLines(products) {
212
187
  line.product_variant_id ?? 0,
213
188
  fingerprint,
214
189
  noteSignature,
190
+ lineMergeBoundary,
215
191
  bookingUid ? String(bookingUid) : "",
216
192
  orderDetailId !== void 0 && orderDetailId !== null && orderDetailId !== "" ? String(orderDetailId) : "",
217
193
  promotion.strategyId,
@@ -355,6 +331,12 @@ function getProductLineNoteSignature(product) {
355
331
  const uid = getOrderProductUid(product);
356
332
  return uid ? `note:${uid}` : `note:${normalizedNote}`;
357
333
  }
334
+ function getPromotionLineMergeBoundary(product) {
335
+ var _a;
336
+ if (((_a = product == null ? void 0 : product.metadata) == null ? void 0 : _a.is_edit_for_runtime) !== true)
337
+ return "";
338
+ return `edit:${getOrderProductUid(product)}`;
339
+ }
358
340
  function isPersistedGeneratedVoucher(product) {
359
341
  const orderDetailId = (product == null ? void 0 : product.order_detail_id) ?? (product == null ? void 0 : product.orderDetailId);
360
342
  if (orderDetailId === void 0 || orderDetailId === null || orderDetailId === "") {
@@ -382,6 +364,7 @@ function buildConsolidateKeyForPromotion(item) {
382
364
  item.product_bundle
383
365
  );
384
366
  const noteSignature = getProductLineNoteSignature(item);
367
+ const lineMergeBoundary = getPromotionLineMergeBoundary(item);
385
368
  const bookingUid = (item == null ? void 0 : item.booking_uid) ?? ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.booking_uid);
386
369
  const orderDetailId = (item == null ? void 0 : item.order_detail_id) ?? (item == null ? void 0 : item.orderDetailId);
387
370
  if (orderDetailId !== void 0 && orderDetailId !== null && orderDetailId !== "") {
@@ -390,6 +373,7 @@ function buildConsolidateKeyForPromotion(item) {
390
373
  item.product_variant_id ?? 0,
391
374
  fingerprint,
392
375
  noteSignature,
376
+ lineMergeBoundary,
393
377
  String(orderDetailId)
394
378
  ].join("#");
395
379
  }
@@ -399,6 +383,7 @@ function buildConsolidateKeyForPromotion(item) {
399
383
  item.product_variant_id ?? 0,
400
384
  fingerprint,
401
385
  noteSignature,
386
+ lineMergeBoundary,
402
387
  String(bookingUid)
403
388
  ].join("#");
404
389
  }
@@ -406,7 +391,8 @@ function buildConsolidateKeyForPromotion(item) {
406
391
  item.product_id,
407
392
  item.product_variant_id ?? 0,
408
393
  fingerprint,
409
- noteSignature
394
+ noteSignature,
395
+ lineMergeBoundary
410
396
  ].join("#");
411
397
  }
412
398
  function consolidateMainProductsForPromotion(entries) {
@@ -483,9 +469,6 @@ function splitXItemsPromoLinesByGroup(lines, strategyActionMap) {
483
469
  function generateNumericId() {
484
470
  return Math.floor(Math.random() * 1e9) + Date.now();
485
471
  }
486
- function isBookingEditProductLine(product) {
487
- return (product == null ? void 0 : product.booking_id) !== void 0 && (product == null ? void 0 : product.booking_id) !== null && product.booking_id !== 0 && product.booking_id !== "0";
488
- }
489
472
  function convertToPromotionProduct(product, index) {
490
473
  const metadata = (product == null ? void 0 : product.metadata) || {};
491
474
  const numericId = generateNumericId();
@@ -498,7 +481,6 @@ function convertToPromotionProduct(product, index) {
498
481
  price: getOrderProductOriginalPriceForPromotion(product),
499
482
  quantity: Number((product == null ? void 0 : product.num) ?? 1) || 1,
500
483
  bundle: getProductBundleForEvaluator(product),
501
- _promotionOnlyForItemReward: isBookingEditProductLine(product),
502
484
  _originalItem: originalItem,
503
485
  _originalId: getOrderProductUid(product),
504
486
  _originalIndex: index
@@ -600,9 +582,6 @@ function resolveStrategyRequiredQuantity(matched) {
600
582
  if (matched.actionType === "BUY_X_GET_Y_FREE") {
601
583
  return Number(detail.buyQuantity) || 1;
602
584
  }
603
- if (matched.actionType === "ITEM_REWARD") {
604
- return Number(detail.triggerQuantity) || 1;
605
- }
606
585
  return 1;
607
586
  }
608
587
  function resolveStrategyEligibleProducts(matched) {
@@ -703,7 +682,7 @@ function appendPromotionTags(products, evaluator) {
703
682
  });
704
683
  }
705
684
  function processCartPromotion(list, evaluator, options) {
706
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
685
+ var _a, _b, _c, _d, _e, _f, _g, _h;
707
686
  const empty = {
708
687
  products: Array.isArray(list) ? [...list] : [],
709
688
  totalDiscount: 0,
@@ -713,10 +692,6 @@ function processCartPromotion(list, evaluator, options) {
713
692
  };
714
693
  if (!list || list.length === 0 || !evaluator)
715
694
  return empty;
716
- const shouldIncludeEditProductsForItemReward = evaluatorHasActionType(
717
- evaluator,
718
- ITEM_REWARD
719
- );
720
695
  const mainProductsWithIndex = [];
721
696
  const existingGiftsWithIndex = [];
722
697
  const editProductsWithIndex = [];
@@ -727,12 +702,8 @@ function processCartPromotion(list, evaluator, options) {
727
702
  editProductsWithIndex.push({ item, originalListIndex: i });
728
703
  } else if (giftInfo) {
729
704
  existingGiftsWithIndex.push({ item, originalListIndex: i });
730
- } else if (isBookingEditProductLine(item)) {
731
- if (shouldIncludeEditProductsForItemReward) {
732
- mainProductsWithIndex.push({ item, originalListIndex: i });
733
- } else {
734
- editProductsWithIndex.push({ item, originalListIndex: i });
735
- }
705
+ } 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") {
706
+ editProductsWithIndex.push({ item, originalListIndex: i });
736
707
  } else {
737
708
  mainProductsWithIndex.push({ item, originalListIndex: i });
738
709
  }
@@ -775,8 +746,7 @@ function processCartPromotion(list, evaluator, options) {
775
746
  name: ((_a2 = item == null ? void 0 : item.metadata) == null ? void 0 : _a2.product_name) || (item == null ? void 0 : item.title) || "",
776
747
  price: getOrderProductBasePrice(item),
777
748
  quantity: Number((item == null ? void 0 : item.num) ?? 1) || 1,
778
- bundle: getProductBundleForEvaluator(item),
779
- _promotionOnlyForItemReward: isBookingEditProductLine(item)
749
+ bundle: getProductBundleForEvaluator(item)
780
750
  };
781
751
  });
782
752
  for (let i = 0; i < consolidatedMainProductsWithIndex.length; i++) {
@@ -862,8 +832,7 @@ function processCartPromotion(list, evaluator, options) {
862
832
  applyPromoUnitPriceToLine(newItem, {
863
833
  promoUnitPrice,
864
834
  originalBasePrice,
865
- strategyTitle: (_b = priced.strategyMetadata) == null ? void 0 : _b.name,
866
- actionType: priced.strategyId ? (_c = strategyActionMap.get(priced.strategyId)) == null ? void 0 : _c.actionType : void 0
835
+ strategyTitle: (_b = priced.strategyMetadata) == null ? void 0 : _b.name
867
836
  });
868
837
  } else {
869
838
  const optionSum = (0, import_utils.sumOptionUnitPrice)((0, import_utils.getProductSkuOptions)(newItem)).toNumber();
@@ -911,7 +880,7 @@ function processCartPromotion(list, evaluator, options) {
911
880
  giftOptions: gift.giftOptions
912
881
  };
913
882
  const bundleIdx = priced.matchedBundleIndex;
914
- if (bundleIdx !== void 0 && Array.isArray(newItem.product_bundle) && ((_d = newItem.product_bundle[bundleIdx]) == null ? void 0 : _d._promotion)) {
883
+ if (bundleIdx !== void 0 && Array.isArray(newItem.product_bundle) && ((_c = newItem.product_bundle[bundleIdx]) == null ? void 0 : _c._promotion)) {
915
884
  newItem.product_bundle[bundleIdx]._promotion.giftInfo = giftInfoData;
916
885
  } else if (metadata._promotion) {
917
886
  metadata._promotion.giftInfo = giftInfoData;
@@ -931,14 +900,14 @@ function processCartPromotion(list, evaluator, options) {
931
900
  const next = item;
932
901
  next._sortIndex = originalListIndex;
933
902
  next._sortSubIndex = 0;
934
- const strategyId = (_e = getGiftInfo(next)) == null ? void 0 : _e.strategyId;
903
+ const strategyId = (_d = getGiftInfo(next)) == null ? void 0 : _d.strategyId;
935
904
  if (strategyId) {
936
905
  const latest = strategyGiftInfoMap.get(strategyId);
937
906
  const owner = strategyGiftInfoOwner.get(strategyId);
938
- if (latest && ((_f = next.metadata) == null ? void 0 : _f._giftInfo)) {
907
+ if (latest && ((_e = next.metadata) == null ? void 0 : _e._giftInfo)) {
939
908
  next.metadata._giftInfo.sourceProductIds = latest.sourceProductIds;
940
909
  }
941
- if (owner && ((_g = next.metadata) == null ? void 0 : _g._giftInfo)) {
910
+ if (owner && ((_f = next.metadata) == null ? void 0 : _f._giftInfo)) {
942
911
  next.metadata._giftInfo.sourceProductId = owner;
943
912
  }
944
913
  }
@@ -991,11 +960,11 @@ function processCartPromotion(list, evaluator, options) {
991
960
  }
992
961
  const giftActions = calculateGiftActions(extendedGifts, existingGifts);
993
962
  for (const gift of existingGifts) {
994
- const strategyId = (_h = getGiftInfo(gift)) == null ? void 0 : _h.strategyId;
963
+ const strategyId = (_g = getGiftInfo(gift)) == null ? void 0 : _g.strategyId;
995
964
  if (!strategyId)
996
965
  continue;
997
966
  const latest = strategyGiftInfoMap.get(strategyId);
998
- if (latest && ((_i = gift.metadata) == null ? void 0 : _i._giftInfo)) {
967
+ if (latest && ((_h = gift.metadata) == null ? void 0 : _h._giftInfo)) {
999
968
  gift.metadata._giftInfo.lastEvaluatedGiftCount = latest.giftCount;
1000
969
  }
1001
970
  }
@@ -2,7 +2,7 @@
2
2
  * 把 `/order/sales/{id}` 响应(OrderData)解析为 ISalesDetail。
3
3
  *
4
4
  * - 纯函数:不依赖任何运行时模块/插件,便于单测与 view-model 适配
5
- * - products 保留 tempOrder / 后端详情原字段,仅做浅拷贝,避免丢失 product_sku 等协议字段
5
+ * - products 保留 tempOrder / 后端详情原字段,仅规范化集合身份并浅拷贝,避免丢失 product_sku 等协议字段
6
6
  * - bookings 平铺保留服务端原顺序,同时输出 byProductUid 反查表与 rootBooking
7
7
  * - header 收敛"非数组顶层字段",便于 ticketBooking view-model 直接消费
8
8
  *
@@ -130,7 +130,7 @@ export interface ISalesDetail {
130
130
  customer: ISalesDetailCustomer | null;
131
131
  /** 服务端 summary(仅输出) */
132
132
  summary: Record<string, any>;
133
- /** 原始响应快照,方便 UI 兜底使用 */
133
+ /** 规范化后的响应快照,方便 UI 兜底使用 */
134
134
  raw: Record<string, any>;
135
135
  }
136
136
  /**
@@ -138,7 +138,7 @@ export interface ISalesDetail {
138
138
  *
139
139
  * 注意:
140
140
  * - 入参允许是 `{ data: OrderData }` 或直接 `OrderData`,自动识别。
141
- * - products 保留原字段;字段补齐由 OrderModule hydrate 负责。
141
+ * - products/bookings/payments 在此补齐集合身份;其余 runtime 字段由 OrderModule hydrate 负责。
142
142
  * - 不做远程请求;不修改入参;返回新对象。
143
143
  */
144
144
  export declare function parseSalesResponse(input: Record<string, any> | null | undefined): ISalesDetail;
@@ -22,6 +22,7 @@ __export(parseSalesResponse_exports, {
22
22
  parseSalesResponse: () => parseSalesResponse
23
23
  });
24
24
  module.exports = __toCommonJS(parseSalesResponse_exports);
25
+ var import_orderCollectionIdentity = require("../../../modules/Order/utils/orderCollectionIdentity");
25
26
  var HEADER_KEYS = [
26
27
  "order_id",
27
28
  "order_number",
@@ -121,14 +122,12 @@ function indexBookingsByProductUid(bookings) {
121
122
  return result;
122
123
  }
123
124
  function parseSalesResponse(input) {
124
- const raw = input && typeof input === "object" && input.data && input.order_id == null ? input.data : input || {};
125
+ const sourceRaw = input && typeof input === "object" && input.data && input.order_id == null ? input.data : input || {};
126
+ const raw = (0, import_orderCollectionIdentity.normalizeOrderCollections)(sourceRaw).order;
125
127
  const productsRaw = Array.isArray(raw == null ? void 0 : raw.products) ? raw.products : [];
126
- const products = productsRaw.map((p, index) => {
128
+ const products = productsRaw.map((p) => {
127
129
  const row = { ...p || {} };
128
130
  const metadata = row.metadata && typeof row.metadata === "object" ? { ...row.metadata } : {};
129
- if (!metadata.unique_identification_number) {
130
- metadata.unique_identification_number = `sales-product-${row.product_id ?? "unknown"}-${row.product_variant_id ?? 0}-${index}`;
131
- }
132
131
  delete metadata.price_schema_version;
133
132
  delete row.identity_key;
134
133
  return { ...row, metadata };
@@ -50,6 +50,12 @@ function toPriceString(value, fallback = "0.00") {
50
50
  return fallback;
51
51
  return parsedValue.toFixed(2);
52
52
  }
53
+ function isBlankValue(value) {
54
+ return value === void 0 || value === null || typeof value === "string" && value.trim() === "";
55
+ }
56
+ function firstNonBlank(...values) {
57
+ return values.find((value) => !isBlankValue(value));
58
+ }
53
59
  function normalizeOptionItems(optionItems) {
54
60
  if (!Array.isArray(optionItems))
55
61
  return [];
@@ -198,6 +204,7 @@ function transformBaseProductToOrderProduct(params) {
198
204
  main_product_selling_price: mainProductSellingPrice,
199
205
  main_product_original_price: mainProductOriginalPrice,
200
206
  price_schema_version: 2,
207
+ holder_config: sourceProduct == null ? void 0 : sourceProduct.holder_config,
201
208
  ...hasPriceOverride ? {
202
209
  price_override: String(payload.price_override),
203
210
  is_manual_discount: 1
@@ -236,6 +243,7 @@ function transformBaseProductToOrderProduct(params) {
236
243
  metadata,
237
244
  note: payload.note != null ? String(payload.note) : "",
238
245
  product_title: productTitle,
246
+ product_cover: firstNonBlank(matchedVariant == null ? void 0 : matchedVariant.cover, sourceProduct == null ? void 0 : sourceProduct.cover),
239
247
  _origin: {
240
248
  ...sourceProduct || {},
241
249
  callbackData: payload
@@ -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 | 2 | 1 | 5 | 3 | 4 | 6;
314
+ weekNum: 0 | 2 | 1 | 6 | 4 | 3 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
322
322
  * 获取当前的客户搜索条件
323
323
  * @returns 当前搜索条件
324
324
  */
325
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
325
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
326
326
  /**
327
327
  * 获取客户列表状态(包含滚动加载相关状态)
328
328
  * @returns 客户状态
@@ -341,15 +341,28 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
341
341
  if (!this.store.order)
342
342
  throw new Error("order 模块未初始化");
343
343
  const raw = await this.store.order.scanCode(code, customerId);
344
+ const scannedList = raw.scannedDiscountList || [];
345
+ const extractedCustomerId = this.getDiscountCustomerId(scannedList);
346
+ const hasOrderCustomer = Boolean(this.store.order.getOrderCustomer());
347
+ if (!hasOrderCustomer && extractedCustomerId) {
348
+ await this.hydrateOrderCustomerFromScanDiscounts(scannedList);
349
+ }
344
350
  if (raw.isAvailable) {
345
- await this.hydrateOrderCustomerFromScanDiscounts(raw.scannedDiscountList || []);
346
351
  await this.store.order.recalculateSummary({ createIfMissing: true });
347
352
  this.store.order.persistTempOrder();
353
+ const tempOrder = this.store.order.ensureTempOrder();
354
+ await this.effectsEmit("onDiscountApplied", {
355
+ productList: tempOrder.products || [],
356
+ discountList: this.store.order.getDiscountList(),
357
+ selectedDiscountList: tempOrder.discount_list || [],
358
+ tempOrder
359
+ });
348
360
  }
349
361
  return {
350
362
  isAvailable: raw.isAvailable,
351
363
  type: raw.type,
352
- unavailableReason: raw.unavailableReason
364
+ unavailableReason: raw.unavailableReason,
365
+ scannedDiscountList: raw.scannedDiscountList
353
366
  };
354
367
  }
355
368
  async hydrateOrderCustomerFromScanDiscounts(discounts) {
@@ -366,11 +379,13 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
366
379
  this.setOrderCustomer(customer);
367
380
  }
368
381
  getDiscountCustomerId(discounts) {
369
- const discount = discounts.find((item) => item.customer_id != null);
370
- const customerId = Number(discount == null ? void 0 : discount.customer_id);
371
- if (!Number.isFinite(customerId) || customerId <= 0)
372
- return null;
373
- return customerId;
382
+ for (const item of discounts) {
383
+ const topLevelId = Number(item.customer_id);
384
+ if (Number.isFinite(topLevelId) && topLevelId > 0) {
385
+ return topLevelId;
386
+ }
387
+ }
388
+ return null;
374
389
  }
375
390
  async resolveCustomerByDiscountCustomerId(customerId) {
376
391
  var _a;
@@ -862,7 +877,17 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
862
877
  void ((_a = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _a.call(discountModule, []));
863
878
  void ((_b = discountModule == null ? void 0 : discountModule.setDiscountList) == null ? void 0 : _b.call(discountModule, []));
864
879
  this.store.order.applyDiscount();
865
- void this.store.order.recalculateSummary({ createIfMissing: true }).then(() => this.store.order.persistTempOrder()).catch((error) => {
880
+ void this.store.order.recalculateSummary({ createIfMissing: true }).then(() => {
881
+ var _a2;
882
+ const tempOrder = this.store.order.ensureTempOrder();
883
+ this.store.order.persistTempOrder();
884
+ return this.effectsEmit("onDiscountApplied", {
885
+ productList: tempOrder.products || [],
886
+ discountList: ((_a2 = discountModule == null ? void 0 : discountModule.getDiscountList) == null ? void 0 : _a2.call(discountModule)) || [],
887
+ selectedDiscountList: tempOrder.discount_list || [],
888
+ tempOrder
889
+ });
890
+ }).catch((error) => {
866
891
  console.error("Failed to recalculate summary after clearing customer:", error);
867
892
  });
868
893
  this.core.effects.emit(`${this.name}:onOrderCustomerChange`, null);
@@ -83,6 +83,8 @@ export interface ILoadProductsParams {
83
83
  extension_type?: string[];
84
84
  /** 商品发布状态 */
85
85
  status?: string;
86
+ /** 智能定价条件上下文,仅影响策略命中,不参与商品集合筛选 */
87
+ strategy_context?: Record<string, any>;
86
88
  }
87
89
  /**
88
90
  * 加载商品详情的参数
@@ -48,10 +48,6 @@ var import_utils2 = require("../../modules/Order/utils");
48
48
  var import_dayjs = __toESM(require("dayjs"));
49
49
  var import_itemRule = require("../../model/strategy/adapter/itemRule");
50
50
  __reExport(ScanOrder_exports, require("./types"), module.exports);
51
- function isItemRewardProductDiscount(discount) {
52
- var _a, _b;
53
- return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
54
- }
55
51
  var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
56
52
  constructor(name, version) {
57
53
  super(name, version);
@@ -746,10 +742,6 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
746
742
  for (const product of tempOrder.products) {
747
743
  if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
748
744
  continue;
749
- if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
750
- product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
751
- continue;
752
- }
753
745
  product.discount_list = (product.discount_list || []).filter((pd) => {
754
746
  var _a2;
755
747
  const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
@@ -505,7 +505,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
505
505
  try {
506
506
  const orderId = this.store.orderId;
507
507
  const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
508
- const goodPassList = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
508
+ const prepareConfigResult = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
509
509
  customer_id: customerId,
510
510
  action: orderId ? "edit" : "create",
511
511
  with_good_pass: 1,
@@ -514,6 +514,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
514
514
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
515
515
  ...orderId ? { order_id: orderId } : {}
516
516
  }));
517
+ const goodPassList = (prepareConfigResult == null ? void 0 : prepareConfigResult.discountList) || [];
517
518
  const scanDiscount = (_c = this.getDiscountList()) == null ? void 0 : _c.filter(
518
519
  (item) => item.isScan
519
520
  );
@@ -65,10 +65,6 @@ var OPEN_DATA_SECTION_CODES = [
65
65
  "workflow",
66
66
  "checkout"
67
67
  ];
68
- function isItemRewardProductDiscount(discount) {
69
- var _a, _b;
70
- return (discount == null ? void 0 : discount.type) === "product" && ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.source) === "promotion" && ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.actionType) === "ITEM_REWARD";
71
- }
72
68
  function cloneCustomDepositData(customDepositData) {
73
69
  if (!customDepositData || typeof customDepositData !== "object")
74
70
  return void 0;
@@ -1343,10 +1339,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1343
1339
  for (const product of tempOrder.products) {
1344
1340
  if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
1345
1341
  continue;
1346
- if ((product.discount_list || []).some(isItemRewardProductDiscount)) {
1347
- product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
1348
- continue;
1349
- }
1350
1342
  product.discount_list = (product.discount_list || []).filter((pd) => {
1351
1343
  var _a2;
1352
1344
  const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.261",
4
+ "version": "2.2.262",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",