@pisell/pisellos 2.2.180 → 2.2.182

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 (175) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/BookingContext/index.d.ts +37 -0
  3. package/dist/modules/BookingContext/index.js +436 -0
  4. package/dist/modules/BookingContext/types.d.ts +102 -0
  5. package/dist/modules/BookingContext/types.js +51 -0
  6. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  7. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +276 -0
  8. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  9. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
  10. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
  11. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +215 -0
  12. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  13. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  14. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  15. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  16. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  17. package/dist/modules/BookingContext/utils/index.js +11 -0
  18. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  19. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  20. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  21. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  22. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  23. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  24. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  25. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  26. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  27. package/dist/modules/BookingContext/utils/resources.js +486 -0
  28. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  29. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  30. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  31. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  32. package/dist/modules/Customer/index.d.ts +6 -0
  33. package/dist/modules/Customer/index.js +129 -83
  34. package/dist/modules/Customer/types.d.ts +2 -0
  35. package/dist/modules/Discount/index.js +4 -3
  36. package/dist/modules/Discount/types.d.ts +1 -0
  37. package/dist/modules/Order/index.d.ts +101 -10
  38. package/dist/modules/Order/index.js +1444 -490
  39. package/dist/modules/Order/types.d.ts +201 -18
  40. package/dist/modules/Order/types.js +31 -0
  41. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  42. package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
  43. package/dist/modules/Order/utils.d.ts +83 -1
  44. package/dist/modules/Order/utils.js +405 -61
  45. package/dist/modules/Product/index.d.ts +1 -1
  46. package/dist/modules/Quotation/index.d.ts +0 -1
  47. package/dist/modules/Quotation/index.js +23 -21
  48. package/dist/modules/Rules/index.d.ts +4 -0
  49. package/dist/modules/Rules/index.js +43 -39
  50. package/dist/modules/Rules/types.d.ts +1 -0
  51. package/dist/modules/SalesSummary/index.js +4 -2
  52. package/dist/modules/SalesSummary/utils.js +21 -7
  53. package/dist/modules/Schedule/index.js +6 -2
  54. package/dist/modules/index.d.ts +1 -0
  55. package/dist/modules/index.js +2 -1
  56. package/dist/server/index.js +87 -29
  57. package/dist/server/modules/order/index.d.ts +23 -0
  58. package/dist/server/modules/order/index.js +123 -46
  59. package/dist/server/modules/order/utils/filterOrders.js +20 -6
  60. package/dist/server/modules/products/index.d.ts +1 -1
  61. package/dist/server/modules/products/index.js +130 -113
  62. package/dist/server/modules/schedule/index.js +13 -6
  63. package/dist/solution/BaseSales/index.d.ts +89 -7
  64. package/dist/solution/BaseSales/index.js +1489 -366
  65. package/dist/solution/BaseSales/types.d.ts +67 -1
  66. package/dist/solution/BaseSales/types.js +3 -1
  67. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +275 -0
  68. package/dist/solution/BaseSales/utils/cartPromotion.js +1258 -0
  69. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  70. package/dist/solution/BaseSales/utils/quotationPrice.js +237 -0
  71. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +68 -16
  72. package/dist/solution/BaseSales/utils.js +46 -8
  73. package/dist/solution/BookingByStep/index.d.ts +1 -1
  74. package/dist/solution/BookingTicket/index.d.ts +152 -2
  75. package/dist/solution/BookingTicket/index.js +848 -184
  76. package/dist/solution/BookingTicket/types.d.ts +2 -0
  77. package/dist/solution/BookingTicket/types.js +3 -0
  78. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
  79. package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
  80. package/dist/solution/BookingTicket/utils/cartView.js +4 -2
  81. package/dist/solution/ScanOrder/index.d.ts +9 -3
  82. package/dist/solution/ScanOrder/index.js +231 -128
  83. package/dist/solution/ScanOrder/utils.js +46 -8
  84. package/dist/solution/VenueBooking/index.d.ts +5 -2
  85. package/dist/solution/VenueBooking/index.js +103 -55
  86. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  87. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
  88. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  89. package/lib/modules/BookingContext/index.d.ts +37 -0
  90. package/lib/modules/BookingContext/index.js +297 -0
  91. package/lib/modules/BookingContext/types.d.ts +102 -0
  92. package/lib/modules/BookingContext/types.js +34 -0
  93. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  94. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +271 -0
  95. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  96. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
  97. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
  98. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +198 -0
  99. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  100. package/lib/modules/BookingContext/utils/flexible.js +80 -0
  101. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  102. package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
  103. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  104. package/lib/modules/BookingContext/utils/index.js +43 -0
  105. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  106. package/lib/modules/BookingContext/utils/noResource.js +90 -0
  107. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  108. package/lib/modules/BookingContext/utils/productExtend.js +283 -0
  109. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  110. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  111. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  112. package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
  113. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  114. package/lib/modules/BookingContext/utils/resources.js +377 -0
  115. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  116. package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
  117. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  118. package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
  119. package/lib/modules/Customer/index.d.ts +6 -0
  120. package/lib/modules/Customer/index.js +26 -11
  121. package/lib/modules/Customer/types.d.ts +2 -0
  122. package/lib/modules/Discount/index.js +5 -1
  123. package/lib/modules/Discount/types.d.ts +1 -0
  124. package/lib/modules/Order/index.d.ts +101 -10
  125. package/lib/modules/Order/index.js +751 -114
  126. package/lib/modules/Order/types.d.ts +201 -18
  127. package/lib/modules/Order/types.js +1 -0
  128. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  129. package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
  130. package/lib/modules/Order/utils.d.ts +83 -1
  131. package/lib/modules/Order/utils.js +340 -22
  132. package/lib/modules/Product/index.d.ts +1 -1
  133. package/lib/modules/Quotation/index.d.ts +0 -1
  134. package/lib/modules/Quotation/index.js +18 -15
  135. package/lib/modules/Rules/index.d.ts +4 -0
  136. package/lib/modules/Rules/index.js +26 -27
  137. package/lib/modules/Rules/types.d.ts +1 -0
  138. package/lib/modules/SalesSummary/index.js +4 -2
  139. package/lib/modules/SalesSummary/utils.js +21 -7
  140. package/lib/modules/Schedule/index.js +3 -1
  141. package/lib/modules/index.d.ts +1 -0
  142. package/lib/modules/index.js +3 -1
  143. package/lib/server/index.js +41 -4
  144. package/lib/server/modules/order/index.d.ts +23 -0
  145. package/lib/server/modules/order/index.js +46 -14
  146. package/lib/server/modules/order/utils/filterOrders.js +12 -4
  147. package/lib/server/modules/products/index.d.ts +1 -1
  148. package/lib/server/modules/products/index.js +30 -20
  149. package/lib/server/modules/schedule/index.js +2 -1
  150. package/lib/solution/BaseSales/index.d.ts +89 -7
  151. package/lib/solution/BaseSales/index.js +742 -23
  152. package/lib/solution/BaseSales/types.d.ts +67 -1
  153. package/lib/solution/BaseSales/types.js +3 -1
  154. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +275 -0
  155. package/lib/solution/BaseSales/utils/cartPromotion.js +836 -0
  156. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  157. package/lib/solution/BaseSales/utils/quotationPrice.js +277 -0
  158. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +71 -12
  159. package/lib/solution/BaseSales/utils.js +46 -6
  160. package/lib/solution/BookingByStep/index.d.ts +1 -1
  161. package/lib/solution/BookingTicket/index.d.ts +152 -2
  162. package/lib/solution/BookingTicket/index.js +389 -9
  163. package/lib/solution/BookingTicket/types.d.ts +2 -0
  164. package/lib/solution/BookingTicket/types.js +6 -0
  165. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
  166. package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
  167. package/lib/solution/BookingTicket/utils/cartView.js +4 -2
  168. package/lib/solution/ScanOrder/index.d.ts +9 -3
  169. package/lib/solution/ScanOrder/index.js +147 -66
  170. package/lib/solution/ScanOrder/utils.js +46 -6
  171. package/lib/solution/VenueBooking/index.d.ts +5 -2
  172. package/lib/solution/VenueBooking/index.js +50 -14
  173. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  174. package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
  175. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  var _excluded = ["id"],
2
- _excluded2 = ["product_id"];
2
+ _excluded2 = ["product_id"],
3
+ _excluded3 = ["product_id"];
3
4
  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); }
4
5
  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; }
5
6
  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; }
@@ -30,12 +31,16 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
30
31
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
31
32
  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); }
32
33
  import { createBookingTicketModule } from "./types";
34
+ import { getProductExtend as getProductExtendUtil, getResourceByIds as getResourceByIdsUtil, getResourceErrors as getResourceErrorsUtil, derivePresetStartTimeFromDate } from "../../modules/BookingContext";
33
35
  import { BaseSalesImpl } from "../BaseSales";
34
36
  import Scan from "./utils/scan";
