@pisell/pisellos 2.3.38 → 2.3.40

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 (229) hide show
  1. package/dist/core/index.d.ts +0 -2
  2. package/dist/core/index.js +0 -7
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  4. package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
  8. package/dist/model/strategy/adapter/promotion/examples.js +0 -99
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
  11. package/dist/model/strategy/adapter/promotion/type.js +0 -45
  12. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -5
  13. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +3 -6
  14. package/dist/modules/Discount/index.d.ts +1 -0
  15. package/dist/modules/Discount/index.js +40 -11
  16. package/dist/modules/Discount/types.d.ts +1 -0
  17. package/dist/modules/Holder/index.d.ts +48 -0
  18. package/dist/modules/Holder/index.js +640 -0
  19. package/dist/modules/Holder/types.d.ts +123 -0
  20. package/dist/modules/Holder/types.js +1 -0
  21. package/dist/modules/Holder/utils.d.ts +13 -0
  22. package/dist/modules/Holder/utils.js +34 -0
  23. package/dist/modules/OpenData/index.d.ts +0 -2
  24. package/dist/modules/OpenData/index.js +2 -10
  25. package/dist/modules/Order/index.d.ts +11 -28
  26. package/dist/modules/Order/index.js +509 -750
  27. package/dist/modules/Order/types.d.ts +10 -33
  28. package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
  29. package/dist/modules/Order/utils.d.ts +10 -0
  30. package/dist/modules/Order/utils.js +41 -13
  31. package/dist/modules/Payment/index.d.ts +0 -2
  32. package/dist/modules/Payment/index.js +50 -79
  33. package/dist/modules/Payment/types.d.ts +28 -99
  34. package/dist/modules/Payment/types.js +3 -20
  35. package/dist/modules/Payment/walletpass.d.ts +1 -25
  36. package/dist/modules/Payment/walletpass.js +157 -707
  37. package/dist/modules/Product/types.d.ts +1 -0
  38. package/dist/modules/ProductList/index.js +33 -14
  39. package/dist/modules/Quotation/index.d.ts +1 -1
  40. package/dist/modules/Quotation/index.js +2 -2
  41. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  42. package/dist/modules/ResourcePlanner/index.js +181 -0
  43. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  44. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  45. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  46. package/dist/modules/ResourcePlanner/types.js +1 -0
  47. package/dist/modules/Rules/index.d.ts +0 -1
  48. package/dist/modules/Rules/index.js +96 -89
  49. package/dist/modules/SalesSummary/index.js +12 -13
  50. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  51. package/dist/modules/ScanOrderLogger/index.js +15 -2
  52. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  53. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  54. package/dist/modules/Schedule/index.d.ts +3 -1
  55. package/dist/modules/Schedule/index.js +21 -16
  56. package/dist/modules/Summary/utils.js +38 -13
  57. package/dist/modules/index.d.ts +2 -0
  58. package/dist/modules/index.js +3 -1
  59. package/dist/plugins/window.d.ts +1 -0
  60. package/dist/server/index.d.ts +14 -16
  61. package/dist/server/index.js +1148 -1930
  62. package/dist/server/modules/order/index.d.ts +4 -54
  63. package/dist/server/modules/order/index.js +695 -1595
  64. package/dist/server/modules/order/types.d.ts +3 -11
  65. package/dist/server/modules/order/types.js +1 -1
  66. package/dist/solution/BaseSales/index.d.ts +20 -109
  67. package/dist/solution/BaseSales/index.js +481 -1797
  68. package/dist/solution/BaseSales/types.d.ts +0 -52
  69. package/dist/solution/BaseSales/types.js +1 -2
  70. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  71. package/dist/solution/BaseSales/utils/cartPromotion.js +31 -90
  72. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  73. package/dist/solution/BookingByStep/index.d.ts +17 -2
  74. package/dist/solution/BookingByStep/index.js +294 -215
  75. package/dist/solution/BookingByStep/types.d.ts +2 -1
  76. package/dist/solution/BookingByStep/types.js +3 -1
  77. package/dist/solution/BookingByStep/utils/capacity.js +17 -1
  78. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  79. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  80. package/dist/solution/BookingTicket/index.d.ts +4 -8
  81. package/dist/solution/BookingTicket/index.js +51 -134
  82. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -6
  83. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  84. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +82 -172
  85. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  86. package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
  87. package/dist/solution/Sales/index.d.ts +0 -1
  88. package/dist/solution/Sales/index.js +2 -10
  89. package/dist/solution/ScanOrder/index.d.ts +26 -14
  90. package/dist/solution/ScanOrder/index.js +1148 -756
  91. package/dist/solution/ScanOrder/types.d.ts +21 -1
  92. package/dist/solution/ScanOrder/utils.d.ts +8 -0
  93. package/dist/solution/ScanOrder/utils.js +66 -25
  94. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  95. package/dist/solution/ShopDiscount/index.js +125 -87
  96. package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
  97. package/dist/solution/UnifiedBookingSales/index.js +1871 -0
  98. package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
  99. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  100. package/dist/solution/VenueBooking/index.d.ts +39 -11
  101. package/dist/solution/VenueBooking/index.js +1176 -860
  102. package/dist/solution/VenueBooking/types.d.ts +3 -0
  103. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  104. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  105. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
  106. package/dist/solution/index.d.ts +1 -0
  107. package/dist/solution/index.js +2 -1
  108. package/dist/types/index.d.ts +1 -1
  109. package/lib/core/index.d.ts +0 -2
  110. package/lib/core/index.js +0 -4
  111. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  112. package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
  113. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  114. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
  115. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
  116. package/lib/model/strategy/adapter/promotion/examples.js +0 -91
  117. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  118. package/lib/model/strategy/adapter/promotion/index.js +0 -2
  119. package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
  120. package/lib/model/strategy/adapter/promotion/type.js +0 -2
  121. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -2
  122. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -2
  123. package/lib/modules/Discount/index.d.ts +1 -0
  124. package/lib/modules/Discount/index.js +9 -0
  125. package/lib/modules/Discount/types.d.ts +1 -0
  126. package/lib/modules/Holder/index.d.ts +48 -0
  127. package/lib/modules/Holder/index.js +402 -0
  128. package/lib/modules/Holder/types.d.ts +123 -0
  129. package/lib/modules/Holder/types.js +17 -0
  130. package/lib/modules/Holder/utils.d.ts +13 -0
  131. package/lib/modules/Holder/utils.js +71 -0
  132. package/lib/modules/OpenData/index.d.ts +0 -2
  133. package/lib/modules/OpenData/index.js +1 -6
  134. package/lib/modules/Order/index.d.ts +11 -28
  135. package/lib/modules/Order/index.js +86 -196
  136. package/lib/modules/Order/types.d.ts +10 -33
  137. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
  138. package/lib/modules/Order/utils.d.ts +10 -0
  139. package/lib/modules/Order/utils.js +40 -16
  140. package/lib/modules/Payment/index.d.ts +0 -2
  141. package/lib/modules/Payment/index.js +13 -34
  142. package/lib/modules/Payment/types.d.ts +28 -99
  143. package/lib/modules/Payment/types.js +3 -4
  144. package/lib/modules/Payment/walletpass.d.ts +1 -25
  145. package/lib/modules/Payment/walletpass.js +21 -470
  146. package/lib/modules/Product/types.d.ts +1 -0
  147. package/lib/modules/ProductList/index.js +40 -31
  148. package/lib/modules/Quotation/index.d.ts +1 -1
  149. package/lib/modules/Quotation/index.js +2 -2
  150. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  151. package/lib/modules/ResourcePlanner/index.js +148 -0
  152. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  153. package/lib/modules/ResourcePlanner/planner.js +933 -0
  154. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  155. package/lib/modules/ResourcePlanner/types.js +17 -0
  156. package/lib/modules/Rules/index.d.ts +0 -1
  157. package/lib/modules/Rules/index.js +40 -47
  158. package/lib/modules/SalesSummary/index.js +6 -7
  159. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  160. package/lib/modules/ScanOrderLogger/index.js +13 -1
  161. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  162. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  163. package/lib/modules/Schedule/index.d.ts +3 -1
  164. package/lib/modules/Schedule/index.js +10 -8
  165. package/lib/modules/Summary/utils.js +21 -1
  166. package/lib/modules/index.d.ts +2 -0
  167. package/lib/modules/index.js +5 -1
  168. package/lib/plugins/window.d.ts +1 -0
  169. package/lib/server/index.d.ts +14 -16
  170. package/lib/server/index.js +83 -675
  171. package/lib/server/modules/order/index.d.ts +4 -54
  172. package/lib/server/modules/order/index.js +66 -679
  173. package/lib/server/modules/order/types.d.ts +3 -11
  174. package/lib/solution/BaseSales/index.d.ts +20 -109
  175. package/lib/solution/BaseSales/index.js +70 -881
  176. package/lib/solution/BaseSales/types.d.ts +0 -52
  177. package/lib/solution/BaseSales/types.js +1 -2
  178. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  179. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -63
  180. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  181. package/lib/solution/BookingByStep/index.d.ts +17 -2
  182. package/lib/solution/BookingByStep/index.js +60 -18
  183. package/lib/solution/BookingByStep/types.d.ts +2 -1
  184. package/lib/solution/BookingByStep/types.js +5 -0
  185. package/lib/solution/BookingByStep/utils/capacity.js +20 -1
  186. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  187. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  188. package/lib/solution/BookingTicket/index.d.ts +4 -8
  189. package/lib/solution/BookingTicket/index.js +19 -64
  190. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -4
  191. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  192. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +4 -36
  193. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  194. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  195. package/lib/solution/Sales/index.d.ts +0 -1
  196. package/lib/solution/Sales/index.js +3 -5
  197. package/lib/solution/ScanOrder/index.d.ts +26 -14
  198. package/lib/solution/ScanOrder/index.js +449 -190
  199. package/lib/solution/ScanOrder/types.d.ts +21 -1
  200. package/lib/solution/ScanOrder/utils.d.ts +8 -0
  201. package/lib/solution/ScanOrder/utils.js +31 -0
  202. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  203. package/lib/solution/ShopDiscount/index.js +14 -0
  204. package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
  205. package/lib/solution/UnifiedBookingSales/index.js +1076 -0
  206. package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
  207. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  208. package/lib/solution/VenueBooking/index.d.ts +39 -11
  209. package/lib/solution/VenueBooking/index.js +328 -123
  210. package/lib/solution/VenueBooking/types.d.ts +3 -0
  211. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  212. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  213. package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
  214. package/lib/solution/index.d.ts +1 -0
  215. package/lib/solution/index.js +3 -1
  216. package/lib/types/index.d.ts +1 -1
  217. package/package.json +1 -1
  218. package/dist/modules/Order/payment-utils.d.ts +0 -26
  219. package/dist/modules/Order/payment-utils.js +0 -225
  220. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +0 -5
  221. package/dist/solution/BookingTicket/utils/weighingProductSku.js +0 -45
  222. package/dist/utils/payment-number.d.ts +0 -9
  223. package/dist/utils/payment-number.js +0 -69
  224. package/lib/modules/Order/payment-utils.d.ts +0 -26
  225. package/lib/modules/Order/payment-utils.js +0 -224
  226. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +0 -5
  227. package/lib/solution/BookingTicket/utils/weighingProductSku.js +0 -63
  228. package/lib/utils/payment-number.d.ts +0 -9
  229. package/lib/utils/payment-number.js +0 -64
