@pisell/pisellos 2.1.151 → 2.1.153

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 (200) hide show
  1. package/dist/apis/picoding.d.ts +0 -0
  2. package/dist/apis/picoding.js +1 -0
  3. package/dist/index.d.ts +0 -1
  4. package/dist/index.js +0 -1
  5. package/dist/model/strategy/adapter/promotion/evaluator.js +26 -99
  6. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
  7. package/dist/model/strategy/adapter/walletPass/evaluator.js +8 -61
  8. package/dist/model/strategy/adapter/walletPass/locales.js +3 -12
  9. package/dist/model/strategy/engine.d.ts +5 -18
  10. package/dist/model/strategy/engine.js +45 -145
  11. package/dist/model/strategy/type.d.ts +0 -17
  12. package/dist/model/strategy/type.js +0 -4
  13. package/dist/modules/Cart/types.d.ts +0 -2
  14. package/dist/modules/Cart/utils/cartProduct.js +25 -56
  15. package/dist/modules/Discount/index.d.ts +9 -3
  16. package/dist/modules/Discount/index.js +103 -11
  17. package/dist/modules/Discount/types.d.ts +8 -19
  18. package/dist/modules/OpenData/index.d.ts +24 -0
  19. package/dist/modules/OpenData/index.js +173 -0
  20. package/dist/modules/OpenData/types.d.ts +73 -0
  21. package/dist/modules/OpenData/types.js +1 -0
  22. package/dist/modules/OpenData/utils.d.ts +2 -0
  23. package/dist/modules/OpenData/utils.js +75 -0
  24. package/dist/modules/Order/index.d.ts +66 -1
  25. package/dist/modules/Order/index.js +906 -30
  26. package/dist/modules/Order/types.d.ts +174 -12
  27. package/dist/modules/Order/types.js +2 -0
  28. package/dist/modules/Order/utils.d.ts +118 -0
  29. package/dist/modules/Order/utils.js +586 -2
  30. package/dist/modules/Payment/index.d.ts +1 -2
  31. package/dist/modules/Payment/index.js +7 -10
  32. package/dist/modules/Payment/utils.js +0 -3
  33. package/dist/modules/Payment/walletpass.d.ts +0 -23
  34. package/dist/modules/Payment/walletpass.js +95 -191
  35. package/dist/modules/Product/utils.js +2 -2
  36. package/dist/modules/ProductList/index.d.ts +1 -1
  37. package/dist/modules/ProductList/index.js +4 -3
  38. package/dist/modules/Quotation/index.d.ts +48 -0
  39. package/dist/modules/Quotation/index.js +248 -0
  40. package/dist/modules/Quotation/types.d.ts +42 -0
  41. package/dist/modules/Quotation/types.js +1 -0
  42. package/dist/modules/Rules/index.d.ts +5 -9
  43. package/dist/modules/Rules/index.js +168 -677
  44. package/dist/modules/Rules/types.d.ts +0 -2
  45. package/dist/modules/SalesSummary/index.d.ts +63 -0
  46. package/dist/modules/SalesSummary/index.js +174 -0
  47. package/dist/modules/SalesSummary/types.d.ts +60 -0
  48. package/dist/modules/SalesSummary/types.js +1 -0
  49. package/dist/modules/SalesSummary/utils.d.ts +30 -0
  50. package/dist/modules/SalesSummary/utils.js +480 -0
  51. package/dist/modules/ScanOrderLogger/index.d.ts +23 -0
  52. package/dist/modules/ScanOrderLogger/index.js +174 -0
  53. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  54. package/dist/modules/ScanOrderLogger/providers/feishu.js +221 -0
  55. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  56. package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
  57. package/dist/modules/ScanOrderLogger/types.d.ts +53 -0
  58. package/dist/modules/ScanOrderLogger/types.js +1 -0
  59. package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
  60. package/dist/modules/Schedule/utils.d.ts +1 -1
  61. package/dist/modules/Summary/types.d.ts +0 -2
  62. package/dist/modules/Summary/utils.d.ts +3 -9
  63. package/dist/modules/Summary/utils.js +41 -52
  64. package/dist/modules/index.d.ts +4 -0
  65. package/dist/modules/index.js +5 -1
  66. package/dist/plugins/window.d.ts +0 -2
  67. package/dist/solution/BookingByStep/index.d.ts +2 -3
  68. package/dist/solution/BookingByStep/index.js +46 -43
  69. package/dist/solution/BookingByStep/types.d.ts +3 -1
  70. package/dist/solution/BookingByStep/types.js +5 -1
  71. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  72. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  73. package/dist/solution/Checkout/index.js +0 -2
  74. package/dist/solution/ScanOrder/index.d.ts +153 -0
  75. package/dist/solution/ScanOrder/index.js +3261 -0
  76. package/dist/solution/ScanOrder/types.d.ts +287 -0
  77. package/dist/solution/ScanOrder/types.js +35 -0
  78. package/dist/solution/ScanOrder/utils.d.ts +167 -0
  79. package/dist/solution/ScanOrder/utils.js +764 -0
  80. package/dist/solution/ShopDiscount/index.d.ts +3 -2
  81. package/dist/solution/ShopDiscount/index.js +60 -59
  82. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  83. package/dist/solution/ShopDiscount/types.js +1 -2
  84. package/dist/solution/ShopDiscount/utils.js +12 -26
  85. package/dist/solution/VenueBooking/index.d.ts +200 -0
  86. package/dist/solution/VenueBooking/index.js +3459 -0
  87. package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  88. package/dist/solution/VenueBooking/types.d.ts +154 -0
  89. package/dist/solution/VenueBooking/types.js +21 -0
  90. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
  91. package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
  92. package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
  93. package/dist/solution/VenueBooking/utils/resource.js +131 -0
  94. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
  95. package/dist/solution/VenueBooking/utils/slotMerge.js +239 -0
  96. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  97. package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
  98. package/dist/solution/VenueBooking/utils.d.ts +1 -0
  99. package/dist/solution/VenueBooking/utils.js +1 -0
  100. package/dist/solution/index.d.ts +2 -0
  101. package/dist/solution/index.js +3 -1
  102. package/lib/apis/picoding.d.ts +0 -0
  103. package/lib/apis/picoding.js +0 -0
  104. package/lib/index.d.ts +0 -1
  105. package/lib/index.js +1 -3
  106. package/lib/model/strategy/adapter/promotion/evaluator.js +8 -57
  107. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
  108. package/lib/model/strategy/adapter/walletPass/evaluator.js +3 -34
  109. package/lib/model/strategy/adapter/walletPass/locales.js +3 -12
  110. package/lib/model/strategy/engine.d.ts +5 -18
  111. package/lib/model/strategy/engine.js +21 -85
  112. package/lib/model/strategy/type.d.ts +0 -17
  113. package/lib/modules/Cart/types.d.ts +0 -2
  114. package/lib/modules/Cart/utils/cartProduct.js +12 -39
  115. package/lib/modules/Discount/index.d.ts +9 -3
  116. package/lib/modules/Discount/index.js +65 -4
  117. package/lib/modules/Discount/types.d.ts +8 -19
  118. package/lib/modules/OpenData/index.d.ts +24 -0
  119. package/lib/modules/OpenData/index.js +119 -0
  120. package/lib/modules/OpenData/types.d.ts +73 -0
  121. package/lib/modules/OpenData/types.js +17 -0
  122. package/lib/modules/OpenData/utils.d.ts +2 -0
  123. package/lib/modules/OpenData/utils.js +111 -0
  124. package/lib/modules/Order/index.d.ts +66 -1
  125. package/lib/modules/Order/index.js +515 -1
  126. package/lib/modules/Order/types.d.ts +174 -12
  127. package/lib/modules/Order/utils.d.ts +118 -0
  128. package/lib/modules/Order/utils.js +483 -2
  129. package/lib/modules/Payment/index.d.ts +1 -2
  130. package/lib/modules/Payment/index.js +0 -1
  131. package/lib/modules/Payment/utils.js +0 -3
  132. package/lib/modules/Payment/walletpass.d.ts +0 -23
  133. package/lib/modules/Payment/walletpass.js +17 -94
  134. package/lib/modules/Product/utils.js +2 -2
  135. package/lib/modules/ProductList/index.d.ts +1 -1
  136. package/lib/modules/ProductList/index.js +5 -3
  137. package/lib/modules/Quotation/index.d.ts +48 -0
  138. package/lib/modules/Quotation/index.js +152 -0
  139. package/lib/modules/Quotation/types.d.ts +42 -0
  140. package/lib/modules/Quotation/types.js +17 -0
  141. package/lib/modules/Rules/index.d.ts +5 -9
  142. package/lib/modules/Rules/index.js +288 -780
  143. package/lib/modules/Rules/types.d.ts +0 -2
  144. package/lib/modules/SalesSummary/index.d.ts +63 -0
  145. package/lib/modules/SalesSummary/index.js +105 -0
  146. package/lib/modules/SalesSummary/types.d.ts +60 -0
  147. package/lib/modules/SalesSummary/types.js +17 -0
  148. package/lib/modules/SalesSummary/utils.d.ts +30 -0
  149. package/lib/modules/SalesSummary/utils.js +420 -0
  150. package/lib/modules/ScanOrderLogger/index.d.ts +23 -0
  151. package/lib/modules/ScanOrderLogger/index.js +147 -0
  152. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  153. package/lib/modules/ScanOrderLogger/providers/feishu.js +157 -0
  154. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  155. package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
  156. package/lib/modules/ScanOrderLogger/types.d.ts +53 -0
  157. package/lib/modules/ScanOrderLogger/types.js +17 -0
  158. package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
  159. package/lib/modules/Schedule/utils.d.ts +1 -1
  160. package/lib/modules/Summary/types.d.ts +0 -2
  161. package/lib/modules/Summary/utils.d.ts +3 -9
  162. package/lib/modules/Summary/utils.js +22 -31
  163. package/lib/modules/index.d.ts +4 -0
  164. package/lib/modules/index.js +9 -1
  165. package/lib/plugins/window.d.ts +0 -2
  166. package/lib/solution/BookingByStep/index.d.ts +2 -3
  167. package/lib/solution/BookingByStep/index.js +6 -4
  168. package/lib/solution/BookingByStep/types.d.ts +3 -1
  169. package/lib/solution/BookingByStep/types.js +10 -0
  170. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  171. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  172. package/lib/solution/Checkout/index.js +0 -2
  173. package/lib/solution/ScanOrder/index.d.ts +153 -0
  174. package/lib/solution/ScanOrder/index.js +1959 -0
  175. package/lib/solution/ScanOrder/types.d.ts +287 -0
  176. package/lib/solution/ScanOrder/types.js +36 -0
  177. package/lib/solution/ScanOrder/utils.d.ts +167 -0
  178. package/lib/solution/ScanOrder/utils.js +635 -0
  179. package/lib/solution/ShopDiscount/index.d.ts +3 -2
  180. package/lib/solution/ShopDiscount/index.js +19 -25
  181. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  182. package/lib/solution/ShopDiscount/utils.js +6 -10
  183. package/lib/solution/VenueBooking/index.d.ts +200 -0
  184. package/lib/solution/VenueBooking/index.js +1926 -0
  185. package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  186. package/lib/solution/VenueBooking/types.d.ts +154 -0
  187. package/lib/solution/VenueBooking/types.js +44 -0
  188. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
  189. package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
  190. package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
  191. package/lib/solution/VenueBooking/utils/resource.js +92 -0
  192. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
  193. package/lib/solution/VenueBooking/utils/slotMerge.js +237 -0
  194. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  195. package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
  196. package/lib/solution/VenueBooking/utils.d.ts +1 -0
  197. package/lib/solution/VenueBooking/utils.js +69 -0
  198. package/lib/solution/index.d.ts +2 -0
  199. package/lib/solution/index.js +5 -1
  200. package/package.json +1 -1