35
37
  import { formatOrderCustomerPatch } from "./utils/orderCustomer";
36
38
  import { handleGlobalScan, handleCustomerScan, handleUniversalScan } from "./utils/scan/handleScan";
37
39
  import scanCache from "./utils/scan/scanCache";
38
40
  import { buildCartView } from "./utils/cartView";
41
+ import { buildCacheItemFromCartDetail, buildCacheItemFromDetail, buildRequiresDetailPayload as _buildRequiresDetailPayload, decideAddProduct as decideAddProductUtil, decideAfterDetail as decideAfterDetailUtil, decideAutoClose as decideAutoCloseUtil, getIsEject as getIsEjectUtil, getIsOnlySession as getIsOnlySessionUtil, transformDetailToProductAndBooking as transformDetailToProductAndBookingUtil } from "./utils/addProductDecision";
42
+ import { buildCacheItemFromOrderLine as buildCacheItemFromOrderLineUtil } from "../../modules/BookingContext/utils/buildCacheItemFromOrderLine";
43
+ import { buildNormalProductCacheItemFromOrderLine as buildNormalProductCacheItemFromOrderLineUtil } from "../../modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine";
39
44
  import { applyBookingsStatus, resolveScheduleId, restoreBookingsStatus } from "./utils/bookingStatus";
40
45
  export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
41
46
  _inherits(BookingTicketImpl, _BaseSalesImpl);
@@ -57,16 +62,24 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
57
62
  _defineProperty(_assertThisInitialized(_this), "platform", void 0);
58
63
  _defineProperty(_assertThisInitialized(_this), "scan", void 0);
59
64
  _defineProperty(_assertThisInitialized(_this), "productCatalog", []);
65
+ _defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshInFlight", null);
66
+ _defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshCustomerId", null);
60
67
  return _this;
61
68
  }
