@pisell/pisellos 2.2.170 → 2.2.171

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 (149) 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 +15 -27
  9. package/dist/modules/Order/index.js +322 -695
  10. package/dist/modules/Order/types.d.ts +14 -49
  11. package/dist/modules/Order/types.js +0 -2
  12. package/dist/modules/Order/utils.d.ts +0 -17
  13. package/dist/modules/Order/utils.js +26 -97
  14. package/dist/modules/Rules/index.d.ts +0 -4
  15. package/dist/modules/Rules/index.js +10 -26
  16. package/dist/modules/SalesSummary/index.js +2 -4
  17. package/dist/modules/index.d.ts +0 -1
  18. package/dist/modules/index.js +1 -2
  19. package/dist/server/modules/order/utils/filterOrders.js +6 -20
  20. package/dist/solution/BaseSales/index.d.ts +7 -46
  21. package/dist/solution/BaseSales/index.js +315 -1009
  22. package/dist/solution/BaseSales/types.d.ts +1 -53
  23. package/dist/solution/BaseSales/types.js +1 -3
  24. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +15 -65
  25. package/dist/solution/BaseSales/utils.js +8 -46
  26. package/dist/solution/BookingByStep/index.d.ts +1 -1
  27. package/dist/solution/BookingTicket/index.d.ts +1 -133
  28. package/dist/solution/BookingTicket/index.js +175 -768
  29. package/dist/solution/BookingTicket/types.d.ts +0 -2
  30. package/dist/solution/BookingTicket/types.js +0 -3
  31. package/dist/solution/ScanOrder/index.d.ts +3 -9
  32. package/dist/solution/ScanOrder/index.js +128 -231
  33. package/dist/solution/ScanOrder/utils.js +8 -46
  34. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  35. package/dist/solution/ShopDiscount/index.js +23 -18
  36. package/dist/solution/VenueBooking/index.d.ts +9 -5
  37. package/dist/solution/VenueBooking/index.js +55 -103
  38. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  39. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  40. package/lib/modules/Customer/index.d.ts +0 -6
  41. package/lib/modules/Customer/index.js +11 -26
  42. package/lib/modules/Customer/types.d.ts +0 -2
  43. package/lib/modules/Discount/index.d.ts +4 -2
  44. package/lib/modules/Discount/index.js +63 -8
  45. package/lib/modules/Discount/types.d.ts +7 -1
  46. package/lib/modules/Order/index.d.ts +15 -27
  47. package/lib/modules/Order/index.js +84 -336
  48. package/lib/modules/Order/types.d.ts +14 -49
  49. package/lib/modules/Order/utils.d.ts +0 -17
  50. package/lib/modules/Order/utils.js +18 -105
  51. package/lib/modules/Rules/index.d.ts +0 -4
  52. package/lib/modules/Rules/index.js +14 -22
  53. package/lib/modules/SalesSummary/index.js +2 -4
  54. package/lib/modules/index.d.ts +0 -1
  55. package/lib/modules/index.js +1 -3
  56. package/lib/server/modules/order/utils/filterOrders.js +4 -12
  57. package/lib/solution/BaseSales/index.d.ts +7 -46
  58. package/lib/solution/BaseSales/index.js +20 -434
  59. package/lib/solution/BaseSales/types.d.ts +1 -53
  60. package/lib/solution/BaseSales/types.js +1 -3
  61. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +11 -70
  62. package/lib/solution/BaseSales/utils.js +6 -46
  63. package/lib/solution/BookingByStep/index.d.ts +1 -1
  64. package/lib/solution/BookingTicket/index.d.ts +1 -133
  65. package/lib/solution/BookingTicket/index.js +8 -341
  66. package/lib/solution/BookingTicket/types.d.ts +0 -2
  67. package/lib/solution/BookingTicket/types.js +0 -6
  68. package/lib/solution/ScanOrder/index.d.ts +3 -9
  69. package/lib/solution/ScanOrder/index.js +66 -147
  70. package/lib/solution/ScanOrder/utils.js +6 -46
  71. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  72. package/lib/solution/ShopDiscount/index.js +4 -2
  73. package/lib/solution/VenueBooking/index.d.ts +9 -5
  74. package/lib/solution/VenueBooking/index.js +14 -50
  75. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  76. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  77. package/package.json +2 -2
  78. package/dist/modules/BookingContext/index.d.ts +0 -37
  79. package/dist/modules/BookingContext/index.js +0 -436
  80. package/dist/modules/BookingContext/types.d.ts +0 -102
  81. package/dist/modules/BookingContext/types.js +0 -51
  82. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  83. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
  84. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  85. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
  86. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  87. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
  88. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  89. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  90. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  91. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  92. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  93. package/dist/modules/BookingContext/utils/index.js +0 -11
  94. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  95. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  96. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  97. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  98. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  99. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  100. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  101. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  102. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  103. package/dist/modules/BookingContext/utils/resources.js +0 -486
  104. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  105. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  106. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  107. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  108. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  109. package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
  110. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  111. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -159
  112. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  113. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  114. package/lib/modules/BookingContext/index.d.ts +0 -37
  115. package/lib/modules/BookingContext/index.js +0 -297
  116. package/lib/modules/BookingContext/types.d.ts +0 -102
  117. package/lib/modules/BookingContext/types.js +0 -34
  118. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  119. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
  120. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  121. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
  122. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  123. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
  124. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  125. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  126. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  127. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  128. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  129. package/lib/modules/BookingContext/utils/index.js +0 -43
  130. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  131. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  132. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  133. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  134. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  135. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  136. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  137. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  138. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  139. package/lib/modules/BookingContext/utils/resources.js +0 -377
  140. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  141. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  142. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  143. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  144. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  145. package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
  146. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  147. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -201
  148. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  149. 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"],