@@ -241,17 +241,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
241
241
  value: function resolveDiscountListForManualOverride(discountList) {
242
242
  return this.excludeDiscountListByType(discountList, 'promotion');
243
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
-
255
244
  // 获取券不可用的原因
256
245
  }, {
257
246
  key: "getUnavailableReason",
@@ -434,13 +423,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
434
423
  _id: product._id,
435
424
  parentId: product._id,
436
425
  quantity: product.quantity,
437
- num: product.num
426
+ num: product.num,
427
+ booking_id: product.booking_id
438
428
  });
439
429
 
440
430
  // 2. 展开 bundle 子商品
441
431
  if (product.bundle && Array.isArray(product.bundle) && product.bundle.length > 0) {
442
432
  product.bundle.forEach(function (bundleItem, bundleIndex) {
443
- var _ref3, _bundleItem$bundle_pr;
444
433
  flattened.push({
445
434
  type: 'bundle',
446
435
  originProduct: originProduct,
@@ -449,7 +438,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
449
438
  bundleIndex: bundleIndex,
450
439
  // 虚拟商品属性
451
440
  price: Number(bundleItem.price || 0),
452
- id: (_ref3 = (_bundleItem$bundle_pr = bundleItem.bundle_product_id) !== null && _bundleItem$bundle_pr !== void 0 ? _bundleItem$bundle_pr : bundleItem._bundle_product_id) !== null && _ref3 !== void 0 ? _ref3 : bundleItem.product_id,
441
+ id: bundleItem._bundle_product_id,
442
+ // 🔥 使用 _bundle_product_id
453
443
  _id: "".concat(product._id, "_bundle_").concat(bundleIndex),
454
444
  parentId: product._id,
455
445
  num: bundleItem.num || 1,
@@ -458,7 +448,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
458
448
  origin_total: new Decimal(bundleItem.price || 0).mul(bundleItem.num || 1).toNumber(),
459
449
  original_price: bundleItem.original_price,
460
450
  // 继承主商品属性
461
- booking_id: product.booking_id,
451
+ booking_id: bundleItem.booking_id,
462
452
  discount_list: bundleItem.discount_list || []
463
453
  });
464
454
  });
@@ -598,10 +588,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
598
588
 
599
589
  // 对扁平化后的列表按价格降序排序(用于应用优惠券时优先选择高价商品)
600
590
  var sortedFlattenedList = flattenedList.sort(function (a, b) {
601
- var _ref4, _a$original_price, _ref5, _b$original_price;
591
+ var _ref3, _a$original_price, _ref4, _b$original_price;
602
592
  // 子商品优先使用 original_price,主商品使用 price
603
- var priceA = new Decimal(a.type === 'bundle' ? (_ref4 = (_a$original_price = a.original_price) !== null && _a$original_price !== void 0 ? _a$original_price : a.price) !== null && _ref4 !== void 0 ? _ref4 : '0' : a.price || '0');
604
- var priceB = new Decimal(b.type === 'bundle' ? (_ref5 = (_b$original_price = b.original_price) !== null && _b$original_price !== void 0 ? _b$original_price : b.price) !== null && _ref5 !== void 0 ? _ref5 : '0' : b.price || '0');
593
+ var priceA = new Decimal(a.type === 'bundle' ? (_ref3 = (_a$original_price = a.original_price) !== null && _a$original_price !== void 0 ? _a$original_price : a.price) !== null && _ref3 !== void 0 ? _ref3 : '0' : a.price || '0');
594
+ var priceB = new Decimal(b.type === 'bundle' ? (_ref4 = (_b$original_price = b.original_price) !== null && _b$original_price !== void 0 ? _b$original_price : b.price) !== null && _ref4 !== void 0 ? _ref4 : '0' : b.price || '0');
605
595
  if (priceA.equals(priceB)) {
606
596
  // 价格相同时,主商品优先
607
597
  if (a.type !== b.type) {
@@ -740,9 +730,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
740
730
  startDate: (_flatItem$parentProdu = flatItem.parentProduct) === null || _flatItem$parentProdu === void 0 ? void 0 : _flatItem$parentProdu.startDate
741
731
  };
742
732
  }
743
- if (_this3.isItemRewardProductDiscount(product)) {
744
- return false;
745
- }
746
733
 
747
734
  // 编辑的商品使用了优惠券不可用
748
735
  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) {
@@ -846,7 +833,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
846
833
  // 收集该折扣卡适用的商品(排除被其他专属折扣卡占用的商品)
847
834
  var applicableProducts = [];
848
835
  sortedFlattenedList.forEach(function (flatItem) {
849
- var _flatItem$parentProdu2, _flatItem$parentProdu3, _product$price, _ref6, _flatItem$original_pr;
836
+ var _flatItem$parentProdu2, _flatItem$parentProdu3, _product$price, _ref5, _flatItem$original_pr;
850
837
  // 🔥 检查该商品是否被其他专属折扣卡占用
851
838
  var occupyingDiscountId = occupiedItems.get(flatItem._id);
852
839
  if (occupyingDiscountId !== undefined && occupyingDiscountId !== discount.id) {
@@ -874,7 +861,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
874
861
 
875
862
  // 对于主商品:使用 price
876
863
  // 对于子商品:优先使用 flatItem.original_price,否则使用 flatItem.price
877
- var originalAmount = flatItem.type === 'main' ? Number((_product$price = product.price) !== null && _product$price !== void 0 ? _product$price : 0) : Number((_ref6 = (_flatItem$original_pr = flatItem.original_price) !== null && _flatItem$original_pr !== void 0 ? _flatItem$original_pr : flatItem.price) !== null && _ref6 !== void 0 ? _ref6 : 0);
864
+ var originalAmount = flatItem.type === 'main' ? Number((_product$price = product.price) !== null && _product$price !== void 0 ? _product$price : 0) : Number((_ref5 = (_flatItem$original_pr = flatItem.original_price) !== null && _flatItem$original_pr !== void 0 ? _flatItem$original_pr : flatItem.price) !== null && _ref5 !== void 0 ? _ref5 : 0);
878
865
 
879
866
  // 传递 parentQuantity 用于差值处理时判断是否是真正的"数量为1"
880
867
  var productData = {
@@ -929,7 +916,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
929
916
  };
930
917
  originProduct = flatItem.originProduct;
931
918
  }
932
- var isItemRewardProductDiscount = _this3.isItemRewardProductDiscount(product);
933
919
  addModeDiscount.forEach(function (discount) {
934
920
  var _product6, _product7, _product8, _product9, _flatItem$bundleItem3, _flatItem$bundleItem4, _discount$config;
935
921
  var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
@@ -955,7 +941,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
955
941
  var isBundleAvailable = _this3.checkPackageSubItemUsageRules(discount, flatItem);
956
942
 
957
943
  // 判断优惠券是否适用于该商品
958
- if (isAvailableProduct && !isItemRewardProductDiscount && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
944
+ if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable && (_discount$config = discount.config) !== null && _discount$config !== void 0 && _discount$config.isAvailable) {
959
945
  var _discountApplicabilit, _discount$metadata4, _discount$metadata5;
960
946
  // 记录此优惠券适用的商品
961
947
  (_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
@@ -983,7 +969,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
983
969
  discount_product_id: discount.product_id
984
970
  },
985
971
  metadata: {
986
- num: num
972
+ num: num,
973
+ discount_rule_uncheck_flag: discount === null || discount === void 0 ? void 0 : discount.discount_rule_uncheck_flag
987
974
  }
988
975
  };
989
976
  applicableProducts.push(productData);
@@ -1003,13 +990,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1003
990
  };
1004
991
  var optionDiscountAmount = 0;
1005
992
  var discountedOptions = options.map(function (option) {
1006
- var _ref7, _ref8, _option$_original_pri, _ref9, _option$num, _rest$price, _option$_original_pri2;
993
+ var _ref6, _ref7, _option$_original_pri, _ref8, _option$num, _rest$price, _option$_original_pri2;
1007
994
  // 折前单价:优先 price,缺失再 add_price;已写回折后价时用 _original_price(或旧字段 _original_add_price)
1008
- var rawUnit = (_ref7 = (_ref8 = (_option$_original_pri = option._original_price) !== null && _option$_original_pri !== void 0 ? _option$_original_pri : option._original_add_price) !== null && _ref8 !== void 0 ? _ref8 : option.price) !== null && _ref7 !== void 0 ? _ref7 : option.add_price;
995
+ var rawUnit = (_ref6 = (_ref7 = (_option$_original_pri = option._original_price) !== null && _option$_original_pri !== void 0 ? _option$_original_pri : option._original_add_price) !== null && _ref7 !== void 0 ? _ref7 : option.price) !== null && _ref6 !== void 0 ? _ref6 : option.add_price;
1009
996
  var baseUnitNum = Number(rawUnit !== null && rawUnit !== void 0 ? rawUnit : 0);
1010
997
  if (baseUnitNum <= 0) return option;
1011
998
  var discountedPrice = getDiscountAmount(discount, baseUnitNum, baseUnitNum);
1012
- var optQty = Number((_ref9 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref9 !== void 0 ? _ref9 : 1);
999
+ var optQty = Number((_ref8 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref8 !== void 0 ? _ref8 : 1);
1013
1000
  optionDiscountAmount = new Decimal(optionDiscountAmount).plus(new Decimal(baseUnitNum).minus(discountedPrice).mul(optQty)).toNumber();
1014
1001
  var _original_add_price = option._original_add_price,
1015
1002
  rest = _objectWithoutProperties(option, _excluded);
@@ -1043,9 +1030,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1043
1030
  var getOptionTotal = function getOptionTotal(options) {
1044
1031
  if (!(options !== null && options !== void 0 && options.length)) return 0;
1045
1032
  return options.reduce(function (sum, opt) {
1046
- var _ref10, _opt$price, _ref11, _opt$num;
1047
- var unit = Number((_ref10 = (_opt$price = opt.price) !== null && _opt$price !== void 0 ? _opt$price : opt.add_price) !== null && _ref10 !== void 0 ? _ref10 : 0);
1048
- var n = Number((_ref11 = (_opt$num = opt.num) !== null && _opt$num !== void 0 ? _opt$num : opt.quantity) !== null && _ref11 !== void 0 ? _ref11 : 1);
1033
+ var _ref9, _opt$price, _ref10, _opt$num;
1034
+ var unit = Number((_ref9 = (_opt$price = opt.price) !== null && _opt$price !== void 0 ? _opt$price : opt.add_price) !== null && _ref9 !== void 0 ? _ref9 : 0);
1035
+ var n = Number((_ref10 = (_opt$num = opt.num) !== null && _opt$num !== void 0 ? _opt$num : opt.quantity) !== null && _ref10 !== void 0 ? _ref10 : 1);
1049
1036
  return new Decimal(sum).plus(new Decimal(unit).mul(n)).toNumber();
1050
1037
  }, 0);
1051
1038
  };
@@ -1100,7 +1087,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1100
1087
  // 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
1101
1088
  var applicableDiscounts = sortedDiscountList.filter(function (discount) {
1102
1089
  var _product$discount_lis3, _product$discount_lis4;
1103
- if (_this3.isItemRewardProductDiscount(product)) return false;
1104
1090
  // 🔥 检查策略可用性(针对 good_pass 和折扣卡)
1105
1091
  var discountType = discount.tag || discount.type;
1106
1092
  var currentOriginUid = getOriginProductUid(originProduct);
@@ -1178,36 +1164,28 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1178
1164
  return false;
1179
1165
  });
1180
1166
 
1181
- // 用户显式点击某张折扣卡时,本次选择优先于自动排序和扫码默认选择。
1182
- // 目标仍必须在当前商品的 applicableDiscounts 中,因此不会绕过 Holder、时间或商品范围校验。
1183
- var explicitlySelectedDiscountCard = (options === null || options === void 0 ? void 0 : options.isSelected) === true && options.discountId !== undefined ? applicableDiscounts.find(function (discount) {
1184
- var discountType = discount.tag || discount.type;
1185
- return String(discount.id) === String(options.discountId) && ['discount_card', 'product_discount_card'].includes(discountType);
1186
- }) : undefined;
1187
-
1188
- // 没有显式选择时保持现有行为:扫码且已选中的折扣卡优先,否则使用自动排序第一项。
1189
- var scannedSelectedDiscountCard = applicableDiscounts.find(function (n) {
1167
+ // 选择第一个适用的优惠券(已经按过期时间排序)
1168
+ // 如果有 isScan isSelected 的折扣卡,则优先选中,否则再选择第一个
1169
+ // 用于处理:先手动扫描了一张折扣卡,扫描完以后带入客户信息,但是之前那张折扣卡不是最优惠的情况
1170
+ var selectedDiscountCard = applicableDiscounts.find(function (n) {
1190
1171
  return n.isScan && n.isSelected && (n.tag || n.type) !== 'good_pass';
1191
1172
  });
1192
- var selectedDiscountCard = explicitlySelectedDiscountCard || scannedSelectedDiscountCard;
1193
1173
  var selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
1194
1174
 
1195
1175
  // 如果是手动折扣,则不适用优惠券
1196
1176
  var isManualDiscount = false;
1197
- var isItemRewardProductDiscount = false;
1198
1177
  if (flatItem.type === 'main') {
1199
1178
  var _product$discount_lis5, _product$discount_lis6, _product12, _product12$every;
1200
1179
  // 主商品:判断自身是否手动折扣
1201
1180
  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) {
1202
1181
  return item.type === 'product';
1203
1182
  })) || product.total != product.origin_total && (product.bundle || []).every(function (item) {
1204
- var _ref12;
1205
- return !((_ref12 = item.discount_list || []) !== null && _ref12 !== void 0 && _ref12.length);
1183
+ var _ref11;
1184
+ return !((_ref11 = item.discount_list || []) !== null && _ref11 !== void 0 && _ref11.length);
1206
1185
  }) && (!((_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) {
1207
1186
  return item.type === 'product';
1208
1187
  })));
1209
- isItemRewardProductDiscount = _this3.isItemRewardProductDiscount(product);
1210
- if (product.inPromotion && !isItemRewardProductDiscount) {
1188
+ if (product.inPromotion) {
1211
1189
  isManualDiscount = false;
1212
1190
  }
1213
1191
  } else {
@@ -1218,8 +1196,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1218
1196
  isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : ((_parentProduct$discou = parentProduct.discount_list) === null || _parentProduct$discou === void 0 ? void 0 : _parentProduct$discou.some(function (item) {
1219
1197
  return item.type === 'product';
1220
1198
  })) || parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
1221
- var _ref13;
1222
- return !((_ref13 = item.discount_list || []) !== null && _ref13 !== void 0 && _ref13.length);
1199
+ var _ref12;
1200
+ return !((_ref12 = item.discount_list || []) !== null && _ref12 !== void 0 && _ref12.length);
1223
1201
  }) && (!((_parentProduct$discou2 = parentProduct.discount_list) !== null && _parentProduct$discou2 !== void 0 && _parentProduct$discou2.length) || (parentProduct === null || parentProduct === void 0 || (_parentProduct$discou3 = parentProduct.discount_list) === null || _parentProduct$discou3 === void 0 || (_parentProduct$discou4 = _parentProduct$discou3.every) === null || _parentProduct$discou4 === void 0 ? void 0 : _parentProduct$discou4.call(_parentProduct$discou3, function (item) {
1224
1202
  return item.type === 'product';
1225
1203
  })));
@@ -1312,22 +1290,19 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1312
1290
  discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(product.discount_list) : _this3.filterDiscountListByType(product.discount_list, 'promotion')
1313
1291
  }))]);
1314
1292
  } else {
1315
- var _ref14, _product$_promotion$f, _product13, _product$origin_total;
1316
- 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;
1293
+ var _ref13, _product$_promotion$f, _product13, _product$origin_total;
1294
+ var total = product.inPromotion ? (_ref13 = (_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 && _ref13 !== void 0 ? _ref13 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
1317
1295
  var main_product_selling_price = product.price;
1318
1296
  if ((product.discount_list || []).some(function (item) {
1319
1297
  return item.type === 'promotion';
1320
- }) || isItemRewardProductDiscount || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
1298
+ }) || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
1321
1299
  var _product$total, _product$main_product;
1322
1300
  total = (_product$total = product.total) !== null && _product$total !== void 0 ? _product$total : product.origin_total;
1323
1301
  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;
1324
1302
  }
1325
- processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? _objectSpread({
1326
- price: product.price,
1327
- main_product_selling_price: isItemRewardProductDiscount ? main_product_selling_price : product.price
1328
- }, isItemRewardProductDiscount ? {
1329
- total: total
1330
- } : {}) : {
1303
+ processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
1304
+ price: product.price
1305
+ } : {
1331
1306
  _id: product._id.split('___')[0] + '___' + index,
1332
1307
  total: total,
1333
1308
  price: product.price,
@@ -1479,7 +1454,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1479
1454
  _num: isGoodPass ? 1 : product.num,
1480
1455
  config: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.config,
1481
1456
  metadata: _objectSpread(_objectSpread({
1482
- num: 1
1457
+ num: 1,
1458
+ discount_rule_uncheck_flag: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.discount_rule_uncheck_flag
1483
1459
  }, productDiscountDifference !== undefined && {
1484
1460
  product_discount_difference: productDiscountDifference
1485
1461
  }), {}, {
@@ -1566,6 +1542,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1566
1542
  metadata: {
1567
1543
  // 🔥 使用拆分后的唯一 _id
1568
1544
  custom_product_bundle_map_id: uniqueId,
1545
+ discount_rule_uncheck_flag: _selectedDiscount2 === null || _selectedDiscount2 === void 0 ? void 0 : _selectedDiscount2.discount_rule_uncheck_flag,
1569
1546
  num: 1
1570
1547
  },
1571
1548
  _num: 1,
@@ -1597,7 +1574,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1597
1574
  _id: "".concat(flatItem._id, "_split_rest"),
1598
1575
  num: normalNum,
1599
1576
  quantity: normalNum,
1600
- discount_list: [],
1577
+ discount_list: _this3.filterDiscountListByType(flatItem.discount_list, 'promotion'),
1601
1578
  processed: true
1602
1579
  }));
1603
1580
  }
@@ -1651,6 +1628,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1651
1628
  metadata: _objectSpread({
1652
1629
  // 🔥 使用唯一的 _id
1653
1630
  custom_product_bundle_map_id: _uniqueId,
1631
+ discount_rule_uncheck_flag: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.discount_rule_uncheck_flag,
1654
1632
  num: product.num || 1
1655
1633
  }, _productDiscountDifference !== undefined && {
1656
1634
  product_discount_difference: _productDiscountDifference
@@ -1666,7 +1644,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1666
1644
  processedItems.push(_objectSpread(_objectSpread({}, flatItem), {}, {
1667
1645
  total: targetProductTotal,
1668
1646
  price: new Decimal(_productOriginTotal || 0).minus(fixedAmountPerItem).toNumber(),
1669
- discount_list: [_discountDetail2],
1647
+ discount_list: _this3.filterDiscountListByType(flatItem.discount_list, 'promotion').concat([_discountDetail2]),
1670
1648
  processed: true
1671
1649
  }));
1672
1650
  }
@@ -1776,11 +1754,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1776
1754
  processedItems.forEach(function (item) {
1777
1755
  // 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
1778
1756
  var updatedDiscountList = (item.discount_list || []).map(function (discount) {
1779
- var _item$metadata3;
1757
+ var _item$metadata;
1780
1758
  return _objectSpread(_objectSpread({}, discount), {}, {
1781
1759
  metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
1782
1760
  num: item.num,
1783
- custom_product_bundle_map_id: (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.custom_product_bundle_map_id
1761
+ custom_product_bundle_map_id: (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.custom_product_bundle_map_id
1784
1762
  })
1785
1763
  // num: item.num, // 使用拆分后的 num
1786
1764
  });
@@ -1799,11 +1777,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1799
1777
  if (item.processed) {
1800
1778
  // 🔥 同样需要更新 discount_list 中的 num
1801
1779
  var _updatedDiscountList = (item.discount_list || []).map(function (discount) {
1802
- var _item$metadata4;
1780
+ var _item$metadata2;
1803
1781
  return _objectSpread(_objectSpread({}, discount), {}, {
1804
1782
  metadata: _objectSpread(_objectSpread({}, discount.metadata), {}, {
1805
1783
  num: item.num,
1806
- custom_product_bundle_map_id: (_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.custom_product_bundle_map_id
1784
+ custom_product_bundle_map_id: (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.custom_product_bundle_map_id
1807
1785
  })
1808
1786
  // num: item.num, // 使用当前的 num
1809
1787
  });
@@ -1844,8 +1822,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1844
1822
 
1845
1823
  // 🔥 使用更新后的列表计算折扣金额
1846
1824
  var mainDiscountList = updatedMainDiscountList.filter(function (item) {
1847
- var _item$metadata5;
1848
- return !(item !== null && item !== void 0 && (_item$metadata5 = item.metadata) !== null && _item$metadata5 !== void 0 && _item$metadata5.custom_product_bundle_map_id);
1825
+ var _item$metadata3;
1826
+ return !(item !== null && item !== void 0 && (_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.custom_product_bundle_map_id);
1849
1827
  });
1850
1828
  if (mainDiscountList && mainDiscountList.length > 0) {
1851
1829
  var _Decimal$minus$toNumb, _mainProductData$orig;
@@ -1918,8 +1896,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1918
1896
 
1919
1897
  // 🔥 使用更新后的列表计算折扣金额
1920
1898
  var mainDiscountListOriginal = updatedMainDiscountListOriginal.filter(function (item) {
1921
- var _item$metadata6;
1922
- return !(item !== null && item !== void 0 && (_item$metadata6 = item.metadata) !== null && _item$metadata6 !== void 0 && _item$metadata6.custom_product_bundle_map_id);
1899
+ var _item$metadata4;
1900
+ return !(item !== null && item !== void 0 && (_item$metadata4 = item.metadata) !== null && _item$metadata4 !== void 0 && _item$metadata4.custom_product_bundle_map_id);
1923
1901
  });
1924
1902
  if (mainDiscountListOriginal && mainDiscountListOriginal.length > 0) {
1925
1903
  var _Decimal$minus$toNumb2, _mainProductData$orig2;
@@ -1960,7 +1938,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1960
1938
  } else {
1961
1939
  // 🔥 没有子商品被拆分,使用原有逻辑
1962
1940
  mainProductArr.forEach(function (mainProduct) {
1963
- var _ref16, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
1941
+ var _ref15, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
1964
1942
  var mainProductData = _this3.hooks.getProduct(mainProduct);
1965
1943
 
1966
1944
  // 重组bundle
@@ -1975,9 +1953,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1975
1953
  } else {
1976
1954
  // 🔥 关键:拆分后的bundle item
1977
1955
  processedBundleItems.forEach(function (item) {
1978
- var _item$price, _ref15, _item$bundle_selling_;
1956
+ var _item$price, _ref14, _item$bundle_selling_;
1979
1957
  var nextBundlePrice = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : bundleItem.price;
1980
- var nextBundleSellingPrice = (_ref15 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref15 !== void 0 ? _ref15 : bundleItem.bundle_selling_price;
1958
+ var nextBundleSellingPrice = (_ref14 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref14 !== void 0 ? _ref14 : bundleItem.bundle_selling_price;
1981
1959
  // 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
1982
1960
  var updatedDiscountList = (item.discount_list || []).map(function (discount) {
1983
1961
  var _discount$metadata10;
@@ -2004,7 +1982,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2004
1982
 
2005
1983
  // 主商品已经在前面的 setProduct 中应用过折扣;这里只替换 bundle,
2006
1984
  // 避免把主商品 discount_list 再扣一次。
2007
- var mainSellingPrice = (_ref16 = (_mainProductData$main = mainProductData.main_product_selling_price) !== null && _mainProductData$main !== void 0 ? _mainProductData$main : mainProductData.price) !== null && _ref16 !== void 0 ? _ref16 : 0;
1985
+ var mainSellingPrice = (_ref15 = (_mainProductData$main = mainProductData.main_product_selling_price) !== null && _mainProductData$main !== void 0 ? _mainProductData$main : mainProductData.price) !== null && _ref15 !== void 0 ? _ref15 : 0;
2008
1986
  var newTotal = Number(mainSellingPrice || 0);
2009
1987
  var newOriginTotal = Number(mainProductData.original_price || mainProductData.price || 0);
2010
1988
 
@@ -2141,6 +2119,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2141
2119
  }, {
2142
2120
  key: "checkPackageSubItemUsageRules",
2143
2121
  value: function checkPackageSubItemUsageRules(discount, flatItem) {
2122
+ var _flatItem$product;
2144
2123
  var limitedData = discount.limited_relation_product_data;
2145
2124
  var usageRules = limitedData === null || limitedData === void 0 ? void 0 : limitedData.package_sub_item_usage_rules;
2146
2125
  var rules = ['original_price'].concat(_toConsumableArray((usageRules === null || usageRules === void 0 ? void 0 : usageRules.rules) || []));
@@ -2152,16 +2131,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2152
2131
  var ruleType = usageRules.type;
2153
2132
  // 套餐适用范围配置
2154
2133
  var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
2155
- var _ref17 = packageScope || {},
2156
- scopeType = _ref17.type,
2157
- _ref17$exclude_bundle = _ref17.exclude_bundle_product_ids,
2158
- exclude_bundle_product_ids = _ref17$exclude_bundle === void 0 ? [] : _ref17$exclude_bundle,
2159
- _ref17$include_bundle = _ref17.include_bundle_product_ids,
2160
- include_bundle_product_ids = _ref17$include_bundle === void 0 ? [] : _ref17$include_bundle,
2161
- _ref17$filter = _ref17.filter,
2162
- filter = _ref17$filter === void 0 ? 0 : _ref17$filter;
2134
+ var _ref16 = packageScope || {},
2135
+ scopeType = _ref16.type,
2136
+ _ref16$exclude_bundle = _ref16.exclude_bundle_product_ids,
2137
+ exclude_bundle_product_ids = _ref16$exclude_bundle === void 0 ? [] : _ref16$exclude_bundle,
2138
+ _ref16$include_bundle = _ref16.include_bundle_product_ids,
2139
+ include_bundle_product_ids = _ref16$include_bundle === void 0 ? [] : _ref16$include_bundle,
2140
+ _ref16$filter = _ref16.filter,
2141
+ filter = _ref16$filter === void 0 ? 0 : _ref16$filter;
2163
2142
  var isMainProduct = flatItem.type === 'main'; // 单独购买
2164
2143
  var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
2144
+ var bundleMainProductId = (_flatItem$product = flatItem.product) === null || _flatItem$product === void 0 ? void 0 : _flatItem$product.product_id;
2165
2145
 
2166
2146
  // 主商品直接可用
2167
2147
  if (isMainProduct) {
@@ -2204,13 +2184,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2204
2184
  if (!filter) {
2205
2185
  isScopeValid = true;
2206
2186
  } else {
2207
- isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
2187
+ isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
2208
2188
  }
2209
2189
  }
2210
2190
 
2211
2191
  // 包含套餐判断, products值兼容旧数据
2212
2192
  if (scopeType === 'specific_packages' || scopeType === 'products') {
2213
- isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
2193
+ isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
2214
2194
  }
2215
2195
 
2216
2196
  // 价格和套餐适用范围都符合,则可用
@@ -2260,16 +2240,43 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2260
2240
 
2261
2241
  // 检查 rules
2262
2242
  if (rules.length > 0) {
2263
- // 检查原价
2264
- if (_isOriginalPrice2 && rules.includes('original_price')) {
2265
- return true;
2243
+ var _isOriginalPrice3 = _isOriginalPrice2 && rules.includes('original_price');
2244
+ var _isMarkupPrice3 = _isMarkupPrice2 && rules.includes('markup_price');
2245
+ // 价格是否符合规则:原价或加价
2246
+ var _isPriceValid = _isOriginalPrice3 || _isMarkupPrice3;
2247
+ // 套餐适用范围校验
2248
+ var _isScopeValid = false;
2249
+
2250
+ // 排除套餐判断, product_all值兼容旧数据
2251
+ if (scopeType === 'all_packages' || scopeType === 'product_all') {
2252
+ // 所有套餐可用
2253
+ if (!filter) {
2254
+ _isScopeValid = true;
2255
+ } else {
2256
+ _isScopeValid = !exclude_bundle_product_ids.includes(Number(bundleMainProductId));
2257
+ }
2266
2258
  }
2267
2259
 
2268
- // 检查加价
2269
- if (_isMarkupPrice2 && rules.includes('markup_price')) {
2260
+ // 包含套餐判断, products值兼容旧数据
2261
+ if (scopeType === 'specific_packages' || scopeType === 'products') {
2262
+ _isScopeValid = include_bundle_product_ids.includes(Number(bundleMainProductId));
2263
+ }
2264
+
2265
+ // 价格和套餐适用范围都符合,则可用
2266
+ if (_isPriceValid && _isScopeValid) {
2270
2267
  return true;
2271
2268
  }
2272
2269
 
2270
+ // 检查原价
2271
+ // if (isOriginalPrice && rules.includes('original_price')) {
2272
+ // return true;
2273
+ // }
2274
+
2275
+ // 检查加价
2276
+ // if (isMarkupPrice && rules.includes('markup_price')) {
2277
+ // return true;
2278
+ // }
2279
+
2273
2280
  // 如果都不匹配,则不可用
2274
2281
  return false;
2275
2282
  }
@@ -64,21 +64,19 @@ 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
- if (this.appPlugin) {
68
- _context.next = 10;
69
- break;
70
- }
71
- throw new Error('SalesSummaryModule 需要 app 插件支持');
72
- case 10:
67
+
68
+ // if (!this.appPlugin) {
69
+ // throw new Error('SalesSummaryModule 需要 app 插件支持');
70
+ // }
73
71
  if (this.request) {
74
- _context.next = 12;
72
+ _context.next = 10;
75
73
  break;
76
74
  }
77
75
  throw new Error('SalesSummaryModule 需要 request 插件支持');
78
- case 12:
79
- _context.next = 14;
76
+ case 10:
77
+ _context.next = 12;
80
78
  return this.getSurchargeList();
81
- case 14:
79
+ case 12:
82
80
  case "end":
83
81
  return _context.stop();
84
82
  }
@@ -192,10 +190,11 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
192
190
  }, {
193
191
  key: "getAppData",
194
192
  value: function getAppData(key) {
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);
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);
197
195
  if (typeof getData === 'function') return getData(key);
198
- var app = this.appPlugin.getApp();
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;
199
198
  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');
200
199
  return coreData === null || coreData === void 0 ? void 0 : coreData[key];
201
200
  }
@@ -11,10 +11,12 @@ 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?;
14
15
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
15
16
  setContext(context: ScanOrderLoggerContext): void;
16
17
  setProvider(provider: ScanOrderLoggerProviderType): void;
17
18
  setProviderConfig(providerConfig: ScanOrderLoggerProviderConfig): void;
19
+ private getCurrentHost;
18
20
  private buildRecord;
19
21
  addLog(params: ScanOrderLogInput): Promise<void>;
20
22
  }
@@ -46,6 +46,7 @@ export var ScanOrderLoggerModule = /*#__PURE__*/function (_BaseModule) {
46
46
  _defineProperty(_assertThisInitialized(_this), "defaultName", 'scanOrderLogger');
47
47
  _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
48
48
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
49
+ _defineProperty(_assertThisInitialized(_this), "window", void 0);
49
50
  return _this;
50
51
  }
51
52
  _createClass(ScanOrderLoggerModule, [{
@@ -64,6 +65,7 @@ export var ScanOrderLoggerModule = /*#__PURE__*/function (_BaseModule) {
64
65
  options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
65
66
  this.core = core;
66
67
  this.store = options.store;
68
+ this.window = core.getPlugin('window') || undefined;
67
69
  provider = ((_options$otherParams = options.otherParams) === null || _options$otherParams === void 0 ? void 0 : _options$otherParams.provider) || 'feishu';
68
70
  providerConfig = ((_options$otherParams2 = options.otherParams) === null || _options$otherParams2 === void 0 ? void 0 : _options$otherParams2.providerConfig) || {};
69
71
  context = ((_options$otherParams3 = options.otherParams) === null || _options$otherParams3 === void 0 ? void 0 : _options$otherParams3.context) || {};
@@ -73,7 +75,7 @@ export var ScanOrderLoggerModule = /*#__PURE__*/function (_BaseModule) {
73
75
  grafana: _objectSpread(_objectSpread({}, defaultProviderConfig.grafana), providerConfig.grafana || {})
74
76
  });
75
77
  this.store.context = context;
76
- case 9:
78
+ case 10:
77
79
  case "end":
78
80
  return _context.stop();
79
81
  }
@@ -102,16 +104,27 @@ export var ScanOrderLoggerModule = /*#__PURE__*/function (_BaseModule) {
102
104
  grafana: _objectSpread(_objectSpread({}, this.store.providerConfig.grafana || {}), providerConfig.grafana || {})
103
105
  });
104
106
  }
107
+ }, {
108
+ key: "getCurrentHost",
109
+ value: function getCurrentHost() {
110
+ var _this$window;
111
+ var host = (_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.location) === null || _this$window === void 0 ? void 0 : _this$window.host;
112
+ if (typeof host === 'string' && host.length > 0) return host;
113
+ return undefined;
114
+ }
105
115
  }, {
106
116
  key: "buildRecord",
107
117
  value: function buildRecord(params) {
118
+ var host = this.getCurrentHost();
108
119
  return {
109
120
  level: params.level || 'info',
110
121
  title: params.title,
111
122
  timestamp: params.timestamp || dayjs().format('YYYY-MM-DD HH:mm:ss'),
112
123
  payload: params.payload || {},
113
124
  extra: params.extra || {},
114
- context: this.store.context || {}
125
+ context: _objectSpread(_objectSpread({}, this.store.context || {}), host ? {
126
+ host: host
127
+ } : {})
115
128
  };
116
129
  }
117
130
  }, {