@@ -22,7 +22,6 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
22
22
  getCurrentBookingTime(): string | null;
23
23
  private filterDiscountListByBookingTime;
24
24
  setCustomer(customer: Customer): Promise<void>;
25
- setOriginTotalAmount(amount: number): void;
26
25
  setHolders(holders: {
27
26
  form_record_id: number;
28
27
  }[]): void;
@@ -30,6 +29,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
30
29
  type?: 'form' | 'customer';
31
30
  [key: string]: any;
32
31
  }): void;
32
+ setOrderId(id?: number): void;
33
33
  calcDiscount(productList: Record<string, any>[], options?: SetDiscountSelectedParams): {
34
34
  productList: Record<string, any>[];
35
35
  discountList: Discount[];
@@ -46,6 +46,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
46
46
  discountList: Discount[];
47
47
  type: "server" | "clientCalc";
48
48
  unavailableReason?: UnavailableReason;
49
+ unavailableReasonKey?: string | null;
49
50
  }>;
50
51
  calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
51
52
  private getCustomer;
@@ -57,7 +58,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
57
58
  private bestDiscount;
58
59
  loadPrepareConfig(params: {
59
60
  customerId: number;
60
- action?: 'create' | 'update';
61
+ action?: 'create' | 'edit';
61
62
  with_good_pass?: 0 | 1;
62
63
  with_discount_card?: 0 | 1;
63
64
  }): Promise<void>;
