@pisell/pisellos 2.2.173 → 2.2.175

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 (159) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/Customer/index.d.ts +0 -6
  3. package/dist/modules/Customer/index.js +83 -129
  4. package/dist/modules/Customer/types.d.ts +0 -2
  5. package/dist/modules/Discount/index.d.ts +4 -2
  6. package/dist/modules/Discount/index.js +93 -8
  7. package/dist/modules/Discount/types.d.ts +7 -1
  8. package/dist/modules/Order/index.d.ts +17 -33
  9. package/dist/modules/Order/index.js +395 -757
  10. package/dist/modules/Order/types.d.ts +17 -58
  11. package/dist/modules/Order/types.js +0 -2
  12. package/dist/modules/Order/utils.d.ts +1 -39
  13. package/dist/modules/Order/utils.js +31 -219
  14. package/dist/modules/Quotation/index.js +5 -16
  15. package/dist/modules/Rules/index.d.ts +0 -4
  16. package/dist/modules/Rules/index.js +10 -26
  17. package/dist/modules/SalesSummary/index.js +2 -4
  18. package/dist/modules/Schedule/index.js +2 -6
  19. package/dist/modules/index.d.ts +0 -1
  20. package/dist/modules/index.js +1 -2
  21. package/dist/server/index.js +6 -10
  22. package/dist/server/modules/order/utils/filterOrders.js +6 -20
  23. package/dist/server/modules/products/index.js +94 -113
  24. package/dist/server/modules/schedule/index.js +6 -13
  25. package/dist/solution/BaseSales/index.d.ts +7 -53
  26. package/dist/solution/BaseSales/index.js +339 -1160
  27. package/dist/solution/BaseSales/types.d.ts +1 -67
  28. package/dist/solution/BaseSales/types.js +1 -3
  29. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +15 -65
  30. package/dist/solution/BaseSales/utils.js +8 -46
  31. package/dist/solution/BookingByStep/index.d.ts +1 -1
  32. package/dist/solution/BookingTicket/index.d.ts +1 -133
  33. package/dist/solution/BookingTicket/index.js +175 -776
  34. package/dist/solution/BookingTicket/types.d.ts +0 -2
  35. package/dist/solution/BookingTicket/types.js +0 -3
  36. package/dist/solution/ScanOrder/index.d.ts +3 -9
  37. package/dist/solution/ScanOrder/index.js +128 -231
  38. package/dist/solution/ScanOrder/utils.js +8 -46
  39. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  40. package/dist/solution/ShopDiscount/index.js +23 -18
  41. package/dist/solution/VenueBooking/index.d.ts +9 -5
  42. package/dist/solution/VenueBooking/index.js +55 -103
  43. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  44. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  45. package/lib/modules/Customer/index.d.ts +0 -6
  46. package/lib/modules/Customer/index.js +11 -26
  47. package/lib/modules/Customer/types.d.ts +0 -2
  48. package/lib/modules/Discount/index.d.ts +4 -2
  49. package/lib/modules/Discount/index.js +63 -8
  50. package/lib/modules/Discount/types.d.ts +7 -1
  51. package/lib/modules/Order/index.d.ts +17 -33
  52. package/lib/modules/Order/index.js +148 -402
  53. package/lib/modules/Order/types.d.ts +17 -58
  54. package/lib/modules/Order/utils.d.ts +1 -39
  55. package/lib/modules/Order/utils.js +22 -197
  56. package/lib/modules/Quotation/index.js +6 -17
  57. package/lib/modules/Rules/index.d.ts +0 -4
  58. package/lib/modules/Rules/index.js +14 -22
  59. package/lib/modules/SalesSummary/index.js +2 -4
  60. package/lib/modules/Schedule/index.js +1 -3
  61. package/lib/modules/index.d.ts +0 -1
  62. package/lib/modules/index.js +1 -3
  63. package/lib/server/index.js +0 -2
  64. package/lib/server/modules/order/utils/filterOrders.js +4 -12
  65. package/lib/server/modules/products/index.js +12 -23
  66. package/lib/server/modules/schedule/index.js +1 -2
  67. package/lib/solution/BaseSales/index.d.ts +7 -53
  68. package/lib/solution/BaseSales/index.js +20 -527
  69. package/lib/solution/BaseSales/types.d.ts +1 -67
  70. package/lib/solution/BaseSales/types.js +1 -3
  71. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +11 -70
  72. package/lib/solution/BaseSales/utils.js +6 -46
  73. package/lib/solution/BookingByStep/index.d.ts +1 -1
  74. package/lib/solution/BookingTicket/index.d.ts +1 -133
  75. package/lib/solution/BookingTicket/index.js +8 -349
  76. package/lib/solution/BookingTicket/types.d.ts +0 -2
  77. package/lib/solution/BookingTicket/types.js +0 -6
  78. package/lib/solution/ScanOrder/index.d.ts +3 -9
  79. package/lib/solution/ScanOrder/index.js +66 -147
  80. package/lib/solution/ScanOrder/utils.js +6 -46
  81. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  82. package/lib/solution/ShopDiscount/index.js +4 -2
  83. package/lib/solution/VenueBooking/index.d.ts +9 -5
  84. package/lib/solution/VenueBooking/index.js +14 -50
  85. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  86. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  87. package/package.json +2 -2
  88. package/dist/modules/BookingContext/index.d.ts +0 -37
  89. package/dist/modules/BookingContext/index.js +0 -436
  90. package/dist/modules/BookingContext/types.d.ts +0 -102
  91. package/dist/modules/BookingContext/types.js +0 -51
  92. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  93. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
  94. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  95. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
  96. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  97. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
  98. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  99. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  100. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  101. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  102. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  103. package/dist/modules/BookingContext/utils/index.js +0 -11
  104. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  105. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  106. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  107. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  108. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  109. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  110. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  111. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  112. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  113. package/dist/modules/BookingContext/utils/resources.js +0 -486
  114. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  115. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  116. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  117. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  118. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  119. package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
  120. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  121. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
  122. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  123. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  124. package/lib/modules/BookingContext/index.d.ts +0 -37
  125. package/lib/modules/BookingContext/index.js +0 -297
  126. package/lib/modules/BookingContext/types.d.ts +0 -102
  127. package/lib/modules/BookingContext/types.js +0 -34
  128. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  129. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
  130. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  131. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
  132. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  133. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
  134. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  135. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  136. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  137. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  138. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  139. package/lib/modules/BookingContext/utils/index.js +0 -43
  140. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  141. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  142. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  143. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  144. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  145. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  146. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  147. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  148. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  149. package/lib/modules/BookingContext/utils/resources.js +0 -377
  150. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  151. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  152. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  153. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  154. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  155. package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
  156. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  157. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
  158. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  159. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
