@pisell/pisellos 2.3.43 → 2.3.45

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 (160) hide show
  1. package/dist/modules/Discount/index.d.ts +0 -1
  2. package/dist/modules/Discount/index.js +11 -40
  3. package/dist/modules/Discount/types.d.ts +0 -1
  4. package/dist/modules/OpenData/index.js +2 -2
  5. package/dist/modules/Order/index.d.ts +2 -3
  6. package/dist/modules/Order/index.js +98 -82
  7. package/dist/modules/Order/types.d.ts +2 -9
  8. package/dist/modules/Order/utils.d.ts +0 -10
  9. package/dist/modules/Order/utils.js +3 -35
  10. package/dist/modules/Payment/walletpass.d.ts +10 -3
  11. package/dist/modules/Payment/walletpass.js +425 -282
  12. package/dist/modules/Product/types.d.ts +0 -1
  13. package/dist/modules/ProductList/index.js +14 -33
  14. package/dist/modules/Quotation/index.d.ts +1 -1
  15. package/dist/modules/Quotation/index.js +2 -2
  16. package/dist/modules/Rules/index.d.ts +2 -0
  17. package/dist/modules/Rules/index.js +72 -102
  18. package/dist/modules/SalesSummary/index.js +13 -12
  19. package/dist/modules/ScanOrderLogger/index.d.ts +0 -2
  20. package/dist/modules/ScanOrderLogger/index.js +2 -15
  21. package/dist/modules/ScanOrderLogger/providers/feishu.js +27 -45
  22. package/dist/modules/ScanOrderLogger/types.d.ts +0 -1
  23. package/dist/modules/Schedule/index.d.ts +1 -3
  24. package/dist/modules/Schedule/index.js +16 -21
  25. package/dist/modules/Summary/utils.js +13 -38
  26. package/dist/modules/index.d.ts +0 -2
  27. package/dist/modules/index.js +1 -3
  28. package/dist/plugins/window.d.ts +0 -1
  29. package/dist/server/index.d.ts +0 -14
  30. package/dist/server/index.js +657 -772
  31. package/dist/solution/BaseSales/index.d.ts +0 -7
  32. package/dist/solution/BaseSales/index.js +48 -67
  33. package/dist/solution/BaseSales/types.d.ts +3 -1
  34. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
  35. package/dist/solution/BookingByStep/index.d.ts +1 -16
  36. package/dist/solution/BookingByStep/index.js +215 -294
  37. package/dist/solution/BookingByStep/types.d.ts +1 -2
  38. package/dist/solution/BookingByStep/types.js +1 -3
  39. package/dist/solution/BookingByStep/utils/capacity.js +1 -17
  40. package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  41. package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
  42. package/dist/solution/BookingTicket/index.d.ts +1 -13
  43. package/dist/solution/BookingTicket/index.js +8 -5
  44. package/dist/solution/BookingTicket/types.d.ts +1 -0
  45. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +3 -3
  46. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -3
  47. package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -10
  48. package/dist/solution/ScanOrder/index.d.ts +14 -26
  49. package/dist/solution/ScanOrder/index.js +739 -1142
  50. package/dist/solution/ScanOrder/types.d.ts +1 -21
  51. package/dist/solution/ScanOrder/utils.d.ts +0 -8
  52. package/dist/solution/ScanOrder/utils.js +25 -66
  53. package/dist/solution/ShopDiscount/index.d.ts +0 -1
  54. package/dist/solution/ShopDiscount/index.js +87 -125
  55. package/dist/solution/VenueBooking/index.d.ts +12 -39
  56. package/dist/solution/VenueBooking/index.js +841 -1167
  57. package/dist/solution/VenueBooking/types.d.ts +0 -3
  58. package/dist/solution/VenueBooking/utils/resource.js +0 -1
  59. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  60. package/dist/solution/VenueBooking/utils/slotMerge.js +5 -10
  61. package/dist/solution/index.d.ts +0 -1
  62. package/dist/solution/index.js +1 -2
  63. package/dist/types/index.d.ts +0 -1
  64. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  65. package/lib/modules/Discount/index.d.ts +0 -1
  66. package/lib/modules/Discount/index.js +0 -9
  67. package/lib/modules/Discount/types.d.ts +0 -1
  68. package/lib/modules/OpenData/index.js +1 -1
  69. package/lib/modules/Order/index.d.ts +2 -3
  70. package/lib/modules/Order/index.js +56 -33
  71. package/lib/modules/Order/types.d.ts +2 -9
  72. package/lib/modules/Order/utils.d.ts +0 -10
  73. package/lib/modules/Order/utils.js +5 -36
  74. package/lib/modules/Payment/walletpass.d.ts +10 -3
  75. package/lib/modules/Payment/walletpass.js +218 -56
  76. package/lib/modules/Product/types.d.ts +0 -1
  77. package/lib/modules/ProductList/index.js +31 -40
  78. package/lib/modules/Quotation/index.d.ts +1 -1
  79. package/lib/modules/Quotation/index.js +2 -2
  80. package/lib/modules/Rules/index.d.ts +2 -0
  81. package/lib/modules/Rules/index.js +24 -36
  82. package/lib/modules/SalesSummary/index.js +7 -6
  83. package/lib/modules/ScanOrderLogger/index.d.ts +0 -2
  84. package/lib/modules/ScanOrderLogger/index.js +1 -13
  85. package/lib/modules/ScanOrderLogger/providers/feishu.js +6 -15
  86. package/lib/modules/ScanOrderLogger/types.d.ts +0 -1
  87. package/lib/modules/Schedule/index.d.ts +1 -3
  88. package/lib/modules/Schedule/index.js +8 -10
  89. package/lib/modules/Summary/utils.js +1 -21
  90. package/lib/modules/index.d.ts +0 -2
  91. package/lib/modules/index.js +1 -5
  92. package/lib/plugins/window.d.ts +0 -1
  93. package/lib/server/index.d.ts +0 -14
  94. package/lib/server/index.js +5 -65
  95. package/lib/solution/BaseSales/index.d.ts +0 -7
  96. package/lib/solution/BaseSales/index.js +9 -24
  97. package/lib/solution/BaseSales/types.d.ts +3 -1
  98. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
  99. package/lib/solution/BookingByStep/index.d.ts +1 -16
  100. package/lib/solution/BookingByStep/index.js +18 -60
  101. package/lib/solution/BookingByStep/types.d.ts +1 -2
  102. package/lib/solution/BookingByStep/types.js +0 -5
  103. package/lib/solution/BookingByStep/utils/capacity.js +1 -20
  104. package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  105. package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
  106. package/lib/solution/BookingTicket/index.d.ts +1 -13
  107. package/lib/solution/BookingTicket/index.js +3 -10
  108. package/lib/solution/BookingTicket/types.d.ts +1 -0
  109. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +2 -2
  110. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +1 -3
  111. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  112. package/lib/solution/ScanOrder/index.d.ts +14 -26
  113. package/lib/solution/ScanOrder/index.js +182 -449
  114. package/lib/solution/ScanOrder/types.d.ts +1 -21
  115. package/lib/solution/ScanOrder/utils.d.ts +0 -8
  116. package/lib/solution/ScanOrder/utils.js +0 -31
  117. package/lib/solution/ShopDiscount/index.d.ts +0 -1
  118. package/lib/solution/ShopDiscount/index.js +0 -14
  119. package/lib/solution/VenueBooking/index.d.ts +12 -39
  120. package/lib/solution/VenueBooking/index.js +110 -322
  121. package/lib/solution/VenueBooking/types.d.ts +0 -3
  122. package/lib/solution/VenueBooking/utils/resource.js +0 -1
  123. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  124. package/lib/solution/VenueBooking/utils/slotMerge.js +4 -6
  125. package/lib/solution/index.d.ts +0 -1
  126. package/lib/solution/index.js +1 -3
  127. package/lib/types/index.d.ts +0 -1
  128. package/package.json +1 -1
  129. package/dist/modules/Holder/index.d.ts +0 -48
  130. package/dist/modules/Holder/index.js +0 -640
  131. package/dist/modules/Holder/types.d.ts +0 -123
  132. package/dist/modules/Holder/types.js +0 -1
  133. package/dist/modules/Holder/utils.d.ts +0 -13
  134. package/dist/modules/Holder/utils.js +0 -34
  135. package/dist/modules/ResourcePlanner/index.d.ts +0 -24
  136. package/dist/modules/ResourcePlanner/index.js +0 -181
  137. package/dist/modules/ResourcePlanner/planner.d.ts +0 -14
  138. package/dist/modules/ResourcePlanner/planner.js +0 -1069
  139. package/dist/modules/ResourcePlanner/types.d.ts +0 -227
  140. package/dist/modules/ResourcePlanner/types.js +0 -1
  141. package/dist/solution/UnifiedBookingSales/index.d.ts +0 -183
  142. package/dist/solution/UnifiedBookingSales/index.js +0 -1891
  143. package/dist/solution/UnifiedBookingSales/types.d.ts +0 -143
  144. package/dist/solution/UnifiedBookingSales/types.js +0 -11
  145. package/lib/modules/Holder/index.d.ts +0 -48
  146. package/lib/modules/Holder/index.js +0 -402
  147. package/lib/modules/Holder/types.d.ts +0 -123
  148. package/lib/modules/Holder/types.js +0 -17
  149. package/lib/modules/Holder/utils.d.ts +0 -13
  150. package/lib/modules/Holder/utils.js +0 -71
  151. package/lib/modules/ResourcePlanner/index.d.ts +0 -24
  152. package/lib/modules/ResourcePlanner/index.js +0 -148
  153. package/lib/modules/ResourcePlanner/planner.d.ts +0 -14
  154. package/lib/modules/ResourcePlanner/planner.js +0 -933
  155. package/lib/modules/ResourcePlanner/types.d.ts +0 -227
  156. package/lib/modules/ResourcePlanner/types.js +0 -17
  157. package/lib/solution/UnifiedBookingSales/index.d.ts +0 -183
  158. package/lib/solution/UnifiedBookingSales/index.js +0 -1084
  159. package/lib/solution/UnifiedBookingSales/types.d.ts +0 -143
  160. package/lib/solution/UnifiedBookingSales/types.js +0 -33