@@ -57,7 +57,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
57
57
  currentBookingTime: "",
58
58
  filteredDiscountList: [],
59
59
  bookingSubject: undefined,
60
- orderTotalAmount: 0
60
+ orderId: undefined
61
61
  };
62
62
  return _this;
63
63
  }
@@ -289,14 +289,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
289
289
  return _setCustomer.apply(this, arguments);
290
290
  }
291
291
  return setCustomer;
292
- }()
293
- }, {
294
- key: "setOriginTotalAmount",
295
- value: function setOriginTotalAmount(amount) {
296
- this.store.orderTotalAmount = amount;
297
- }
298
-
299
- // 设置holders
292
+ }() // 设置holders
300
293
  }, {
301
294
  key: "setHolders",
302
295
  value: function setHolders(holders) {
@@ -307,6 +300,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
307
300
  value: function setBookingSubject(bookingSubject) {
308
301
  this.store.bookingSubject = bookingSubject;
309
302
  }
303
+ }, {
304
+ key: "setOrderId",
305
+ value: function setOrderId(id) {
306
+ this.store.orderId = id;
307
+ }
310
308
 
311
309
  // 计算优惠券
312
310
  }, {
@@ -324,7 +322,6 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
324
322
  var _ref = rulesModule.calcDiscount({
325
323
  productList: productList,
326
324
  discountList: this.getDiscountList(),
327
- orderTotalAmount: this.store.orderTotalAmount || 0,
328
325
  holders: this.store.holders || [],
329
326
  isFormSubject: ((_this$store$bookingSu = this.store.bookingSubject) === null || _this$store$bookingSu === void 0 ? void 0 : _this$store$bookingSu.type) === 'form'
330
327
  }, options) || {
@@ -437,25 +434,32 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
437
434
  key: "scanCode",
438
435
  value: function () {
439
436
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
440
- var _this$store$discount4, _this$store$bookingSu2, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, unavailableReason, _this$options$otherPa6;
437
+ var _this$store$discount4, _this$store$bookingSu2, resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, unavailableReason, _this$options$otherPa6;
441
438
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
442
439
  while (1) switch (_context6.prev = _context6.next) {
443
440
  case 0:
444
441
  _context6.prev = 0;
445
442
  _context6.next = 3;
446
- return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.batchSearch(code, customerId);
443
+ return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.batchSearch(code, {
444
+ customerId: customerId,
445
+ orderId: this.store.orderId
446
+ });
447
447
  case 3:
448
448
  _context6.t0 = _context6.sent;
449
449
  if (_context6.t0) {
450
450
  _context6.next = 6;
451
451
  break;
452
452
  }
453
- _context6.t0 = [];
453
+ _context6.t0 = {
454
+ discountList: [],
455
+ unavailableReasonKey: null
456
+ };
454
457
  case 6:
455
- resultDiscountList = _context6.t0;
458
+ resultDiscountWithReason = _context6.t0;
459
+ resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
456
460
  rulesModule = this.store.rules;
457
461
  if (rulesModule) {
458
- _context6.next = 10;
462
+ _context6.next = 11;
459
463
  break;
460
464
  }
461
465
  return _context6.abrupt("return", {
@@ -465,18 +469,19 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
465
469
  discountList: this.getDiscountList(),
466
470
  unavailableReason: UnavailableReason.Unknown
467
471
  });
468
- case 10:
472
+ case 11:
469
473
  if (resultDiscountList.length) {
470
- _context6.next = 12;
474
+ _context6.next = 13;
471
475
  break;
472
476
  }
473
477
  return _context6.abrupt("return", {
474
478
  type: "server",
475
479
  isAvailable: false,
476
480
  productList: this.store.productList || [],
477
- discountList: this.getDiscountList()
481
+ discountList: this.getDiscountList(),
482
+ unavailableReasonKey: unavailableReasonKey
478
483
  });
479
- case 12:
484
+ case 13:
480
485
  withScanList = resultDiscountList.map(function (item) {
481
486
  return _objectSpread(_objectSpread({}, item), {}, {
482
487
  isScan: true
@@ -490,7 +495,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
490
495
  return m.id === n.id;
491
496
  });
492
497
  }))) {
493
- _context6.next = 16;
498
+ _context6.next = 17;
494
499
  break;
495
500
  }
496
501
  return _context6.abrupt("return", {
@@ -499,12 +504,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
499
504
  productList: this.store.productList || [],
500
505
  discountList: this.getDiscountList()
501
506
  });
502
- case 16:
507
+ case 17:
503
508
  _ref2 = rulesModule.isDiscountListAvailable({
504
509
  productList: this.store.productList || [],
505
510
  oldDiscountList: this.getDiscountList(),
506
511
  newDiscountList: withScanList,
507
- orderTotalAmount: this.store.orderTotalAmount || 0,
508
512
  holders: this.store.holders || [],
509
513
  isFormSubject: ((_this$store$bookingSu2 = this.store.bookingSubject) === null || _this$store$bookingSu2 === void 0 ? void 0 : _this$store$bookingSu2.type) === 'form'
510
514
  }) || {
@@ -513,19 +517,19 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
513
517
  discountList: this.getDiscountList()
514
518
  }, newProductList = _ref2.productList, newDiscountList = _ref2.discountList, isAvailable = _ref2.isAvailable, unavailableReason = _ref2.unavailableReason;
515
519
  if (!isAvailable) {
516
- _context6.next = 24;
520
+ _context6.next = 25;
517
521
  break;
518
522
  }
519
523
  this.setDiscountList(newDiscountList || []);
520
524
  this.store.originalDiscountList = newDiscountList || [];
521
525
  this.setProductList(newProductList || []);
522
526
  if (!(this.isWalkIn() && resultDiscountList.length && ((_this$options$otherPa6 = this.options.otherParams) === null || _this$options$otherPa6 === void 0 ? void 0 : _this$options$otherPa6.platform) === 'shop')) {
523
- _context6.next = 24;
527
+ _context6.next = 25;
524
528
  break;
525
529
  }
526
- _context6.next = 24;
530
+ _context6.next = 25;
527
531
  return this.getCustomerWallet(resultDiscountList[0].customer_id);
528
- case 24:
532
+ case 25:
529
533
  return _context6.abrupt("return", {
530
534
  type: "clientCalc",
531
535
  isAvailable: isAvailable || false,
@@ -533,8 +537,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
533
537
  discountList: newDiscountList || this.getDiscountList(),
534
538
  unavailableReason: unavailableReason
535
539
  });
536
- case 27:
537
- _context6.prev = 27;
540
+ case 28:
541
+ _context6.prev = 28;
538
542
  _context6.t1 = _context6["catch"](0);
539
543
  console.error('[ShopDiscount] 扫码出错:', _context6.t1);
540
544
  return _context6.abrupt("return", {
@@ -544,11 +548,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
544
548
  discountList: this.getDiscountList(),
545
549
  unavailableReason: UnavailableReason.Unknown
546
550
  });
547
- case 31:
551
+ case 32:
548
552
  case "end":
549
553
  return _context6.stop();
550
554
  }
551
- }, _callee6, this, [[0, 27]]);
555
+ }, _callee6, this, [[0, 28]]);
552
556
  }));
