@pisell/pisellos 2.1.170 → 2.1.172

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 (231) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -3
  3. package/dist/model/strategy/adapter/index.d.ts +0 -4
  4. package/dist/model/strategy/adapter/index.js +1 -5
  5. package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
  6. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  7. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  8. package/dist/model/strategy/adapter/walletPass/evaluator.js +61 -8
  9. package/dist/model/strategy/adapter/walletPass/locales.js +12 -3
  10. package/dist/model/strategy/engine.d.ts +18 -5
  11. package/dist/model/strategy/engine.js +145 -45
  12. package/dist/model/strategy/type.d.ts +17 -0
  13. package/dist/model/strategy/type.js +4 -0
  14. package/dist/modules/Cart/types.d.ts +2 -0
  15. package/dist/modules/Cart/utils/cartProduct.js +56 -25
  16. package/dist/modules/Cart/utils/changePrice.js +9 -16
  17. package/dist/modules/Discount/index.d.ts +4 -13
  18. package/dist/modules/Discount/index.js +12 -124
  19. package/dist/modules/Discount/types.d.ts +18 -13
  20. package/dist/modules/Order/index.d.ts +1 -67
  21. package/dist/modules/Order/index.js +30 -918
  22. package/dist/modules/Order/types.d.ts +12 -176
  23. package/dist/modules/Order/types.js +0 -2
  24. package/dist/modules/Order/utils.d.ts +0 -118
  25. package/dist/modules/Order/utils.js +2 -586
  26. package/dist/modules/Payment/index.d.ts +2 -1
  27. package/dist/modules/Payment/index.js +10 -7
  28. package/dist/modules/Payment/utils.js +3 -0
  29. package/dist/modules/Payment/walletpass.d.ts +23 -0
  30. package/dist/modules/Payment/walletpass.js +191 -95
  31. package/dist/modules/Product/utils.js +2 -2
  32. package/dist/modules/ProductList/index.d.ts +2 -4
  33. package/dist/modules/ProductList/index.js +12 -24
  34. package/dist/modules/Rules/index.d.ts +9 -5
  35. package/dist/modules/Rules/index.js +669 -173
  36. package/dist/modules/Rules/types.d.ts +2 -0
  37. package/dist/modules/Schedule/getDateIsInSchedule.js +18 -16
  38. package/dist/modules/Schedule/utils.d.ts +1 -1
  39. package/dist/modules/Summary/types.d.ts +2 -0
  40. package/dist/modules/Summary/utils.d.ts +9 -3
  41. package/dist/modules/Summary/utils.js +57 -67
  42. package/dist/modules/index.d.ts +0 -4
  43. package/dist/modules/index.js +1 -5
  44. package/dist/plugins/window.d.ts +2 -0
  45. package/dist/solution/BookingByStep/index.d.ts +3 -2
  46. package/dist/solution/BookingByStep/index.js +43 -46
  47. package/dist/solution/BookingByStep/types.d.ts +1 -3
  48. package/dist/solution/BookingByStep/types.js +1 -5
  49. package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  50. package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
  51. package/dist/solution/Checkout/index.js +2 -0
  52. package/dist/solution/ShopDiscount/index.d.ts +2 -3
  53. package/dist/solution/ShopDiscount/index.js +60 -62
  54. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  55. package/dist/solution/ShopDiscount/types.js +2 -1
  56. package/dist/solution/ShopDiscount/utils.js +26 -12
  57. package/dist/solution/index.d.ts +0 -2
  58. package/dist/solution/index.js +1 -3
  59. package/lib/index.d.ts +1 -1
  60. package/lib/index.js +3 -4
  61. package/lib/model/strategy/adapter/index.d.ts +0 -4
  62. package/lib/model/strategy/adapter/index.js +2 -13
  63. package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
  64. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  65. package/lib/model/strategy/adapter/walletPass/evaluator.js +34 -3
  66. package/lib/model/strategy/adapter/walletPass/locales.js +12 -3
  67. package/lib/model/strategy/engine.d.ts +18 -5
  68. package/lib/model/strategy/engine.js +85 -21
  69. package/lib/model/strategy/type.d.ts +17 -0
  70. package/lib/modules/Cart/types.d.ts +2 -0
  71. package/lib/modules/Cart/utils/cartProduct.js +39 -12
  72. package/lib/modules/Cart/utils/changePrice.js +9 -13
  73. package/lib/modules/Discount/index.d.ts +4 -13
  74. package/lib/modules/Discount/index.js +5 -76
  75. package/lib/modules/Discount/types.d.ts +18 -13
  76. package/lib/modules/Order/index.d.ts +1 -67
  77. package/lib/modules/Order/index.js +1 -525
  78. package/lib/modules/Order/types.d.ts +12 -176
  79. package/lib/modules/Order/utils.d.ts +0 -118
  80. package/lib/modules/Order/utils.js +2 -483
  81. package/lib/modules/Payment/index.d.ts +2 -1
  82. package/lib/modules/Payment/index.js +1 -0
  83. package/lib/modules/Payment/utils.js +3 -0
  84. package/lib/modules/Payment/walletpass.d.ts +23 -0
  85. package/lib/modules/Payment/walletpass.js +94 -17
  86. package/lib/modules/Product/utils.js +2 -2
  87. package/lib/modules/ProductList/index.d.ts +2 -4
  88. package/lib/modules/ProductList/index.js +39 -46
  89. package/lib/modules/Rules/index.d.ts +9 -5
  90. package/lib/modules/Rules/index.js +776 -292
  91. package/lib/modules/Rules/types.d.ts +2 -0
  92. package/lib/modules/Schedule/getDateIsInSchedule.js +11 -13
  93. package/lib/modules/Schedule/utils.d.ts +1 -1
  94. package/lib/modules/Summary/types.d.ts +2 -0
  95. package/lib/modules/Summary/utils.d.ts +9 -3
  96. package/lib/modules/Summary/utils.js +34 -45
  97. package/lib/modules/index.d.ts +0 -4
  98. package/lib/modules/index.js +1 -9
  99. package/lib/plugins/window.d.ts +2 -0
  100. package/lib/solution/BookingByStep/index.d.ts +3 -2
  101. package/lib/solution/BookingByStep/index.js +4 -6
  102. package/lib/solution/BookingByStep/types.d.ts +1 -3
  103. package/lib/solution/BookingByStep/types.js +0 -10
  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/Checkout/index.js +2 -0
  107. package/lib/solution/ShopDiscount/index.d.ts +2 -3
  108. package/lib/solution/ShopDiscount/index.js +27 -22
  109. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  110. package/lib/solution/ShopDiscount/utils.js +10 -6
  111. package/lib/solution/index.d.ts +0 -2
  112. package/lib/solution/index.js +1 -5
  113. package/package.json +2 -2
  114. package/dist/apis/picoding.d.ts +0 -0
  115. package/dist/apis/picoding.js +0 -1
  116. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  117. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  118. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  119. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -867
  120. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  121. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  122. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  123. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  124. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -149
  125. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  126. package/dist/modules/OpenData/index.d.ts +0 -24
  127. package/dist/modules/OpenData/index.js +0 -173
  128. package/dist/modules/OpenData/types.d.ts +0 -73
  129. package/dist/modules/OpenData/types.js +0 -1
  130. package/dist/modules/OpenData/utils.d.ts +0 -2
  131. package/dist/modules/OpenData/utils.js +0 -75
  132. package/dist/modules/Quotation/index.d.ts +0 -48
  133. package/dist/modules/Quotation/index.js +0 -248
  134. package/dist/modules/Quotation/types.d.ts +0 -42
  135. package/dist/modules/Quotation/types.js +0 -1
  136. package/dist/modules/SalesSummary/index.d.ts +0 -63
  137. package/dist/modules/SalesSummary/index.js +0 -174
  138. package/dist/modules/SalesSummary/types.d.ts +0 -60
  139. package/dist/modules/SalesSummary/types.js +0 -1
  140. package/dist/modules/SalesSummary/utils.d.ts +0 -30
  141. package/dist/modules/SalesSummary/utils.js +0 -480
  142. package/dist/modules/ScanOrderLogger/index.d.ts +0 -23
  143. package/dist/modules/ScanOrderLogger/index.js +0 -174
  144. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  145. package/dist/modules/ScanOrderLogger/providers/feishu.js +0 -221
  146. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  147. package/dist/modules/ScanOrderLogger/providers/grafana.js +0 -50
  148. package/dist/modules/ScanOrderLogger/types.d.ts +0 -53
  149. package/dist/modules/ScanOrderLogger/types.js +0 -1
  150. package/dist/solution/ScanOrder/index.d.ts +0 -158
  151. package/dist/solution/ScanOrder/index.js +0 -3474
  152. package/dist/solution/ScanOrder/types.d.ts +0 -306
  153. package/dist/solution/ScanOrder/types.js +0 -35
  154. package/dist/solution/ScanOrder/utils.d.ts +0 -172
  155. package/dist/solution/ScanOrder/utils.js +0 -796
  156. package/dist/solution/VenueBooking/index.d.ts +0 -252
  157. package/dist/solution/VenueBooking/index.js +0 -3769
  158. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  159. package/dist/solution/VenueBooking/types.d.ts +0 -156
  160. package/dist/solution/VenueBooking/types.js +0 -22
  161. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  162. package/dist/solution/VenueBooking/utils/dateSummary.js +0 -91
  163. package/dist/solution/VenueBooking/utils/resource.d.ts +0 -14
  164. package/dist/solution/VenueBooking/utils/resource.js +0 -131
  165. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
  166. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -233
  167. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -71
  168. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -302
  169. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
  170. package/dist/solution/VenueBooking/utils/timeSlot.js +0 -458
  171. package/dist/solution/VenueBooking/utils.d.ts +0 -1
  172. package/dist/solution/VenueBooking/utils.js +0 -1
  173. package/lib/apis/picoding.d.ts +0 -0
  174. package/lib/apis/picoding.js +0 -0
  175. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  176. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  177. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  178. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -666
  179. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  180. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  181. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  182. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  183. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -149
  184. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
  185. package/lib/modules/OpenData/index.d.ts +0 -24
  186. package/lib/modules/OpenData/index.js +0 -119
  187. package/lib/modules/OpenData/types.d.ts +0 -73
  188. package/lib/modules/OpenData/types.js +0 -17
  189. package/lib/modules/OpenData/utils.d.ts +0 -2
  190. package/lib/modules/OpenData/utils.js +0 -111
  191. package/lib/modules/Quotation/index.d.ts +0 -48
  192. package/lib/modules/Quotation/index.js +0 -152
  193. package/lib/modules/Quotation/types.d.ts +0 -42
  194. package/lib/modules/Quotation/types.js +0 -17
  195. package/lib/modules/SalesSummary/index.d.ts +0 -63
  196. package/lib/modules/SalesSummary/index.js +0 -105
  197. package/lib/modules/SalesSummary/types.d.ts +0 -60
  198. package/lib/modules/SalesSummary/types.js +0 -17
  199. package/lib/modules/SalesSummary/utils.d.ts +0 -30
  200. package/lib/modules/SalesSummary/utils.js +0 -420
  201. package/lib/modules/ScanOrderLogger/index.d.ts +0 -23
  202. package/lib/modules/ScanOrderLogger/index.js +0 -147
  203. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  204. package/lib/modules/ScanOrderLogger/providers/feishu.js +0 -157
  205. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  206. package/lib/modules/ScanOrderLogger/providers/grafana.js +0 -52
  207. package/lib/modules/ScanOrderLogger/types.d.ts +0 -53
  208. package/lib/modules/ScanOrderLogger/types.js +0 -17
  209. package/lib/solution/ScanOrder/index.d.ts +0 -158
  210. package/lib/solution/ScanOrder/index.js +0 -2135
  211. package/lib/solution/ScanOrder/types.d.ts +0 -306
  212. package/lib/solution/ScanOrder/types.js +0 -36
  213. package/lib/solution/ScanOrder/utils.d.ts +0 -172
  214. package/lib/solution/ScanOrder/utils.js +0 -658
  215. package/lib/solution/VenueBooking/index.d.ts +0 -252
  216. package/lib/solution/VenueBooking/index.js +0 -2204
  217. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  218. package/lib/solution/VenueBooking/types.d.ts +0 -156
  219. package/lib/solution/VenueBooking/types.js +0 -45
  220. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  221. package/lib/solution/VenueBooking/utils/dateSummary.js +0 -105
  222. package/lib/solution/VenueBooking/utils/resource.d.ts +0 -14
  223. package/lib/solution/VenueBooking/utils/resource.js +0 -92
  224. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
  225. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -236
  226. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -71
  227. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -225
  228. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
  229. package/lib/solution/VenueBooking/utils/timeSlot.js +0 -343
  230. package/lib/solution/VenueBooking/utils.d.ts +0 -1
  231. package/lib/solution/VenueBooking/utils.js +0 -69