62
69
  _createClass(BookingTicketImpl, [{
63
70
  key: "getRegisteredModuleNames",
64
71
  value:
65
72
  /**
66
- * 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer。
73
+ * 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext
74
+ * bookingContext 是 SalesSdk 加车下沉所需的「预约 UI 上下文」(bookingConfig / resourcesOrigin / date)。
67
75
  */
68
76
  function getRegisteredModuleNames() {
69
- return [].concat(_toConsumableArray(_get(_getPrototypeOf(BookingTicketImpl.prototype), "getRegisteredModuleNames", this).call(this)), ['customer']);
77
+ return [].concat(_toConsumableArray(_get(_getPrototypeOf(BookingTicketImpl.prototype), "getRegisteredModuleNames", this).call(this)), ['customer', 'bookingContext']);
78
+ }
79
+ }, {
80
+ key: "getSubmitOrderSalesChannel",
81
+ value: function getSubmitOrderSalesChannel() {
82
+ return 'pos';
70
83
  }
71
84
 
72
85
  /**
@@ -125,7 +138,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
125
138
  key: "loadSalesDetail",
126
139
  value: (function () {
127
140
  var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(orderIdOrParams) {
128
- var sales, customerModule, detailCustomer, _detailCustomer$name, _ref, detailCustomerId, detailCustomerRest, rawId, customer;
141
+ var _ref;
142
+ var sales, customerModule, detailCustomer, orderCustomerSnapshot, protocolCustomerId, protocolCustomer, selectedCustomer, _selectedCustomer$nam, _ref2, detailCustomerId, detailCustomerRest, rawId, customer;
129
143
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
130
144
  while (1) switch (_context2.prev = _context2.next) {
131
145
  case 0:
@@ -133,24 +147,38 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
133
147
  return _get(_getPrototypeOf(BookingTicketImpl.prototype), "loadSalesDetail", this).call(this, orderIdOrParams);
134
148
  case 2:
135
149
  sales = _context2.sent;
136
- console.log(sales, '1234sales');
137
150
  customerModule = this.store.customer;
138
151
  detailCustomer = sales === null || sales === void 0 ? void 0 : sales.customer;
139
- if (customerModule && detailCustomer) {
140
- _ref = detailCustomer !== null && detailCustomer !== void 0 ? detailCustomer : {}, detailCustomerId = _ref.id, detailCustomerRest = _objectWithoutProperties(_ref, _excluded);
141
- rawId = detailCustomerId !== null && detailCustomerId !== void 0 ? detailCustomerId : '';
142
- customer = _objectSpread(_objectSpread({}, detailCustomerRest), {}, {
143
- id: rawId == null ? '' : rawId,
144
- name: (_detailCustomer$name = detailCustomer === null || detailCustomer === void 0 ? void 0 : detailCustomer.name) !== null && _detailCustomer$name !== void 0 ? _detailCustomer$name : '',
145
- phone: detailCustomer === null || detailCustomer === void 0 ? void 0 : detailCustomer.phone,
146
- email: detailCustomer === null || detailCustomer === void 0 ? void 0 : detailCustomer.email,
147
- country_calling_code: detailCustomer === null || detailCustomer === void 0 ? void 0 : detailCustomer.country_calling_code
148
- });
149
- customerModule.setSelectedCustomer(customer);
150
- this.setOrderCustomer(customer);
152
+ orderCustomerSnapshot = this.store.order.getOrderCustomerSnapshot();
153
+ protocolCustomerId = sales === null || sales === void 0 ? void 0 : sales.customer_id;
154
+ protocolCustomer = protocolCustomerId !== undefined && protocolCustomerId !== null ? {
155
+ id: protocolCustomerId,
156
+ name: String((sales === null || sales === void 0 ? void 0 : sales.customer_name) || ''),
157
+ phone: sales === null || sales === void 0 ? void 0 : sales.phone,
158
+ email: sales === null || sales === void 0 ? void 0 : sales.email,
159
+ country_calling_code: sales === null || sales === void 0 ? void 0 : sales.country_calling_code
160
+ } : null;
161
+ selectedCustomer = (_ref = detailCustomer !== null && detailCustomer !== void 0 ? detailCustomer : orderCustomerSnapshot) !== null && _ref !== void 0 ? _ref : protocolCustomer;
162
+ if (!(customerModule && selectedCustomer)) {
163
+ _context2.next = 17;
164
+ break;
151
165
  }
166
+ _ref2 = selectedCustomer !== null && selectedCustomer !== void 0 ? selectedCustomer : {}, detailCustomerId = _ref2.id, detailCustomerRest = _objectWithoutProperties(_ref2, _excluded);
167
+ rawId = detailCustomerId !== null && detailCustomerId !== void 0 ? detailCustomerId : '';
168
+ customer = _objectSpread(_objectSpread({}, detailCustomerRest), {}, {
169
+ id: rawId == null ? '' : rawId,
170
+ name: (_selectedCustomer$nam = selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.name) !== null && _selectedCustomer$nam !== void 0 ? _selectedCustomer$nam : '',
171
+ phone: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.phone,
172
+ email: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.email,
173
+ country_calling_code: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.country_calling_code
174
+ });
175
+ customerModule.setSelectedCustomer(customer);
176
+ this.setOrderCustomer(customer);
177
+ _context2.next = 17;
178
+ return this.store.order.saveDraft();
179
+ case 17:
152
180
  return _context2.abrupt("return", sales);
153
- case 8:
181
+ case 18:
154
182
  case "end":
155
183
  return _context2.stop();
156
184
  }
@@ -160,7 +188,188 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
160
188
  return _loadSalesDetail.apply(this, arguments);
161
189
  }
162
190
  return loadSalesDetail;
191
+ }())
192
+ }, {
193
+ key: "scanPromotionCode",
194
+ value: function () {
195
+ var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(code, customerId) {
196
+ var raw;
197
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
198
+ while (1) switch (_context3.prev = _context3.next) {
199
+ case 0:
200
+ if (this.store.order) {
201
+ _context3.next = 2;
202
+ break;
203
+ }
204
+ throw new Error('order 模块未初始化');
205
+ case 2:
206
+ _context3.next = 4;
207
+ return this.store.order.scanCode(code, customerId);
208
+ case 4:
209
+ raw = _context3.sent;
210
+ if (!raw.isAvailable) {
211
+ _context3.next = 11;
212
+ break;
213
+ }
214
+ _context3.next = 8;
215
+ return this.hydrateOrderCustomerFromScanDiscounts(raw.scannedDiscountList || []);
216
+ case 8:
217
+ _context3.next = 10;
218
+ return this.store.order.recalculateSummary({
219
+ createIfMissing: true
220
+ });
221
+ case 10:
222
+ this.store.order.persistTempOrder();
223
+ case 11:
224
+ return _context3.abrupt("return", {
225
+ isAvailable: raw.isAvailable,
226
+ type: raw.type,
227
+ unavailableReason: raw.unavailableReason
228
+ });
229
+ case 12:
230
+ case "end":
231
+ return _context3.stop();
232
+ }
233
+ }, _callee3, this);
234
+ }));
235
+ function scanPromotionCode(_x3, _x4) {
236
+ return _scanPromotionCode.apply(this, arguments);
237
+ }
238
+ return scanPromotionCode;
239
+ }()
240
+ }, {
241
+ key: "hydrateOrderCustomerFromScanDiscounts",
242
+ value: function () {
243
+ var _hydrateOrderCustomerFromScanDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(discounts) {
244
+ var currentOrderCustomer, customerId, customer;
245
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
246
+ while (1) switch (_context4.prev = _context4.next) {
247
+ case 0:
248
+ currentOrderCustomer = this.store.order.getOrderCustomer();
249
+ if (!currentOrderCustomer) {
250
+ _context4.next = 3;
251
+ break;
252
+ }
253
+ return _context4.abrupt("return");
254
+ case 3:
255
+ customerId = this.getDiscountCustomerId(discounts);
256
+ if (customerId) {
257
+ _context4.next = 6;
258
+ break;
259
+ }
260
+ return _context4.abrupt("return");
261
+ case 6:
262
+ _context4.next = 8;
263
+ return this.resolveCustomerByDiscountCustomerId(customerId);
264
+ case 8:
265
+ customer = _context4.sent;
266
+ if (customer) {
267
+ _context4.next = 11;
268
+ break;
269
+ }
270
+ return _context4.abrupt("return");
271
+ case 11:
272
+ this.store.customer.setSelectedCustomer(customer);
273
+ this.setOrderCustomer(customer);
274
+ case 13:
275
+ case "end":
276
+ return _context4.stop();
277
+ }
278
+ }, _callee4, this);
279
+ }));
280
+ function hydrateOrderCustomerFromScanDiscounts(_x5) {
281
+ return _hydrateOrderCustomerFromScanDiscounts.apply(this, arguments);
282
+ }
283
+ return hydrateOrderCustomerFromScanDiscounts;
284
+ }()
285
+ }, {
286
+ key: "getDiscountCustomerId",
287
+ value: function getDiscountCustomerId(discounts) {
288
+ var discount = discounts.find(function (item) {
289
+ return item.customer_id != null;
290
+ });
291
+ var customerId = Number(discount === null || discount === void 0 ? void 0 : discount.customer_id);
292
+ if (!Number.isFinite(customerId) || customerId <= 0) return null;
293
+ return customerId;
294
+ }
295
+ }, {
296
+ key: "resolveCustomerByDiscountCustomerId",
297
+ value: function () {
298
+ var _resolveCustomerByDiscountCustomerId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(customerId) {
299
+ var _result$list;
300
+ var localCustomers, localCustomer, normalizedLocalCustomer, result, remoteCustomer;
301
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
302
+ while (1) switch (_context5.prev = _context5.next) {
303
+ case 0:
304
+ localCustomers = this.store.customer.getCustomers();
305
+ localCustomer = this.findCustomerById(localCustomers, customerId);
306
+ normalizedLocalCustomer = localCustomer ? this.normalizeCustomer(localCustomer) : null;
307
+ if (!(normalizedLocalCustomer && this.hasUsableCustomerDetails(normalizedLocalCustomer))) {
308
+ _context5.next = 5;
309
+ break;
310
+ }
311
+ return _context5.abrupt("return", normalizedLocalCustomer);
312
+ case 5:
313
+ _context5.next = 7;
314
+ return this.store.customer.queryCustomerList({
315
+ ids: [customerId],
316
+ skip: 1,
317
+ num: 1
318
+ });
319
+ case 7:
320
+ result = _context5.sent;
321
+ 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;
322
+ return _context5.abrupt("return", remoteCustomer ? this.normalizeCustomer(remoteCustomer) : null);
323
+ case 10:
324
+ case "end":
325
+ return _context5.stop();
326
+ }
327
+ }, _callee5, this);
328
+ }));
329
+ function resolveCustomerByDiscountCustomerId(_x6) {
330
+ return _resolveCustomerByDiscountCustomerId.apply(this, arguments);
331
+ }
332
+ return resolveCustomerByDiscountCustomerId;
163
333
  }()
334
+ }, {
335
+ key: "findCustomerById",
336
+ value: function findCustomerById() {
337
+ var _this2 = this;
338
+ var customers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
339
+ var customerId = arguments.length > 1 ? arguments[1] : undefined;
340
+ return customers.find(function (customer) {
341
+ var rawId = _this2.getRawCustomerId(customer);
342
+ return rawId !== null && String(rawId) === String(customerId);
343
+ }) || null;
344
+ }
345
+ }, {
346
+ key: "normalizeCustomer",
347
+ value: function normalizeCustomer(customer) {
348
+ var _ref3, _ref4, _customer$phone, _ref5, _customer$email, _ref6, _customer$country_cal;
349
+ var raw = customer;
350
+ var rawId = this.getRawCustomerId(customer);
351
+ var name = customer.name || raw.display_name || raw.nickname || raw.customer_name || [raw.first_name, raw.last_name].filter(Boolean).join(' ') || '';
352
+ return _objectSpread(_objectSpread({}, customer), {}, {
353
+ id: rawId !== null && rawId !== void 0 ? rawId : customer.id,
354
+ name: name,
355
+ phone: (_ref3 = (_ref4 = (_customer$phone = customer.phone) !== null && _customer$phone !== void 0 ? _customer$phone : raw.phone) !== null && _ref4 !== void 0 ? _ref4 : raw.mobile) !== null && _ref3 !== void 0 ? _ref3 : '',
356
+ email: (_ref5 = (_customer$email = customer.email) !== null && _customer$email !== void 0 ? _customer$email : raw.email) !== null && _ref5 !== void 0 ? _ref5 : '',
357
+ country_calling_code: (_ref6 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : raw.country_calling_code) !== null && _ref6 !== void 0 ? _ref6 : ''
358
+ });
359
+ }
360
+ }, {
361
+ key: "getRawCustomerId",
362
+ value: function getRawCustomerId(customer) {
363
+ var _ref7, _ref8, _customer$id;
364
+ var raw = customer;
365
+ return (_ref7 = (_ref8 = (_customer$id = customer.id) !== null && _customer$id !== void 0 ? _customer$id : raw.customer_id) !== null && _ref8 !== void 0 ? _ref8 : raw.customerId) !== null && _ref7 !== void 0 ? _ref7 : null;
366
+ }
367
+ }, {
368
+ key: "hasUsableCustomerDetails",
369
+ value: function hasUsableCustomerDetails(customer) {
370
+ return !!(customer.name || customer.phone || customer.email || customer.display_name || customer.customer_name);
371
+ }
372
+
164
373
  /**
165
374
  * 更新当前预约的 appointment_status。
166
375
  *
@@ -175,66 +384,65 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
175
384
  * @param status 目标状态(如 'confirmed')
176
385
  * @returns 接口返回的 data
177
386
  */
178
- )
179
387
  }, {
180
388
  key: "setBookingStatus",
181
389
  value: (function () {
182
- var _setBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(status) {
390
+ var _setBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(status) {
183
391
  var _this$store$order, _this$store$order$get;
184
392
  var tempOrder, orderId, scheduleId, bookings, previous, _data, res;
185
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
186
- while (1) switch (_context3.prev = _context3.next) {
393
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
394
+ while (1) switch (_context6.prev = _context6.next) {
187
395
  case 0:
188
396
  tempOrder = (_this$store$order = this.store.order) === null || _this$store$order === void 0 || (_this$store$order$get = _this$store$order.getTempOrder) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.call(_this$store$order);
189
397
  if (tempOrder) {
190
- _context3.next = 3;
398
+ _context6.next = 3;
191
399
  break;
192
400
  }
193
401
  throw new Error('setBookingStatus: tempOrder 未加载');
194
402
  case 3:
195
403
  orderId = tempOrder.order_id;
196
404
  if (!(orderId === undefined || orderId === null)) {
197
- _context3.next = 6;
405
+ _context6.next = 6;
198
406
  break;
199
407
  }
200
408
  throw new Error('setBookingStatus: tempOrder.order_id 缺失');
201
409
  case 6:
202
410
  scheduleId = resolveScheduleId(tempOrder);
203
411
  if (!(scheduleId === null)) {
204
- _context3.next = 9;
412
+ _context6.next = 9;
205
413
  break;
206
414
  }
207
415
  throw new Error('setBookingStatus: 无法解析 schedule id(metadata 与 root booking 均缺失)');
208
416
  case 9:
209
417
  bookings = Array.isArray(tempOrder.bookings) ? tempOrder.bookings : [];
210
418
  previous = applyBookingsStatus(bookings, status);
211
- _context3.prev = 11;
212
- _context3.next = 14;
419
+ _context6.prev = 11;
420
+ _context6.next = 14;
213
421
  return this.request.put("/schedule/booking/appointment-status/".concat(scheduleId), {
214
422
  appointment_status: status
215
423
  });
216
424
  case 14:
217
- res = _context3.sent;
218
- _context3.next = 17;
425
+ res = _context6.sent;
426
+ _context6.next = 17;
219
427
  return this.refreshSalesDetail();
220
428
  case 17:
221
429
  this.core.effects.emit("".concat(this.name, ":onBookingStatusChange"), {
222
430
  orderId: orderId,
223
431
  status: status
224
432
  });
225
- return _context3.abrupt("return", (_data = res === null || res === void 0 ? void 0 : res.data) !== null && _data !== void 0 ? _data : res);
433
+ return _context6.abrupt("return", (_data = res === null || res === void 0 ? void 0 : res.data) !== null && _data !== void 0 ? _data : res);
226
434
  case 21:
227
- _context3.prev = 21;
228
- _context3.t0 = _context3["catch"](11);
435
+ _context6.prev = 21;
436
+ _context6.t0 = _context6["catch"](11);
229
437
  restoreBookingsStatus(bookings, previous);
230
- throw _context3.t0;
438
+ throw _context6.t0;
231
439
  case 25:
232
440
  case "end":
233
- return _context3.stop();
441
+ return _context6.stop();
234
442
  }
235
- }, _callee3, this, [[11, 21]]);
443
+ }, _callee6, this, [[11, 21]]);
236
444
  }));