@@ -35,16 +35,12 @@ __export(BookingTicket_exports, {
35
35
  });
36
36
  module.exports = __toCommonJS(BookingTicket_exports);
37
37
  var import_types = require("./types");
38
- var import_BookingContext = require("../../modules/BookingContext");
39
38
  var import_BaseSales = require("../BaseSales");
40
39
  var import_scan = __toESM(require("./utils/scan"));
41
40
  var import_orderCustomer = require("./utils/orderCustomer");
42
41
  var import_handleScan = require("./utils/scan/handleScan");
43
42
  var import_scanCache = __toESM(require("./utils/scan/scanCache"));
44
43
  var import_cartView = require("./utils/cartView");
45
- var import_addProductDecision = require("./utils/addProductDecision");
46
- var import_buildCacheItemFromOrderLine = require("../../modules/BookingContext/utils/buildCacheItemFromOrderLine");
47
- var import_buildNormalProductCacheItemFromOrderLine = require("../../modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine");
48
44
  var import_bookingStatus = require("./utils/bookingStatus");
49
45
  __reExport(BookingTicket_exports, require("./types"), module.exports);
50
46
  var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
@@ -58,18 +54,12 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
58
54
  */
59
55
  this.store = {};
60
56
  this.productCatalog = [];
61
- this.orderCustomerDiscountRefreshInFlight = null;
62
- this.orderCustomerDiscountRefreshCustomerId = null;
63
57
  }
64
58
  /**
65
- * 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext
66
- * bookingContext 是 SalesSdk 加车下沉所需的「预约 UI 上下文」(bookingConfig / resourcesOrigin / date)。
59
+ * 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer。
67
60
  */