553
557
  function scanCode(_x5, _x6) {
554
558
  return _scanCode.apply(this, arguments);
@@ -618,27 +622,21 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
618
622
  return n.id === (((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id);
619
623
  });
620
624
  if (index !== -1) {
621
- var _editModeDiscountList, _discount$metadata, _discount$metadata2;
625
+ var _discount$metadata;
622
626
  editModeDiscountList[index] = _objectSpread(_objectSpread({}, editModeDiscountList[index]), {}, {
623
- metadata: _objectSpread(_objectSpread({}, discount.metadata || {}), {}, {
624
- num: ((editModeDiscountList === null || editModeDiscountList === void 0 || (_editModeDiscountList = editModeDiscountList[index]) === null || _editModeDiscountList === void 0 || (_editModeDiscountList = _editModeDiscountList.metadata) === null || _editModeDiscountList === void 0 ? void 0 : _editModeDiscountList.num) || 1) + (((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.num) || 1)
625
- }),
626
627
  amount: new Decimal(discount.amount || 0).plus(new Decimal(editModeDiscountList[index].amount || 0)).toNumber(),
627
- savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.product_discount_difference) || 0).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
628
+ savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
628
629
  });
629
630
  } else {
630
- var _discount$metadata3, _discount$metadata4, _discount$discount2, _discount$discount3, _discount$discount4;
631
+ var _discount$metadata2, _discount$discount2, _discount$discount3, _discount$discount4;
631
632
  if (discount.type && !discount.tag) {
632
633
  discount.tag = discount.type;
633
634
  }
634
635
  editModeDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
635
- metadata: _objectSpread(_objectSpread({}, discount.metadata || {}), {}, {
636
- num: ((_discount$metadata3 = discount.metadata) === null || _discount$metadata3 === void 0 ? void 0 : _discount$metadata3.num) || 1
637
- }),
638
636
  name: discount.name || discount.discount.title.auto,
639
637
  isEditMode: true,
640
638
  limited_relation_product_data: {},
641
- savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata4 = discount.metadata) === null || _discount$metadata4 === void 0 ? void 0 : _discount$metadata4.product_discount_difference) || 0).toNumber(),
639
+ savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.product_discount_difference) || 0).toNumber(),
642
640
  isAvailable: true,