@@ -57,7 +57,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
57
57
  currentBookingTime: "",
58
58
  filteredDiscountList: [],
59
59
  bookingSubject: void 0,
60
- orderId: void 0
60
+ orderTotalAmount: 0
61
61
  };
62
62
  }
63
63
  // =========== 生命周期方法 ===========
@@ -195,6 +195,9 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
195
195
  );
196
196
  }
197
197
  }
198
+ setOriginTotalAmount(amount) {
199
+ this.store.orderTotalAmount = amount;
200
+ }
198
201
  // 设置holders
199
202
  setHolders(holders) {
200
203
  this.store.holders = holders;
@@ -202,9 +205,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
202
205
  setBookingSubject(bookingSubject) {
203
206
  this.store.bookingSubject = bookingSubject;
204
207
  }
205
- setOrderId(id) {
206
- this.store.orderId = id;
207
- }
208
208
  // 计算优惠券
209
209
  calcDiscount(productList, options) {
210
210
  var _a;
@@ -217,6 +217,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
217
217
  {
218
218
  productList,
219
219
  discountList: this.getDiscountList(),
220
+ orderTotalAmount: this.store.orderTotalAmount || 0,
220
221
  holders: this.store.holders || [],
221
222
  isFormSubject: ((_a = this.store.bookingSubject) == null ? void 0 : _a.type) === "form"
222
223
  },
@@ -281,8 +282,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
281
282
  async scanCode(code, customerId) {
282
283
  var _a, _b, _c;
283
284
  try {
284
- const resultDiscountWithReason = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, { customerId, orderId: this.store.orderId })) || { discountList: [], unavailableReasonKey: null };
285
- const { discountList: resultDiscountList, unavailableReasonKey } = resultDiscountWithReason;
285
+ const resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, customerId)) || [];
286
286
  const rulesModule = this.store.rules;
