@pisell/pisellos 2.2.260 → 2.2.261

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 (129) hide show
  1. package/dist/model/strategy/adapter/index.d.ts +0 -4
  2. package/dist/model/strategy/adapter/index.js +1 -5
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  4. package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
  8. package/dist/model/strategy/adapter/promotion/examples.js +99 -0
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/index.js +1 -1
  11. package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
  12. package/dist/model/strategy/adapter/promotion/type.js +45 -0
  13. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +17 -13
  14. package/dist/modules/Order/index.d.ts +33 -2
  15. package/dist/modules/Order/index.js +615 -288
  16. package/dist/modules/Order/types.d.ts +20 -2
  17. package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  18. package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
  19. package/dist/modules/Order/utils.d.ts +4 -0
  20. package/dist/modules/Order/utils.js +116 -29
  21. package/dist/modules/Product/types.d.ts +0 -22
  22. package/dist/modules/ProductList/index.d.ts +1 -1
  23. package/dist/modules/ProductList/index.js +2 -4
  24. package/dist/modules/ProductList/types.d.ts +0 -2
  25. package/dist/modules/Rules/index.d.ts +4 -3
  26. package/dist/modules/Rules/index.js +42 -17
  27. package/dist/modules/Rules/types.d.ts +2 -1
  28. package/dist/modules/SalesSummary/index.d.ts +7 -3
  29. package/dist/modules/SalesSummary/index.js +67 -39
  30. package/dist/modules/SalesSummary/types.d.ts +1 -0
  31. package/dist/modules/SalesSummary/utils.js +2 -1
  32. package/dist/modules/SurchargeList/index.d.ts +6 -4
  33. package/dist/modules/SurchargeList/index.js +62 -39
  34. package/dist/modules/SurchargeList/types.d.ts +6 -2
  35. package/dist/server/index.d.ts +3 -50
  36. package/dist/server/index.js +1075 -1040
  37. package/dist/server/modules/order/index.d.ts +22 -3
  38. package/dist/server/modules/order/index.js +398 -316
  39. package/dist/server/modules/products/index.d.ts +7 -26
  40. package/dist/server/modules/products/index.js +76 -166
  41. package/dist/server/modules/products/types.d.ts +0 -14
  42. package/dist/solution/BaseSales/index.d.ts +22 -2
  43. package/dist/solution/BaseSales/index.js +995 -701
  44. package/dist/solution/BaseSales/types.d.ts +1 -0
  45. package/dist/solution/BaseSales/types.js +2 -1
  46. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  47. package/dist/solution/BaseSales/utils/cartPromotion.js +74 -29
  48. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
  49. package/dist/solution/BookingByStep/index.d.ts +1 -1
  50. package/dist/solution/BookingTicket/index.d.ts +9 -1
  51. package/dist/solution/BookingTicket/index.js +153 -6
  52. package/dist/solution/BookingTicket/types.d.ts +0 -2
  53. package/dist/solution/ScanOrder/index.js +31 -20
  54. package/dist/solution/VenueBooking/index.js +30 -19
  55. package/lib/model/strategy/adapter/index.d.ts +0 -4
  56. package/lib/model/strategy/adapter/index.js +2 -13
  57. package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  58. package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
  59. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  60. package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
  61. package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
  62. package/lib/model/strategy/adapter/promotion/examples.js +91 -0
  63. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  64. package/lib/model/strategy/adapter/promotion/index.js +2 -0
  65. package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
  66. package/lib/model/strategy/adapter/promotion/type.js +2 -0
  67. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -1
  68. package/lib/modules/Order/index.d.ts +33 -2
  69. package/lib/modules/Order/index.js +402 -64
  70. package/lib/modules/Order/types.d.ts +20 -2
  71. package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  72. package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
  73. package/lib/modules/Order/utils.d.ts +4 -0
  74. package/lib/modules/Order/utils.js +90 -3
  75. package/lib/modules/Product/types.d.ts +0 -22
  76. package/lib/modules/ProductList/index.d.ts +1 -1
  77. package/lib/modules/ProductList/index.js +2 -4
  78. package/lib/modules/ProductList/types.d.ts +0 -2
  79. package/lib/modules/Rules/index.d.ts +4 -3
  80. package/lib/modules/Rules/index.js +27 -7
  81. package/lib/modules/Rules/types.d.ts +2 -1
  82. package/lib/modules/SalesSummary/index.d.ts +7 -3
  83. package/lib/modules/SalesSummary/index.js +28 -11
  84. package/lib/modules/SalesSummary/types.d.ts +1 -0
  85. package/lib/modules/SalesSummary/utils.js +2 -0
  86. package/lib/modules/SurchargeList/index.d.ts +6 -4
  87. package/lib/modules/SurchargeList/index.js +41 -21
  88. package/lib/modules/SurchargeList/types.d.ts +6 -2
  89. package/lib/server/index.d.ts +3 -50
  90. package/lib/server/index.js +244 -215
  91. package/lib/server/modules/order/index.d.ts +22 -3
  92. package/lib/server/modules/order/index.js +103 -53
  93. package/lib/server/modules/products/index.d.ts +7 -26
  94. package/lib/server/modules/products/index.js +35 -113
  95. package/lib/server/modules/products/types.d.ts +0 -14
  96. package/lib/solution/BaseSales/index.d.ts +22 -2
  97. package/lib/solution/BaseSales/index.js +246 -60
  98. package/lib/solution/BaseSales/types.d.ts +1 -0
  99. package/lib/solution/BaseSales/types.js +2 -1
  100. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  101. package/lib/solution/BaseSales/utils/cartPromotion.js +59 -16
  102. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -6
  103. package/lib/solution/BookingByStep/index.d.ts +1 -1
  104. package/lib/solution/BookingTicket/index.d.ts +9 -1
  105. package/lib/solution/BookingTicket/index.js +101 -0
  106. package/lib/solution/BookingTicket/types.d.ts +0 -2
  107. package/lib/solution/ScanOrder/index.js +8 -0
  108. package/lib/solution/VenueBooking/index.js +8 -0
  109. package/package.json +1 -1
  110. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -49
  111. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -152
  112. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -87
  113. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -755
  114. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  115. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -282
  116. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  117. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  118. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -146
  119. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  120. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -49
  121. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -139
  122. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -87
  123. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -564
  124. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  125. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -295
  126. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  127. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  128. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -146
  129. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