68
61
  getRegisteredModuleNames() {
69
- return [...super.getRegisteredModuleNames(), "customer", "bookingContext"];
70
- }
71
- getSubmitOrderSalesChannel() {
72
- return "pos";
62
+ return [...super.getRegisteredModuleNames(), "customer"];
73
63
  }
74
64
  /**
75
65
  * 业务侧子模块工厂:BookingTicket 自带的 createBookingTicketModule 优先匹配;
@@ -106,110 +96,22 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
106
96
  console.log(sales, "1234sales");
107
97
  const customerModule = this.store.customer;
108
98
  const detailCustomer = sales == null ? void 0 : sales.customer;
109
- const orderCustomerSnapshot = this.store.order.getOrderCustomerSnapshot();
110
- const protocolCustomerId = sales == null ? void 0 : sales.customer_id;
111
- const protocolCustomer = protocolCustomerId !== void 0 && protocolCustomerId !== null ? {
112
- id: protocolCustomerId,
113
- name: String((sales == null ? void 0 : sales.customer_name) || ""),
114
- phone: sales == null ? void 0 : sales.phone,
115
- email: sales == null ? void 0 : sales.email,
116
- country_calling_code: sales == null ? void 0 : sales.country_calling_code
117
- } : null;
118
- const selectedCustomer = detailCustomer ?? orderCustomerSnapshot ?? protocolCustomer;
119
- if (customerModule && selectedCustomer) {
120
- const { id: detailCustomerId, ...detailCustomerRest } = selectedCustomer ?? {};
99
+ if (customerModule && detailCustomer) {
100
+ const { id: detailCustomerId, ...detailCustomerRest } = detailCustomer ?? {};
121
101
  const rawId = detailCustomerId ?? "";
122
102
  const customer = {
123
103
  ...detailCustomerRest,
124
104
  id: rawId == null ? "" : rawId,
125
- name: (selectedCustomer == null ? void 0 : selectedCustomer.name) ?? "",
126
- phone: selectedCustomer == null ? void 0 : selectedCustomer.phone,
127
- email: selectedCustomer == null ? void 0 : selectedCustomer.email,
128
- country_calling_code: selectedCustomer == null ? void 0 : selectedCustomer.country_calling_code
105
+ name: (detailCustomer == null ? void 0 : detailCustomer.name) ?? "",
106
+ phone: detailCustomer == null ? void 0 : detailCustomer.phone,
107
+ email: detailCustomer == null ? void 0 : detailCustomer.email,
108
+ country_calling_code: detailCustomer == null ? void 0 : detailCustomer.country_calling_code
129
109
  };
130
110
  customerModule.setSelectedCustomer(customer);
131
111
  this.setOrderCustomer(customer);
132
- await this.store.order.saveDraft();
133
112
  }
134
113
  return sales;
135
114
  }
136
- async scanPromotionCode(code, customerId) {
137
- if (!this.store.order)
138
- throw new Error("order 模块未初始化");
139
- const raw = await this.store.order.scanCode(code, customerId);
140
- if (raw.isAvailable) {
141
- await this.hydrateOrderCustomerFromScanDiscounts(raw.scannedDiscountList);
142
- await this.store.order.recalculateSummary({ createIfMissing: true });
143
- this.store.order.persistTempOrder();
144
- }
145
- return {
146
- isAvailable: raw.isAvailable,
147
- type: raw.type,
148
- unavailableReason: raw.unavailableReason
149
- };
150
- }
151
- async hydrateOrderCustomerFromScanDiscounts(discounts) {
152
- const currentOrderCustomer = this.store.order.getOrderCustomer();
153
- if (currentOrderCustomer)
154
- return;
155
- const customerId = this.getDiscountCustomerId(discounts);
156
- if (!customerId)
157
- return;
158
- const customer = await this.resolveCustomerByDiscountCustomerId(customerId);
159
- if (!customer)
160
- return;
161
- this.store.customer.setSelectedCustomer(customer);
162
- this.setOrderCustomer(customer);
163
- }
164
- getDiscountCustomerId(discounts) {
165
- const discount = discounts.find((item) => item.customer_id != null);
166
- const customerId = Number(discount == null ? void 0 : discount.customer_id);
167
- if (!Number.isFinite(customerId) || customerId <= 0)
168
- return null;
169
- return customerId;
170
- }
171
- async resolveCustomerByDiscountCustomerId(customerId) {
172
- var _a;
173
- const localCustomers = this.store.customer.getCustomers();
174
- const localCustomer = this.findCustomerById(localCustomers, customerId);
175
- const normalizedLocalCustomer = localCustomer ? this.normalizeCustomer(localCustomer) : null;
176
- if (normalizedLocalCustomer && this.hasUsableCustomerDetails(normalizedLocalCustomer)) {
177
- return normalizedLocalCustomer;
178
- }
179
- const result = await this.store.customer.queryCustomerList({
180
- ids: [customerId],
181
- skip: 1,
182
- num: 1
183
- });
184
- const remoteCustomer = this.findCustomerById((result == null ? void 0 : result.list) || [], customerId) || ((_a = result == null ? void 0 : result.list) == null ? void 0 : _a[0]) || null;
185
- return remoteCustomer ? this.normalizeCustomer(remoteCustomer) : null;
186
- }
187
- findCustomerById(customers = [], customerId) {
188
- return customers.find((customer) => {
189
- const rawId = this.getRawCustomerId(customer);
190
- return rawId !== null && String(rawId) === String(customerId);
191
- }) || null;
192
- }
193
- normalizeCustomer(customer) {
194
- const raw = customer;
195
- const rawId = this.getRawCustomerId(customer);
196
- const name = customer.name || raw.display_name || raw.nickname || raw.customer_name || [raw.first_name, raw.last_name].filter(Boolean).join(" ") || "";
197
- return {
198
- ...customer,
199
- id: rawId ?? customer.id,
200
- name,
201
- phone: customer.phone ?? raw.phone ?? raw.mobile ?? "",
202
- email: customer.email ?? raw.email ?? "",
203
- country_calling_code: customer.country_calling_code ?? raw.country_calling_code ?? ""
204
- };
205
- }
206
- getRawCustomerId(customer) {
207
- const raw = customer;
208
- return customer.id ?? raw.customer_id ?? raw.customerId ?? null;
209
- }
210
- hasUsableCustomerDetails(customer) {
211
- return !!(customer.name || customer.phone || customer.email || customer.display_name || customer.customer_name);
212
- }
213
115
  /**
214
116
  * 更新当前预约的 appointment_status。
215
117
  *
@@ -290,10 +192,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
290
192
  */