237
- function setBookingStatus(_x3) {
445
+ function setBookingStatus(_x7) {
238
446
  return _setBookingStatus.apply(this, arguments);
239
447
  }
240
448
  return setBookingStatus;
@@ -253,35 +461,35 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
253
461
  }, {
254
462
  key: "refreshSalesDetail",
255
463
  value: (function () {
256
- var _refreshSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
464
+ var _refreshSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
257
465
  var _this$store$order2, _this$store$order2$ge;
258
466
  var tempOrder, orderId;
259
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
260
- while (1) switch (_context4.prev = _context4.next) {
467
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
468
+ while (1) switch (_context7.prev = _context7.next) {
261
469
  case 0:
262
470
  tempOrder = (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || (_this$store$order2$ge = _this$store$order2.getTempOrder) === null || _this$store$order2$ge === void 0 ? void 0 : _this$store$order2$ge.call(_this$store$order2);
263
471
  if (tempOrder) {
264
- _context4.next = 3;
472
+ _context7.next = 3;
265
473
  break;
266
474
  }
267
475
  throw new Error('refreshSalesDetail: tempOrder 未加载');
268
476
  case 3:
269
477
  orderId = tempOrder.order_id;
270
478
  if (!(orderId === undefined || orderId === null)) {
271
- _context4.next = 6;
479
+ _context7.next = 6;
272
480
  break;
273
481
  }
274
482
  throw new Error('refreshSalesDetail: tempOrder.order_id 缺失');
275
483
  case 6:
276
- return _context4.abrupt("return", this.loadSalesDetail({
484
+ return _context7.abrupt("return", this.loadSalesDetail({
277
485
  orderId: Number(orderId),
278
486
  forceRemote: true
279
487
  }));
280
488
  case 7:
281
489
  case "end":
282
- return _context4.stop();
490
+ return _context7.stop();
283
491
  }
284
- }, _callee4, this);
492
+ }, _callee7, this);
285
493
  }));
286
494
  function refreshSalesDetail() {
287
495
  return _refreshSalesDetail.apply(this, arguments);
@@ -297,50 +505,111 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
297
505
  }, {
298
506
  key: "loadProducts",
299
507
  value: (function () {
300
- var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
508
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
301
509
  var params,
302
510
  options,
303
511
  schedule_date,
304
512
  customer_id,
305
513
  menu_list_ids,
306
514
  schedule_datetime,
515
+ bookingDate,
307
516
  _result,
308
- _args5 = arguments;
309
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
310
- while (1) switch (_context5.prev = _context5.next) {
517
+ _args8 = arguments;
518
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
519
+ while (1) switch (_context8.prev = _context8.next) {
311
520
  case 0:
312
- params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
313
- options = _args5.length > 1 ? _args5[1] : undefined;
314
- schedule_date = params.schedule_date, customer_id = params.customer_id, menu_list_ids = params.menu_list_ids, schedule_datetime = params.schedule_datetime;
315
- _context5.prev = 3;
316
- _context5.next = 6;
521
+ params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
522
+ options = _args8.length > 1 ? _args8[1] : undefined;
523
+ schedule_date = params.schedule_date, customer_id = params.customer_id, menu_list_ids = params.menu_list_ids, schedule_datetime = params.schedule_datetime; // 优先写入 schedule_datetime(含时分),供加购 presetStartTime 与 TimeBar 对齐;
524
+ // requiresDetail 弹窗仍通过 formatBookingDateForUI 只取日历日 YYYY-MM-DD。
525
+ bookingDate = schedule_datetime || schedule_date || '';
526
+ if (bookingDate) {
527
+ this.setBookingDate(bookingDate);
528
+ }
529
+ _context8.prev = 5;
530
+ _context8.next = 8;
317
531
  return this.store.products.loadProducts(_objectSpread(_objectSpread({
318
532
  with_count: ['bundleGroup', 'optionGroup'],
319
533
  with_schedule: 1
320
534
  }, params), {}, {
321
535
  cacheId: this.cacheId
322
536
  }), options);
323
- case 6:
324
- _result = _context5.sent;
537
+ case 8:
538
+ _result = _context8.sent;
325
539
  this.productCatalog = Array.isArray(_result) ? _toConsumableArray(_result) : [];
326
540
  this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), _result);
327
- return _context5.abrupt("return", _result);
328
- case 12:
329
- _context5.prev = 12;
330
- _context5.t0 = _context5["catch"](3);
331
- console.error('Failed to load products:', _context5.t0);
332
- throw _context5.t0;
333
- case 16:
541
+ return _context8.abrupt("return", _result);
542
+ case 14:
543
+ _context8.prev = 14;
544
+ _context8.t0 = _context8["catch"](5);
545
+ console.error('Failed to load products:', _context8.t0);
546
+ throw _context8.t0;
547
+ case 18:
334
548
  case "end":
335
- return _context5.stop();
549
+ return _context8.stop();
336
550
  }
337
- }, _callee5, this, [[3, 12]]);
551
+ }, _callee8, this, [[5, 14]]);
338
552
  }));
339
553
  function loadProducts() {
340
554
  return _loadProducts.apply(this, arguments);
341
555
  }
342
556
  return loadProducts;
343
557
  }()