@@ -490,7 +388,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
490
388
  this.store.order.setOrderCustomer(patch, customer);
491
389
  const next = this.buildOrderCustomerPayload();
492
390
  this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
493
- this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
494
391
  }
495
392
  /**
496
393
  * 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
@@ -508,34 +405,9 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
508
405
  * 清空下单客户(协议字段 + snapshot)。
509
406
  */
510
407
  clearOrderCustomer() {
511
- var _a, _b;
512
408
  this.store.order.clearOrderCustomer();
513
- const orderStore = this.store.order.store || {};
514
- const discountModule = orderStore.discount;
515
- void ((_a = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _a.call(discountModule, []));
516
- void ((_b = discountModule == null ? void 0 : discountModule.setDiscountList) == null ? void 0 : _b.call(discountModule, []));
517
- this.store.order.applyDiscount();
518
- void this.store.order.recalculateSummary({ createIfMissing: true }).then(() => this.store.order.persistTempOrder()).catch((error) => {
519
- console.error("Failed to recalculate summary after clearing customer:", error);
520
- });
521
409
  this.core.effects.emit(`${this.name}:onOrderCustomerChange`, null);
522
410
  }
523
- /**
524
- * 重置 tempOrder,并同步清空下单客户运行态。
525
- *
526
- * OrderModule.restoreOrder 会重建空单(customer_id 已为 null),但不会:
527
- * - emit BookingTicket `onOrderCustomerChange`
528
- * - 重置 CustomerModule.selectedCustomer(老路 getActiveCustomer)
529
- *
530
- * 因此在 super.restoreOrder 之后显式清客户,保证 SalesSdk / ticketBooking 订阅方与 tempOrder 一致。
531
- */
532
- async restoreOrder() {
533
- var _a;
534
- const tempOrder = await super.restoreOrder();
535
- this.clearOrderCustomer();
536
- (_a = this.store.customer) == null ? void 0 : _a.setSelectedCustomer(null);
537
- return tempOrder;
538
- }
539
411
  /** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */
540
412
  buildOrderCustomerPayload() {
541
413
  const patch = this.store.order.getOrderCustomer();
@@ -546,34 +418,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
546
418
  snapshot: this.store.order.getOrderCustomerSnapshot()
547
419
  };
548
420
  }