@@ -118,7 +118,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
118
118
  // 非表单类型 holder 视为匹配
119
119
  if (((_discount$holder = discount.holder) === null || _discount$holder === void 0 ? void 0 : _discount$holder.holder_type) !== 'form') return true;
120
120
  // 主预约holder, 目前(20251124)默认只考虑单个holder的情况
121
- var orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id : undefined;
121
+ // 旧版 holders[0].form_record_id 新版 holders[0]
122
+ var orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id || holders[0] : undefined;
122
123
  var productHolderId = Array.isArray(product.holder_id) ? product.holder_id[0] : product.holder_id;
123
124
  // 商品不需要选holder,则不对比holder,直接返回true,
124
125
  if (!product.isNeedHolder) return true;
@@ -240,6 +241,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
240
241
  value: function resolveDiscountListForManualOverride(discountList) {
241
242
  return this.excludeDiscountListByType(discountList, 'promotion');
242
243
  }
244
+ }, {
245
+ key: "isItemRewardProductDiscount",
246
+ value: function isItemRewardProductDiscount(product) {
247
+ var _product$_promotion;
248
+ var discountList = Array.isArray(product === null || product === void 0 ? void 0 : product.discount_list) ? product.discount_list : [];
249
+ return (product === null || product === void 0 || (_product$_promotion = product._promotion) === null || _product$_promotion === void 0 ? void 0 : _product$_promotion.actionType) === 'ITEM_REWARD' && discountList.some(function (item) {
250
+ var _item$metadata, _item$metadata2;
251
+ return (item === null || item === void 0 ? void 0 : item.type) === 'product' && (item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.source) === 'promotion' && (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.actionType) === 'ITEM_REWARD';
252
+ });
253
+ }
254
+
243
255
  // 获取券不可用的原因
244
256
  }, {
245
257
  key: "getUnavailableReason",
@@ -323,6 +335,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
323
335
  holders = _ref2.holders,
324
336
  isFormSubject = _ref2.isFormSubject,
325
337
  orderTotalAmount = _ref2.orderTotalAmount;
338
+ var resolveIsFormSubject = function resolveIsFormSubject(product) {
339
+ return typeof isFormSubject === 'function' ? Boolean(isFormSubject(product)) : Boolean(isFormSubject);
340
+ };
341
+
326
342
  // 识别出来是不是在编辑的界面里又新增了商品
327
343
  // 这种情况下,如果有可用的优惠券,也会自动勾选上
328
344
  var isEditModeAddNewProduct = productList.find(function (n) {
@@ -693,6 +709,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
693
709
  startDate: (_flatItem$parentProdu = flatItem.parentProduct) === null || _flatItem$parentProdu === void 0 ? void 0 : _flatItem$parentProdu.startDate
694
710
  };
695
711
  }
712
+ if (_this3.isItemRewardProductDiscount(product)) {
713
+ return false;
714
+ }
696
715
 
697
716
  // 编辑的商品使用了优惠券不可用
698
717
  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) {
@@ -879,13 +898,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
879
898
  };