558
+ /**
559
+ * 只读查询单商品详情:走 ProductList 报价查询,但不写 productCatalog、
560
+ * 不 emit onProductsLoaded、不修改 BookingDate。
561
+ *
562
+ * 供「列表已 loadProducts、仅需补 product_resource / capacity」等场景使用,
563
+ * 避免 loadProductDetail 覆盖左侧商品列表。
564
+ *
565
+ * @example
566
+ * const detail = await bookingTicket.queryProductDetail({
567
+ * product_id: 2,
568
+ * schedule_date: '2030-01-15',
569
+ * schedule_datetime: '2030-01-15 10:00:00',
570
+ * });
571
+ */
572
+ )
573
+ }, {
574
+ key: "queryProductDetail",
575
+ value: (function () {
576
+ var _queryProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params, options) {
577
+ var product_id, queryParams, _result2, list;
578
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
579
+ while (1) switch (_context9.prev = _context9.next) {
580
+ case 0:
581
+ product_id = params.product_id, queryParams = _objectWithoutProperties(params, _excluded2);
582
+ _context9.prev = 1;
583
+ _context9.next = 4;
584
+ return this.store.products.loadProducts(_objectSpread(_objectSpread({
585
+ with_count: ['bundleGroup', 'optionGroup'],
586
+ with_schedule: 1
587
+ }, queryParams), {}, {
588
+ product_ids: [product_id],
589
+ cacheId: this.cacheId
590
+ }), options);
591
+ case 4:
592
+ _result2 = _context9.sent;
593
+ list = Array.isArray(_result2) ? _result2 : [];
594
+ return _context9.abrupt("return", list.find(function (product) {
595
+ return Number(product.id) === Number(product_id);
596
+ }));
597
+ case 9:
598
+ _context9.prev = 9;
599
+ _context9.t0 = _context9["catch"](1);
600
+ console.error('Failed to query product detail:', _context9.t0);
601
+ throw _context9.t0;
602
+ case 13:
603
+ case "end":
604
+ return _context9.stop();
605
+ }
606
+ }, _callee9, this, [[1, 9]]);
607
+ }));
608
+ function queryProductDetail(_x8, _x9) {
609
+ return _queryProductDetail.apply(this, arguments);
610
+ }
611
+ return queryProductDetail;
612
+ }()
344
613
  /**
345
614
  * 按预约时间加载单个商品详情。
346
615
  * 价格仍由 server products 的报价单桥接统一计算,避免 solution 实例重复请求报价单。
@@ -349,28 +618,28 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
349
618
  }, {
350
619
  key: "loadProductDetail",
351
620
  value: (function () {
352
- var _loadProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params, options) {
621
+ var _loadProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params, options) {
353
622
  var product_id, queryParams, products;
354
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
355
- while (1) switch (_context6.prev = _context6.next) {
623
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
624
+ while (1) switch (_context10.prev = _context10.next) {
356
625
  case 0:
357
- product_id = params.product_id, queryParams = _objectWithoutProperties(params, _excluded2);
358
- _context6.next = 3;
626
+ product_id = params.product_id, queryParams = _objectWithoutProperties(params, _excluded3);
627
+ _context10.next = 3;
359
628
  return this.loadProducts(_objectSpread(_objectSpread({}, queryParams), {}, {
360
629
  product_ids: [product_id]
361
630
  }), options);
362
631
  case 3:
363
- products = _context6.sent;
364
- return _context6.abrupt("return", products.find(function (product) {
632
+ products = _context10.sent;
633
+ return _context10.abrupt("return", products.find(function (product) {
365
634
  return Number(product.id) === Number(product_id);
366
635
  }));
367
636
  case 5:
368
637
  case "end":
369
- return _context6.stop();
638
+ return _context10.stop();
370
639
  }
371
- }, _callee6, this);
640
+ }, _callee10, this);
372
641
  }));
373
- function loadProductDetail(_x4, _x5) {
642
+ function loadProductDetail(_x10, _x11) {
374
643
  return _loadProductDetail.apply(this, arguments);
375
644
  }
376
645
  return loadProductDetail;
@@ -403,16 +672,16 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
403
672
  }, {
404
673
  key: "getProducts",
405
674
  value: (function () {
406
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
407
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
408
- while (1) switch (_context7.prev = _context7.next) {
675
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
676
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
677
+ while (1) switch (_context11.prev = _context11.next) {
409
678
  case 0:
410
- return _context7.abrupt("return", this.store.products.getProducts());
679
+ return _context11.abrupt("return", this.store.products.getProducts());
411
680
  case 1:
412
681
  case "end":
413
- return _context7.stop();
682
+ return _context11.stop();
414
683
  }
415
- }, _callee7, this);
684
+ }, _callee11, this);
416
685
  }));
417
686
  function getProducts() {
418
687
  return _getProducts.apply(this, arguments);
@@ -465,18 +734,18 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
465
734
  }, {
466
735
  key: "getProductByIds",
467
736
  value: (function () {
468
- var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(ids) {
469
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
470
- while (1) switch (_context8.prev = _context8.next) {
737
+ var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(ids) {
738
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
739
+ while (1) switch (_context12.prev = _context12.next) {
471
740
  case 0:
472
- return _context8.abrupt("return", this.store.products.getProductByIds(ids));
741
+ return _context12.abrupt("return", this.store.products.getProductByIds(ids));
473
742
  case 1:
474
743
  case "end":
475
- return _context8.stop();
744
+ return _context12.stop();
476
745
  }
477
- }, _callee8, this);
746
+ }, _callee12, this);
478
747
  }));
479
- function getProductByIds(_x6) {
748
+ function getProductByIds(_x12) {
480
749
  return _getProductByIds.apply(this, arguments);
481
750
  }
482
751
  return getProductByIds;
@@ -490,27 +759,27 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
490
759
  }, {
491
760
  key: "getScheduleTimePoints",
492
761
  value: (function () {
493
- var _getScheduleTimePoints = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
762
+ var _getScheduleTimePoints = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(params) {
494
763
  var result;
495
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
496
- while (1) switch (_context9.prev = _context9.next) {
764
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
765
+ while (1) switch (_context13.prev = _context13.next) {
497
766
  case 0:
498
- _context9.next = 2;
767
+ _context13.next = 2;
499
768
  return this.request.post('/menu/schedule-time-points', {
500
769
  menu_list_ids: params.menu_list_ids
501
770
  }, {
502
771
  osServer: true
503
772
  });
504
773
  case 2:
505
- result = _context9.sent;
506
- return _context9.abrupt("return", result.data || []);
774
+ result = _context13.sent;
775
+ return _context13.abrupt("return", result.data || []);
507
776
  case 4:
508
777
  case "end":
509
- return _context9.stop();
778
+ return _context13.stop();
510
779
  }
511
- }, _callee9, this);
780
+ }, _callee13, this);
512
781
  }));
513
- function getScheduleTimePoints(_x7) {
782
+ function getScheduleTimePoints(_x13) {
514
783
  return _getScheduleTimePoints.apply(this, arguments);
515
784
  }
516
785
  return getScheduleTimePoints;
@@ -524,30 +793,30 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
524
793
  }, {
525
794
  key: "getCustomerList",
526
795
  value: (function () {
527
- var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
796
+ var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
528
797
  var params,
529
- _result2,
530
- _args10 = arguments;
531
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
532
- while (1) switch (_context10.prev = _context10.next) {
798
+ _result3,
799
+ _args14 = arguments;
800
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
801
+ while (1) switch (_context14.prev = _context14.next) {
533
802
  case 0:
534
- params = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
535
- _context10.prev = 1;
536
- _context10.next = 4;
803
+ params = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
804
+ _context14.prev = 1;
805
+ _context14.next = 4;
537
806
  return this.store.customer.getCustomerList(params);
538
807
  case 4:
539
- _result2 = _context10.sent;
540
- return _context10.abrupt("return", _result2);
808
+ _result3 = _context14.sent;
809
+ return _context14.abrupt("return", _result3);
541
810
  case 8:
542
- _context10.prev = 8;
543
- _context10.t0 = _context10["catch"](1);
544
- console.error('Failed to get customer list:', _context10.t0);
545
- throw _context10.t0;
811
+ _context14.prev = 8;
812
+ _context14.t0 = _context14["catch"](1);
813
+ console.error('Failed to get customer list:', _context14.t0);
814
+ throw _context14.t0;
546
815
  case 12:
547
816
  case "end":
548
- return _context10.stop();
817
+ return _context14.stop();
549
818
  }
550
- }, _callee10, this, [[1, 8]]);
819
+ }, _callee14, this, [[1, 8]]);
551
820
  }));
552
821
  function getCustomerList() {
553
822
  return _getCustomerList.apply(this, arguments);
@@ -654,14 +923,29 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
654
923
  }, {
655
924
  key: "setOrderCustomer",
656
925
  value: function setOrderCustomer(customer) {
926
+ var _this$store$order$get3;
657
927
  if (!customer) {
658
928
  this.clearOrderCustomer();
659
929
  return;
660
930
  }
931
+ var previousCustomerId = (_this$store$order$get3 = this.store.order.getOrderCustomer()) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.customer_id;
661
932
  var patch = formatOrderCustomerPatch(customer);
933
+ var customerUnchanged = Number(previousCustomerId || 0) === Number(patch.customer_id || 0);
934
+ if (!customerUnchanged) {
935
+ this.discountConfigCacheKey = null;
936
+ this.hasManualDiscountSelection = false;
937
+ }
662
938
  this.store.order.setOrderCustomer(patch, customer);
939
+ if (customerUnchanged) {
940
+ return;
941
+ }
663
942
  var next = this.buildOrderCustomerPayload();
664
943
  this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), next);
944
+ this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
945
+ // 客户切换可能改变可用促销/赠品;触发一次重算(recursion-safe)。
946
+ void this.store.order.applyPromotion().catch(function (error) {
947
+ console.error('[BookingTicket] applyPromotion after customer change failed', error);
948
+ });
665
949
  }
666
950
 
667
951
  /**
@@ -688,11 +972,63 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
688
972
  }, {
689
973
  key: "clearOrderCustomer",
690
974
  value: function clearOrderCustomer() {
975
+ var _discountModule$setOr,
976
+ _discountModule$setDi,
977
+ _this3 = this;
691
978
  this.store.order.clearOrderCustomer();
979
+ this.discountConfigCacheKey = null;
980
+ this.hasManualDiscountSelection = false;
981
+ var orderStore = this.store.order.store || {};
982
+ var discountModule = orderStore.discount;
983
+ void (discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, []));
984
+ void (discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, []));
985
+ this.store.order.applyDiscount();
986
+ void this.store.order.recalculateSummary({
987
+ createIfMissing: true
988
+ }).then(function () {
989
+ return _this3.store.order.persistTempOrder();
990
+ }).catch(function (error) {
991
+ console.error('Failed to recalculate summary after clearing customer:', error);
992
+ });
692
993
  this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), null);
693
994
  }
694
995
 
695
- /** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */
996
+ /**
997
+ * 重置 tempOrder,并同步清空下单客户运行态。
998
+ *
999
+ * OrderModule.restoreOrder 会重建空单(customer_id 已为 null),但不会:
1000
+ * - emit BookingTicket `onOrderCustomerChange`
1001
+ * - 重置 CustomerModule.selectedCustomer(老路 getActiveCustomer)
1002
+ *
1003
+ * 因此在 super.restoreOrder 之后显式清客户,保证 SalesSdk / ticketBooking 订阅方与 tempOrder 一致。
1004
+ */
1005
+ }, {
1006
+ key: "restoreOrder",
1007
+ value: (function () {
1008
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1009
+ var _this$store$customer;
1010
+ var tempOrder;
1011
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1012
+ while (1) switch (_context15.prev = _context15.next) {
1013
+ case 0:
1014
+ _context15.next = 2;
1015
+ return _get(_getPrototypeOf(BookingTicketImpl.prototype), "restoreOrder", this).call(this);
1016
+ case 2:
1017
+ tempOrder = _context15.sent;
1018
+ this.clearOrderCustomer();
1019
+ (_this$store$customer = this.store.customer) === null || _this$store$customer === void 0 || _this$store$customer.setSelectedCustomer(null);
1020
+ return _context15.abrupt("return", tempOrder);
1021
+ case 6:
1022
+ case "end":
1023
+ return _context15.stop();
1024
+ }
1025
+ }, _callee15, this);
1026
+ }));
1027
+ function restoreOrder() {
1028
+ return _restoreOrder.apply(this, arguments);
1029
+ }
1030
+ return restoreOrder;
1031
+ }() /** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */)
696
1032
  }, {
697
1033
  key: "buildOrderCustomerPayload",
698
1034
  value: function buildOrderCustomerPayload() {
@@ -703,6 +1039,56 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
703
1039
  snapshot: this.store.order.getOrderCustomerSnapshot()
704
1040
  };
705
1041
  }
