@pisell/pisellos 2.3.67 → 2.3.68

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 (85) hide show
  1. package/dist/core/index.d.ts +0 -7
  2. package/dist/core/index.js +65 -109
  3. package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -1
  4. package/dist/model/strategy/adapter/walletPass/utils.js +0 -2
  5. package/dist/modules/BaseModule.d.ts +1 -0
  6. package/dist/modules/BaseModule.js +24 -28
  7. package/dist/modules/Customer/index.d.ts +4 -0
  8. package/dist/modules/Customer/index.js +91 -59
  9. package/dist/modules/Customer/types.d.ts +2 -0
  10. package/dist/modules/Order/index.d.ts +22 -2
  11. package/dist/modules/Order/index.js +313 -142
  12. package/dist/modules/Order/types.d.ts +13 -1
  13. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
  14. package/dist/modules/Order/utils/orderCollectionIdentity.js +75 -0
  15. package/dist/modules/Order/utils.js +0 -1
  16. package/dist/modules/Payment/index.d.ts +4 -0
  17. package/dist/modules/Payment/index.js +14 -4
  18. package/dist/modules/Payment/walletpass.js +52 -18
  19. package/dist/modules/Quotation/index.d.ts +0 -6
  20. package/dist/modules/Quotation/index.js +19 -75
  21. package/dist/modules/Rules/index.js +46 -31
  22. package/dist/plugins/request.d.ts +0 -1
  23. package/dist/server/index.d.ts +2 -8
  24. package/dist/server/index.js +143 -212
  25. package/dist/server/modules/floor-plan/index.d.ts +0 -4
  26. package/dist/server/modules/floor-plan/index.js +98 -240
  27. package/dist/server/modules/menu/index.js +23 -48
  28. package/dist/server/modules/order/index.d.ts +8 -17
  29. package/dist/server/modules/order/index.js +453 -506
  30. package/dist/server/modules/products/index.d.ts +2 -8
  31. package/dist/server/modules/products/index.js +75 -167
  32. package/dist/server/modules/resource/index.js +13 -21
  33. package/dist/server/utils/small-ticket.js +2 -1
  34. package/dist/solution/BaseSales/index.d.ts +3 -1
  35. package/dist/solution/BaseSales/index.js +99 -82
  36. package/dist/solution/BaseSales/utils.js +31 -20
  37. package/dist/solution/BookingTicket/index.d.ts +6 -2
  38. package/dist/solution/BookingTicket/index.js +123 -75
  39. package/dist/solution/ScanOrder/utils.js +31 -20
  40. package/dist/solution/UnifiedBookingSales/index.d.ts +25 -0
  41. package/dist/solution/UnifiedBookingSales/index.js +640 -321
  42. package/dist/solution/UnifiedBookingSales/types.d.ts +7 -0
  43. package/lib/core/index.d.ts +0 -7
  44. package/lib/core/index.js +2 -20
  45. package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -1
  46. package/lib/model/strategy/adapter/walletPass/utils.js +0 -1
  47. package/lib/modules/BaseModule.d.ts +1 -0
  48. package/lib/modules/BaseModule.js +24 -37
  49. package/lib/modules/Customer/index.d.ts +4 -0
  50. package/lib/modules/Customer/index.js +11 -0
  51. package/lib/modules/Customer/types.d.ts +2 -0
  52. package/lib/modules/Order/index.d.ts +22 -2
  53. package/lib/modules/Order/index.js +212 -54
  54. package/lib/modules/Order/types.d.ts +13 -1
  55. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
  56. package/lib/modules/Order/utils/orderCollectionIdentity.js +70 -0
  57. package/lib/modules/Order/utils.js +0 -1
  58. package/lib/modules/Payment/index.d.ts +4 -0
  59. package/lib/modules/Payment/index.js +7 -0
  60. package/lib/modules/Payment/walletpass.js +27 -2
  61. package/lib/modules/Quotation/index.d.ts +0 -6
  62. package/lib/modules/Quotation/index.js +5 -49
  63. package/lib/modules/Rules/index.js +17 -1
  64. package/lib/plugins/request.d.ts +0 -1
  65. package/lib/server/index.d.ts +2 -8
  66. package/lib/server/index.js +20 -58
  67. package/lib/server/modules/floor-plan/index.d.ts +0 -4
  68. package/lib/server/modules/floor-plan/index.js +6 -54
  69. package/lib/server/modules/menu/index.js +5 -31
  70. package/lib/server/modules/order/index.d.ts +8 -17
  71. package/lib/server/modules/order/index.js +106 -199
  72. package/lib/server/modules/products/index.d.ts +2 -8
  73. package/lib/server/modules/products/index.js +24 -97
  74. package/lib/server/modules/resource/index.js +2 -7
  75. package/lib/server/utils/small-ticket.js +1 -1
  76. package/lib/solution/BaseSales/index.d.ts +3 -1
  77. package/lib/solution/BaseSales/index.js +29 -16
  78. package/lib/solution/BaseSales/utils.js +29 -18
  79. package/lib/solution/BookingTicket/index.d.ts +6 -2
  80. package/lib/solution/BookingTicket/index.js +53 -14
  81. package/lib/solution/ScanOrder/utils.js +29 -18
  82. package/lib/solution/UnifiedBookingSales/index.d.ts +25 -0
  83. package/lib/solution/UnifiedBookingSales/index.js +188 -0
  84. package/lib/solution/UnifiedBookingSales/types.d.ts +7 -0
  85. package/package.json +1 -1