880
899
  originProduct = flatItem.originProduct;
881
900
  }
901
+ var isItemRewardProductDiscount = _this3.isItemRewardProductDiscount(product);
882
902
  addModeDiscount.forEach(function (discount) {
883
903
  var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config;
884
904
  var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
885
905
  // 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
886
906
  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;
887
907
  var isHolderMatch = _this3.checkHolderMatch(discount, {
888
- isNeedHolder: isFormSubject && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
908
+ isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
889
909
  holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
890
910
  }, holders);
891
911
  var timeLimit = true;
@@ -904,7 +924,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
904
924
  var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
905
925
 
906
926
  // 判断优惠券是否适用于该商品
907
- if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
927
+ if (isAvailableProduct && !isItemRewardProductDiscount && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
908
928
  var _discountApplicabilit, _discount$metadata4, _discount$metadata5;
909
929
  // 记录此优惠券适用的商品
910
930
  (_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
@@ -1049,6 +1069,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1049
1069
  // 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
1050
1070
  var applicableDiscounts = sortedDiscountList.filter(function (discount) {
1051
1071
  var _product$discount_lis3, _product$discount_lis4;
1072
+ if (_this3.isItemRewardProductDiscount(product)) return false;
1052
1073
  // 🔥 检查策略可用性(针对 good_pass 和折扣卡)
1053
1074
  var discountType = discount.tag || discount.type;
1054
1075
  if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType)) {
@@ -1088,7 +1109,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1088
1109
  // 拿到discount配置的holder信息 product信息 product.holder 不可用return false
1089
1110
  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;
1090
1111
  var isHolderMatch = _this3.checkHolderMatch(discount, {
1091
- isNeedHolder: isFormSubject && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
1112
+ isNeedHolder: resolveIsFormSubject(_tempVar) && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
1092
1113
  holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
1093
1114
  }, holders);
1094
1115
  // 如果 holder 不匹配,则不适用
@@ -1129,6 +1150,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1129
1150
 
1130
1151
  // 如果是手动折扣,则不适用优惠券
1131
1152
  var isManualDiscount = false;
1153
+ var isItemRewardProductDiscount = false;
1132
1154
  if (flatItem.type === 'main') {
1133
1155
  var _product$discount_lis5, _product$discount_lis6, _product12, _product12$every;
1134
1156
  // 主商品:判断自身是否手动折扣
@@ -1140,7 +1162,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1140
1162
  }) && (!((_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) {
1141
1163
  return item.type === 'product';
1142
1164
  })));
1143
- if (product.inPromotion) {
1165
+ isItemRewardProductDiscount = _this3.isItemRewardProductDiscount(product);
1166
+ if (product.inPromotion && !isItemRewardProductDiscount) {
1144
1167
  isManualDiscount = false;
1145
1168
  }
1146
1169
  } else {
@@ -1250,15 +1273,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1250
1273
  var main_product_selling_price = product.price;
1251
1274
  if ((product.discount_list || []).some(function (item) {
1252
1275
  return item.type === 'promotion';
1253
- }) || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
1276
+ }) || isItemRewardProductDiscount || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
1254
1277
  var _product$total, _product$main_product;
1255
1278
  total = (_product$total = product.total) !== null && _product$total !== void 0 ? _product$total : product.origin_total;
1256
1279
  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;
1257
1280
  }
1258
- processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
1281
+ processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? _objectSpread({
1259
1282
  price: product.price,
1260
- main_product_selling_price: product.price
1261
- } : {
1283
+ main_product_selling_price: isItemRewardProductDiscount ? main_product_selling_price : product.price
1284
+ }, isItemRewardProductDiscount ? {
1285
+ total: total
1286
+ } : {}) : {
1262
1287
  _id: product._id.split('___')[0] + '___' + index,
1263
1288
  total: total,
1264
1289
  price: product.price,
@@ -1699,11 +1724,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1699
1724
  processedItems.forEach(function (item) {
1700
1725
  // 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
1701
1726
  var updatedDiscountList = (item.discount_list || []).map(function (discount) {
1702
- var _item$metadata;
1727
+ var _item$metadata3;
1703
1728
  return _objectSpread(_objectSpread({}, discount), {}, {
1704
1729
  metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
1705
1730
  num: item.num,
1706
- custom_product_bundle_map_id: (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.custom_product_bundle_map_id
1731
+ custom_product_bundle_map_id: (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.custom_product_bundle_map_id
1707
1732
  })
1708
1733
  // num: item.num, // 使用拆分后的 num
1709
1734
  });
@@ -1722,11 +1747,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1722
1747
  if (item.processed) {
1723
1748
  // 🔥 同样需要更新 discount_list 中的 num
1724
1749
  var _updatedDiscountList = (item.discount_list || []).map(function (discount) {
1725
- var _item$metadata2;
1750
+ var _item$metadata4;
1726
1751
  return _objectSpread(_objectSpread({}, discount), {}, {
1727
1752
  metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
1728
1753
  num: item.num,
1729
- custom_product_bundle_map_id: (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.custom_product_bundle_map_id
1754
+ custom_product_bundle_map_id: (_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.custom_product_bundle_map_id
1730
1755
  })
1731
1756
  // num: item.num, // 使用当前的 num
1732
1757
  });
@@ -1767,8 +1792,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1767
1792
 
1768
1793
  // 🔥 使用更新后的列表计算折扣金额
1769
1794
  var mainDiscountList = updatedMainDiscountList.filter(function (item) {
1770
- var _item$metadata3;
1771
- return !(item !== null && item !== void 0 && (_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.custom_product_bundle_map_id);
1795
+ var _item$metadata5;
1796
+ return !(item !== null && item !== void 0 && (_item$metadata5 = item.metadata) !== null && _item$metadata5 !== void 0 && _item$metadata5.custom_product_bundle_map_id);
1772
1797
  });
1773
1798
  if (mainDiscountList && mainDiscountList.length > 0) {
1774
1799
  var _Decimal$minus$toNumb, _mainProductData$orig;
@@ -1841,8 +1866,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1841
1866
 
1842
1867
  // 🔥 使用更新后的列表计算折扣金额
1843
1868
  var mainDiscountListOriginal = updatedMainDiscountListOriginal.filter(function (item) {
1844
- var _item$metadata4;
1845
- return !(item !== null && item !== void 0 && (_item$metadata4 = item.metadata) !== null && _item$metadata4 !== void 0 && _item$metadata4.custom_product_bundle_map_id);
1869
+ var _item$metadata6;
1870
+ return !(item !== null && item !== void 0 && (_item$metadata6 = item.metadata) !== null && _item$metadata6 !== void 0 && _item$metadata6.custom_product_bundle_map_id);
1846
1871
  });
1847
1872
  if (mainDiscountListOriginal && mainDiscountListOriginal.length > 0) {
1848
1873
  var _Decimal$minus$toNumb2, _mainProductData$orig2;
@@ -22,6 +22,7 @@ export interface DiscountResult {
22
22
  productList: any[];
23
23
  discountList: any[];
24
24
  }
25
+ export type RulesFormSubject = boolean | ((product: any) => boolean);
25
26
  export interface RulesModuleAPI {
26
27
  setRulesList: (rulesList: Rules[]) => Promise<void>;
27
28
  clear: () => Promise<void>;
@@ -31,7 +32,7 @@ export interface RulesModuleAPI {
31
32
  holders: {
32
33
  form_record_id: number;
33
34
  }[];
34
- isFormSubject: boolean;
35
+ isFormSubject: RulesFormSubject;
35
36
  orderTotalAmount: number;
36
37
  }) => DiscountResult;
37
38
  }
@@ -9,16 +9,19 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
9
9
  private store;
10
10
  private request;
11
11
  private surchargeListModuleName;
12
+ private otherParams;
13
+ private surchargeListChannel;
12
14
  constructor(name?: string, version?: string);
13
15
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
14
16
  /**
15
- * 更新父级解决方案透传的运行态参数,并在 surcharge 模块名变化时刷新附加费列表。
17
+ * 更新父级解决方案透传的运行态参数,并在 surcharge 模块名或渠道变化时刷新附加费列表。
16
18
  *
17
19
  * @example
18
- * await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
20
+ * await salesSummaryModule.updateOtherParams({ channel: 'pos', surchargeListModuleName: 'custom_surchargeList' });
19
21
  */
20
22
  updateOtherParams(params: Record<string, any>): Promise<void>;
21
- getSurchargeList(): Promise<void>;
23
+ private resolveChannel;
24
+ getSurchargeList(channel?: string): Promise<void>;
22
25
  private getAppData;
23
26
  private getTaxConfig;
24
27
  getSummary(params: {
@@ -26,6 +29,7 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
26
29
  isPriceIncludeTax?: number;
27
30
  taxRate?: number;
28
31
  shopDiscount?: string | number;
32
+ channel?: string;
29
33
  }): Promise<{
30
34
  tax_title: string;
31
35
  tax_rate: number | undefined;
@@ -30,6 +30,7 @@ var salesSummaryDataKeys = {
30
30
  taxTitle: 'tax_title',
31
31
  taxCountryCode: 'tax_country_code'
32
32
  };
33
+ var DEFAULT_SURCHARGE_CHANNEL = 'online-store';
33
34
  export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
34
35
  _inherits(SalesSummaryModule, _BaseModule);
35
36
  var _super = _createSuper(SalesSummaryModule);
@@ -43,13 +44,15 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
43
44
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
44
45
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
45
46
  _defineProperty(_assertThisInitialized(_this), "surchargeListModuleName", 'surchargeList');
47
+ _defineProperty(_assertThisInitialized(_this), "otherParams", {});
48
+ _defineProperty(_assertThisInitialized(_this), "surchargeListChannel", DEFAULT_SURCHARGE_CHANNEL);
46
49
  return _this;
47
50
  }
48
51
  _createClass(SalesSummaryModule, [{
49
52
  key: "initialize",
50
53
  value: function () {
51
54
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
52
- var _options$initialState, _options$initialState2, _options$otherParams;
55
+ var _options$initialState, _options$initialState2, _this$otherParams;
53
56
  return _regeneratorRuntime().wrap(function _callee$(_context) {
54
57
  while (1) switch (_context.prev = _context.next) {
55
58
  case 0:
@@ -57,24 +60,25 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
57
60
  this.store = options.store;
58
61
  this.appPlugin = this.core.getPlugin('app');
59
62
  this.request = this.core.getPlugin('request');
63
+ this.otherParams = options.otherParams || {};
60
64
  this.store.surchargeList = ((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.surchargeList) || [];
61
65
  this.store.summary = ((_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.summary) || createEmptySalesSummary();
62
- this.surchargeListModuleName = ((_options$otherParams = options.otherParams) === null || _options$otherParams === void 0 ? void 0 : _options$otherParams.surchargeListModuleName) || 'surchargeList';
66
+ this.surchargeListModuleName = ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.surchargeListModuleName) || 'surchargeList';
63
67
  if (this.appPlugin) {
64
- _context.next = 9;
68
+ _context.next = 10;
65
69
  break;
66
70
  }
67
71
  throw new Error('SalesSummaryModule 需要 app 插件支持');
68
- case 9:
72
+ case 10:
69
73
  if (this.request) {
70
- _context.next = 11;
74
+ _context.next = 12;
71
75
  break;
72
76
  }
73
77
  throw new Error('SalesSummaryModule 需要 request 插件支持');
74
- case 11:
75
- _context.next = 13;
78
+ case 12:
79
+ _context.next = 14;
76
80
  return this.getSurchargeList();
77
- case 13:
81
+ case 14:
78
82
  case "end":
79
83
  return _context.stop();
80
84
  }
@@ -86,30 +90,32 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
86
90
  return initialize;
87
91
  }()
88
92
  /**
89
- * 更新父级解决方案透传的运行态参数,并在 surcharge 模块名变化时刷新附加费列表。
93
+ * 更新父级解决方案透传的运行态参数,并在 surcharge 模块名或渠道变化时刷新附加费列表。
90
94
  *
91
95
  * @example
92
- * await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
96
+ * await salesSummaryModule.updateOtherParams({ channel: 'pos', surchargeListModuleName: 'custom_surchargeList' });
93
97
  */
94
98
  }, {
95
99
  key: "updateOtherParams",
96
100
  value: (function () {
97
101
  var _updateOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
98
- var nextSurchargeListModuleName;
102
+ var previousChannel, nextSurchargeListModuleName, nextChannel, shouldReload;
99
103
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
100
104
  while (1) switch (_context2.prev = _context2.next) {
101
105
  case 0:
106
+ previousChannel = this.resolveChannel();
102
107
  nextSurchargeListModuleName = (params === null || params === void 0 ? void 0 : params.surchargeListModuleName) || 'surchargeList';
103
- if (!(nextSurchargeListModuleName === this.surchargeListModuleName)) {
104
- _context2.next = 3;
108
+ nextChannel = this.resolveChannel(params);
109
+ shouldReload = nextSurchargeListModuleName !== this.surchargeListModuleName || nextChannel !== previousChannel;
110
+ this.otherParams = params || {};
111
+ this.surchargeListModuleName = nextSurchargeListModuleName;
112
+ if (!shouldReload) {
113
+ _context2.next = 9;
105
114
  break;
106
115
  }
107
- return _context2.abrupt("return");
108
- case 3:
109
- this.surchargeListModuleName = nextSurchargeListModuleName;
110
- _context2.next = 6;
111
- return this.getSurchargeList();
112
- case 6:
116
+ _context2.next = 9;
117
+ return this.getSurchargeList(nextChannel);
118
+ case 9:
113
119
  case "end":
114
120
  return _context2.stop();
115
121
  }
@@ -120,49 +126,63 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
120
126
  }
121
127
  return updateOtherParams;
122
128
  }())
129
+ }, {
130
+ key: "resolveChannel",
131
+ value: function resolveChannel() {
132
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.otherParams;
133
+ return (params === null || params === void 0 ? void 0 : params.channel) || DEFAULT_SURCHARGE_CHANNEL;
134
+ }
123
135
  }, {
124
136
  key: "getSurchargeList",
125
137
  value: function () {
126
138
  var _getSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
127
- var surchargeListModule, surchargeList;
139
+ var channel,
140
+ surchargeListModule,
141
+ surchargeList,
142
+ _args3 = arguments;
128
143
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
129
144
  while (1) switch (_context3.prev = _context3.next) {
130
145
  case 0:
131
- _context3.prev = 0;
146
+ channel = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : this.resolveChannel();
147
+ _context3.prev = 1;
132
148
  surchargeListModule = this.core.getModule(this.surchargeListModuleName);
133
149
  if (!(surchargeListModule !== null && surchargeListModule !== void 0 && surchargeListModule.getSurchargeList)) {
134
- _context3.next = 7;
150
+ _context3.next = 9;
135
151
  break;
136
152
  }
137
- _context3.next = 5;
138
- return surchargeListModule.getSurchargeList();
139
- case 5:
153
+ _context3.next = 6;
154
+ return surchargeListModule.getSurchargeList({
155
+ channel: channel
156
+ });
157
+ case 6:
140
158
  this.store.surchargeList = _context3.sent;
159
+ this.surchargeListChannel = channel;
141
160
  return _context3.abrupt("return");
142
- case 7:
143
- _context3.next = 9;
161
+ case 9:
162
+ _context3.next = 11;
144
163
  return this.request.get('/order/custom-surcharge/available/v2', {
145
- // TODO 真实的渠道
146
- channel: 'online-store',
164
+ channel: channel,
147
165
  is_assemble_product_data: 1,
148
166
  is_assemble_schedule_data: 1,
149
167
  with: ['relationSchedule']
150
168
  });
151
- case 9:
169
+ case 11:
152
170
  surchargeList = _context3.sent;
153
171
  this.store.surchargeList = (surchargeList === null || surchargeList === void 0 ? void 0 : surchargeList.data) || [];
154
- _context3.next = 17;
172
+ this.surchargeListChannel = channel;
173
+ _context3.next = 21;
155
174
  break;
156
- case 13:
157
- _context3.prev = 13;
158
- _context3.t0 = _context3["catch"](0);
175
+ case 16:
176
+ _context3.prev = 16;
177
+ _context3.t0 = _context3["catch"](1);
159
178
  console.warn('[SalesSummaryModule] 加载附加费配置失败', _context3.t0);
160
179
  this.store.surchargeList = [];
161
- case 17:
180
+ this.surchargeListChannel = channel;
181
+ case 21:
162
182
  case "end":
163
183
  return _context3.stop();
164
184
  }
165
- }, _callee3, this, [[0, 13]]);
185
+ }, _callee3, this, [[1, 16]]);
166
186
  }));
167
187
  function getSurchargeList() {
168
188
  return _getSurchargeList.apply(this, arguments);
@@ -194,11 +214,19 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
194
214
  value: function () {
195
215
  var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
196
216
  var _this$store$surcharge, _ref;
197
- var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount, taxConfig, summarySchedule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary, summaryWithTaxMeta;
217
+ var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount, channel, summaryChannel, taxConfig, summarySchedule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary, summaryWithTaxMeta;
198
218
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
199
219
  while (1) switch (_context4.prev = _context4.next) {
200
220
  case 0:
201
- _params$products = params.products, products = _params$products === void 0 ? [] : _params$products, isPriceIncludeTax = params.isPriceIncludeTax, taxRate = params.taxRate, shopDiscount = params.shopDiscount;
221
+ _params$products = params.products, products = _params$products === void 0 ? [] : _params$products, isPriceIncludeTax = params.isPriceIncludeTax, taxRate = params.taxRate, shopDiscount = params.shopDiscount, channel = params.channel;
222
+ summaryChannel = channel || this.resolveChannel();
223
+ if (!(summaryChannel !== this.surchargeListChannel)) {
224
+ _context4.next = 5;
225
+ break;
226
+ }
227
+ _context4.next = 5;
228
+ return this.getSurchargeList(summaryChannel);
229
+ case 5:
202
230
  taxConfig = this.getTaxConfig();
203
231
  summarySchedule = this.core.getModule("".concat(this.name.split('_')[0], "_schedule"));
204
232
  needScheduleIds = (((_this$store$surcharge = this.store.surchargeList) === null || _this$store$surcharge === void 0 || (_this$store$surcharge = _this$store$surcharge.map(function (item) {
@@ -237,7 +265,7 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
237
265
  });
238
266
  this.store.summary = summaryWithTaxMeta;
239
267
  return _context4.abrupt("return", summaryWithTaxMeta);
240
- case 11:
268
+ case 15:
241
269
  case "end":
242
270
  return _context4.stop();
243
271
  }
@@ -63,5 +63,6 @@ export interface SalesSummaryModuleAPI {
63
63
  isPriceIncludeTax?: number;
64
64
  taxRate?: number;
65
65
  shopDiscount?: string | number;
66
+ channel?: string;
66
67
  }): Promise<SalesSummaryData>;
67
68
  }
@@ -329,11 +329,12 @@ function buildSurchargeQuantityTotals(nodes) {
329
329
  }
330
330
  function getFallbackAllProductSurchargeIds(surchargeList) {
331
331
  return (surchargeList || []).reduce(function (ids, config) {
332
- var _config$open_product, _config$is_all;
332
+ var _config$open_product, _config$is_all, _config$open_schedule;
333
333
  var id = getSurchargeConfigId(config);
334
334
  if (id === undefined) return ids;
335
335
  if (Number((_config$open_product = config.open_product) !== null && _config$open_product !== void 0 ? _config$open_product : 0) === 0) return ids;
336
336
  if (Number((_config$is_all = config.is_all) !== null && _config$is_all !== void 0 ? _config$is_all : 0) !== 1) return ids;
337
+ if (Number((_config$open_schedule = config.open_schedule) !== null && _config$open_schedule !== void 0 ? _config$open_schedule : 0) === 1 && config.schedule_type !== 'all') return ids;
337
338
  ids.push(id);
338
339
  return ids;
339
340
  }, []);
@@ -1,16 +1,18 @@
1
1
  import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { SurchargeListItem, SurchargeListModuleAPI } from './types';
3
+ import { SurchargeListItem, SurchargeListModuleAPI, SurchargeListQuery } from './types';
4
4
  export * from './types';
5
5
  export declare class SurchargeListModule extends BaseModule implements Module, SurchargeListModuleAPI {
6
6
  protected defaultName: string;
7
7
  protected defaultVersion: string;
8
8
  private request;
9
9
  private store;
10
- private loadingPromise;
10
+ private loadingPromises;
11
+ private requestVersion;
11
12
  constructor(name?: string, version?: string);
12
13
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
13
- getSurchargeList(): Promise<SurchargeListItem[]>;
14
- refreshSurchargeList(): Promise<SurchargeListItem[]>;
14
+ private resolveChannel;
15
+ getSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
16
+ refreshSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
15
17
  private loadSurchargeList;
16
18
  }