1042
+ }, {
1043
+ key: "refreshDiscountConfigAfterOrderCustomerChange",
1044
+ value: function refreshDiscountConfigAfterOrderCustomerChange(customerId) {
1045
+ var _this4 = this;
1046
+ if (!customerId || customerId === 1) return;
1047
+ if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
1048
+ return;
1049
+ }
1050
+ var previousRefresh = this.orderCustomerDiscountRefreshInFlight;
1051
+ var refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1052
+ var currentCustomer;
1053
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1054
+ while (1) switch (_context16.prev = _context16.next) {
1055
+ case 0:
1056
+ if (!previousRefresh) {
1057
+ _context16.next = 3;
1058
+ break;
1059
+ }
1060
+ _context16.next = 3;
1061
+ return previousRefresh.catch(function () {
1062
+ return undefined;
1063
+ });
1064
+ case 3:
1065
+ currentCustomer = _this4.store.order.getOrderCustomer();
1066
+ if (!(!currentCustomer || Number(currentCustomer.customer_id) !== customerId)) {
1067
+ _context16.next = 6;
1068
+ break;
1069
+ }
1070
+ return _context16.abrupt("return");
1071
+ case 6:
1072
+ _context16.next = 8;
1073
+ return _this4.loadDiscountConfig({
1074
+ customerId: customerId
1075
+ });
1076
+ case 8:
1077
+ case "end":
1078
+ return _context16.stop();
1079
+ }
1080
+ }, _callee16);
1081
+ }))();
1082
+ this.orderCustomerDiscountRefreshInFlight = refreshTask;
1083
+ this.orderCustomerDiscountRefreshCustomerId = customerId;
1084
+ refreshTask.catch(function (error) {
1085
+ console.error('Failed to load discount config after customer change:', error);
1086
+ }).finally(function () {
1087
+ if (_this4.orderCustomerDiscountRefreshInFlight !== refreshTask) return;
1088
+ _this4.orderCustomerDiscountRefreshInFlight = null;
1089
+ _this4.orderCustomerDiscountRefreshCustomerId = null;
1090
+ });
1091
+ }
706
1092
 