549
- refreshDiscountConfigAfterOrderCustomerChange(customerId) {
550
- if (!customerId || customerId === 1)
551
- return;
552
- if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
553
- return;
554
- }
555
- const previousRefresh = this.orderCustomerDiscountRefreshInFlight;
556
- const refreshTask = (async () => {
557
- if (previousRefresh) {
558
- await previousRefresh.catch(() => void 0);
559
- }
560
- const currentCustomer = this.store.order.getOrderCustomer();
561
- if (!currentCustomer || Number(currentCustomer.customer_id) !== customerId) {
562
- return;
563
- }
564
- await this.loadDiscountConfig({ customerId });
565
- })();
566
- this.orderCustomerDiscountRefreshInFlight = refreshTask;
567
- this.orderCustomerDiscountRefreshCustomerId = customerId;
568
- refreshTask.catch((error) => {
569
- console.error("Failed to load discount config after customer change:", error);
570
- }).finally(() => {
571
- if (this.orderCustomerDiscountRefreshInFlight !== refreshTask)
572
- return;
573
- this.orderCustomerDiscountRefreshInFlight = null;
574
- this.orderCustomerDiscountRefreshCustomerId = null;
575
- });
576
- }
577
421
  /**
578
422
  * 获取客户分页信息
579
423
  * @returns 分页信息
@@ -769,183 +613,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
769
613
  async getOtherParams() {
770
614
  return this.otherParams;
771
615
  }
772
- // ─── BookingContext API(透传给 BookingContextModule) ──────────────────────
773
- // SalesSdkProvider 挂载时默认调 initBookingContext;也可由 UI 显式 set* 灌入已有数据。
774
- /** 拉取 board config 并写入 BookingContext。 */
775
- loadBookingConfig(params) {
776
- return this.store.bookingContext.loadBookingConfig(params);
777
- }
778
- /** 拉取资源全集并写入 BookingContext。 */
779
- loadBookingResources(params) {
780
- return this.store.bookingContext.loadResources(params);
781
- }
782
- /** 初始化 BookingContext(date + config + resources)。 */
783
- initBookingContext(params) {
784
- return this.store.bookingContext.initBookingContext(params);
785
- }
786
- /** 当前 store 是否已具备与入参等价的 config / resources(无需再请求接口)。 */
787
- isBookingContextReady(params) {
788
- return this.store.bookingContext.isBookingContextReady(params);
789
- }
790
- /** 写入 booking config(来源:`/core/board/management/config`)。 */
791
- setBookingConfig(config) {
792
- this.store.bookingContext.setBookingConfig(config);
793
- }
794
- /** 读取当前 booking config。 */
795
- getBookingConfig() {
796
- return this.store.bookingContext.getBookingConfig();
797
- }
798
- /** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
799
- setResources(resources) {
800
- this.store.bookingContext.setResources(resources);
801
- }
802
- /** 读取资源全集(浅克隆)。 */
803
- getResourcesOrigin() {
804
- return this.store.bookingContext.getResourcesOrigin();
805
- }
806
- /** 读取资源全集 map(id → resource)。 */
807
- getResourcesOriginMap() {
808
- return this.store.bookingContext.getResourcesOriginMap();
809
- }
810
- /** 写入当前选择的日期;支持 dayjs / Date / string。 */
811
- setBookingDate(date) {
812
- this.store.bookingContext.setDate(date);
813
- }
814
- /** 读取当前选择的日期(统一 string)。 */
815
- getBookingDate() {
816
- return this.store.bookingContext.getDate();
817
- }
818
- /** 读取 BookingContext 完整 store(调试 / 测试 / 透传给 SDK 使用)。 */
819
- getBookingContextState() {
820
- return this.store.bookingContext.getState();
821
- }
822
- /** 清空 BookingContext(切租户 / destroy 场景)。 */
823
- clearBookingContext() {
824
- this.store.bookingContext.clear();
825
- }
826
- /**
827
- * 构造 BookingContext 计算上下文(供 getProductExtend / getResourceByIds 等读 API 复用)。
828
- */
829
- buildBookingCalcContext(extra) {
830
- const state = this.store.bookingContext.getState();
831
- const date = (extra == null ? void 0 : extra.date) ?? state.date;
832
- return {
833
- bookingConfig: state.bookingConfig,
834
- resourcesOrigin: state.resourcesOrigin,
835
- resourcesOriginMap: state.resourcesOriginMap,
836
- date,
837
- presetStartTime: (extra == null ? void 0 : extra.presetStartTime) ?? (0, import_BookingContext.derivePresetStartTimeFromDate)(date),
838
- ...extra || {}
839
- };
840
- }
841
- /**
842
- * 取商品当前可选资源列表(透传 OS BookingContext utils#getResourceByIds)。
843
- * `extraResources` 用于把拖入未绑定的资源也展示出来。
844
- */
845
- getResourcesForProduct(product, options) {
846
- var _a, _b;
847
- const ctx = this.buildBookingCalcContext();
848
- return (0, import_BookingContext.getResourceByIds)(ctx.resourcesOriginMap || {}, product, {
849
- resourceTab: (_b = (_a = ctx.bookingConfig) == null ? void 0 : _a.config) == null ? void 0 : _b.resource_tab,
850
- resourcesOrigin: ctx.resourcesOrigin,
851
- extraResources: (options == null ? void 0 : options.extraResources) || []
852
- });
853
- }
854
- /**
855
- * 拼装 cacheItem 的 _extend / _data(资源 / 容量 / timeObj),与 info2 `getProductExtend` 等价。
856
- */
857
- getProductExtend(cacheItem, extra) {
858
- return (0, import_BookingContext.getProductExtend)({
859
- cacheItem,
860
- ctx: this.buildBookingCalcContext(extra)
861
- });
862
- }
863
- /**
864
- * 取资源不可用原因列表(结构化 enum + params,i18n 文案由 UI 渲染)。
865
- */
866
- getResourceErrors(resource, cacheItem) {
867
- return (0, import_BookingContext.getResourceErrors)(resource, cacheItem);
868
- }
869
- // ─── addProduct 决策 / 转换 API(SDK 加车下沉所需) ─────────────────────────
870
- // 这一组方法是 SalesSdkCartContext.addProduct / confirmDetail 的 OS 后端。
871
- // 调用方传入 ProductData,OS 自取 bookingContext / customer / date 等上下文,
872
- // 输出 (a) autoClose 决策结果或 (b) `{ product, booking }` 协议入参。
873
- /**
874
- * 拼装 addProductDecision 通用上下文(从 store 自取)。
875
- */
876
- buildAddProductCtx(extra) {
877
- var _a, _b;
878
- const bookingContextState = this.store.bookingContext.getState();
879
- const date = (extra == null ? void 0 : extra.date) ?? bookingContextState.date;
880
- const orderCustomerId = ((_a = this.getOrderCustomerSnapshot()) == null ? void 0 : _a.id) ?? ((_b = this.store.order.getTempOrder()) == null ? void 0 : _b.customer_id) ?? void 0;
881
- return {
882
- bookingConfig: bookingContextState.bookingConfig,
883
- resourcesOrigin: bookingContextState.resourcesOrigin,
884
- resourcesOriginMap: bookingContextState.resourcesOriginMap,
885
- date,
886
- presetStartTime: (extra == null ? void 0 : extra.presetStartTime) ?? (0, import_BookingContext.derivePresetStartTimeFromDate)(date),
887
- customerId: orderCustomerId,
888
- ...extra || {}
889
- };
890
- }
891
- /**
892
- * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
893
- * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
894
- */
895
- decideAddProduct(item, options) {
896
- return (0, import_addProductDecision.decideAddProduct)(item, this.buildAddProductCtx(options));
897
- }
898
- /** 规格弹窗 callback 后的第二段决策。 */
899
- decideAfterDetail(cacheItem, options) {
900
- return (0, import_addProductDecision.decideAfterDetail)(cacheItem, this.buildAddProductCtx(options));
901
- }
902
- /**
903
- * @deprecated 请用 `decideAddProduct`;`autoClose=true` 仅当 action=add。
904
- */
905
- decideAutoClose(item, options) {
906
- return (0, import_addProductDecision.decideAutoClose)(item, this.buildAddProductCtx(options));
907
- }
908
- /** 替代 info2 `getIsEject`:商品是否需要弹窗(0/1)。 */
909
- getIsEject(item, type = "select") {
910
- return (0, import_addProductDecision.getIsEject)(item, type);
911
- }
912
- /** 仅 session 商品(无 variant/option/package)→ true。 */
913
- getIsOnlySession(item) {
914
- return (0, import_addProductDecision.getIsOnlySession)(item);
915
- }
916
- /**
917
- * 拼装 requiresDetail payload(给 SDK 直接 return 给 UI 用)。
918
- */
919
- buildRequiresDetailPayload(item, options) {
920
- return (0, import_addProductDecision.buildRequiresDetailPayload)(item, this.buildAddProductCtx(options));
921
- }
922
- /**
923
- * 把 detail 弹窗回调结果(e, extension_type, detail)转换为 `(product, booking)` 入参。
924
- * 内部会先拼 cacheItem,再走 cacheItemToBookingInput 严格协议对齐。
925
- */
926
- transformDetailToProductAndBooking(input) {
927
- const { item, cacheItem: preparedCacheItem, detailResult, options } = input;
928
- const ctx = this.buildAddProductCtx(options);
929
- const cacheItem = preparedCacheItem || (detailResult ? (0, import_addProductDecision.buildCacheItemFromDetail)(item, detailResult, ctx) : (0, import_addProductDecision.buildCacheItemFromCartDetail)(item, ctx));
930
- return (0, import_addProductDecision.transformDetailToProductAndBooking)(cacheItem, ctx);
931
- }
932
- /**
933
- * 从已加车的 order line + booking 反查资源编辑抽屉所需的 cacheItem。
934
- * 供 SalesSdk「编辑资源」等场景使用;字段语义与 buildCacheItemFromDetail 产出对齐。
935
- */
936
- buildCacheItemFromOrderLine(input) {
937
- return (0, import_buildCacheItemFromOrderLine.buildCacheItemFromOrderLine)(input);
938
- }
939
- /**
940
- * 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
941
- */
942
- buildNormalProductCacheItemFromOrderLine(input) {
943
- return (0, import_buildNormalProductCacheItemFromOrderLine.buildNormalProductCacheItemFromOrderLine)(input);
944
- }
945
- /** 文档别名:与 OrderModule.updateOrderProduct 一致。 */
946
- async updateProductInOrder(params) {
947
- return this.updateOrderProduct(params);
948
- }
949
616
  /**
950
617
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
951
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;