643
641
  id: ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) || discount.id,
644
642
  format_title: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.title) || discount.format_title,
@@ -785,24 +783,27 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
785
783
  key: "loadPrepareConfig",
786
784
  value: function () {
787
785
  var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
788
- var _this$getCustomer2, _this$store$discount8, _this$getDiscountList, _this$store$discount9, _this$store$productLi2, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
786
+ var _this$getCustomer2, _this$store$discount8, _this$getDiscountList, _this$store$discount9, _this$store$productLi2, orderId, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
789
787
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
790
788
  while (1) switch (_context10.prev = _context10.next) {
791
789
  case 0:
792
790
  _context10.prev = 0;
791
+ orderId = this.store.orderId;
793
792
  customerId = params.customerId || ((_this$getCustomer2 = this.getCustomer()) === null || _this$getCustomer2 === void 0 ? void 0 : _this$getCustomer2.id); // if (customerId === 1 || !customerId) {
794
793
  // return
795
794
  // }
796
- _context10.next = 4;
797
- return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.loadPrepareConfig({
795
+ _context10.next = 5;
796
+ return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.loadPrepareConfig(_objectSpread({
798
797
  customer_id: customerId,
799
- action: 'create',
798
+ action: orderId ? 'edit' : 'create',
800
799
  with_good_pass: 1,
801
800
  with_discount_card: 1,
802
801
  with_wallet_pass_holder: 1,
803
802
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
804
- });
805
- case 4:
803
+ }, orderId ? {
804
+ order_id: orderId
805
+ } : {}));
806
+ case 5:
806
807
  goodPassList = _context10.sent;
807
808
  scanDiscount = (_this$getDiscountList = this.getDiscountList()) === null || _this$getDiscountList === void 0 ? void 0 : _this$getDiscountList.filter(function (item) {
808
809
  return item.isScan;
@@ -815,35 +816,35 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
815
816
  });
816
817
  newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
817
818
  this.store.originalDiscountList = newDiscountList;
818
- _context10.next = 12;
819
+ _context10.next = 13;
819
820
  return (_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.setOriginalDiscountList(newDiscountList);
820
- case 12:
821
+ case 13:
821
822
  // 根据当前预约时间过滤优惠券列表
822
823
  filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
823
824
  this.store.filteredDiscountList = filteredDiscountList;
824
825
  this.setDiscountList(filteredDiscountList || []);
825
826
  if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
826
- _context10.next = 19;
827
+ _context10.next = 20;
827
828
  break;
828
829
  }
829
830
  _result3 = this.calcDiscount(this.store.productList);
830
- _context10.next = 19;
831
+ _context10.next = 20;
831
832
  return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
832
- case 19:
833
- _context10.next = 21;
834
- return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), newDiscountList);
835
- case 21:
836
- _context10.next = 26;
833
+ case 20:
834
+ _context10.next = 22;
835
+ return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
836
+ case 22:
837
+ _context10.next = 27;
837
838
  break;