287
287
  if (!rulesModule) {
288
288
  return {
@@ -298,8 +298,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
298
298
  type: "server",
299
299
  isAvailable: false,
300
300
  productList: this.store.productList || [],
301
- discountList: this.getDiscountList(),
302
- unavailableReasonKey
301
+ discountList: this.getDiscountList()
303
302
  };
304
303
  }
305
304
  const withScanList = resultDiscountList.map((item) => {
@@ -326,6 +325,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
326
325
  productList: this.store.productList || [],
327
326
  oldDiscountList: this.getDiscountList(),
328
327
  newDiscountList: withScanList,
328
+ orderTotalAmount: this.store.orderTotalAmount || 0,
329
329
  holders: this.store.holders || [],
330
330
  isFormSubject: ((_b = this.store.bookingSubject) == null ? void 0 : _b.type) === "form"
331
331
  }) || {
@@ -394,7 +394,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
394
394
  if (item.booking_id) {
395
395
  const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(item);
396
396
  (item.discount_list || []).forEach((discount) => {
397
- var _a3, _b, _c, _d, _e;
397
+ var _a3, _b, _c, _d, _e, _f, _g, _h, _i;
398
398
  if (discount.id && ["good_pass", "discount_card"].includes(discount.type)) {
399
399
  const index = editModeDiscountList.findIndex((n) => {
400
400
  var _a4;
@@ -403,8 +403,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
403
403
  if (index !== -1) {
404
404
  editModeDiscountList[index] = {
405
405
  ...editModeDiscountList[index],
406
+ metadata: {
407
+ ...discount.metadata || {},
408
+ num: (((_b = (_a3 = editModeDiscountList == null ? void 0 : editModeDiscountList[index]) == null ? void 0 : _a3.metadata) == null ? void 0 : _b.num) || 1) + (((_c = discount.metadata) == null ? void 0 : _c.num) || 1)
409
+ },
406
410
  amount: new import_decimal.default(discount.amount || 0).plus(new import_decimal.default(editModeDiscountList[index].amount || 0)).toNumber(),
407
- savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((_a3 = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a3.product_discount_difference) || 0).plus(new import_decimal.default(editModeDiscountList[index].savedAmount || 0)).toNumber()
411
+ savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((_d = discount == null ? void 0 : discount.metadata) == null ? void 0 : _d.product_discount_difference) || 0).plus(new import_decimal.default(editModeDiscountList[index].savedAmount || 0)).toNumber()
408
412
  };
409
413
  } else {
410
414
  if (discount.type && !discount.tag) {
@@ -412,16 +416,20 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
412
416
  }
413
417
  editModeDiscountList.push({
414
418
  ...discount,
419
+ metadata: {
420
+ ...discount.metadata || {},
421
+ num: ((_e = discount.metadata) == null ? void 0 : _e.num) || 1
422
+ },
415
423
  name: discount.name || discount.discount.title.auto,
416
424
  isEditMode: true,
417
425
  limited_relation_product_data: {},
418
- savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.product_discount_difference) || 0).toNumber(),
426
+ savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((_f = discount == null ? void 0 : discount.metadata) == null ? void 0 : _f.product_discount_difference) || 0).toNumber(),
419
427
  isAvailable: true,
420
- id: ((_c = discount.discount) == null ? void 0 : _c.resource_id) || discount.id,
421
- format_title: ((_d = discount.discount) == null ? void 0 : _d.title) || discount.format_title,
428
+ id: ((_g = discount.discount) == null ? void 0 : _g.resource_id) || discount.id,
429
+ format_title: ((_h = discount.discount) == null ? void 0 : _h.title) || discount.format_title,
422
430
  isDisabled: true,
423
431
  isSelected: true,
424
- product_id: ((_e = discount.discount) == null ? void 0 : _e.product_id) || discount.product_id
432
+ product_id: ((_i = discount.discount) == null ? void 0 : _i.product_id) || discount.product_id
425
433
  });
426
434
  }
427
435
  }
@@ -509,23 +517,20 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
509
517
  async loadPrepareConfig(params) {
510
518
  var _a, _b, _c, _d, _e;
511
519
  try {
512
- const orderId = this.store.orderId;
513
520
  const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
514
- const prepareConfig = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
521
+ const goodPassList = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
515
522
  customer_id: customerId,
516
- action: orderId ? "edit" : "create",
523
+ action: "create",
517
524
  with_good_pass: 1,
518
525
  with_discount_card: 1,
519
526
  with_wallet_pass_holder: 1,
520
- request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
521
- ...orderId ? { order_id: orderId } : {}
527
+ request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
522
528
  }));
523
- const goodPassList = (prepareConfig == null ? void 0 : prepareConfig.discountList) || [];
524
529
  const scanDiscount = (_c = this.getDiscountList()) == null ? void 0 : _c.filter(
525
530
  (item) => item.isScan
526
531
  );
527
532
  const scanDiscountIds = scanDiscount.map((n) => n.id);
528
- const newGoodPassList = goodPassList.filter((n) => !scanDiscountIds.includes(n.id));
533
+ const newGoodPassList = goodPassList == null ? void 0 : goodPassList.filter((n) => !scanDiscountIds.includes(n.id));
529
534
  const newDiscountList = [...scanDiscount, ...newGoodPassList || []];
530
535
  this.store.originalDiscountList = newDiscountList;
531
536
  await ((_d = this.store.discount) == null ? void 0 : _d.setOriginalDiscountList(newDiscountList));
@@ -541,7 +546,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
541
546
  }