707
1093
  /**
708
1094
  * 获取客户分页信息
@@ -744,29 +1130,29 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
744
1130
  }, {
745
1131
  key: "changeCustomerPage",
746
1132
  value: (function () {
747
- var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(page, pageSize) {
748
- var _result3;
749
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
750
- while (1) switch (_context11.prev = _context11.next) {
1133
+ var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(page, pageSize) {
1134
+ var _result4;
1135
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1136
+ while (1) switch (_context17.prev = _context17.next) {
751
1137
  case 0:
752
- _context11.prev = 0;
753
- _context11.next = 3;
1138
+ _context17.prev = 0;
1139
+ _context17.next = 3;
754
1140
  return this.store.customer.changeCustomerPage(page, pageSize);
755
1141
  case 3:
756
- _result3 = _context11.sent;
757
- return _context11.abrupt("return", _result3);
1142
+ _result4 = _context17.sent;
1143
+ return _context17.abrupt("return", _result4);
758
1144
  case 7:
759
- _context11.prev = 7;
760
- _context11.t0 = _context11["catch"](0);
761
- console.error('Failed to change customer page:', _context11.t0);
762
- throw _context11.t0;
1145
+ _context17.prev = 7;
1146
+ _context17.t0 = _context17["catch"](0);
1147
+ console.error('Failed to change customer page:', _context17.t0);
1148
+ throw _context17.t0;
763
1149
  case 11:
764
1150
  case "end":
765
- return _context11.stop();
1151
+ return _context17.stop();
766
1152
  }
767
- }, _callee11, this, [[0, 7]]);
1153
+ }, _callee17, this, [[0, 7]]);
768
1154
  }));
769
- function changeCustomerPage(_x8, _x9) {
1155
+ function changeCustomerPage(_x14, _x15) {
770
1156
  return _changeCustomerPage.apply(this, arguments);
771
1157
  }
772
1158
  return changeCustomerPage;
@@ -779,28 +1165,28 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
779
1165
  }, {
780
1166
  key: "loadMoreCustomers",
781
1167
  value: (function () {
782
- var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
783
- var _result4;
784
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
785
- while (1) switch (_context12.prev = _context12.next) {
1168
+ var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1169
+ var _result5;
1170
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1171
+ while (1) switch (_context18.prev = _context18.next) {
786
1172
  case 0:
787
- _context12.prev = 0;
788
- _context12.next = 3;
1173
+ _context18.prev = 0;
1174
+ _context18.next = 3;
789
1175
  return this.store.customer.loadMoreCustomers();
790
1176
  case 3:
791
- _result4 = _context12.sent;
792
- this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), _result4);
793
- return _context12.abrupt("return", _result4);
1177
+ _result5 = _context18.sent;
1178
+ this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), _result5);
1179
+ return _context18.abrupt("return", _result5);
794
1180
  case 8:
795
- _context12.prev = 8;
796
- _context12.t0 = _context12["catch"](0);
797
- console.error('Failed to load more customers:', _context12.t0);
798
- throw _context12.t0;
1181
+ _context18.prev = 8;
1182
+ _context18.t0 = _context18["catch"](0);
1183
+ console.error('Failed to load more customers:', _context18.t0);
1184
+ throw _context18.t0;
799
1185
  case 12:
800
1186
  case "end":
801
- return _context12.stop();
1187
+ return _context18.stop();
802
1188
  }
803
- }, _callee12, this, [[0, 8]]);
1189
+ }, _callee18, this, [[0, 8]]);
804
1190
  }));
805
1191
  function loadMoreCustomers() {
806
1192
  return _loadMoreCustomers.apply(this, arguments);
@@ -816,31 +1202,31 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
816
1202
  }, {
817
1203
  key: "resetAndLoadCustomers",
818
1204
  value: (function () {
819
- var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1205
+ var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
820
1206
  var params,
821
- _result5,
822
- _args13 = arguments;
823
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
824
- while (1) switch (_context13.prev = _context13.next) {
1207
+ _result6,
1208
+ _args19 = arguments;
1209
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1210
+ while (1) switch (_context19.prev = _context19.next) {
825
1211
  case 0:
826
- params = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
827
- _context13.prev = 1;
828
- _context13.next = 4;
1212
+ params = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : {};
1213
+ _context19.prev = 1;
1214
+ _context19.next = 4;
829
1215
  return this.store.customer.resetAndLoadCustomers(params);
830
1216
  case 4:
831
- _result5 = _context13.sent;
832
- this.core.effects.emit("".concat(this.name, ":onCustomerListReset"), _result5);
833
- return _context13.abrupt("return", _result5);
1217
+ _result6 = _context19.sent;
1218
+ this.core.effects.emit("".concat(this.name, ":onCustomerListReset"), _result6);
1219
+ return _context19.abrupt("return", _result6);
834
1220
  case 9:
835
- _context13.prev = 9;
836
- _context13.t0 = _context13["catch"](1);
837
- console.error('Failed to reset and load customers:', _context13.t0);
838
- throw _context13.t0;
1221
+ _context19.prev = 9;
1222
+ _context19.t0 = _context19["catch"](1);
1223
+ console.error('Failed to reset and load customers:', _context19.t0);
1224
+ throw _context19.t0;
839
1225
  case 13:
840
1226
  case "end":
841
- return _context13.stop();
1227
+ return _context19.stop();
842
1228
  }
843
- }, _callee13, this, [[1, 9]]);
1229
+ }, _callee19, this, [[1, 9]]);
844
1230
  }));
845
1231
  function resetAndLoadCustomers() {
846
1232
  return _resetAndLoadCustomers.apply(this, arguments);
@@ -885,9 +1271,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
885
1271
  }, {
886
1272
  key: "scanGlobalListener",
887
1273
  value: function scanGlobalListener(callback) {
888
- var _this2 = this;
1274
+ var _this5 = this;
889
1275
  var localSearch = function localSearch(v) {
890
- return _this2.store.products.findProductsByCodeOrBarcode(v);
1276
+ return _this5.store.products.findProductsByCodeOrBarcode(v);
891
1277
  };
892
1278
  var scanCallback = handleGlobalScan(this.request, localSearch);
893
1279
  var safeCallback = function safeCallback(d) {
@@ -1002,15 +1388,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1002
1388
  }, {
1003
1389
  key: "setOtherParams",
1004
1390
  value: (function () {
1005
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
1006
- var _ref2,
1007
- _ref2$cover,
1391
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
1392
+ var _ref10,
1393
+ _ref10$cover,
1008
1394
  cover,
1009
- _args14 = arguments;
1010
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1011
- while (1) switch (_context14.prev = _context14.next) {
1395
+ _args20 = arguments;
1396
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1397
+ while (1) switch (_context20.prev = _context20.next) {
1012
1398
  case 0:
1013
- _ref2 = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {}, _ref2$cover = _ref2.cover, cover = _ref2$cover === void 0 ? false : _ref2$cover;
1399
+ _ref10 = _args20.length > 1 && _args20[1] !== undefined ? _args20[1] : {}, _ref10$cover = _ref10.cover, cover = _ref10$cover === void 0 ? false : _ref10$cover;
1014
1400
  if (cover) {
1015
1401
  this.otherParams = params;
1016
1402
  } else {
@@ -1018,11 +1404,11 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1018
1404
  }
1019
1405
  case 2:
1020
1406
  case "end":
1021
- return _context14.stop();
1407
+ return _context20.stop();
1022
1408
  }
1023
- }, _callee14, this);
1409
+ }, _callee20, this);
1024
1410
  }));
1025
- function setOtherParams(_x10) {
1411
+ function setOtherParams(_x16) {
1026
1412
  return _setOtherParams.apply(this, arguments);
1027
1413
  }
1028
1414
  return setOtherParams;
@@ -1035,21 +1421,299 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1035
1421
  }, {
1036
1422
  key: "getOtherParams",
1037
1423
  value: (function () {
1038
- var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1039
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1040
- while (1) switch (_context15.prev = _context15.next) {
1424
+ var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1425
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1426
+ while (1) switch (_context21.prev = _context21.next) {
1041
1427
  case 0:
1042
- return _context15.abrupt("return", this.otherParams);
1428
+ return _context21.abrupt("return", this.otherParams);
1043
1429
  case 1:
1044
1430
  case "end":
1045
- return _context15.stop();
1431
+ return _context21.stop();
1046
1432
  }
1047
- }, _callee15, this);
1433
+ }, _callee21, this);
1048
1434
  }));
1049
1435
  function getOtherParams() {
1050
1436
  return _getOtherParams.apply(this, arguments);
1051
1437
  }
1052
1438
  return getOtherParams;
1439
+ }() // ─── BookingContext API(透传给 BookingContextModule) ──────────────────────
1440
+ // SalesSdkProvider 挂载时默认调 initBookingContext;也可由 UI 显式 set* 灌入已有数据。
1441
+ /** 拉取 board config 并写入 BookingContext。 */
1442
+ )
1443
+ }, {
1444
+ key: "loadBookingConfig",
1445
+ value: function loadBookingConfig(params) {
1446
+ return this.store.bookingContext.loadBookingConfig(params);
1447
+ }
1448
+
1449
+ /** 拉取资源全集并写入 BookingContext。 */
1450
+ }, {
1451
+ key: "loadBookingResources",
1452
+ value: function loadBookingResources(params) {
1453
+ return this.store.bookingContext.loadResources(params);
1454
+ }
1455
+
1456
+ /** 初始化 BookingContext(date + config + resources)。 */
1457
+ }, {
1458
+ key: "initBookingContext",
1459
+ value: function initBookingContext(params) {
1460
+ return this.store.bookingContext.initBookingContext(params);
1461
+ }
1462
+
1463
+ /** 当前 store 是否已具备与入参等价的 config / resources(无需再请求接口)。 */
1464
+ }, {
1465
+ key: "isBookingContextReady",
1466
+ value: function isBookingContextReady(params) {
1467
+ return this.store.bookingContext.isBookingContextReady(params);
1468
+ }
1469
+
1470
+ /** 写入 booking config(来源:`/core/board/management/config`)。 */
1471
+ }, {
1472
+ key: "setBookingConfig",
1473
+ value: function setBookingConfig(config) {
1474
+ this.store.bookingContext.setBookingConfig(config);
1475
+ }
1476
+
1477
+ /** 读取当前 booking config。 */
1478
+ }, {
1479
+ key: "getBookingConfig",
1480
+ value: function getBookingConfig() {
1481
+ return this.store.bookingContext.getBookingConfig();
1482
+ }
1483
+
1484
+ /** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
1485
+ }, {
1486
+ key: "setResources",
1487
+ value: function setResources(resources) {
1488
+ this.store.bookingContext.setResources(resources);
1489
+ }
1490
+
1491
+ /** 读取资源全集(浅克隆)。 */
1492
+ }, {
1493
+ key: "getResourcesOrigin",
1494
+ value: function getResourcesOrigin() {
1495
+ return this.store.bookingContext.getResourcesOrigin();
1496
+ }
1497
+
1498
+ /** 读取资源全集 map(id → resource)。 */
1499
+ }, {
1500
+ key: "getResourcesOriginMap",
1501
+ value: function getResourcesOriginMap() {
1502
+ return this.store.bookingContext.getResourcesOriginMap();
1503
+ }
1504
+
1505
+ /** 写入当前选择的日期;支持 dayjs / Date / string。 */
1506
+ }, {
1507
+ key: "setBookingDate",
1508
+ value: function setBookingDate(date) {
1509
+ this.store.bookingContext.setDate(date);
1510
+ }
1511
+
1512
+ /** 读取当前选择的日期(统一 string)。 */
1513
+ }, {
1514
+ key: "getBookingDate",
1515
+ value: function getBookingDate() {
1516
+ return this.store.bookingContext.getDate();
1517
+ }
1518
+
1519
+ /** 读取 BookingContext 完整 store(调试 / 测试 / 透传给 SDK 使用)。 */
1520
+ }, {
1521
+ key: "getBookingContextState",
1522
+ value: function getBookingContextState() {
1523
+ return this.store.bookingContext.getState();
1524
+ }
1525
+
1526
+ /** 清空 BookingContext(切租户 / destroy 场景)。 */
1527
+ }, {
1528
+ key: "clearBookingContext",
1529
+ value: function clearBookingContext() {
1530
+ this.store.bookingContext.clear();
1531
+ }
1532
+
1533
+ /**
1534
+ * 构造 BookingContext 计算上下文(供 getProductExtend / getResourceByIds 等读 API 复用)。
1535
+ */
1536
+ }, {
1537
+ key: "buildBookingCalcContext",
1538
+ value: function buildBookingCalcContext(extra) {
1539
+ var _extra$date, _extra$presetStartTim;
1540
+ var state = this.store.bookingContext.getState();
1541
+ var date = (_extra$date = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date !== void 0 ? _extra$date : state.date;
1542
+ return _objectSpread({
1543
+ bookingConfig: state.bookingConfig,
1544
+ resourcesOrigin: state.resourcesOrigin,
1545
+ resourcesOriginMap: state.resourcesOriginMap,
1546
+ date: date,
1547
+ presetStartTime: (_extra$presetStartTim = extra === null || extra === void 0 ? void 0 : extra.presetStartTime) !== null && _extra$presetStartTim !== void 0 ? _extra$presetStartTim : derivePresetStartTimeFromDate(date)
1548
+ }, extra || {});
1549
+ }
1550
+
1551
+ /**
1552
+ * 取商品当前可选资源列表(透传 OS BookingContext utils#getResourceByIds)。
1553
+ * `extraResources` 用于把拖入未绑定的资源也展示出来。
1554
+ */
1555
+ }, {
1556
+ key: "getResourcesForProduct",
1557
+ value: function getResourcesForProduct(product, options) {
1558
+ var _ctx$bookingConfig;
1559
+ var ctx = this.buildBookingCalcContext();
1560
+ return getResourceByIdsUtil(ctx.resourcesOriginMap || {}, product, {
1561
+ resourceTab: (_ctx$bookingConfig = ctx.bookingConfig) === null || _ctx$bookingConfig === void 0 || (_ctx$bookingConfig = _ctx$bookingConfig.config) === null || _ctx$bookingConfig === void 0 ? void 0 : _ctx$bookingConfig.resource_tab,
1562
+ resourcesOrigin: ctx.resourcesOrigin,
1563
+ extraResources: (options === null || options === void 0 ? void 0 : options.extraResources) || []
1564
+ });
1565
+ }
1566
+
1567
+ /**
1568
+ * 拼装 cacheItem 的 _extend / _data(资源 / 容量 / timeObj),与 info2 `getProductExtend` 等价。
1569
+ */
1570
+ }, {
1571
+ key: "getProductExtend",
1572
+ value: function getProductExtend(cacheItem, extra) {
1573
+ return getProductExtendUtil({
1574
+ cacheItem: cacheItem,
1575
+ ctx: this.buildBookingCalcContext(extra)
1576
+ });
1577
+ }
1578
+
1579
+ /**
1580
+ * 取资源不可用原因列表(结构化 enum + params,i18n 文案由 UI 渲染)。
1581
+ */
1582
+ }, {
1583
+ key: "getResourceErrors",
1584
+ value: function getResourceErrors(resource, cacheItem) {
1585
+ return getResourceErrorsUtil(resource, cacheItem);
1586
+ }
1587
+
1588
+ // ─── addProduct 决策 / 转换 API(SDK 加车下沉所需) ─────────────────────────
1589
+ // 这一组方法是 SalesSdkCartContext.addProduct / confirmDetail 的 OS 后端。
1590
+ // 调用方传入 ProductData,OS 自取 bookingContext / customer / date 等上下文,
1591
+ // 输出 (a) autoClose 决策结果或 (b) `{ product, booking }` 协议入参。
1592
+
1593
+ /**
1594
+ * 拼装 addProductDecision 通用上下文(从 store 自取)。
1595
+ */
1596
+ }, {
1597
+ key: "buildAddProductCtx",
1598
+ value: function buildAddProductCtx(extra) {
1599
+ var _extra$date2, _ref11, _this$getOrderCustome, _this$getOrderCustome2, _this$store$order$get4, _extra$presetStartTim2;
1600
+ var bookingContextState = this.store.bookingContext.getState();
1601
+ var date = (_extra$date2 = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date2 !== void 0 ? _extra$date2 : bookingContextState.date;
1602
+ var orderCustomerId = (_ref11 = (_this$getOrderCustome = (_this$getOrderCustome2 = this.getOrderCustomerSnapshot()) === null || _this$getOrderCustome2 === void 0 ? void 0 : _this$getOrderCustome2.id) !== null && _this$getOrderCustome !== void 0 ? _this$getOrderCustome : (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.customer_id) !== null && _ref11 !== void 0 ? _ref11 : undefined;
1603
+ return _objectSpread({
1604
+ bookingConfig: bookingContextState.bookingConfig,
1605
+ resourcesOrigin: bookingContextState.resourcesOrigin,
1606
+ resourcesOriginMap: bookingContextState.resourcesOriginMap,
1607
+ date: date,
1608
+ presetStartTime: (_extra$presetStartTim2 = extra === null || extra === void 0 ? void 0 : extra.presetStartTime) !== null && _extra$presetStartTim2 !== void 0 ? _extra$presetStartTim2 : derivePresetStartTimeFromDate(date),
1609
+ customerId: orderCustomerId
1610
+ }, extra || {});
1611
+ }
1612
+
1613
+ /**
1614
+ * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
1615
+ * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
1616
+ */
1617
+ }, {
1618
+ key: "decideAddProduct",
1619
+ value: function decideAddProduct(item, options) {
1620
+ return decideAddProductUtil(item, this.buildAddProductCtx(options));
1621
+ }
1622
+
1623
+ /** 规格弹窗 callback 后的第二段决策。 */
1624
+ }, {
1625
+ key: "decideAfterDetail",
1626
+ value: function decideAfterDetail(cacheItem, options) {
1627
+ return decideAfterDetailUtil(cacheItem, this.buildAddProductCtx(options));
1628
+ }
1629
+
1630
+ /**
1631
+ * @deprecated 请用 `decideAddProduct`;`autoClose=true` 仅当 action=add。
1632
+ */
1633
+ }, {
1634
+ key: "decideAutoClose",
1635
+ value: function decideAutoClose(item, options) {
1636
+ return decideAutoCloseUtil(item, this.buildAddProductCtx(options));
1637
+ }
1638
+
1639
+ /** 替代 info2 `getIsEject`:商品是否需要弹窗(0/1)。 */
1640
+ }, {
1641
+ key: "getIsEject",
1642
+ value: function getIsEject(item) {
1643
+ var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'select';
1644
+ return getIsEjectUtil(item, type);
1645
+ }
1646
+
1647
+ /** 仅 session 商品(无 variant/option/package)→ true。 */
1648
+ }, {
1649
+ key: "getIsOnlySession",
1650
+ value: function getIsOnlySession(item) {
1651
+ return getIsOnlySessionUtil(item);
1652
+ }
1653
+
1654
+ /**
1655
+ * 拼装 requiresDetail payload(给 SDK 直接 return 给 UI 用)。
1656
+ */
1657
+ }, {
1658
+ key: "buildRequiresDetailPayload",
1659
+ value: function buildRequiresDetailPayload(item, options) {
1660
+ return _buildRequiresDetailPayload(item, this.buildAddProductCtx(options));
1661
+ }
1662
+
1663
+ /**
1664
+ * 把 detail 弹窗回调结果(e, extension_type, detail)转换为 `(product, booking)` 入参。
1665
+ * 内部会先拼 cacheItem,再走 cacheItemToBookingInput 严格协议对齐。
1666
+ */
1667
+ }, {
1668
+ key: "transformDetailToProductAndBooking",
1669
+ value: function transformDetailToProductAndBooking(input) {
1670
+ var item = input.item,
1671
+ preparedCacheItem = input.cacheItem,
1672
+ detailResult = input.detailResult,
1673
+ options = input.options;
1674
+ var ctx = this.buildAddProductCtx(options);
1675
+ var cacheItem = preparedCacheItem || (detailResult ? buildCacheItemFromDetail(item, detailResult, ctx) : buildCacheItemFromCartDetail(item, ctx));
1676
+ return transformDetailToProductAndBookingUtil(cacheItem, ctx);
1677
+ }
1678
+
1679
+ /**
1680
+ * 从已加车的 order line + booking 反查资源编辑抽屉所需的 cacheItem。
1681
+ * 供 SalesSdk「编辑资源」等场景使用;字段语义与 buildCacheItemFromDetail 产出对齐。
1682
+ */
1683
+ }, {
1684
+ key: "buildCacheItemFromOrderLine",
1685
+ value: function buildCacheItemFromOrderLine(input) {
1686
+ return buildCacheItemFromOrderLineUtil(input);
1687
+ }
1688
+
1689
+ /**
1690
+ * 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
1691
+ */
1692
+ }, {
1693
+ key: "buildNormalProductCacheItemFromOrderLine",
1694
+ value: function buildNormalProductCacheItemFromOrderLine(input) {
1695
+ return buildNormalProductCacheItemFromOrderLineUtil(input);
1696
+ }
1697
+
1698
+ /** 文档别名:与 OrderModule.updateOrderProduct 一致。 */
1699
+ }, {
1700
+ key: "updateProductInOrder",
1701
+ value: (function () {
1702
+ var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
1703
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1704
+ while (1) switch (_context22.prev = _context22.next) {
1705
+ case 0:
1706
+ return _context22.abrupt("return", this.updateOrderProduct(params));
1707
+ case 1:
1708
+ case "end":
1709
+ return _context22.stop();
1710
+ }
1711
+ }, _callee22, this);
1712
+ }));
1713
+ function updateProductInOrder(_x17) {
1714
+ return _updateProductInOrder.apply(this, arguments);
1715
+ }
1716
+ return updateProductInOrder;
1053
1717
  }()
1054
1718
  /**
1055
1719
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
@@ -1059,12 +1723,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1059
1723
  }, {
1060
1724
  key: "destroy",
1061
1725
  value: (function () {
1062
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1726
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1063
1727
  var _this$scan;
1064
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1065
- while (1) switch (_context16.prev = _context16.next) {
1728
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1729
+ while (1) switch (_context23.prev = _context23.next) {
1066
1730
  case 0:
1067
- _context16.next = 2;
1731
+ _context23.next = 2;
1068
1732
  return _get(_getPrototypeOf(BookingTicketImpl.prototype), "destroy", this).call(this);
1069
1733
  case 2:
1070
1734
  try {
@@ -1075,9 +1739,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1075
1739
  scanCache.clear();
1076
1740
  case 4:
1077
1741
  case "end":
1078
- return _context16.stop();
1742
+ return _context23.stop();
1079
1743
  }
1080
- }, _callee16, this);
1744
+ }, _callee23, this);
1081
1745
  }));
1082
1746
  function destroy() {
1083
1747
  return _destroy.apply(this, arguments);