@@ -150,7 +150,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
150
150
  }
151
151
 
152
152
  // 编辑商品已有商品券
153
- if (productList.every(function (item) {
153
+ if (productList.length > 0 && productList.every(function (item) {
154
154
  var _product$discount_lis;
155
155
  var product = _this2.hooks.getProduct(item);
156
156
  return product.booking_id && (((_product$discount_lis = product.discount_list) === null || _product$discount_lis === void 0 ? void 0 : _product$discount_lis.length) || product.total == 0);
@@ -214,6 +214,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
214
214
  return {
215
215
  isAvailable: hasApplicableDiscount,
216
216
  discountList: hasApplicableDiscount ? result.discountList : oldDiscountList,
217
+ evaluatedDiscountList: result.discountList,
217
218
  productList: hasApplicableDiscount ? result.productList : productList,
218
219
  unavailableReason: unavailableReason
219
220
  };
@@ -256,19 +257,22 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
256
257
  }, {
257
258
  key: "getUnavailableReason",
258
259
  value: function getUnavailableReason(discountList, productList) {
260
+ var _this3 = this;
259
261
  // 检查时间限制
260
262
  var _iterator = _createForOfIteratorHelper(discountList),
261
263
  _step;
262
264
  try {
263
265
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
264
266
  var discount = _step.value;
265
- var _iterator3 = _createForOfIteratorHelper(productList),
267
+ var bookingTimes = productList.length ? productList.map(function (item) {
268
+ var product = _this3.hooks.getProduct(item);
269
+ return ((product === null || product === void 0 ? void 0 : product.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss');
270
+ }) : [dayjs().format('YYYY-MM-DD HH:mm:ss')];
271
+ var _iterator3 = _createForOfIteratorHelper(bookingTimes),
266
272
  _step3;
267
273
  try {
268
274
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
269
- var item = _step3.value;
270
- var product = this.hooks.getProduct(item);
271
- var bookingTime = ((product === null || product === void 0 ? void 0 : product.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss');
275
+ var bookingTime = _step3.value;
272
276
  var filteredList = filterDiscountListByBookingTime([discount], bookingTime);
273
277
  if (filteredList.length === 0) {
274
278
  return UnavailableReason.TimeLimit;
@@ -299,12 +303,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
299
303
  try {
300
304
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
301
305
  var _limitedData$product_;
302
- var _item = _step4.value;
303
- var _product = this.hooks.getProduct(_item);
306
+ var item = _step4.value;
307
+ var product = this.hooks.getProduct(item);
304
308
  if (limitedData.type === 'product_all') {
305
309
  hasApplicableProduct = true;
306
310
  break;
307
- } else if ((_limitedData$product_ = limitedData.product_ids) !== null && _limitedData$product_ !== void 0 && _limitedData$product_.includes(_product.id)) {
311
+ } else if ((_limitedData$product_ = limitedData.product_ids) !== null && _limitedData$product_ !== void 0 && _limitedData$product_.includes(product.id)) {
308
312
  hasApplicableProduct = true;
309
313
  break;
310
314
  }
@@ -329,7 +333,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
329
333
  key: "calcDiscount",
330
334
  value: function calcDiscount(_ref2, options) {
331
335
  var _options$selectedList,
332
- _this3 = this;
336
+ _this4 = this;
333
337
  var discountList = _ref2.discountList,
334
338
  productList = _ref2.productList,
335
339
  holders = _ref2.holders,
@@ -422,7 +426,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
422
426
  var flattenProductsWithBundle = function flattenProductsWithBundle(productList) {
423
427
  var flattened = [];
424
428
  productList.forEach(function (originProduct) {
425
- var product = _this3.hooks.getProduct(originProduct);
429
+ var product = _this4.hooks.getProduct(originProduct);
426
430
 
427
431
  // 1. 添加主商品
428
432
  flattened.push({
@@ -434,8 +438,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
434
438
  _id: product._id,
435
439
  parentId: product._id,
436
440
  quantity: product.quantity,
437
- num: product.num,
438
- booking_id: product.booking_id
441
+ num: product.num
439
442
  });
440
443
 
441
444
  // 2. 展开 bundle 子商品
@@ -459,7 +462,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
459
462
  origin_total: new Decimal(bundleItem.price || 0).mul(bundleItem.num || 1).toNumber(),
460
463
  original_price: bundleItem.original_price,
461
464
  // 继承主商品属性
462
- booking_id: bundleItem.booking_id,
465
+ booking_id: product.booking_id,
463
466
  discount_list: bundleItem.discount_list || []
464
467
  });
465
468
  });
@@ -724,7 +727,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
724
727
 
725
728
  // 辅助函数:检查商品是否对某个折扣卡可用
726
729
  var checkItemApplicableForDiscount = function checkItemApplicableForDiscount(flatItem, discount) {
727
- var _product2, _product3, _product4, _flatItem$bundleItem, _flatItem$bundleItem2, _product5;
730
+ var _product, _product2, _product3, _flatItem$bundleItem, _flatItem$bundleItem2, _product4;
728
731
  var product;
729
732
  if (flatItem.type === 'main') {
730
733
  product = flatItem.product;
@@ -741,12 +744,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
741
744
  startDate: (_flatItem$parentProdu = flatItem.parentProduct) === null || _flatItem$parentProdu === void 0 ? void 0 : _flatItem$parentProdu.startDate
742
745
  };
743
746
  }
744
- if (_this3.isItemRewardProductDiscount(product)) {
747
+ if (_this4.isItemRewardProductDiscount(product)) {
745
748
  return false;
746
749
  }
747
750
 
748
751
  // 编辑的商品使用了优惠券不可用
749
- var isAvailableProduct = flatItem.type === 'main' ? !((_product2 = product) !== null && _product2 !== void 0 && _product2.booking_id && (_product3 = product) !== null && _product3 !== void 0 && (_product3 = _product3.discount_list) !== null && _product3 !== void 0 && _product3.length && (_product4 = product) !== null && _product4 !== void 0 && (_product4 = _product4.discount_list) !== null && _product4 !== void 0 && _product4.every(function (d) {
752
+ var isAvailableProduct = flatItem.type === 'main' ? !((_product = product) !== null && _product !== void 0 && _product.booking_id && (_product2 = product) !== null && _product2 !== void 0 && (_product2 = _product2.discount_list) !== null && _product2 !== void 0 && _product2.length && (_product3 = product) !== null && _product3 !== void 0 && (_product3 = _product3.discount_list) !== null && _product3 !== void 0 && _product3.every(function (d) {
750
753
  return d.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(d.tag || d.type);
751
754
  })) : !(flatItem !== null && flatItem !== void 0 && flatItem.booking_id && !!(flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem = flatItem.bundleItem) !== null && _flatItem$bundleItem !== void 0 && (_flatItem$bundleItem = _flatItem$bundleItem.discount_list) !== null && _flatItem$bundleItem !== void 0 && _flatItem$bundleItem.length) && flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem2 = flatItem.bundleItem) !== null && _flatItem$bundleItem2 !== void 0 && (_flatItem$bundleItem2 = _flatItem$bundleItem2.discount_list) !== null && _flatItem$bundleItem2 !== void 0 && _flatItem$bundleItem2.every(function (d) {
752
755
  return d.id;
@@ -767,7 +770,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
767
770
  var limitedData = discount.limited_relation_product_data;
768
771
 
769
772
  // 时间限制检查
770
- var timeLimit = !!filterDiscountListByBookingTime([discount], (((_product5 = product) === null || _product5 === void 0 ? void 0 : _product5.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
773
+ var timeLimit = !!filterDiscountListByBookingTime([discount], (((_product4 = product) === null || _product4 === void 0 ? void 0 : _product4.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
771
774
  if (!timeLimit) {
772
775
  return false;
773
776
  }
@@ -787,7 +790,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
787
790
  }
788
791
 
789
792
  // 套餐规则检查
790
- var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
793
+ var isBundleAvailable = _this4.checkPackageSubItemUsageRules(discount, flatItem);
791
794
  return isLimitedProduct && isBundleAvailable;
792
795
  };
793
796
 
@@ -930,30 +933,30 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
930
933
  };
931
934
  originProduct = flatItem.originProduct;
932
935
  }
933
- var isItemRewardProductDiscount = _this3.isItemRewardProductDiscount(product);
936
+ var isItemRewardProductDiscount = _this4.isItemRewardProductDiscount(product);
934
937
  addModeDiscount.forEach(function (discount) {
935
- var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config;
938
+ var _product5, _product6, _product7, _product8, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config;
936
939
  var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
937
940
  // 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
938
941
  var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
939
- var isHolderMatch = _this3.checkHolderMatch(discount, {
942
+ var isHolderMatch = _this4.checkHolderMatch(discount, {
940
943
  isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
941
944
  holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
942
945
  }, holders);
943
946
  var timeLimit = true;
944
- timeLimit = !!filterDiscountListByBookingTime([discount], (((_product6 = product) === null || _product6 === void 0 ? void 0 : _product6.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
947
+ timeLimit = !!filterDiscountListByBookingTime([discount], (((_product5 = product) === null || _product5 === void 0 ? void 0 : _product5.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
945
948
  // 是符合折扣的商品
946
949
  var 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;
947
950
 
948
951
  // 编辑的商品 使用了优惠券不可用
949
- var isAvailableProduct = flatItem.type === 'main' ? !((_product7 = product) !== null && _product7 !== void 0 && _product7.booking_id && (_product8 = product) !== null && _product8 !== void 0 && (_product8 = _product8.discount_list) !== null && _product8 !== void 0 && _product8.length && (_product9 = product) !== null && _product9 !== void 0 && (_product9 = _product9.discount_list) !== null && _product9 !== void 0 && _product9.every(function (discount) {
952
+ var isAvailableProduct = flatItem.type === 'main' ? !((_product6 = product) !== null && _product6 !== void 0 && _product6.booking_id && (_product7 = product) !== null && _product7 !== void 0 && (_product7 = _product7.discount_list) !== null && _product7 !== void 0 && _product7.length && (_product8 = product) !== null && _product8 !== void 0 && (_product8 = _product8.discount_list) !== null && _product8 !== void 0 && _product8.every(function (discount) {
950
953
  return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
951
954
  })) : !(flatItem !== null && flatItem !== void 0 && flatItem.booking_id && !!(flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem3 = flatItem.bundleItem) !== null && _flatItem$bundleItem3 !== void 0 && (_flatItem$bundleItem3 = _flatItem$bundleItem3.discount_list) !== null && _flatItem$bundleItem3 !== void 0 && _flatItem$bundleItem3.length) && flatItem !== null && flatItem !== void 0 && (_flatItem$bundleItem4 = flatItem.bundleItem) !== null && _flatItem$bundleItem4 !== void 0 && (_flatItem$bundleItem4 = _flatItem$bundleItem4.discount_list) !== null && _flatItem$bundleItem4 !== void 0 && _flatItem$bundleItem4.every(function (discount) {
952
955
  return discount.id;
953
956
  }));
954
957
 
955
958
  // 套餐是否可用判断
956
- var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
959
+ var isBundleAvailable = _this4.checkPackageSubItemUsageRules(discount, flatItem);
957
960
 
958
961
  // 判断优惠券是否适用于该商品
959
962
  if (isAvailableProduct && !isItemRewardProductDiscount && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
@@ -984,8 +987,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
984
987
  discount_product_id: discount.product_id
985
988
  },
986
989
  metadata: {
987
- num: num,
988
- discount_rule_uncheck_flag: discount === null || discount === void 0 ? void 0 : discount.discount_rule_uncheck_flag
990
+ num: num
989
991
  }
990
992
  };
991
993
  applicableProducts.push(productData);
@@ -1055,7 +1057,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1055
1057
  // 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
1056
1058
  // 🔥 使用扁平化后的列表进行处理
1057
1059
  sortedFlattenedList.forEach(function (flatItem, index) {
1058
- var _product10, _originProduct, _originProduct2, _originProduct3, _product$discount_lis2, _product11;
1060
+ var _product9, _originProduct, _originProduct2, _originProduct3, _product$discount_lis2, _product10;
1059
1061
  // 获取商品数据
1060
1062
  var product, originProduct;
1061
1063
  if (flatItem.type === 'main') {
@@ -1079,8 +1081,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1079
1081
  };
1080
1082
  originProduct = flatItem.originProduct;
1081
1083
  }
1082
- var isPersistedProduct = ((_product10 = product) === null || _product10 === void 0 ? void 0 : _product10.booking_id) || ((_originProduct = originProduct) === null || _originProduct === void 0 ? void 0 : _originProduct.order_detail_id) || ((_originProduct2 = originProduct) === null || _originProduct2 === void 0 ? void 0 : _originProduct2.orderDetailId) || ((_originProduct3 = originProduct) === null || _originProduct3 === void 0 ? void 0 : _originProduct3.booking_id);
1083
- var hasExistingWalletDiscount = ((_product$discount_lis2 = product.discount_list) === null || _product$discount_lis2 === void 0 ? void 0 : _product$discount_lis2.length) && ((_product11 = product) === null || _product11 === void 0 || (_product11 = _product11.discount_list) === null || _product11 === void 0 ? void 0 : _product11.every(function (discount) {
1084
+ var isPersistedProduct = ((_product9 = product) === null || _product9 === void 0 ? void 0 : _product9.booking_id) || ((_originProduct = originProduct) === null || _originProduct === void 0 ? void 0 : _originProduct.order_detail_id) || ((_originProduct2 = originProduct) === null || _originProduct2 === void 0 ? void 0 : _originProduct2.orderDetailId) || ((_originProduct3 = originProduct) === null || _originProduct3 === void 0 ? void 0 : _originProduct3.booking_id);
1085
+ var hasExistingWalletDiscount = ((_product$discount_lis2 = product.discount_list) === null || _product$discount_lis2 === void 0 ? void 0 : _product$discount_lis2.length) && ((_product10 = product) === null || _product10 === void 0 || (_product10 = _product10.discount_list) === null || _product10 === void 0 ? void 0 : _product10.every(function (discount) {
1084
1086
  var _discount$id, _discount$discount4;
1085
1087
  var discountIdentity = (_discount$id = discount.id) !== null && _discount$id !== void 0 ? _discount$id : (_discount$discount4 = discount.discount) === null || _discount$discount4 === void 0 ? void 0 : _discount$discount4.resource_id;
1086
1088
  var discountType = discount.tag || discount.type;
@@ -1102,7 +1104,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1102
1104
  // 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
1103
1105
  var applicableDiscounts = sortedDiscountList.filter(function (discount) {
1104
1106
  var _product$discount_lis3, _product$discount_lis4;
1105
- if (_this3.isItemRewardProductDiscount(product)) return false;
1107
+ if (_this4.isItemRewardProductDiscount(product)) return false;
1106
1108
  // 🔥 检查策略可用性(针对 good_pass 和折扣卡)
1107
1109
  var discountType = discount.tag || discount.type;
1108
1110
  var currentOriginUid = getOriginProductUid(originProduct);
@@ -1148,7 +1150,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1148
1150
 
1149
1151
  // 拿到discount配置的holder信息 product信息 product.holder 不可用return false
1150
1152
  var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
1151
- var isHolderMatch = _this3.checkHolderMatch(discount, {
1153
+ var isHolderMatch = _this4.checkHolderMatch(discount, {
1152
1154
  isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
1153
1155
  holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
1154
1156
  }, holders);
@@ -1166,13 +1168,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1166
1168
  return false;
1167
1169
  }
1168
1170
  // 检查 package_sub_item_usage_rules
1169
- if (!_this3.checkPackageSubItemUsageRules(discount, flatItem)) {
1171
+ if (!_this4.checkPackageSubItemUsageRules(discount, flatItem)) {
1170
1172
  return false;
1171
1173
  }
1172
1174
  return true;
1173
1175
  } else if (limitedData.product_ids && limitedData.product_ids.includes(product.id)) {
1174
1176
  // 检查 package_sub_item_usage_rules
1175
- if (!_this3.checkPackageSubItemUsageRules(discount, flatItem)) {
1177
+ if (!_this4.checkPackageSubItemUsageRules(discount, flatItem)) {
1176
1178
  return false;
1177
1179
  }
1178
1180
  return true;
@@ -1198,17 +1200,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1198
1200
  var isManualDiscount = false;
1199
1201
  var isItemRewardProductDiscount = false;
1200
1202
  if (flatItem.type === 'main') {
1201
- var _product$discount_lis5, _product$discount_lis6, _product12, _product12$every;
1203
+ var _product$discount_lis5, _product$discount_lis6, _product11, _product11$every;
1202
1204
  // 主商品:判断自身是否手动折扣
1203
1205
  isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : ((_product$discount_lis5 = product.discount_list) === null || _product$discount_lis5 === void 0 ? void 0 : _product$discount_lis5.some(function (item) {
1204
1206
  return item.type === 'product';
1205
1207
  })) || product.total != product.origin_total && (product.bundle || []).every(function (item) {
1206
1208
  var _ref12;
1207
1209
  return !((_ref12 = item.discount_list || []) !== null && _ref12 !== void 0 && _ref12.length);
1208
- }) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || ((_product12 = product) === null || _product12 === void 0 || (_product12 = _product12.discount_list) === null || _product12 === void 0 || (_product12$every = _product12.every) === null || _product12$every === void 0 ? void 0 : _product12$every.call(_product12, function (item) {
1210
+ }) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.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) {
1209
1211
  return item.type === 'product';
1210
1212
  })));
1211
- isItemRewardProductDiscount = _this3.isItemRewardProductDiscount(product);
1213
+ isItemRewardProductDiscount = _this4.isItemRewardProductDiscount(product);
1212
1214
  if (product.inPromotion && !isItemRewardProductDiscount) {
1213
1215
  isManualDiscount = false;
1214
1216
  }
@@ -1291,7 +1293,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1291
1293
  // 主商品:保持原有逻辑,还原 option 价格
1292
1294
  var restoredOptions = restoreOptionPrices(product.options);
1293
1295
  if (product.isClient) {
1294
- processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
1296
+ processedProductsMap.set(product._id, [_this4.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
1295
1297
  origin_total: getProductOriginTotalPrice({
1296
1298
  product: {
1297
1299
  original_price: product.original_price
@@ -1311,11 +1313,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1311
1313
  price: product.price,
1312
1314
  options: restoredOptions
1313
1315
  }), {}, {
1314
- discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(product.discount_list) : _this3.filterDiscountListByType(product.discount_list, 'promotion')
1316
+ discount_list: isManualDiscount ? _this4.resolveDiscountListForManualOverride(product.discount_list) : _this4.filterDiscountListByType(product.discount_list, 'promotion')
1315
1317
  }))]);
1316
1318
  } else {
1317
- var _ref14, _product$_promotion$f, _product13, _product$origin_total;
1318
- var total = product.inPromotion ? (_ref14 = (_product$_promotion$f = (_product13 = product) === null || _product13 === void 0 || (_product13 = _product13._promotion) === null || _product13 === void 0 ? void 0 : _product13.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref14 !== void 0 ? _ref14 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
1319
+ var _ref14, _product$_promotion$f, _product12, _product$origin_total;
1320
+ var total = product.inPromotion ? (_ref14 = (_product$_promotion$f = (_product12 = product) === null || _product12 === void 0 || (_product12 = _product12._promotion) === null || _product12 === void 0 ? void 0 : _product12.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref14 !== void 0 ? _ref14 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
1319
1321
  var main_product_selling_price = product.price;
1320
1322
  if ((product.discount_list || []).some(function (item) {
1321
1323
  return item.type === 'promotion';
@@ -1324,7 +1326,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1324
1326
  total = (_product$total = product.total) !== null && _product$total !== void 0 ? _product$total : product.origin_total;
1325
1327
  main_product_selling_price = (_product$main_product = product.main_product_selling_price) !== null && _product$main_product !== void 0 ? _product$main_product : main_product_selling_price;
1326
1328
  }
1327
- processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? _objectSpread({
1329
+ processedProductsMap.set(product._id, [_this4.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? _objectSpread({
1328
1330
  price: product.price,
1329
1331
  main_product_selling_price: isItemRewardProductDiscount ? main_product_selling_price : product.price
1330
1332
  }, isItemRewardProductDiscount ? {
@@ -1336,14 +1338,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1336
1338
  main_product_selling_price: main_product_selling_price,
1337
1339
  options: restoredOptions
1338
1340
  }), {}, {
1339
- discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(product.discount_list) : _this3.filterDiscountListByType(product.discount_list, 'promotion')
1341
+ discount_list: isManualDiscount ? _this4.resolveDiscountListForManualOverride(product.discount_list) : _this4.filterDiscountListByType(product.discount_list, 'promotion')
1340
1342
  }))]);
1341
1343
  }
1342
1344
  } else {
1343
1345
  var _flatItem$bundleItem8, _flatItem$bundleItem9;
1344
1346
  // bundle子商品:保存到扁平化Map
1345
1347
  processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
1346
- discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(((_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.discount_list) || []) : _this3.filterDiscountListByType(((_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.discount_list) || [], 'promotion'),
1348
+ discount_list: isManualDiscount ? _this4.resolveDiscountListForManualOverride(((_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.discount_list) || []) : _this4.filterDiscountListByType(((_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.discount_list) || [], 'promotion'),
1347
1349
  price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
1348
1350
  processed: true
1349
1351
  })]);
@@ -1384,8 +1386,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1384
1386
  var _product$total2;
1385
1387
  _total = (_product$total2 = product.total) !== null && _product$total2 !== void 0 ? _product$total2 : product.origin_total;
1386
1388
  }
1387
- arr.push(_this3.hooks.setProduct(originProduct, {
1388
- discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
1389
+ arr.push(_this4.hooks.setProduct(originProduct, {
1390
+ discount_list: _this4.filterDiscountListByType(product.discount_list, 'promotion'),
1389
1391
  quantity: totalQuantity - splitCount,
1390
1392
  _id: product._id.split('___')[0],
1391
1393
  total: _total
@@ -1409,7 +1411,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1409
1411
  // 优先从 origin_total拿,可能会拿不到(比如用户端预约在没有配置 original_price 的情况下)
1410
1412
  var productOriginTotal = product.origin_total || product.total || 0;
1411
1413
  // 如果当前 product 有 discount_list,则先从 origin_total 拿
1412
- if (_this3.filterDiscountListByType(product.discount_list, 'promotion').length && product.origin_total) {
1414
+ if (_this4.filterDiscountListByType(product.discount_list, 'promotion').length && product.origin_total) {
1413
1415
  productOriginTotal = product.origin_total;
1414
1416
  }
1415
1417
  // 如果originProduct?._productInit?.original_price为 0,product.origin_total可能为空,此时取 product.total
@@ -1481,8 +1483,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1481
1483
  _num: isGoodPass ? 1 : product.num,
1482
1484
  config: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.config,
1483
1485
  metadata: _objectSpread(_objectSpread({
1484
- num: 1,
1485
- discount_rule_uncheck_flag: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.discount_rule_uncheck_flag
1486
+ num: 1
1486
1487
  }, productDiscountDifference !== undefined && {
1487
1488
  product_discount_difference: productDiscountDifference
1488
1489
  }), {}, {
@@ -1497,7 +1498,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1497
1498
  // 记录应用了优惠券的商品
1498
1499
  // 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
1499
1500
  if (product.isClient) {
1500
- arr.push(_this3.hooks.setProduct(originProduct, {
1501
+ arr.push(_this4.hooks.setProduct(originProduct, {
1501
1502
  discount_list: [discountDetail],
1502
1503
  // good_pass:主商品价以折后价为准;勿用 product.price - amount(amount 含 option 优惠时会算错)
1503
1504
  price: isGoodPass ? mainProductSellingPrice : product.price,
@@ -1515,8 +1516,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1515
1516
  options: discountedOptions
1516
1517
  }));
1517
1518
  } else {
1518
- arr.push(_this3.hooks.setProduct(originProduct, {
1519
- discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion').concat([discountDetail]),
1519
+ arr.push(_this4.hooks.setProduct(originProduct, {
1520
+ discount_list: _this4.filterDiscountListByType(product.discount_list, 'promotion').concat([discountDetail]),
1520
1521
  _id: product._id.split('___')[0] + '___' + _selectedDiscount.id + index,
1521
1522
  price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
1522
1523
  quantity: isNeedSplit ? 1 : product.quantity,
@@ -1569,7 +1570,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1569
1570
  metadata: {
1570
1571
  // 🔥 使用拆分后的唯一 _id
1571
1572
  custom_product_bundle_map_id: uniqueId,
1572
- discount_rule_uncheck_flag: _selectedDiscount2 === null || _selectedDiscount2 === void 0 ? void 0 : _selectedDiscount2.discount_rule_uncheck_flag,
1573
1573
  num: 1
1574
1574
  },
1575
1575
  _num: 1,
@@ -1601,7 +1601,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1601
1601
  _id: "".concat(flatItem._id, "_split_rest"),
1602
1602
  num: normalNum,
1603
1603
  quantity: normalNum,
1604
- discount_list: _this3.filterDiscountListByType(flatItem.discount_list, 'promotion'),
1604
+ discount_list: [],
1605
1605
  processed: true
1606
1606
  }));
1607
1607
  }
@@ -1655,7 +1655,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1655
1655
  metadata: _objectSpread({
1656
1656
  // 🔥 使用唯一的 _id
1657
1657
  custom_product_bundle_map_id: _uniqueId,
1658
- discount_rule_uncheck_flag: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.discount_rule_uncheck_flag,
1659
1658
  num: product.num || 1
1660
1659
  }, _productDiscountDifference !== undefined && {
1661
1660
  product_discount_difference: _productDiscountDifference
@@ -1671,7 +1670,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1671
1670
  processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
1672
1671
  total: targetProductTotal,
1673
1672
  price: new Decimal(_productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
1674
- discount_list: _this3.filterDiscountListByType(flatItem.discount_list, 'promotion').concat([_discountDetail2]),
1673
+ discount_list: [_discountDetail2],
1675
1674
  processed: true
1676
1675
  }));
1677
1676
  }
@@ -1683,7 +1682,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1683
1682
  var reconstructProductsWithBundle = function reconstructProductsWithBundle(processedProductsMap, processedFlatItemsMap, originalProductList) {
1684
1683
  var result = [];
1685
1684
  originalProductList.forEach(function (originProduct) {
1686
- var product = _this3.hooks.getProduct(originProduct);
1685
+ var product = _this4.hooks.getProduct(originProduct);
1687
1686
 
1688
1687
  // 获取主商品处理结果
1689
1688
  var mainProductArr = processedProductsMap.get(product._id);
@@ -1692,8 +1691,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1692
1691
  var getDefaultProduct = function getDefaultProduct() {
1693
1692
  var restoredOptions = restoreOptionPrices(product.options);
1694
1693
  if (product.isClient) {
1695
- return _this3.hooks.setProduct(originProduct, {
1696
- discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
1694
+ return _this4.hooks.setProduct(originProduct, {
1695
+ discount_list: _this4.filterDiscountListByType(product.discount_list, 'promotion'),
1697
1696
  price: product.price,
1698
1697
  origin_total: getProductOriginTotalPrice({
1699
1698
  product: {
@@ -1714,8 +1713,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1714
1713
  options: restoredOptions
1715
1714
  });
1716
1715
  } else {
1717
- return _this3.hooks.setProduct(originProduct, {
1718
- discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
1716
+ return _this4.hooks.setProduct(originProduct, {
1717
+ discount_list: _this4.filterDiscountListByType(product.discount_list, 'promotion'),
1719
1718
  total: product.total,
1720
1719
  origin_total: product.origin_total,
1721
1720
  price: product.price,
@@ -1763,10 +1762,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1763
1762
  }
1764
1763
 
1765
1764
  // 🔥 2. 如果有子商品应用了商品券,且主商品数量大于1,需要拆分主商品
1766
- var mainProductQuantity = mainProductArr[0] ? _this3.hooks.getProduct(mainProductArr[0]).quantity : 1;
1765
+ var mainProductQuantity = mainProductArr[0] ? _this4.hooks.getProduct(mainProductArr[0]).quantity : 1;
1767
1766
  if (hasGoodPassApplied && mainProductArr.length === 1 && mainProductQuantity > 1) {
1768
1767
  var mainProduct = mainProductArr[0];
1769
- var mainProductData = _this3.hooks.getProduct(mainProduct);
1768
+ var mainProductData = _this4.hooks.getProduct(mainProduct);
1770
1769
 
1771
1770
  // 🔥 方案:拆分成2个主商品
1772
1771
  // 1. 一个主商品(qty=1)包含拆分后的bundle
@@ -1881,7 +1880,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1881
1880
  }
1882
1881
 
1883
1882
  // 添加第一个主商品:qty=1,包含拆分后的bundle
1884
- result.push(_this3.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
1883
+ result.push(_this4.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
1885
1884
  _id: "".concat(mainProductData._id.split('___')[0], "___split_discount"),
1886
1885
  quantity: 1,
1887
1886
  discount_list: updatedMainDiscountList,
@@ -1953,7 +1952,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1953
1952
  newOriginTotalOriginal = new Decimal(newOriginTotalOriginal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
1954
1953
 
1955
1954
  // 添加第二个主商品:qty=原quantity-1,包含原始bundle
1956
- result.push(_this3.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
1955
+ result.push(_this4.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
1957
1956
  _id: "".concat(mainProductData._id.split('___')[0], "___split_normal"),
1958
1957
  quantity: mainProductQuantity - 1,
1959
1958
  discount_list: updatedMainDiscountListOriginal,
@@ -1966,7 +1965,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1966
1965
  // 🔥 没有子商品被拆分,使用原有逻辑
1967
1966
  mainProductArr.forEach(function (mainProduct) {
1968
1967
  var _ref16, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
1969
- var mainProductData = _this3.hooks.getProduct(mainProduct);
1968
+ var mainProductData = _this4.hooks.getProduct(mainProduct);
1970
1969
 
1971
1970
  // 重组bundle
1972
1971
  var newBundle = [];
@@ -2053,7 +2052,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2053
2052
  newOriginTotal = new Decimal(newOriginTotal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
2054
2053
 
2055
2054
  // 生成最终的主商品
2056
- result.push(_this3.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
2055
+ result.push(_this4.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
2057
2056
  bundle: newBundle,
2058
2057
  total: newTotal,
2059
2058
  origin_total: newOriginTotal
@@ -2146,7 +2145,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2146
2145
  }, {
2147
2146
  key: "checkPackageSubItemUsageRules",
2148
2147
  value: function checkPackageSubItemUsageRules(discount, flatItem) {
2149
- var _flatItem$product;
2150
2148
  var limitedData = discount.limited_relation_product_data;
2151
2149
  var usageRules = limitedData === null || limitedData === void 0 ? void 0 : limitedData.package_sub_item_usage_rules;
2152
2150
  var rules = ['original_price'].concat(_toConsumableArray((usageRules === null || usageRules === void 0 ? void 0 : usageRules.rules) || []));
@@ -2168,7 +2166,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2168
2166
  filter = _ref17$filter === void 0 ? 0 : _ref17$filter;
2169
2167
  var isMainProduct = flatItem.type === 'main'; // 单独购买
2170
2168
  var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
2171
- var bundleMainProductId = (_flatItem$product = flatItem.product) === null || _flatItem$product === void 0 ? void 0 : _flatItem$product.product_id;
2172
2169
 
2173
2170
  // 主商品直接可用
2174
2171
  if (isMainProduct) {
@@ -2211,13 +2208,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2211
2208
  if (!filter) {
2212
2209
  isScopeValid = true;
2213
2210
  } else {
2214
- isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
2211
+ isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
2215
2212
  }
2216
2213
  }
2217
2214
 
2218
2215
  // 包含套餐判断, products值兼容旧数据
2219
2216
  if (scopeType === 'specific_packages' || scopeType === 'products') {
2220
- isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
2217
+ isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
2221
2218
  }
2222
2219
 
2223
2220
  // 价格和套餐适用范围都符合,则可用
@@ -2267,42 +2264,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2267
2264
 
2268
2265
  // 检查 rules
2269
2266
  if (rules.length > 0) {
2270
- var _isOriginalPrice3 = _isOriginalPrice2 && rules.includes('original_price');
2271
- var _isMarkupPrice3 = _isMarkupPrice2 && rules.includes('markup_price');
2272
- // 价格是否符合规则:原价或加价
2273
- var _isPriceValid = _isOriginalPrice3 || _isMarkupPrice3;
2274
- // 套餐适用范围校验
2275
- var _isScopeValid = false;
2276
-
2277
- // 排除套餐判断, product_all值兼容旧数据
2278
- if (scopeType === 'all_packages' || scopeType === 'product_all') {
2279
- // 所有套餐可用
2280
- if (!filter) {
2281
- _isScopeValid = true;
2282
- } else {
2283
- _isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
2284
- }
2285
- }
2286
-
2287
- // 包含套餐判断, products值兼容旧数据
2288
- if (scopeType === 'specific_packages' || scopeType === 'products') {
2289
- _isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
2290
- }
2291
-
2292
- // 价格和套餐适用范围都符合,则可用
2293
- if (_isPriceValid && _isScopeValid) {
2267
+ // 检查原价
2268
+ if (_isOriginalPrice2 && rules.includes('original_price')) {
2294
2269
  return true;
2295
2270
  }
2296
2271
 
2297
- // 检查原价
2298
- // if (isOriginalPrice && rules.includes('original_price')) {
2299
- // return true;
2300
- // }
2301
-
2302
2272
  // 检查加价
2303
- // if (isMarkupPrice && rules.includes('markup_price')) {
2304
- // return true;
2305
- // }
2273
+ if (_isMarkupPrice2 && rules.includes('markup_price')) {
2274
+ return true;
2275
+ }
2306
2276
 
2307
2277
  // 如果都不匹配,则不可用
2308
2278
  return false;
@@ -64,19 +64,21 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
64
64
  this.store.surchargeList = ((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.surchargeList) || [];
65
65
  this.store.summary = ((_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.summary) || createEmptySalesSummary();
66
66
  this.surchargeListModuleName = ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.surchargeListModuleName) || 'surchargeList';
67
-
68
- // if (!this.appPlugin) {
69
- // throw new Error('SalesSummaryModule 需要 app 插件支持');
70
- // }
71
- if (this.request) {
67
+ if (this.appPlugin) {
72
68
  _context.next = 10;
73
69
  break;
74
70
  }
75
- throw new Error('SalesSummaryModule 需要 request 插件支持');
71
+ throw new Error('SalesSummaryModule 需要 app 插件支持');
76
72
  case 10:
77
- _context.next = 12;
78
- return this.getSurchargeList();
73
+ if (this.request) {
74
+ _context.next = 12;
75
+ break;
76
+ }
77
+ throw new Error('SalesSummaryModule 需要 request 插件支持');
79
78
  case 12:
79
+ _context.next = 14;
80
+ return this.getSurchargeList();
81
+ case 14:
80
82
  case "end":
81
83
  return _context.stop();
82
84
  }
@@ -190,11 +192,10 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
190
192
  }, {
191
193
  key: "getAppData",
192
194
  value: function getAppData(key) {
193
- var _this$appPlugin, _this$appPlugin$getDa, _this$appPlugin2, _this$appPlugin2$getA, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
194
- var getData = (_this$appPlugin = this.appPlugin) === null || _this$appPlugin === void 0 || (_this$appPlugin$getDa = _this$appPlugin.getData) === null || _this$appPlugin$getDa === void 0 ? void 0 : _this$appPlugin$getDa.call(_this$appPlugin);
195
+ var _this$appPlugin$getDa, _this$appPlugin, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
196
+ var getData = (_this$appPlugin$getDa = (_this$appPlugin = this.appPlugin).getData) === null || _this$appPlugin$getDa === void 0 ? void 0 : _this$appPlugin$getDa.call(_this$appPlugin);
195
197
  if (typeof getData === 'function') return getData(key);
196
- var app = (_this$appPlugin2 = this.appPlugin) === null || _this$appPlugin2 === void 0 || (_this$appPlugin2$getA = _this$appPlugin2.getApp) === null || _this$appPlugin2$getA === void 0 ? void 0 : _this$appPlugin2$getA.call(_this$appPlugin2);
197
- if (!app) return undefined;
198
+ var app = this.appPlugin.getApp();
198
199
  var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
199
200
  return coreData === null || coreData === void 0 ? void 0 : coreData[key];
200
201
  }
@@ -11,12 +11,10 @@ export declare class ScanOrderLoggerModule extends BaseModule implements Module,
11
11
  protected defaultName: string;
12
12
  protected defaultVersion: string;
13
13
  private store;
14
- private window?;
15
14
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
16
15
  setContext(context: ScanOrderLoggerContext): void;
17
16
  setProvider(provider: ScanOrderLoggerProviderType): void;
18
17
  setProviderConfig(providerConfig: ScanOrderLoggerProviderConfig): void;
19
- private getCurrentHost;
20
18
  private buildRecord;
21
19
  addLog(params: ScanOrderLogInput): Promise<void>;
22
20
  }