542
547
  await this.core.effects.emit(
543
548
  `${this.name}:onLoadDiscountList`,
544
- filteredDiscountList
549
+ newDiscountList
545
550
  );
546
551
  } catch (error) {
547
552
  console.error("[ShopDiscount] 加载准备配置出错:", error);
@@ -23,6 +23,7 @@ export interface ShopDiscountState {
23
23
  discount: DiscountModule | null;
24
24
  rules: RulesModule | null;
25
25
  productList: Record<string, any>[];
26
+ orderTotalAmount?: number;
26
27
  holders?: {
27
28
  form_record_id: number;
28
29
  form_id?: number;
@@ -35,7 +36,6 @@ export interface ShopDiscountState {
35
36
  type?: 'form' | 'customer';
36
37
  [key: string]: any;
37
38
  };
38
- orderId?: number;
39
39
  }
40
40
  export interface SetDiscountSelectedParams {
41
41
  discountId: number;
@@ -56,14 +56,18 @@ var isAllNormalProduct = (items) => {
56
56
  };
57
57
  var getDiscountAmount = (discount, total, price) => {
58
58
  var _a;
59
+ let discountedPrice = 0;
59
60
  if (discount.tag === "good_pass") {
60
- return new import_decimal.default(price).minus(new import_decimal.default(price || 0)).toNumber();
61
- }
62
- const isFixedAmount = ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.discount_card_type) === "fixed_amount";
63
- if (isFixedAmount) {
64
- return Math.max(new import_decimal.default(price).minus(new import_decimal.default((discount.amount ?? discount.par_value) || 0)).toNumber(), 0);
61
+ discountedPrice = new import_decimal.default(price).minus(new import_decimal.default(price || 0)).toNumber();
62
+ } else {
63
+ const isFixedAmount = ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.discount_card_type) === "fixed_amount";
64
+ if (isFixedAmount) {
65
+ discountedPrice = Math.max(new import_decimal.default(price).minus(new import_decimal.default(discount.par_value || 0)).toNumber(), 0);
66
+ } else {
67
+ discountedPrice = new import_decimal.default(100).minus(discount.par_value || 0).div(100).mul(new import_decimal.default(price)).toNumber();
68
+ }
65
69
  }
66
- return new import_decimal.default(100).minus(discount.par_value || 0).div(100).mul(new import_decimal.default(price)).toNumber();
70
+ return discountedPrice;
67
71
  };
68
72
  var getDiscountListAmountTotal = (discount) => {
69
73
  return discount.reduce((acc, cur) => {
@@ -4,5 +4,3 @@ export * from './BookingTicket';
4
4
  export * from './ShopDiscount';
5
5
  export * from './RegisterAndLogin';
6
6
  export * from './Checkout';
7
- export * from './ScanOrder';
8
- export * from './VenueBooking';
@@ -22,8 +22,6 @@ __reExport(solution_exports, require("./BookingTicket"), module.exports);
22
22
  __reExport(solution_exports, require("./ShopDiscount"), module.exports);
23
23
  __reExport(solution_exports, require("./RegisterAndLogin"), module.exports);
24
24
  __reExport(solution_exports, require("./Checkout"), module.exports);
25
- __reExport(solution_exports, require("./ScanOrder"), module.exports);
26
- __reExport(solution_exports, require("./VenueBooking"), module.exports);
27
25
  // Annotate the CommonJS export names for ESM import in node:
28
26
  0 && (module.exports = {
29
27
  ...require("./BuyTickets"),
@@ -31,7 +29,5 @@ __reExport(solution_exports, require("./VenueBooking"), module.exports);
31
29
  ...require("./BookingTicket"),
32
30
  ...require("./ShopDiscount"),
33
31
  ...require("./RegisterAndLogin"),
34
- ...require("./Checkout"),
35
- ...require("./ScanOrder"),
36
- ...require("./VenueBooking")
32
+ ...require("./Checkout")
37
33
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.170",
4
+ "version": "2.1.172",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
19
19
  "changeset": "changeset",
20
20
  "version": "changeset version",
21
- "release": "changeset publish --registry=https://registry.npmjs.com/ && npm run sync && git push",
21
+ "release": "changeset publish && npm run sync && git push",
22
22
  "example": "npx parcel-bundler examples/index.html",
23
23
  "docs": "typedoc --out docs src/index.ts",
24
24
  "sync": "node sync.js",
File without changes
@@ -1 +0,0 @@
1
- // picoding 相关公共 api
@@ -1,50 +0,0 @@
1
- import type { EvaluationResult, RuntimeContext } from '../../type';
2
- import type { BusinessAdapter } from '../type';
3
- import type { DataVariantBusinessData, DataVariantProduct } from './type';
4
- /**
5
- * Data Variant 适配器。
6
- *
7
- * 负责把智能定价运行态数据转换为 StrategyEngine 能识别的 attributes。
8
- */
9
- export declare class DataVariantAdapter implements BusinessAdapter {
10
- name: string;
11
- version: string;
12
- /**
13
- * 准备批量全局上下文。
14
- *
15
- * 这里只放不依赖单个商品的字段,用于预计算 schedule/channel/orderType 等条件。
16
- */
17
- prepareContext(businessData: DataVariantBusinessData): RuntimeContext;
18
- /**
19
- * 准备全局预计算上下文。
20
- */
21
- prepareGlobalContext(businessData: DataVariantBusinessData): RuntimeContext;
22
- /**
23
- * 准备单商品上下文。
24
- *
25
- * 商品级条件只在当前商品 data_variants 引用到对应规则后才评估。
26
- */
27
- prepareProductContext(businessData: DataVariantBusinessData, product: DataVariantProduct): RuntimeContext;
28
- transformResult(result: EvaluationResult): EvaluationResult;
29
- formatConfig(result: EvaluationResult, businessData?: DataVariantBusinessData): {
30
- result: EvaluationResult;
31
- businessData?: DataVariantBusinessData;
32
- };
33
- /**
34
- * 构建 menu_match 使用的轻量商品对象。
35
- *
36
- * collection_ids 来自商品 collection 字段,避免 operator 读取复杂商品对象。
37
- */
38
- buildProductValue(product: DataVariantProduct): {
39
- id: number;
40
- product_variant_id: number;
41
- collection_ids: number[];
42
- };
43
- private toNumber;
44
- /**
45
- * 归一化客户 id:无效值返回 undefined,有效值统一为 number。
46
- */
47
- private normalizeCustomerId;
48
- private normalizeNumberArray;
49
- }
50
- export default DataVariantAdapter;
@@ -1,167 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
6
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
7
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
- /**
11
- * Data Variant 适配器。
12
- *
13
- * 负责把智能定价运行态数据转换为 StrategyEngine 能识别的 attributes。
14
- */
15
- export var DataVariantAdapter = /*#__PURE__*/function () {
16
- function DataVariantAdapter() {
17
- _classCallCheck(this, DataVariantAdapter);
18
- _defineProperty(this, "name", 'DataVariantAdapter');
19
- _defineProperty(this, "version", '1.0.0');
20
- }
21
- _createClass(DataVariantAdapter, [{
22
- key: "prepareContext",
23
- value:
24
- /**
25
- * 准备批量全局上下文。
26
- *
27
- * 这里只放不依赖单个商品的字段,用于预计算 schedule/channel/orderType 等条件。
28
- */
29
- function prepareContext(businessData) {
30
- return this.prepareGlobalContext(businessData);
31
- }
32
-
33
- /**
34
- * 准备全局预计算上下文。
35
- */
36
- }, {
37
- key: "prepareGlobalContext",
38
- value: function prepareGlobalContext(businessData) {
39
- var products = businessData.products,
40
- scheduleDateTime = businessData.scheduleDateTime,
41
- channel = businessData.channel,
42
- orderType = businessData.orderType,
43
- businessCode = businessData.businessCode,
44
- customerId = businessData.customerId,
45
- availableWalletIds = businessData.availableWalletIds,
46
- custom = businessData.custom;
47
-
48
- // customer_id 统一归一化为 number,避免 in 运算符因 string/number 不一致而误判
49
- var normalizedCustomerId = this.normalizeCustomerId(customerId);
50
- var normalizedAvailableWalletIds = this.normalizeNumberArray(availableWalletIds !== null && availableWalletIds !== void 0 ? availableWalletIds : custom === null || custom === void 0 ? void 0 : custom.available_wallet_ids);
51
- var resolvedBusinessCode = businessCode || (custom === null || custom === void 0 ? void 0 : custom.business_code) || (custom === null || custom === void 0 ? void 0 : custom.businessCode) || '';
52
- return {
53
- entities: {
54
- products: products
55
- },
56
- attributes: _objectSpread(_objectSpread({}, custom), {}, {
57
- schedule: scheduleDateTime || '',
58
- channel: channel || (custom === null || custom === void 0 ? void 0 : custom.channel) || '',
59
- orderType: orderType || (custom === null || custom === void 0 ? void 0 : custom.orderType) || (custom === null || custom === void 0 ? void 0 : custom.order_type) || '',
60
- // snake_case 与策略配置 field 对齐;customerId 保留兼容旧配置
61
- customer_id: normalizedCustomerId,
62
- customerId: normalizedCustomerId,
63
- available_wallet_ids: normalizedAvailableWalletIds,
64
- availableWalletIds: normalizedAvailableWalletIds,
65
- business_code: resolvedBusinessCode
66
- }),
67
- metadata: {
68
- timestamp: Date.now()
69
- }
70
- };
71
- }
72
-
73
- /**
74
- * 准备单商品上下文。
75
- *
76
- * 商品级条件只在当前商品 data_variants 引用到对应规则后才评估。
77
- */
78
- }, {
79
- key: "prepareProductContext",
80
- value: function prepareProductContext(businessData, product) {
81
- var base = this.prepareGlobalContext(businessData);
82
- var productValue = this.buildProductValue(product);
83
- return _objectSpread(_objectSpread({}, base), {}, {
84
- entities: _objectSpread(_objectSpread({}, base.entities), {}, {
85
- currentProduct: product
86
- }),
87
- attributes: _objectSpread(_objectSpread({}, base.attributes), {}, {
88
- product: productValue,
89
- productIdAndVariantId: {
90
- product_id: productValue.id,
91
- product_variant_id: productValue.product_variant_id
92
- }
93
- })
94
- });
95
- }
96
- }, {
97
- key: "transformResult",
98
- value: function transformResult(result) {
99
- return result;
100
- }
101
- }, {
102
- key: "formatConfig",
103
- value: function formatConfig(result, businessData) {
104
- return {
105
- result: result,
106
- businessData: businessData
107
- };
108
- }
109
-
110
- /**
111
- * 构建 menu_match 使用的轻量商品对象。
112
- *
113
- * collection_ids 来自商品 collection 字段,避免 operator 读取复杂商品对象。
114
- */
115
- }, {
116
- key: "buildProductValue",
117
- value: function buildProductValue(product) {
118
- var _product$id,
119
- _product$product_vari,
120
- _this = this;
121
- var productId = this.toNumber((_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : product.product_id);
122
- var variantId = this.toNumber((_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : product.variant_id);
123
- var collectionIds = Array.isArray(product.collection) ? product.collection.map(function (item) {
124
- return _this.toNumber(item === null || item === void 0 ? void 0 : item.id);
125
- }).filter(function (id) {
126
- return id > 0;
127
- }) : [];
128
- return {
129
- id: productId,
130
- product_variant_id: variantId,
131
- collection_ids: collectionIds
132
- };
133
- }
134
- }, {
135
- key: "toNumber",
136
- value: function toNumber(value) {
137
- var parsed = Number(value);
138
- return Number.isFinite(parsed) ? parsed : 0;
139
- }
140
-
141
- /**
142
- * 归一化客户 id:无效值返回 undefined,有效值统一为 number。
143
- */
144
- }, {
145
- key: "normalizeCustomerId",
146
- value: function normalizeCustomerId(value) {
147
- if (value === undefined || value === null || value === '') {
148
- return undefined;
149
- }
150
- var parsed = Number(value);
151
- return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
152
- }
153
- }, {
154
- key: "normalizeNumberArray",
155
- value: function normalizeNumberArray(value) {
156
- if (!Array.isArray(value)) return [];
157
- var ids = value.map(function (item) {
158
- return Number(item);
159
- }).filter(function (item) {
160
- return Number.isFinite(item) && item > 0;
161
- });
162
- return Array.from(new Set(ids));
163
- }
164
- }]);
165
- return DataVariantAdapter;
166
- }();
167
- export default DataVariantAdapter;
@@ -1,89 +0,0 @@
1
- import type { ConditionRule, StrategyConfig } from '../../type';
2
- import type { ConditionScope, DataVariantBusinessData, DataVariantMenu, DataVariantRuleMetadata, MenuScope, ResolvedDataVariantResult } from './type';
3
- /**
4
- * Data Variant 评估器。
5
- *
6
- * 当前阶段只提供策略模型能力和示例验证,不接入 ProductList 业务链路。
7
- */
8
- export declare class DataVariantEvaluator {
9
- private adapter;
10
- private strategyConfigs;
11
- constructor();
12
- /**
13
- * 设置策略配置列表,仅保留 metadata.type === 'data_variant' 的策略。
14
- */
15
- setStrategyConfigs(configs: StrategyConfig[]): void;
16
- getStrategyConfigs(): StrategyConfig<DataVariantRuleMetadata>[];
17
- /**
18
- * 批量解析商品 Data Variant。
19
- *
20
- * 先执行全局预计算,再只针对商品自身 data_variants 引用到的规则做商品级判断。
21
- */
22
- resolveProducts(businessData: DataVariantBusinessData): ResolvedDataVariantResult;
23
- /**
24
- * 根据 operator/field 判断条件是否依赖当前商品。
25
- */
26
- getConditionScope(rule: ConditionRule): ConditionScope;
27
- /**
28
- * 将餐牌 partyroom_package 预构建为 Map/Set 索引。
29
- */
30
- buildMenuScopeMap(menuList: DataVariantMenu[]): Map<number, MenuScope>;
31
- /**
32
- * 从当前策略中所有 schedule_match.value 绑定的 schedule_id 提取时间点。
33
- *
34
- * 这里不依赖餐牌,只读取策略配置和调用方传入的 scheduleList。
35
- */
36
- buildScheduleTimePoints(strategyConfigs: StrategyConfig<DataVariantRuleMetadata>[], scheduleList: NonNullable<DataVariantBusinessData['scheduleList']>): string[];
37
- private buildGlobalEffectiveRuleMap;
38
- private resolveProduct;
39
- /**
40
- * 解析套餐子商品上的 Data Variant 覆盖。
41
- *
42
- * bundle_item 以 bundle_product_id / bundle_variant_id 作为商品身份参与 product_match 等条件判断。
43
- */
44
- private resolveProductBundleItems;
45
- /**
46
- * 将 bundle_item 转为 DataVariantProduct 并评估 data_variants。
47
- */
48
- private resolveBundleItem;
49
- /**
50
- * bundle_item 的商品身份映射:bundle_product_id + bundle_variant_id。
51
- */
52
- private toBundleItemDataVariantProduct;
53
- /**
54
- * 仅回写命中的字段,避免污染 bundle_item 的结构字段。
55
- */
56
- private mergeBundleItemResolvedData;
57
- private evaluateProductRules;
58
- /**
59
- * 拆分策略条件。
60
- *
61
- * 当前 MVP 支持顶层 and 原子条件拆分;复杂条件保守地放到商品级完整判断。
62
- */
63
- private splitStrategyConfig;
64
- private createEngine;
65
- private evaluateScheduleMatch;
66
- private evaluateMenuMatch;
67
- private evaluateArrayIntersects;
68
- private collectScheduleIdsFromStrategies;
69
- private extractTimePointsFromSchedules;
70
- private addDateTimePoint;
71
- private addRawTimePoint;
72
- private extractTimeFromDateTime;
73
- private normalizeTime;
74
- private timeToMinutes;
75
- private isProductInMenuScope;
76
- private mergeMatchedVariants;
77
- private getProductDataVariants;
78
- private normalizeStrategyConfigs;
79
- private isStrategyActive;
80
- private getStrategyPriority;
81
- private createAlwaysTrueConditions;
82
- private flattenConditionRules;
83
- private isConditionGroup;
84
- private normalizeNumberArray;
85
- private normalizeComparableArray;
86
- private buildProductKey;
87
- private toNumber;
88
- }
89
- export default DataVariantEvaluator;