@@ -29,6 +29,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
29
29
  private addTimeProductsCatalog;
30
30
  private orderCustomerDiscountRefreshInFlight;
31
31
  private orderCustomerDiscountRefreshCustomerId;
32
+ private orderCustomerPromotionRefreshInFlight;
32
33
  private loadOpenDataConfigInFlight;
33
34
  /**
34
35
  * 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext。
@@ -63,6 +64,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
63
64
  scanPromotionCode(code: string, customerId?: number): Promise<BaseSalesScanCodeResult>;
64
65
  private hydrateOrderCustomerFromScanDiscounts;
65
66
  private getDiscountCustomerId;
67
+ resolveCustomerById(customerId: string | number): Promise<ICustomer | null>;
68
+ /** 兼容既有优惠码扫码逻辑。 */
66
69
  private resolveCustomerByDiscountCustomerId;
67
70
  private findCustomerById;
68
71
  private normalizeCustomer;
@@ -282,7 +285,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
282
285
  restoreOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
283
286
  /** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */
284
287
  private buildOrderCustomerPayload;
285
- private refreshDiscountConfigAfterOrderCustomerChange;
288
+ protected refreshDiscountConfigAfterOrderCustomerChange(customerId: number | null): Promise<void>;
289
+ protected waitForOrderCustomerPromotionRefresh(): Promise<void>;
286
290
  /**
287
291
  * 获取客户分页信息
288
292
  * @returns 分页信息
@@ -326,7 +330,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
326
330
  * 获取当前的客户搜索条件
327
331
  * @returns 当前搜索条件
328
332
  */