838
- case 23:
839
- _context10.prev = 23;
839
+ case 24:
840
+ _context10.prev = 24;
840
841
  _context10.t0 = _context10["catch"](0);
841
842
  console.error('[ShopDiscount] 加载准备配置出错:', _context10.t0);
842
- case 26:
843
+ case 27:
843
844
  case "end":
844
845
  return _context10.stop();
845
846
  }
846
- }, _callee10, this, [[0, 23]]);
847
+ }, _callee10, this, [[0, 24]]);
847
848
  }));
848
849
  function loadPrepareConfig(_x10) {
849
850
  return _loadPrepareConfig.apply(this, arguments);
@@ -23,7 +23,6 @@ export interface ShopDiscountState {
23
23
  discount: DiscountModule | null;
24
24
  rules: RulesModule | null;
25
25
  productList: Record<string, any>[];
26
- orderTotalAmount?: number;
27
26
  holders?: {
28
27
  form_record_id: number;
29
28
  form_id?: number;
@@ -36,6 +35,7 @@ export interface ShopDiscountState {
36
35
  type?: 'form' | 'customer';
37
36
  [key: string]: any;
38
37
  };
38
+ orderId?: number;
39
39
  }
40
40
  export interface SetDiscountSelectedParams {
41
41
  discountId: number;
@@ -8,5 +8,4 @@ export var ShopDiscountHooks = /*#__PURE__*/function (ShopDiscountHooks) {
8
8
  ShopDiscountHooks["onRulesListChange"] = "shopDiscount:onRulesListChange";
9
9
  ShopDiscountHooks["onLoadPrepareCalcResult"] = "shopDiscount:onLoadPrepareCalcResult";
10
10
  return ShopDiscountHooks;
11
- }({});
12
- ;
11
+ }({});
@@ -40,37 +40,23 @@ export var isAllNormalProduct = function isAllNormalProduct(items) {
40
40
  * @returns
41
41
  */
42
42
  export var getDiscountAmount = function getDiscountAmount(discount, total, price) {
43
- var discountedPrice = 0;
44
-
43
+ var _discount$metadata;
45
44
  // 商品券
46
45
  if (discount.tag === 'good_pass') {
47
- discountedPrice = new Decimal(price).minus(new Decimal(price || 0)).toNumber();
48
- } else {
49
- var _discount$metadata;
50
- // 判断是否是固定金额
51
- var isFixedAmount = (discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.discount_card_type) === 'fixed_amount';
52
-
53
- // 固定金额 小于0时返回0
54
- if (isFixedAmount) {
55
- discountedPrice = Math.max(new Decimal(price).minus(new Decimal(discount.par_value || 0)).toNumber(), 0);
56
- } else {
57
- // 百分比:根据折扣卡金额计算
58
- discountedPrice = new Decimal(100).minus(discount.par_value || 0).div(100).mul(new Decimal(price)).toNumber();
59
- }
46
+ return new Decimal(price).minus(new Decimal(price || 0)).toNumber();
60
47
  }
61
48
 
62
- /*
63
- // 🔥 如果有 maxDeductionAmount 限制,确保折扣金额不超过限制
64
- if (discount.config?.maxDeductionAmount) {
65
- const actualDiscountAmount = new Decimal(price).minus(discountedPrice).toNumber();
66
- if (actualDiscountAmount > discount.config.maxDeductionAmount) {
67
- // 折扣金额超过限制,重新计算折扣后价格
68
- discountedPrice = new Decimal(price).minus(discount.config.maxDeductionAmount).toNumber();
69
- }
70
- }
71
- */
49
+ // 判断是否是固定金额
50
+ var isFixedAmount = (discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.discount_card_type) === 'fixed_amount';
51
+
52
+ // 固定金额 小于0时返回0
53
+ if (isFixedAmount) {
54
+ var _discount$amount;
55
+ return Math.max(new Decimal(price).minus(new Decimal(((_discount$amount = discount.amount) !== null && _discount$amount !== void 0 ? _discount$amount : discount.par_value) || 0)).toNumber(), 0);
56
+ }
72
57
 
73
- return discountedPrice;
58
+ // 百分比:根据折扣卡金额计算
59
+ return new Decimal(100).minus(discount.par_value || 0).div(100).mul(new Decimal(price)).toNumber();
74
60
  };
75
61
  export var getDiscountListAmountTotal = function getDiscountListAmountTotal(discount) {
76
62
  return discount.reduce(function (acc, cur) {
@@ -0,0 +1,200 @@
1
+ import { Module, ModuleOptions, PisellCore } from '../../types';
2
+ import { BaseModule } from '../../modules/BaseModule';
3
+ import { VenueBookingAddLogParams, VenueBookingSlotConfig, VenueDateSummaryItem, VenueSlotSelection, VenueTimeSlotGrid } from './types';
4
+ import type { ScanOrderOrderProduct, ScanOrderOrderProductIdentity } from '../ScanOrder/types';
5
+ import type { UpdateProductInOrderParams } from '../../modules/Order/types';
6
+ import type { OpenDataAvailabilityResult } from '../../modules/OpenData';
7
+ import type { ProductData } from '../../modules/Product/types';
8
+ import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
9
+ import type { StrategyConfig } from '../../model/strategy/type';
10
+ export * from './types';
11
+ interface VenueBookingItemRuleRuntimeConfig {
12
+ strategyConfigs?: StrategyConfig[];
13
+ pax?: Partial<PaxInfo>;
14
+ historicalItems?: CartItemSummary[];
15
+ serviceType?: string;
16
+ submissionIndex?: number;
17
+ custom?: Record<string, any>;
18
+ }
19
+ export declare class VenueBookingImpl extends BaseModule implements Module {
20
+ protected defaultName: string;
21
+ protected defaultVersion: string;
22
+ isSolution: boolean;
23
+ private initializeOptions;
24
+ private store;
25
+ private otherParams;
26
+ private cacheId;
27
+ private window;
28
+ private request;
29
+ private baseSlotConfig;
30
+ private itemRuleEvaluator;
31
+ private itemRuleConfigs;
32
+ private itemRuleConfigsPromise;
33
+ private itemRulePrefillApplied;
34
+ private itemRuleRuntimeConfig;
35
+ private resourceProductMap;
36
+ private loginEffectDisposers;
37
+ private customerLoginRefreshInFlight;
38
+ private customerLoginRefreshIdInFlight;
39
+ private loadAllProductsInFlight;
40
+ private productsLoaded;
41
+ private loadOpenDataConfigInFlight;
42
+ private static readonly OPEN_DATA_CACHE_TTL;
43
+ private getLoggerContext;
44
+ private safeStringify;
45
+ private pickErrorMessage;
46
+ private serializeError;
47
+ private addVenueBookingLog;
48
+ private logMethodStart;
49
+ private logMethodSuccess;
50
+ private logMethodError;
51
+ addLog(params: VenueBookingAddLogParams): Promise<void>;
52
+ constructor(name?: string, version?: string);
53
+ private normalizeCustomerId;
54
+ private resolveCustomerIdFromLoginPayload;
55
+ private clearLoginEffectListeners;
56
+ private registerLoginEffect;
57
+ private registerCustomerLoginListeners;
58
+ private refreshOrderMarketingAfterLogin;
59
+ initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
60
+ destroy(): Promise<void>;
61
+ retryInit(): Promise<void>;
62
+ refresh(): Promise<void>;
63
+ getStatus(): import("./types").VenueBookingStatus;
64
+ getEntryContext(): import("./types").VenueBookingEntryContext | null;
65
+ getItemRuleQuantityLimits(): QuantityLimitResult[];
66
+ getCartValidationPassed(): boolean | null;
67
+ getCartValidation(): {
68
+ passed: boolean | null;
69
+ failures: QuantityCheckResult[];
70
+ };
71
+ loadAllProducts(): Promise<{
72
+ venueProducts: ProductData[];
73
+ addonProducts: ProductData[];
74
+ }>;
75
+ private _doLoadAllProducts;
76
+ loadVenueProducts(): Promise<ProductData[]>;
77
+ loadAddonProducts(): Promise<ProductData[]>;
78
+ getVenueProducts(): ProductData[];
79
+ getAddonProductsList(): ProductData[];
80
+ loadQuotations(params?: {
81
+ channel?: string;
82
+ }): Promise<void>;
83
+ fetchResourceAvailability(params: {
84
+ startDate: string;
85
+ endDate: string;
86
+ }): Promise<void>;
87
+ private getOperatingHoursScheduleIds;
88
+ private resolveSlotConfigForDate;
89
+ private syncOperatingHoursToSlotConfig;
90
+ getDateRangeSummary(params: {
91
+ startDate: string;
92
+ endDate: string;
93
+ }): VenueDateSummaryItem[];
94
+ getTimeSlotGrid(date: string): VenueTimeSlotGrid;
95
+ /**
96
+ * 切换单个时段的选中状态(选中/取消)。
97
+ * 内部自动处理连续时段的合并与拆分,订单是唯一真相源。
98
+ *
99
+ * slot.productId 指定当前操作针对的是该 resourceId 下的哪一个商品。
100
+ * 同一资源下不同 productId 之间互相隔离,不会相互合并。
101
+ */
102
+ toggleSlot(slot: VenueSlotSelection): Promise<ScanOrderOrderProduct[]>;
103
+ /**
104
+ * 获取某资源当前选中的所有独立时段(从订单中解析)。
105
+ * 不传 productId 时返回该资源下所有商品的选中时段;传了则精确匹配。
106
+ */
107
+ getSelectedSlotsForResource(resourceId: number | string, productId?: number): VenueSlotSelection[];
108
+ /** getSelectedSlotsForResource 的 (resourceId, productId) 精确版,内部使用。 */
109
+ private getSelectedSlotsForResourceProduct;
110
+ /**
111
+ * 判断某个时段是否已选中。
112
+ * 不传 productId 时:只要该资源下任一商品在 startTime 被选中即返回 true;传了则精确匹配。
113
+ */
114
+ isSlotSelected(resourceId: number | string, startTime: string, productId?: number): boolean;
115
+ /**
116
+ * 判断指定 (resourceId, productId, startTime) 格子是否应因其它已选项而被禁用。
117
+ * 规则:
118
+ * 1) 同一 resourceId 下若已选了另一个 productId 的同 startTime → 禁用
119
+ * 2) 当前 resource 是组合资源:若其任一 child resource 在 startTime 被选中 → 禁用
120
+ * 3) 当前 resource 是某些组合资源的 child:若该组合资源在 startTime 被选中 → 禁用
121
+ * 4) 两个组合资源的 child 集合有交集,且对方在该 startTime 被选中 → 禁用
122
+ */
123
+ isSlotDisabledBySelection(params: {
124
+ resourceId: number | string;
125
+ productId: number;
126
+ startTime: string;
127
+ }): boolean;
128
+ /**
129
+ * 获取所有已选时段(按资源分组)。每个 slot 上带 productId,便于 UI 做 per-product 判定。
130
+ */
131
+ getAllSelectedSlots(): Map<number | string, VenueSlotSelection[]>;
132
+ /**
133
+ * 对指定 (resourceId, productId) 的订单商品进行 reconcile:
134
+ * 清除旧商品 → 合并连续时段 → 重新写入。
135
+ * 同一场地下不同商品互不干扰,各自单独 reconcile。
136
+ */
137
+ private reconcileOrderForResourceProduct;
138
+ /** 给定一个父 rawResource,返回其 combined_resource.resource_ids 对应的子 rawResource 列表。 */
139
+ private getCombinedChildRawResources;
140
+ setSlotConfig(config: Partial<VenueBookingSlotConfig>): void;
141
+ getSlotConfig(): VenueBookingSlotConfig;
142
+ loadSchedules(): Promise<void>;
143
+ private injectScheduleResolverToQuotation;
144
+ getScheduleListByIds(ids: number[]): import("../../modules/Schedule/types").ScheduleItem[];
145
+ getTempOrder(): import("./types").ScanOrderTempOrder | null;
146
+ updateTempOrderNote(note: string): string;
147
+ updateTempOrderContactsInfo(contactsInfo: any[]): any[];
148
+ private ensureTempOrder;
149
+ onCustomerLogin(params: {
150
+ customerId: number;
151
+ }): Promise<void>;
152
+ private recalculateOrderPricesFromQuotation;
153
+ scanCode(code: string, customerId?: number): Promise<{
154
+ isAvailable: boolean;
155
+ discountList: import("../../modules/Discount").Discount[];
156
+ type: "server" | "clientCalc";
157
+ unavailableReason?: import("../../modules/Rules/types").UnavailableReason | undefined;
158
+ unavailableReasonKey?: string | null | undefined;
159
+ }>;
160
+ /** 获取当前折扣列表(包装 order.getDiscountList) */
161
+ getDiscountList(): import("../../modules/Discount").Discount[];
162
+ /** 勾选/取消勾选某张折扣券,重新计算折扣并持久化 */
163
+ setDiscountSelected(params: {
164
+ discountId: number;
165
+ isSelected: boolean;
166
+ }): Promise<import("../../modules/Discount").Discount[]>;
167
+ addNewOrder(): Promise<import("./types").ScanOrderTempOrder>;
168
+ getOrderProducts(): ScanOrderOrderProduct[];
169
+ getSummary(): Promise<import("./types").ScanOrderSummary>;
170
+ submitOrder<T = any>(): Promise<T>;
171
+ addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
172
+ updateProductInOrder(params: UpdateProductInOrderParams): Promise<ScanOrderOrderProduct[]>;
173
+ removeProductFromOrder(identity: ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
174
+ getProductList(): Promise<ProductData[]>;
175
+ private loadOpenDataConfig;
176
+ private loadRuntimeConfigs;
177
+ private fetchItemRuleConfigsByModelIds;
178
+ private buildPrefillProductSourceMap;
179
+ private getItemRuleRuntimeConfig;
180
+ private ensureItemRuleConfigsLoaded;
181
+ private refreshItemRuleQuantityLimits;
182
+ private applyPrefillByItemRule;
183
+ applyItemRulePrefill(): Promise<void>;
184
+ private evaluateCartValidationByItemRule;
185
+ private validateBeforeSubmitByItemRule;
186
+ private refreshCartValidationPassed;
187
+ setItemRuleRuntimeConfig(config?: VenueBookingItemRuleRuntimeConfig): Promise<void>;
188
+ getOtherParams(): Record<string, any>;
189
+ private static readonly UI_STATE_KEY_PREFIX;
190
+ private getUIStateBucketKey;
191
+ private readUIStateBucket;
192
+ private writeUIStateBucket;
193
+ setUIState(key: string, value: any): void;
194
+ getUIState<T = any>(key: string): T | undefined;
195
+ deleteUIState(key: string): void;
196
+ checkOpenDataAvailability(): Promise<OpenDataAvailabilityResult>;
197
+ setOtherParams(params: Record<string, any>, { cover }?: {
198
+ cover?: boolean;
199
+ }): Promise<void>;
200
+ }