291
193
  async loadProducts(params = {}, options) {
292
194
  const { schedule_date, customer_id, menu_list_ids, schedule_datetime } = params;
293
- const bookingDate = schedule_datetime || schedule_date || "";
294
- if (bookingDate) {
295
- this.setBookingDate(bookingDate);
296
- }
297
195
  try {
298
196
  const result = await this.store.products.loadProducts({
299
197
  with_count: ["bundleGroup", "optionGroup"],
@@ -482,21 +380,14 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
482
380
  * 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
483
381
  */
484
382
  setOrderCustomer(customer) {
485
- var _a;
486
383
  if (!customer) {
487
384
  this.clearOrderCustomer();
488
385
  return;
489
386
  }
490
- const previousCustomerId = (_a = this.store.order.getOrderCustomer()) == null ? void 0 : _a.customer_id;
491
387
  const patch = (0, import_orderCustomer.formatOrderCustomerPatch)(customer);
492
- if (Number(previousCustomerId || 0) !== Number(patch.customer_id || 0)) {
493
- this.discountConfigCacheKey = null;
494
- this.hasManualDiscountSelection = false;
495
- }
496
388
  this.store.order.setOrderCustomer(patch, customer);
497
389
  const next = this.buildOrderCustomerPayload();
498
390
  this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
499
- this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
500
391
  }
501
392
  /**
502
393
  * 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
@@ -514,36 +405,9 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
514
405
  * 清空下单客户(协议字段 + snapshot)。
515
406
  */
516
407
  clearOrderCustomer() {
517
- var _a, _b;
518
408
  this.store.order.clearOrderCustomer();
519
- this.discountConfigCacheKey = null;
520
- this.hasManualDiscountSelection = false;
521
- const orderStore = this.store.order.store || {};
522
- const discountModule = orderStore.discount;
523
- void ((_a = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _a.call(discountModule, []));
524
- void ((_b = discountModule == null ? void 0 : discountModule.setDiscountList) == null ? void 0 : _b.call(discountModule, []));
525
- this.store.order.applyDiscount();
526
- void this.store.order.recalculateSummary({ createIfMissing: true }).then(() => this.store.order.persistTempOrder()).catch((error) => {
527
- console.error("Failed to recalculate summary after clearing customer:", error);
528
- });
529
409
  this.core.effects.emit(`${this.name}:onOrderCustomerChange`, null);
530
410
  }
531
- /**
532
- * 重置 tempOrder,并同步清空下单客户运行态。
533
- *
534
- * OrderModule.restoreOrder 会重建空单(customer_id 已为 null),但不会:
535
- * - emit BookingTicket `onOrderCustomerChange`
536
- * - 重置 CustomerModule.selectedCustomer(老路 getActiveCustomer)
537
- *
538
- * 因此在 super.restoreOrder 之后显式清客户,保证 SalesSdk / ticketBooking 订阅方与 tempOrder 一致。
539
- */
540
- async restoreOrder() {
541
- var _a;
542
- const tempOrder = await super.restoreOrder();
543
- this.clearOrderCustomer();
544
- (_a = this.store.customer) == null ? void 0 : _a.setSelectedCustomer(null);
545
- return tempOrder;
546
- }
547
411
  /** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */
548
412
  buildOrderCustomerPayload() {
549
413
  const patch = this.store.order.getOrderCustomer();
@@ -554,34 +418,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
554
418
  snapshot: this.store.order.getOrderCustomerSnapshot()
555
419
  };
556
420
  }
557
- refreshDiscountConfigAfterOrderCustomerChange(customerId) {
558
- if (!customerId || customerId === 1)
559
- return;
560
- if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
561
- return;
562
- }
563
- const previousRefresh = this.orderCustomerDiscountRefreshInFlight;
564
- const refreshTask = (async () => {
565
- if (previousRefresh) {
566
- await previousRefresh.catch(() => void 0);
567
- }
568
- const currentCustomer = this.store.order.getOrderCustomer();
569
- if (!currentCustomer || Number(currentCustomer.customer_id) !== customerId) {
570
- return;
571
- }
572
- await this.loadDiscountConfig({ customerId });
573
- })();
574
- this.orderCustomerDiscountRefreshInFlight = refreshTask;
575
- this.orderCustomerDiscountRefreshCustomerId = customerId;
576
- refreshTask.catch((error) => {
577
- console.error("Failed to load discount config after customer change:", error);
578
- }).finally(() => {
579
- if (this.orderCustomerDiscountRefreshInFlight !== refreshTask)
580
- return;
581
- this.orderCustomerDiscountRefreshInFlight = null;
582
- this.orderCustomerDiscountRefreshCustomerId = null;
583
- });
584
- }
585
421
  /**
586
422
  * 获取客户分页信息
587
423
  * @returns 分页信息
@@ -777,183 +613,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
777
613
  async getOtherParams() {
778
614
  return this.otherParams;
779
615
  }
780
- // ─── BookingContext API(透传给 BookingContextModule) ──────────────────────
781
- // SalesSdkProvider 挂载时默认调 initBookingContext;也可由 UI 显式 set* 灌入已有数据。
782
- /** 拉取 board config 并写入 BookingContext。 */
783
- loadBookingConfig(params) {
784
- return this.store.bookingContext.loadBookingConfig(params);
785
- }
786
- /** 拉取资源全集并写入 BookingContext。 */
787
- loadBookingResources(params) {
788
- return this.store.bookingContext.loadResources(params);
789
- }
790
- /** 初始化 BookingContext(date + config + resources)。 */
791
- initBookingContext(params) {
792
- return this.store.bookingContext.initBookingContext(params);
793
- }
794
- /** 当前 store 是否已具备与入参等价的 config / resources(无需再请求接口)。 */
795
- isBookingContextReady(params) {
796
- return this.store.bookingContext.isBookingContextReady(params);
797
- }
798
- /** 写入 booking config(来源:`/core/board/management/config`)。 */
799
- setBookingConfig(config) {
800
- this.store.bookingContext.setBookingConfig(config);
801
- }
802
- /** 读取当前 booking config。 */
803
- getBookingConfig() {
804
- return this.store.bookingContext.getBookingConfig();
805
- }
806
- /** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
807
- setResources(resources) {
808
- this.store.bookingContext.setResources(resources);
809
- }
810
- /** 读取资源全集(浅克隆)。 */
811
- getResourcesOrigin() {
812
- return this.store.bookingContext.getResourcesOrigin();
813
- }
814
- /** 读取资源全集 map(id → resource)。 */
815
- getResourcesOriginMap() {
816
- return this.store.bookingContext.getResourcesOriginMap();
817
- }
818
- /** 写入当前选择的日期;支持 dayjs / Date / string。 */
819
- setBookingDate(date) {
820
- this.store.bookingContext.setDate(date);
821
- }
822
- /** 读取当前选择的日期(统一 string)。 */
823
- getBookingDate() {
824
- return this.store.bookingContext.getDate();
825
- }
826
- /** 读取 BookingContext 完整 store(调试 / 测试 / 透传给 SDK 使用)。 */
827
- getBookingContextState() {
828
- return this.store.bookingContext.getState();
829
- }
830
- /** 清空 BookingContext(切租户 / destroy 场景)。 */
831
- clearBookingContext() {
832
- this.store.bookingContext.clear();
833
- }
834
- /**
835
- * 构造 BookingContext 计算上下文(供 getProductExtend / getResourceByIds 等读 API 复用)。
836
- */
837
- buildBookingCalcContext(extra) {
838
- const state = this.store.bookingContext.getState();
839
- const date = (extra == null ? void 0 : extra.date) ?? state.date;
840
- return {
841
- bookingConfig: state.bookingConfig,
842
- resourcesOrigin: state.resourcesOrigin,
843
- resourcesOriginMap: state.resourcesOriginMap,
844
- date,
845
- presetStartTime: (extra == null ? void 0 : extra.presetStartTime) ?? (0, import_BookingContext.derivePresetStartTimeFromDate)(date),
846
- ...extra || {}
847
- };
848
- }
849
- /**
850
- * 取商品当前可选资源列表(透传 OS BookingContext utils#getResourceByIds)。
851
- * `extraResources` 用于把拖入未绑定的资源也展示出来。
852
- */
853
- getResourcesForProduct(product, options) {
854
- var _a, _b;
855
- const ctx = this.buildBookingCalcContext();
856
- return (0, import_BookingContext.getResourceByIds)(ctx.resourcesOriginMap || {}, product, {
857
- resourceTab: (_b = (_a = ctx.bookingConfig) == null ? void 0 : _a.config) == null ? void 0 : _b.resource_tab,
858
- resourcesOrigin: ctx.resourcesOrigin,
859
- extraResources: (options == null ? void 0 : options.extraResources) || []
860
- });
861
- }
862
- /**
863
- * 拼装 cacheItem 的 _extend / _data(资源 / 容量 / timeObj),与 info2 `getProductExtend` 等价。
864
- */
865
- getProductExtend(cacheItem, extra) {
866
- return (0, import_BookingContext.getProductExtend)({
867
- cacheItem,
868
- ctx: this.buildBookingCalcContext(extra)
869
- });
870
- }
871
- /**
872
- * 取资源不可用原因列表(结构化 enum + params,i18n 文案由 UI 渲染)。
873
- */
874
- getResourceErrors(resource, cacheItem) {
875
- return (0, import_BookingContext.getResourceErrors)(resource, cacheItem);
876
- }
877
- // ─── addProduct 决策 / 转换 API(SDK 加车下沉所需) ─────────────────────────
878
- // 这一组方法是 SalesSdkCartContext.addProduct / confirmDetail 的 OS 后端。
879
- // 调用方传入 ProductData,OS 自取 bookingContext / customer / date 等上下文,
880
- // 输出 (a) autoClose 决策结果或 (b) `{ product, booking }` 协议入参。
881
- /**
882
- * 拼装 addProductDecision 通用上下文(从 store 自取)。
883
- */
884
- buildAddProductCtx(extra) {
885
- var _a, _b;
886
- const bookingContextState = this.store.bookingContext.getState();
887
- const date = (extra == null ? void 0 : extra.date) ?? bookingContextState.date;
888
- const orderCustomerId = ((_a = this.getOrderCustomerSnapshot()) == null ? void 0 : _a.id) ?? ((_b = this.store.order.getTempOrder()) == null ? void 0 : _b.customer_id) ?? void 0;
889
- return {
890
- bookingConfig: bookingContextState.bookingConfig,
891
- resourcesOrigin: bookingContextState.resourcesOrigin,
892
- resourcesOriginMap: bookingContextState.resourcesOriginMap,
893
- date,
894
- presetStartTime: (extra == null ? void 0 : extra.presetStartTime) ?? (0, import_BookingContext.derivePresetStartTimeFromDate)(date),
895
- customerId: orderCustomerId,
896
- ...extra || {}
897
- };
898
- }
899
- /**
900
- * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
901
- * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
902
- */
903
- decideAddProduct(item, options) {
904
- return (0, import_addProductDecision.decideAddProduct)(item, this.buildAddProductCtx(options));
905
- }
906
- /** 规格弹窗 callback 后的第二段决策。 */
907
- decideAfterDetail(cacheItem, options) {
908
- return (0, import_addProductDecision.decideAfterDetail)(cacheItem, this.buildAddProductCtx(options));
909
- }
910
- /**
911
- * @deprecated 请用 `decideAddProduct`;`autoClose=true` 仅当 action=add。
912
- */
913
- decideAutoClose(item, options) {
914
- return (0, import_addProductDecision.decideAutoClose)(item, this.buildAddProductCtx(options));
915
- }
916
- /** 替代 info2 `getIsEject`:商品是否需要弹窗(0/1)。 */
917
- getIsEject(item, type = "select") {
918
- return (0, import_addProductDecision.getIsEject)(item, type);
919
- }
920
- /** 仅 session 商品(无 variant/option/package)→ true。 */
921
- getIsOnlySession(item) {
922
- return (0, import_addProductDecision.getIsOnlySession)(item);
923
- }
924
- /**
925
- * 拼装 requiresDetail payload(给 SDK 直接 return 给 UI 用)。
926
- */
927
- buildRequiresDetailPayload(item, options) {
928
- return (0, import_addProductDecision.buildRequiresDetailPayload)(item, this.buildAddProductCtx(options));
929
- }
930
- /**
931
- * 把 detail 弹窗回调结果(e, extension_type, detail)转换为 `(product, booking)` 入参。
932
- * 内部会先拼 cacheItem,再走 cacheItemToBookingInput 严格协议对齐。
933
- */
934
- transformDetailToProductAndBooking(input) {
935
- const { item, cacheItem: preparedCacheItem, detailResult, options } = input;
936
- const ctx = this.buildAddProductCtx(options);
937
- const cacheItem = preparedCacheItem || (detailResult ? (0, import_addProductDecision.buildCacheItemFromDetail)(item, detailResult, ctx) : (0, import_addProductDecision.buildCacheItemFromCartDetail)(item, ctx));
938
- return (0, import_addProductDecision.transformDetailToProductAndBooking)(cacheItem, ctx);
939
- }
940
- /**
941
- * 从已加车的 order line + booking 反查资源编辑抽屉所需的 cacheItem。
942
- * 供 SalesSdk「编辑资源」等场景使用;字段语义与 buildCacheItemFromDetail 产出对齐。
943
- */
944
- buildCacheItemFromOrderLine(input) {
945
- return (0, import_buildCacheItemFromOrderLine.buildCacheItemFromOrderLine)(input);
946
- }
947
- /**
948
- * 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
949
- */
950
- buildNormalProductCacheItemFromOrderLine(input) {
951
- return (0, import_buildNormalProductCacheItemFromOrderLine.buildNormalProductCacheItemFromOrderLine)(input);
952
- }
953
- /** 文档别名:与 OrderModule.updateOrderProduct 一致。 */
954
- async updateProductInOrder(params) {
955
- return this.updateOrderProduct(params);
956
- }
957
616
  /**
958
617
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
959
618
  * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
@@ -1,5 +1,4 @@
1
1
  import { ProductList, OrderModule } from '../../modules';
2
- import { BookingContextModule } from '../../modules/BookingContext';
3
2
  import { CustomerModule } from '../../modules/Customer';
4
3
  import { SalesSummaryModule } from '../../modules/SalesSummary';
5
4
  import { ScheduleModule } from '../../modules/Schedule';
@@ -17,7 +16,6 @@ export interface BookingTicketState extends BaseSalesState {
17
16
  salesSummary: SalesSummaryModule;
18
17
  schedule: ScheduleModule;
19
18
  customer: CustomerModule;
20
- bookingContext: BookingContextModule;
21
19
  }
22
20
  export declare function createBookingTicketModule<T extends keyof BookingTicketState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingTicketState[T] | null;
23
21
  export declare enum BookingTicketHooks {
@@ -24,7 +24,6 @@ __export(types_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(types_exports);
26
26
  var import_modules = require("../../modules");
27
- var import_BookingContext = require("../../modules/BookingContext");
28
27
  var import_Customer = require("../../modules/Customer");
29
28
  var import_SalesSummary = require("../../modules/SalesSummary");
30
29
  var import_Schedule = require("../../modules/Schedule");
@@ -55,11 +54,6 @@ function createBookingTicketModule(moduleName, solutionName, name, version) {
55
54
  `${solutionName}_${name || moduleName}`,
56
55
  version
57
56
  );
58
- case "bookingContext":
59
- return new import_BookingContext.BookingContextModule(
60
- `${solutionName}_${name || moduleName}`,
61
- version
62
- );
63
57
  default:
64
58
  return null;
65
59
  }
@@ -1,11 +1,10 @@
1
1
  import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
3
  import { ScanOrderAddLogParams, ScanOrderAvailabilityInfo, ScanOrderOrderProduct, ScanOrderOrderProductIdentity, ScanOrderScanCodeResult } from './types';
4
- import type { UpdateOrderProductParams } from '../../modules/Order/types';
4
+ import type { UpdateProductInOrderParams } from '../../modules/Order/types';
5
5
  import type { Discount } from '../../modules/Discount/types';
6
6
  import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
7
7
  import type { StrategyConfig } from '../../model/strategy/type';
8
- import type { ProductData } from '../../modules/Product/types';
9
8
  export * from './types';
10
9
  interface ScanOrderItemRuleRuntimeConfig {
11
10
  strategyConfigs?: StrategyConfig[];
@@ -37,14 +36,11 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
37
36
  private customerLoginRefreshIdInFlight;
38
37
  private static readonly PISELL1_LOGIN_SUCCESS;
39
38
  private getScanOrderLoggerContext;
40
- private safeStringify;
41
- private pickErrorMessage;
42
39
  private serializeError;
43
40
  private addScanOrderLog;
44
41
  private logMethodStart;
45
42
  private logMethodSuccess;
46
43
  private logMethodError;
47
- private assertProductListLoaded;
48
44
  addLog(params: ScanOrderAddLogParams): Promise<void>;
49
45
  private normalizeCustomerId;
50
46
  private resolveCustomerIdFromLoginPayload;
@@ -90,12 +86,10 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
90
86
  onCustomerLogin(params: {
91
87
  customerId: number;
92
88
  }): Promise<void>;
93
- private findReservationRuleResource;
94
- private buildScanOrderResourceMetadata;
95
89
  private buildSubmitPayloadEnhancer;
96
90
  submitScanOrder<T = any>(): Promise<T>;
97
91
  addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<import("../../modules/Order/types").OrderProduct[]>;
98
- updateOrderProduct(params: UpdateOrderProductParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
92
+ updateProductInOrder(params: UpdateProductInOrderParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
99
93
  /**
100
94
  * 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
101
95
  * 多行同 SKU 时必须传入与删除/更新一致的 identity(如 `identity_key`)。
@@ -126,7 +120,7 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
126
120
  orderAmount: number;
127
121
  orderItems: any[];
128
122
  }>;
129
- getProductList(): Promise<ProductData[]>;
123
+ getProductList(): Promise<any>;
130
124
  getOtherParams(): Record<string, any>;
131
125
  setOtherParams(params: Record<string, any>, { cover }?: {
132
126
  cover?: boolean;