329
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
333
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
330
334
  /**
331
335
  * 获取客户列表状态(包含滚动加载相关状态)
332
336
  * @returns 客户状态
@@ -52,6 +52,7 @@ import { resolveBestAddTimePlan as _resolveBestAddTimePlan } from "./utils/resol
52
52
  import { createUuidV4 } from "../../modules/Order/utils";
53
53
  var OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow'];
54
54
  var OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
55
+ var USER_PLATFORM = ['pc', 'h5'];
55
56
 
56
57
  /**
57
58
  * 读取已有 booking 的协议唯一值,用于加时商品行绑定原预约。
@@ -178,6 +179,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
178
179
  _defineProperty(_assertThisInitialized(_this), "addTimeProductsCatalog", []);
179
180
  _defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshInFlight", null);
180
181
  _defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshCustomerId", null);
182
+ _defineProperty(_assertThisInitialized(_this), "orderCustomerPromotionRefreshInFlight", null);
181
183
  _defineProperty(_assertThisInitialized(_this), "loadOpenDataConfigInFlight", null);
182
184
  return _this;
183
185
  }
@@ -400,35 +402,35 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
400
402
  value: function () {
401
403
  var _configureIdGeneratorFromOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
402
404
  var _openDataConfig, _openDataConfig2, _openDataConfig3, _openDataConfig4, _openDataConfig5, _openDataConfig6;
403
- var openDataConfig, idGenerator, receiptSequenceLength, receiptSequenceStart, prefix, shopOrderPrefix, resetReceiptSequenceDaily, operatingDayBoundary, deviceId, businessCode;
405
+ var idGenerator, openDataConfig, receiptSequenceLength, receiptSequenceStart, prefix, shopOrderPrefix, resetReceiptSequenceDaily, operatingDayBoundary, deviceId, businessCode;
404
406
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
405
407
  while (1) switch (_context5.prev = _context5.next) {
406
408
  case 0:
407
409
  // 业务码切换或配置失败时不能复用上一次初始化的短号。
408
410
  this.setPaymentNumberDevicePrefix(null);
409
- openDataConfig = null;
410
- _context5.prev = 2;
411
- _context5.next = 5;
412
- return this.loadOpenDataConfig();
413
- case 5:
414
- openDataConfig = _context5.sent;
415
- _context5.next = 12;
416
- break;
417
- case 8:
418
- _context5.prev = 8;
419
- _context5.t0 = _context5["catch"](2);
420
- console.warn('[BookingTicket] OpenData 配置加载失败,跳过 idGenerator 配置', _context5.t0);
421
- return _context5.abrupt("return");
422
- case 12:
423
- // if (!openDataConfig) return;
424
411
  idGenerator = this.getIdGeneratorPlugin();
425
412
  if (idGenerator !== null && idGenerator !== void 0 && idGenerator.configure) {
426
- _context5.next = 16;
413
+ _context5.next = 5;
427
414
  break;
428
415
  }
429
416
  console.warn('[BookingTicket] idGenerator 插件不可用,跳过配置');
430
417
  return _context5.abrupt("return");
418
+ case 5:
419
+ openDataConfig = null;
420
+ _context5.prev = 6;
421
+ _context5.next = 9;
422
+ return this.loadOpenDataConfig();
423
+ case 9:
424
+ openDataConfig = _context5.sent;
425
+ _context5.next = 16;
426
+ break;
427
+ case 12:
428
+ _context5.prev = 12;
429
+ _context5.t0 = _context5["catch"](6);
430
+ console.warn('[BookingTicket] OpenData 配置加载失败,跳过 idGenerator 配置', _context5.t0);
431
+ return _context5.abrupt("return");
431
432
  case 16:
433
+ // if (!openDataConfig) return;
432
434
  receiptSequenceLength = this.normalizePositiveInteger((_openDataConfig = openDataConfig) === null || _openDataConfig === void 0 ? void 0 : _openDataConfig['sale.short_number_digits'], 5);
433
435
  receiptSequenceStart = this.normalizePositiveInteger((_openDataConfig2 = openDataConfig) === null || _openDataConfig2 === void 0 ? void 0 : _openDataConfig2['sale.short_number_start_number'], 1);
434
436
  prefix = this.normalizeIdPrefix((_openDataConfig3 = openDataConfig) === null || _openDataConfig3 === void 0 ? void 0 : _openDataConfig3['sale.short_number_prefix'], '');
@@ -475,7 +477,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
475
477
  case "end":
476
478
  return _context5.stop();
477
479
  }
478
- }, _callee5, this, [[2, 8], [30, 35]]);
480
+ }, _callee5, this, [[6, 12], [30, 35]]);
479
481
  }));
480
482
  function configureIdGeneratorFromOpenData() {
481
483
  return _configureIdGeneratorFromOpenData.apply(this, arguments);
@@ -559,7 +561,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
559
561
  key: "scanPromotionCode",
560
562
  value: function () {
561
563
  var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(code, customerId) {
562
- var raw, scannedList, extractedCustomerId, hasOrderCustomer, tempOrder;
564
+ var raw, scannedList, extractedCustomerId, hasOrderCustomer, isUserPlatform, tempOrder;
563
565
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
564
566
  while (1) switch (_context7.prev = _context7.next) {
565
567
  case 0:
@@ -575,33 +577,34 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
575
577
  raw = _context7.sent;
576
578
  scannedList = raw.scannedDiscountList || [];
577
579
  extractedCustomerId = this.getDiscountCustomerId(scannedList);
578
- hasOrderCustomer = Boolean(this.store.order.getOrderCustomer()); // 缺 Holder 等场景 isAvailable=false,但仍需把 Pass 归属客户带入订单,供 Holder 弹窗使用。
579
- if (!(!hasOrderCustomer && extractedCustomerId)) {
580
- _context7.next = 11;
580
+ hasOrderCustomer = Boolean(this.store.order.getOrderCustomer());
581
+ isUserPlatform = USER_PLATFORM.includes(this.otherParams.platform); // Holder 等场景 isAvailable=false,但仍需把 Pass 归属客户带入订单,供 Holder 弹窗使用。
582
+ if (!(!hasOrderCustomer && extractedCustomerId && !isUserPlatform)) {
583
+ _context7.next = 12;
581
584
  break;
582
585
  }
583
- _context7.next = 11;
586
+ _context7.next = 12;
584
587
  return this.hydrateOrderCustomerFromScanDiscounts(scannedList);
585
- case 11:
588
+ case 12:
586
589
  if (!raw.isAvailable) {
587
- _context7.next = 18;
590
+ _context7.next = 19;
588
591
  break;
589
592
  }
590
- _context7.next = 14;
593
+ _context7.next = 15;
591
594
  return this.store.order.recalculateSummary({
592
595
  createIfMissing: true
593
596
  });
594
- case 14:
597
+ case 15:
595
598
  this.store.order.persistTempOrder();
596
599
  tempOrder = this.store.order.ensureTempOrder();
597
- _context7.next = 18;
600
+ _context7.next = 19;
598
601
  return this.effectsEmit('onDiscountApplied', {
599
602
  productList: tempOrder.products || [],
600
603
  discountList: this.store.order.getDiscountList(),
601
604
  selectedDiscountList: tempOrder.discount_list || [],
602
605
  tempOrder: tempOrder
603
606
  });
604
- case 18:
607
+ case 19:
605
608
  return _context7.abrupt("return", _objectSpread(_objectSpread({
606
609
  isAvailable: raw.isAvailable
607
610
  }, raw.isAccepted !== undefined ? {
@@ -611,7 +614,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
611
614
  unavailableReason: raw.unavailableReason,
612
615
  scannedDiscountList: raw.scannedDiscountList
613
616
  }));
614
- case 19:
617
+ case 20:
615
618
  case "end":
616
619
  return _context7.stop();
617
620
  }
@@ -688,11 +691,11 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
688
691
  return null;
689
692
  }
690
693
  }, {
691
- key: "resolveCustomerByDiscountCustomerId",
694
+ key: "resolveCustomerById",
692
695
  value: function () {
693
- var _resolveCustomerByDiscountCustomerId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(customerId) {
696
+ var _resolveCustomerById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(customerId) {
694
697
  var _result$list;
695
- var localCustomers, localCustomer, normalizedLocalCustomer, result, remoteCustomer;
698
+ var localCustomers, localCustomer, normalizedLocalCustomer, result, remoteCustomer, detailCustomer;
696
699
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
697
700
  while (1) switch (_context9.prev = _context9.next) {
698
701
  case 0:
@@ -714,18 +717,42 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
714
717
  case 7:
715
718
  result = _context9.sent;
716
719
  remoteCustomer = this.findCustomerById((result === null || result === void 0 ? void 0 : result.list) || [], customerId) || (result === null || result === void 0 || (_result$list = result.list) === null || _result$list === void 0 ? void 0 : _result$list[0]) || null;
717
- return _context9.abrupt("return", remoteCustomer ? this.normalizeCustomer(remoteCustomer) : null);
718
- case 10:
720
+ if (!remoteCustomer) {
721
+ _context9.next = 11;
722
+ break;
723
+ }
724
+ return _context9.abrupt("return", this.normalizeCustomer(remoteCustomer));
725
+ case 11:
726
+ _context9.prev = 11;
727
+ _context9.next = 14;
728
+ return this.store.customer.queryCustomerDetail(customerId);
729
+ case 14:
730
+ detailCustomer = _context9.sent;
731
+ return _context9.abrupt("return", detailCustomer ? this.normalizeCustomer(detailCustomer) : null);
732
+ case 18:
733
+ _context9.prev = 18;
734
+ _context9.t0 = _context9["catch"](11);
735
+ console.warn('[BookingTicket] resolveCustomerById detail request failed', {
736
+ customerId: customerId,
737
+ error: _context9.t0
738
+ });
739
+ return _context9.abrupt("return", null);
740
+ case 22:
719
741
  case "end":
720
742
  return _context9.stop();
721
743
  }
722
- }, _callee9, this);
744
+ }, _callee9, this, [[11, 18]]);
723
745
  }));
724
- function resolveCustomerByDiscountCustomerId(_x6) {
725
- return _resolveCustomerByDiscountCustomerId.apply(this, arguments);
746
+ function resolveCustomerById(_x6) {
747
+ return _resolveCustomerById.apply(this, arguments);
726
748
  }
727
- return resolveCustomerByDiscountCustomerId;
728
- }()
749
+ return resolveCustomerById;
750
+ }() /** 兼容既有优惠码扫码逻辑。 */
751
+ }, {
752
+ key: "resolveCustomerByDiscountCustomerId",
753
+ value: function resolveCustomerByDiscountCustomerId(customerId) {
754
+ return this.resolveCustomerById(customerId);
755
+ }
729
756
  }, {
730
757
  key: "findCustomerById",
731
758
  value: function findCustomerById() {
@@ -1532,7 +1559,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1532
1559
  }, {
1533
1560
  key: "setOrderCustomer",
1534
1561
  value: function setOrderCustomer(customer) {
1535
- var _this$store$order$get3;
1562
+ var _this$store$order$get3,
1563
+ _this3 = this;
1536
1564
  if (!customer) {
1537
1565
  this.clearOrderCustomer();
1538
1566
  return;
@@ -1561,8 +1589,17 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1561
1589
  this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), next);
1562
1590
  this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
1563
1591
  // 客户切换可能改变可用促销/赠品;触发一次重算(recursion-safe)。
1564
- void this.store.order.applyPromotion().catch(function (error) {
1592
+ var promotionRefreshTask = this.store.order.applyPromotion().then(function () {
1593
+ return undefined;
1594
+ });
1595
+ this.orderCustomerPromotionRefreshInFlight = promotionRefreshTask;
1596
+ void promotionRefreshTask.then(function () {
1597
+ if (_this3.orderCustomerPromotionRefreshInFlight !== promotionRefreshTask) return;
1598
+ _this3.orderCustomerPromotionRefreshInFlight = null;
1599
+ }, function (error) {
1565
1600
  console.error('[BookingTicket] applyPromotion after customer change failed', error);
1601
+ if (_this3.orderCustomerPromotionRefreshInFlight !== promotionRefreshTask) return;
1602
+ _this3.orderCustomerPromotionRefreshInFlight = null;
1566
1603
  });
1567
1604
  }
1568
1605
 
@@ -1592,7 +1629,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1592
1629
  value: function clearOrderCustomer() {
1593
1630
  var _discountModule$setOr,
1594
1631
  _discountModule$setDi,
1595
- _this3 = this;
1632
+ _this4 = this;
1596
1633
  this.store.order.clearOrderCustomer();
1597
1634
  this.discountConfigCacheKey = null;
1598
1635
  this.hasManualDiscountSelection = false;
@@ -1605,9 +1642,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1605
1642
  createIfMissing: true
1606
1643
  }).then(function () {
1607
1644
  var _discountModule$getDi;
1608
- var tempOrder = _this3.store.order.ensureTempOrder();
1609
- _this3.store.order.persistTempOrder();
1610
- return _this3.effectsEmit('onDiscountApplied', {
1645
+ var tempOrder = _this4.store.order.ensureTempOrder();
1646
+ _this4.store.order.persistTempOrder();
1647
+ return _this4.effectsEmit('onDiscountApplied', {
1611
1648
  productList: tempOrder.products || [],
1612
1649
  discountList: (discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [],
1613
1650
  selectedDiscountList: tempOrder.discount_list || [],
@@ -1668,14 +1705,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1668
1705
  }, {
1669
1706
  key: "refreshDiscountConfigAfterOrderCustomerChange",
1670
1707
  value: function refreshDiscountConfigAfterOrderCustomerChange(customerId) {
1671
- var _this4 = this;
1672
- if (!customerId || customerId === 1) return;
1708
+ var _this5 = this;
1709
+ if (!customerId || customerId === 1) return Promise.resolve();
1673
1710
  if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
1674
- return;
1711
+ return this.orderCustomerDiscountRefreshInFlight;
1675
1712
  }
1676
1713
  var previousRefresh = this.orderCustomerDiscountRefreshInFlight;
1677
1714
  var refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1678
- var currentCustomer;
1715
+ var _this5$store$order$ge, _this5$store$order, _this5$getOrderIdenti;
1716
+ var currentCustomer, tempOrder, orderId, action;
1679
1717
  return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1680
1718
  while (1) switch (_context22.prev = _context22.next) {
1681
1719
  case 0:
@@ -1688,18 +1726,22 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1688
1726
  return undefined;
1689
1727
  });
1690
1728
  case 3:
1691
- currentCustomer = _this4.store.order.getOrderCustomer();
1729
+ currentCustomer = _this5.store.order.getOrderCustomer();
1692
1730
  if (!(!currentCustomer || Number(currentCustomer.customer_id) !== customerId)) {
1693
1731
  _context22.next = 6;
1694
1732
  break;
1695
1733
  }
1696
1734
  return _context22.abrupt("return");
1697
1735
  case 6:
1698
- _context22.next = 8;
1699
- return _this4.loadDiscountConfig({
1700
- customerId: customerId
1736
+ tempOrder = (_this5$store$order$ge = (_this5$store$order = _this5.store.order).getTempOrder) === null || _this5$store$order$ge === void 0 ? void 0 : _this5$store$order$ge.call(_this5$store$order);
1737
+ orderId = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) || ((_this5$getOrderIdenti = _this5.getOrderIdentity) === null || _this5$getOrderIdenti === void 0 || (_this5$getOrderIdenti = _this5$getOrderIdenti.call(_this5)) === null || _this5$getOrderIdenti === void 0 ? void 0 : _this5$getOrderIdenti.orderId);
1738
+ action = !orderId || String(orderId).startsWith('local_order') ? 'create' : 'edit';
1739
+ _context22.next = 11;
1740
+ return _this5.loadDiscountConfig({
1741
+ customerId: customerId,
1742
+ action: action
1701
1743
  });
1702
- case 8:
1744
+ case 11:
1703
1745
  case "end":
1704
1746
  return _context22.stop();
1705
1747
  }
@@ -1710,10 +1752,16 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1710
1752
  refreshTask.catch(function (error) {
1711
1753
  console.error('Failed to load discount config after customer change:', error);
1712
1754
  }).finally(function () {
1713
- if (_this4.orderCustomerDiscountRefreshInFlight !== refreshTask) return;
1714
- _this4.orderCustomerDiscountRefreshInFlight = null;
1715
- _this4.orderCustomerDiscountRefreshCustomerId = null;
1755
+ if (_this5.orderCustomerDiscountRefreshInFlight !== refreshTask) return;
1756
+ _this5.orderCustomerDiscountRefreshInFlight = null;
1757
+ _this5.orderCustomerDiscountRefreshCustomerId = null;
1716
1758
  });
1759
+ return refreshTask;
1760
+ }
1761
+ }, {
1762
+ key: "waitForOrderCustomerPromotionRefresh",
1763
+ value: function waitForOrderCustomerPromotionRefresh() {
1764
+ return this.orderCustomerPromotionRefreshInFlight || Promise.resolve();
1717
1765
  }
1718
1766
 
1719
1767
  /**
@@ -1897,9 +1945,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1897
1945
  }, {
1898
1946
  key: "scanGlobalListener",
1899
1947
  value: function scanGlobalListener(callback) {
1900
- var _this5 = this;
1948
+ var _this6 = this;
1901
1949
  var localSearch = function localSearch(v) {
1902
- return _this5.store.products.findProductsByCodeOrBarcode(v);
1950
+ return _this6.store.products.findProductsByCodeOrBarcode(v);
1903
1951
  };
1904
1952
  var scanCallback = handleGlobalScan(this.request, localSearch, this.getSubmitOrderSalesChannel());
1905
1953
  var safeCallback = function safeCallback(d) {
@@ -2375,7 +2423,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2375
2423
  key: "handleGlobalScanCode",
2376
2424
  value: (function () {
2377
2425
  var _handleGlobalScanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(code, bridge) {
2378
- var _this6 = this;
2426
+ var _this7 = this;
2379
2427
  var trimmed, _bridge$onNotify, _bridge$refresh, localSearch, scanCallback, raw, formatted, _bridge$onNotify2, _result7, _bridge$onNotify3;
2380
2428
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2381
2429
  while (1) switch (_context28.prev = _context28.next) {
@@ -2393,7 +2441,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2393
2441
  case 4:
2394
2442
  _context28.prev = 4;
2395
2443
  localSearch = function localSearch(v) {
2396
- return _this6.store.products.findProductsByCodeOrBarcode(v);
2444
+ return _this7.store.products.findProductsByCodeOrBarcode(v);
2397
2445
  };
2398
2446
  scanCallback = handleGlobalScan(this.request, localSearch, this.getSubmitOrderSalesChannel());
2399
2447
  _context28.next = 9;
@@ -2417,35 +2465,35 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2417
2465
  _context28.next = 16;
2418
2466
  return applyGlobalScan({
2419
2467
  setOrderCustomer: function setOrderCustomer(customer) {
2420
- return _this6.setOrderCustomer(customer);
2468
+ return _this7.setOrderCustomer(customer);
2421
2469
  },
2422
2470
  getOrderCustomerSnapshot: function getOrderCustomerSnapshot() {
2423
- return _this6.getOrderCustomerSnapshot();
2471
+ return _this7.getOrderCustomerSnapshot();
2424
2472
  },
2425
2473
  getBusinessCode: function getBusinessCode() {
2426
- var _this6$otherParams;
2427
- return (_this6$otherParams = _this6.otherParams) === null || _this6$otherParams === void 0 ? void 0 : _this6$otherParams.businessCode;
2474
+ var _this7$otherParams;
2475
+ return (_this7$otherParams = _this7.otherParams) === null || _this7$otherParams === void 0 ? void 0 : _this7$otherParams.businessCode;
2428
2476
  },
2429
2477
  buildAddProductCtx: function buildAddProductCtx(extra) {
2430
- return _this6.buildAddProductCtx(extra);
2478
+ return _this7.buildAddProductCtx(extra);
2431
2479
  },
2432
2480
  decideAddProduct: function decideAddProduct(item, options) {
2433
- return _this6.decideAddProduct(item, options);
2481
+ return _this7.decideAddProduct(item, options);
2434
2482
  },
2435
2483
  decideAfterDetail: function decideAfterDetail(cacheItem, options) {
2436
- return _this6.decideAfterDetail(cacheItem, options);
2484
+ return _this7.decideAfterDetail(cacheItem, options);
2437
2485
  },
2438
2486
  transformDetailToProductAndBooking: function transformDetailToProductAndBooking(input) {
2439
- return _this6.transformDetailToProductAndBooking(input);
2487
+ return _this7.transformDetailToProductAndBooking(input);
2440
2488
  },
2441
2489
  addProductToOrder: function addProductToOrder(product, booking) {
2442
- return _this6.addProductToOrder(product, booking);
2490
+ return _this7.addProductToOrder(product, booking);
2443
2491
  },
2444
2492
  refreshWalletAssets: function refreshWalletAssets(params) {
2445
- return _this6.refreshWalletAssets(params);
2493
+ return _this7.refreshWalletAssets(params);
2446
2494
  },
2447
2495
  scanWalletAsset: function scanWalletAsset(scanCode) {
2448
- return _this6.scanWalletAsset(scanCode);
2496
+ return _this7.scanWalletAsset(scanCode);
2449
2497
  }
2450
2498
  }, formatted, bridge);
2451
2499
  case 16:
@@ -2584,7 +2632,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2584
2632
  key: "addAddTimeProductsToBooking",
2585
2633
  value: (function () {
2586
2634
  var _addAddTimeProductsToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(input) {
2587
- var _this7 = this,
2635
+ var _this8 = this,
2588
2636
  _input$bookingPatch;
2589
2637
  var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator2, _step2, line;
2590
2638
  return _regeneratorRuntime().wrap(function _callee30$(_context30) {
@@ -2599,7 +2647,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2599
2647
  case 3:
2600
2648
  orderLines = (input.products || []).map(function (line) {
2601
2649
  return {
2602
- product: _this7.buildAddTimeOrderLine(line, bookingUid)
2650
+ product: _this8.buildAddTimeOrderLine(line, bookingUid)
2603
2651
  };
2604
2652
  });
2605
2653
  if (this.store.order) {
@@ -388,35 +388,46 @@ export function attachItemRuleLimitsToTopLevelProducts(productList, limits) {
388
388
  * 数组元素先按主键排序再序列化,避免顺序差异导致误判为不同行。
389
389
  */
390
390
  export function buildProductLineFingerprint(productOptionItem, productBundle) {
391
- var optArr = Array.isArray(productOptionItem) ? productOptionItem : [];
392
- var normalizedOpts = optArr.map(function (item) {
393
- var _ref, _item$add_price;
394
- return {
395
- option_group_item_id: Number(item === null || item === void 0 ? void 0 : item.option_group_item_id) || 0,
396
- option_group_id: Number(item === null || item === void 0 ? void 0 : item.option_group_id) || 0,
397
- num: typeof (item === null || item === void 0 ? void 0 : item.num) === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
398
- price: String((_ref = (_item$add_price = item === null || item === void 0 ? void 0 : item.add_price) !== null && _item$add_price !== void 0 ? _item$add_price : item === null || item === void 0 ? void 0 : item.price) !== null && _ref !== void 0 ? _ref : '')
399
- };
400
- }).sort(function (p, q) {
401
- if (p.option_group_item_id !== q.option_group_item_id) {
402
- return p.option_group_item_id - q.option_group_item_id;
403
- }
404
- if (p.option_group_id !== q.option_group_id) return p.option_group_id - q.option_group_id;
405
- if (p.num !== q.num) return p.num - q.num;
406
- return p.price.localeCompare(q.price);
407
- });
391
+ var normalizeOptions = function normalizeOptions(options) {
392
+ var optionArr = Array.isArray(options) ? options : [];
393
+ return optionArr.map(function (item) {
394
+ var _ref, _item$add_price;
395
+ return {
396
+ option_group_item_id: Number(item === null || item === void 0 ? void 0 : item.option_group_item_id) || 0,
397
+ option_group_id: Number(item === null || item === void 0 ? void 0 : item.option_group_id) || 0,
398
+ num: typeof (item === null || item === void 0 ? void 0 : item.num) === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
399
+ price: String((_ref = (_item$add_price = item === null || item === void 0 ? void 0 : item.add_price) !== null && _item$add_price !== void 0 ? _item$add_price : item === null || item === void 0 ? void 0 : item.price) !== null && _ref !== void 0 ? _ref : '')
400
+ };
401
+ }).sort(function (p, q) {
402
+ if (p.option_group_item_id !== q.option_group_item_id) {
403
+ return p.option_group_item_id - q.option_group_item_id;
404
+ }
405
+ if (p.option_group_id !== q.option_group_id) {
406
+ return p.option_group_id - q.option_group_id;
407
+ }
408
+ if (p.num !== q.num) return p.num - q.num;
409
+ return p.price.localeCompare(q.price);
410
+ });
411
+ };
412
+ var normalizedOpts = normalizeOptions(productOptionItem);
408
413
  var bundleArr = Array.isArray(productBundle) ? productBundle : [];
409
414
  var normalizedBundles = bundleArr.map(function (item) {
410
- var _ref2, _item$bundle_id;
415
+ var _ref2, _item$bundle_id, _item$bundle_variant_;
411
416
  return {
412
417
  bundle_id: Number((_ref2 = (_item$bundle_id = item === null || item === void 0 ? void 0 : item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item === null || item === void 0 ? void 0 : item.id) !== null && _ref2 !== void 0 ? _ref2 : 0) || 0,
413
418
  product_id: Number(item === null || item === void 0 ? void 0 : item.product_id) || 0,
414
- num: typeof (item === null || item === void 0 ? void 0 : item.num) === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1
419
+ product_variant_id: Number((_item$bundle_variant_ = item === null || item === void 0 ? void 0 : item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item === null || item === void 0 ? void 0 : item.product_variant_id) || 0,
420
+ num: typeof (item === null || item === void 0 ? void 0 : item.num) === 'number' && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
421
+ option: normalizeOptions(item === null || item === void 0 ? void 0 : item.option)
415
422
  };
416
423
  }).sort(function (p, q) {
417
424
  if (p.bundle_id !== q.bundle_id) return p.bundle_id - q.bundle_id;
418
425
  if (p.product_id !== q.product_id) return p.product_id - q.product_id;
419
- return p.num - q.num;
426
+ if (p.product_variant_id !== q.product_variant_id) {
427
+ return p.product_variant_id - q.product_variant_id;
428
+ }
429
+ if (p.num !== q.num) return p.num - q.num;
430
+ return JSON.stringify(p.option).localeCompare(JSON.stringify(q.option));
420
431
  });
421
432
  return JSON.stringify([normalizedOpts, normalizedBundles]);
422
433
  }
@@ -63,6 +63,24 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
63
63
  private openDataTarget;
64
64
  private loadOpenDataInFlight;
65
65
  private loadOpenDataInFlightTarget;
66
+ protected getSubmitOrderSalesChannel(): string;
67
+ protected isSessionStoragePersistEnabled(): boolean;
68
+ protected shouldUseSessionStorageForSubModule(moduleName?: string): boolean;
69
+ /**
70
+ * 读取与当前 cacheId 同分桶的 Solution 会话状态。
71
+ * 该状态独立于 otherParams,适合页面皮肤保存短生命周期 UI 状态。
72
+ */
73
+ getSessionStateValue<T = unknown>(key: string): T | undefined;
74
+ /**
75
+ * 写入与当前 cacheId 同分桶的 Solution 会话状态。
76
+ * value 为 undefined 时删除该 key;存储失败不阻断业务流程。
77
+ */
78
+ setSessionStateValue(key: string, value: unknown): void;
79
+ /**
80
+ * 清除当前 cacheId 的可恢复订单快照,同时保留 Solution UI sessionState。
81
+ * 用于支付跳转等终态场景,避免浏览器返回时恢复已提交订单。
82
+ */
83
+ clearSessionStorageOrderSnapshot(): void;
66
84
  /**
67
85
  * Kiosk 不能把已收款订单留在本地等待重试:默认直接等待云端 checkout。
68
86
  * 兼容仍需要 WebPOS 待同步模式的入口可显式传 checkoutSyncTaskEnabled: true。
@@ -72,6 +90,13 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
72
90
  protected getDefaultCheckoutSmallTicketDataFlag(): number;
73
91
  protected getRegisteredModuleNames(): readonly string[];
74
92
  protected createSubModule(moduleName: string): Module | null;
93
+ addNewOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
94
+ syncAuthenticatedOrderCustomer(): Promise<boolean>;
95
+ private isAuthenticatedCustomerUserPlatform;
96
+ private resolveDiscountOrderIdentity;
97
+ private resolveDiscountAction;
98
+ private resetCachedCustomerDiscountState;
99
+ private refreshLegacySessionCustomerDiscounts;
75
100
  /**
76
101
  * Loads OpenData without borrowing BookingTicket. Cache ownership is tied to the exact
77
102
  * business/channel target so a reused solution instance cannot leak another entry's menus.