@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
@@ -33,6 +33,13 @@ __export(filterOrders_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(filterOrders_exports);
35
35
  var import_dayjs = __toESM(require("dayjs"));
36
+ function getOrderPaymentCodes(order) {
37
+ const payments = order.payments;
38
+ if (!Array.isArray(payments) || payments.length === 0) {
39
+ return [];
40
+ }
41
+ return payments.map((item) => item == null ? void 0 : item.code).filter((code) => typeof code === "string" && code.length > 0);
42
+ }
36
43
  function filterOrders(orders, filters) {
37
44
  const safeFilters = filters || {};
38
45
  if (!orders || !Array.isArray(orders)) {
@@ -133,26 +140,27 @@ function filterOrders(orders, filters) {
133
140
  }
134
141
  }
135
142
  if (safeFilters.payment_methods && safeFilters.payment_methods.length > 0) {
136
- if (!order.payment_methods || !Array.isArray(order.payment_methods) || order.payment_methods.length === 0) {
143
+ const orderPaymentCodes = getOrderPaymentCodes(order);
144
+ if (orderPaymentCodes.length === 0) {
137
145
  rejected.push({
138
146
  order_id: order.order_id,
139
147
  order_number: order.order_number,
140
148
  reason: {
141
149
  field: "payment_methods",
142
- actual: order.payment_methods,
150
+ actual: order.payments,
143
151
  expected: safeFilters.payment_methods
144
152
  }
145
153
  });
146
154
  return false;
147
155
  }
148
- const hasMatch = order.payment_methods.some((pm) => safeFilters.payment_methods.includes(pm));
156
+ const hasMatch = orderPaymentCodes.some((code) => safeFilters.payment_methods.includes(code));
149
157
  if (!hasMatch) {
150
158
  rejected.push({
151
159
  order_id: order.order_id,
152
160
  order_number: order.order_number,
153
161
  reason: {
154
162
  field: "payment_methods",
155
- actual: order.payment_methods,
163
+ actual: orderPaymentCodes,
156
164
  expected: safeFilters.payment_methods
157
165
  }
158
166
  });
@@ -21,7 +21,7 @@ export declare class ProductsModule extends BaseModule implements Module {
21
21
  private isPriceFormatterRegistered;
22
22
  private quotationPriceBridge?;
23
23
  private quotationBridgeChannel?;
24
- private quotationBridgeCustomerId?;
24
+ private quotationBridgeLoadedKey?;
25
25
  private quotationBridgeRefreshPromise?;
26
26
  private quotationBridgeRefreshKey?;
27
27
  private productDataSource;
@@ -44,6 +44,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
44
44
  this.formatters = [];
45
45
  // 是否已注册内置价格格式化器
46
46
  this.isPriceFormatterRegistered = false;
47
+ this.quotationBridgeLoadedKey = "";
47
48
  this.pendingSyncMessages = [];
48
49
  }
49
50
  async initialize(core, options) {
@@ -177,7 +178,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
177
178
  * Server 层负责传入完整 schedule 模块,Products 只负责把报价单计算结果转成价格响应形状。
178
179
  */
179
180
  async setupQuotationPriceBridge(params) {
180
- var _a, _b, _c;
181
+ var _a;
181
182
  if (!this.core) {
182
183
  this.logWarning("setupQuotationPriceBridge: core 尚未初始化");
183
184
  return;
@@ -190,15 +191,25 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
190
191
  this.quotationPriceBridge = quotation;
191
192
  }
192
193
  if (params.scheduleModule) {
193
- const scheduleList = ((_c = (_b = params.scheduleModule).getScheduleList) == null ? void 0 : _c.call(_b)) || [];
194
- const scheduleMap = new Map(
195
- scheduleList.map((schedule) => [schedule.id, schedule])
196
- );
194
+ const scheduleCache = /* @__PURE__ */ new Map();
195
+ let hasLoadedScheduleList = false;
197
196
  this.quotationPriceBridge.setScheduleResolver((id) => {
198
- var _a2, _b2;
199
- if (scheduleMap.has(id))
200
- return scheduleMap.get(id);
201
- const schedules = ((_b2 = (_a2 = params.scheduleModule).getScheduleByIds) == null ? void 0 : _b2.call(_a2, [id])) || [];
197
+ var _a2, _b, _c, _d, _e, _f;
198
+ const scheduleId = String(id);
199
+ if (scheduleCache.has(scheduleId))
200
+ return scheduleCache.get(scheduleId);
201
+ if (!hasLoadedScheduleList) {
202
+ const scheduleList = ((_b = (_a2 = params.scheduleModule).getScheduleList) == null ? void 0 : _b.call(_a2)) || [];
203
+ for (const schedule of scheduleList) {
204
+ scheduleCache.set(String(schedule.id), schedule);
205
+ }
206
+ hasLoadedScheduleList = true;
207
+ }
208
+ if (scheduleCache.has(scheduleId))
209
+ return scheduleCache.get(scheduleId);
210
+ const schedules = ((_d = (_c = params.scheduleModule).getScheduleListByIds) == null ? void 0 : _d.call(_c, [id])) || ((_f = (_e = params.scheduleModule).getScheduleByIds) == null ? void 0 : _f.call(_e, [id])) || [];
211
+ if (schedules[0])
212
+ scheduleCache.set(scheduleId, schedules[0]);
202
213
  return schedules[0];
203
214
  });
204
215
  }
@@ -210,8 +221,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
210
221
  async refreshQuotationPriceBridge(params) {
211
222
  if (!this.quotationPriceBridge)
212
223
  return;
213
- const customerId = params && "customer_id" in params ? params.customer_id : this.quotationBridgeCustomerId;
214
- const refreshKey = this.getQuotationBridgeScopeKey(customerId);
224
+ const refreshKey = this.getQuotationBridgeScopeKey();
215
225
  if (this.quotationBridgeRefreshPromise && this.quotationBridgeRefreshKey === refreshKey) {
216
226
  await this.quotationBridgeRefreshPromise;
217
227
  return;
@@ -221,10 +231,9 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
221
231
  }
222
232
  this.quotationBridgeRefreshKey = refreshKey;
223
233
  this.quotationBridgeRefreshPromise = this.quotationPriceBridge.loadQuotations({
224
- channel: this.quotationBridgeChannel,
225
- customer_id: customerId
234
+ channel: this.quotationBridgeChannel
226
235
  }).then(() => {
227
- this.quotationBridgeCustomerId = customerId;
236
+ this.quotationBridgeLoadedKey = refreshKey;
228
237
  }).finally(() => {
229
238
  this.quotationBridgeRefreshPromise = void 0;
230
239
  this.quotationBridgeRefreshKey = void 0;
@@ -243,12 +252,12 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
243
252
  if (this.quotationBridgeRefreshPromise) {
244
253
  await this.quotationBridgeRefreshPromise;
245
254
  }
246
- if (this.getQuotationBridgeScopeKey(customerId) !== this.getQuotationBridgeScopeKey(this.quotationBridgeCustomerId)) {
255
+ if (this.getQuotationBridgeScopeKey() !== this.quotationBridgeLoadedKey) {
247
256
  await this.refreshQuotationPriceBridge({ customer_id: customerId });
248
257
  }
249
258
  }
250
- getQuotationBridgeScopeKey(customerId) {
251
- return `${this.quotationBridgeChannel || ""}:${customerId ?? ""}`;
259
+ getQuotationBridgeScopeKey() {
260
+ return this.quotationBridgeChannel || "";
252
261
  }
253
262
  buildPriceDataFromQuotation(product, datetime, customerId) {
254
263
  var _a;
@@ -258,10 +267,11 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
258
267
  customer_id: customerId
259
268
  });
260
269
  const productPrice = quotedPrice ?? product.price;
270
+ const productBasePrice = quotedPrice ?? product.base_price ?? product.price ?? 0;
261
271
  return {
262
272
  id: product.id,
263
273
  price: String(productPrice ?? 0),
264
- base_price: String(product.base_price ?? product.price ?? 0),
274
+ base_price: String(productBasePrice),
265
275
  variant: this.buildVariantPriceData(product, datetime, customerId),
266
276
  bundle_group: this.buildBundleGroupPriceData(product, datetime, customerId)
267
277
  };
@@ -278,7 +288,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
278
288
  customer_id: customerId
279
289
  });
280
290
  const price = quotedPrice ?? variant.price ?? product.price ?? 0;
281
- const basePrice = variant.base_price ?? variant.price ?? product.base_price ?? product.price ?? 0;
291
+ const basePrice = quotedPrice ?? variant.base_price ?? variant.price ?? product.base_price ?? product.price ?? 0;
282
292
  return {
283
293
  id: Number(variant.id),
284
294
  product_id: Number(variant.product_id ?? product.id),
@@ -303,7 +313,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
303
313
  customer_id: customerId
304
314
  });
305
315
  const price = quotedPrice ?? item.price ?? 0;
306
- const basePrice = item.base_price ?? item.price ?? 0;
316
+ const basePrice = quotedPrice ?? item.base_price ?? item.price ?? 0;
307
317
  return {
308
318
  id: Number(item.id),
309
319
  product_id: Number(item.product_id ?? product.id),
@@ -183,8 +183,9 @@ var ScheduleModuleEx = class extends import_BaseModule.BaseModule {
183
183
  return [];
184
184
  }
185
185
  const result = [];
186
+ const scheduleList = this.store.scheduleList || [];
186
187
  for (const id of ids) {
187
- const schedule = this.store.map.get(id);
188
+ const schedule = this.store.map.get(id) || scheduleList.find((item) => String(item.id) === String(id));
188
189
  if (schedule) {
189
190
  result.push(schedule);
190
191
  }
@@ -1,8 +1,8 @@
1
1
  import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
- import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesScanCodeResult } from './types';
3
+ import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult, BaseSalesScanCodeResult } from './types';
4
4
  import { OrderModule } from '../../modules/Order';
5
- import type { AddProductBookingInput, LoadSalesDetailParams, OrderPaymentData, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateProductInOrderParams } from '../../modules/Order/types';
5
+ import type { AddProductBookingInput, LoadSalesDetailParams, OrderPaymentData, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from '../../modules/Order/types';
6
6
  import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
7
7
  import type { Discount } from '../../modules/Discount/types';
8
8
  import { RequestPlugin, WindowPlugin } from '../../plugins';
@@ -11,6 +11,7 @@ import { ProductList } from '../../modules/ProductList';
11
11
  import { PaymentModule } from '../../modules/Payment';
12
12
  import type { SalesSummaryModule } from '../../modules/SalesSummary';
13
13
  import type { ScheduleModule } from '../../modules/Schedule';
14
+ import { QuotationModule } from '../../modules/Quotation';
14
15
  import type { ISalesDetail, ISalesDetailHeader, ISalesBooking, ISalesPayment, ISalesSurcharge } from './utils/parseSalesResponse';
15
16
  import { type TransformBaseProductToOrderProductParams } from './utils/transformBaseProductToOrderProduct';
16
17
  export interface BaseSalesState {
@@ -19,6 +20,7 @@ export interface BaseSalesState {
19
20
  payment?: PaymentModule;
20
21
  salesSummary?: SalesSummaryModule;
21
22
  schedule?: ScheduleModule;
23
+ quotation?: QuotationModule;
22
24
  }
23
25
  export declare class BaseSalesImpl extends BaseModule implements Module {
24
26
  protected defaultName: string;
@@ -26,6 +28,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
26
28
  isSolution: boolean;
27
29
  protected initializeOptions: ModuleOptions;
28
30
  private logger;
31
+ private appPlugin;
29
32
  protected store: BaseSalesState;
30
33
  protected otherParams: Record<string, any>;
31
34
  protected cacheId: string | undefined;
@@ -36,10 +39,12 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
36
39
  window: WindowPlugin;
37
40
  request: RequestPlugin;
38
41
  protected currentSalesDetail: ISalesDetail | null;
42
+ protected discountConfigCacheKey: string | null;
43
+ protected hasManualDiscountSelection: boolean;
39
44
  constructor(name?: string, version?: string);
40
45
  /**
41
46
  * 子类可覆盖此方法以追加/收敛要注册的子模块。
42
- * 默认包含通用销售模块:products / order / salesSummary / schedule / payment。
47
+ * 默认包含通用销售模块:products / order / salesSummary / schedule / payment / quotation
43
48
  */
44
49
  protected getRegisteredModuleNames(): readonly string[];
45
50
  /**
@@ -55,6 +60,17 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
55
60
  */
56
61
  private logError;
57
62
  get payment(): PaymentModule | undefined;
63
+ private getCurrentOrderCustomerId;
64
+ private applyQuotationScheduleResolver;
65
+ private loadQuotationForPriceQuery;
66
+ private getPriceQueryProductId;
67
+ private getPriceQuerySchedule;
68
+ private loadProductForPriceQuery;
69
+ private getAuthoritativeBundleItems;
70
+ private findAuthoritativeBundleItem;
71
+ private getAuthoritativeBundleUnitPrice;
72
+ private mergeProductForPriceQuery;
73
+ protected getSubmitOrderSalesChannel(): string | undefined;
58
74
  /**
59
75
  * 工厂入口:根据子模块名实例化对应模块。
60
76
  * 默认使用 BookingByStep 公共 `createModule`。子类若需引入额外类型(如 customer),
@@ -67,6 +83,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
67
83
  * sessionStorage 损坏时静默忽略,按空状态注册。
68
84
  */
69
85
  protected readSessionCacheData(): Record<string, any>;
86
+ private getAppData;
87
+ private syncAppDataToTempOrder;
70
88
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
71
89
  destroy(): Promise<void>;
72
90
  /**
@@ -91,27 +109,59 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
91
109
  getPayments(): ISalesPayment[];
92
110
  /** 获取附加费用(运费/服务费/税费等)。 */
93
111
  getSurcharges(): ISalesSurcharge[];
94
- getTempOrder(): import("../../modules/Order/types").OrderTempOrder | null;
112
+ getTempOrder(): OrderTempOrder | null;
113
+ replaceTempOrder(tempOrder: OrderTempOrder): Promise<OrderTempOrder>;
95
114
  getOrderIdentity(): import("../../modules/Order/types").OrderIdentitySnapshot | null;
96
115
  getOrderSnapshot(): import("../../modules/Order/types").OrderSnapshot | null;
97
116
  getOrderSyncState(): import("../../modules/Order/types").OrderSyncState;
98
117
  getOrderAmountSnapshot(): import("../../modules/Order/types").OrderAmountSnapshot | null;
99
118
  getTempOrderNote(): string;
100
119
  updateTempOrderNote(note: string): string;
120
+ updateTempOrderNote(note: string, sync: true): Promise<string>;
121
+ updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
122
+ updateRemoteOrderNote(orderId: number | string, note: string): void;
101
123
  updateTempOrderShopDiscount(amount: string | number): string;
102
124
  updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
125
+ /** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
126
+ setEnableTempOrderPersist(enabled: boolean): void;
127
+ /** 是否允许 saveDraft 写入 IndexedDB 草稿。 */
128
+ isTempOrderPersistEnabled(): boolean;
103
129
  private ensureTempOrder;
104
- addNewOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
130
+ addNewOrder(): Promise<OrderTempOrder>;
105
131
  saveDraft(): Promise<void>;
106
- restoreOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
132
+ restoreOrder(): Promise<OrderTempOrder>;
133
+ /**
134
+ * 仅清空 tempOrder 购物车行(products / bookings / discount_list)。
135
+ * 同步清空内存中的 salesDetail 商品/预约视图,避免编辑态仍读到旧 bookings。
136
+ */
137
+ clearOrderCartLines(): Promise<OrderTempOrder>;
107
138
  getOrderProducts(): import("../../modules/Order/types").OrderProduct[];
108
139
  getSummary(): Promise<import("../../modules/Order/types").OrderSummary>;
140
+ private getHistoricalProductDiscountList;
141
+ private isPersistedOrderProduct;
142
+ private mergeHistoricalDiscountList;
143
+ private mergeCurrentDiscountSelectionState;
144
+ loadDiscountConfig(params?: {
145
+ customerId?: number;
146
+ action?: 'create' | 'edit';
147
+ }): Promise<{
148
+ productList: Record<string, any>[];
149
+ discountList: Discount[];
150
+ }>;
151
+ bestDiscount(cb?: (result: any) => void): Promise<{
152
+ productList: Record<string, any>[];
153
+ discountList: Discount[];
154
+ }>;
109
155
  getDiscountList(): Discount[];
110
156
  scanPromotionCode(code: string, customerId?: number): Promise<BaseSalesScanCodeResult>;
111
157
  setDiscountSelected(params: {
112
158
  discountId: number;
113
159
  isSelected: boolean;
114
160
  }): Promise<void>;
161
+ applyDiscountCalculationResult(result?: {
162
+ productList?: Record<string, any>[];
163
+ discountList?: Discount[];
164
+ }): Promise<void>;
115
165
  submitScanOrder<T = any>(params?: {
116
166
  payments?: OrderPaymentSource[];
117
167
  paymentStatus?: BaseSalesPaymentStatus;
@@ -183,14 +233,46 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
183
233
  submitBeforeSend?: boolean;
184
234
  }): Promise<T>;
185
235
  transformBaseProductToOrderProduct(params: TransformBaseProductToOrderProductParams): import("./utils/transformBaseProductToOrderProduct").BaseProductOrderProductInput | null;
236
+ calculateProductBookingPrice(params: BaseSalesCalculateProductBookingPriceParams): Promise<BaseSalesProductBookingPriceResult>;
186
237
  addProductToOrder(product: Partial<BaseSalesOrderProduct> & BaseSalesOrderProductIdentity, booking?: AddProductBookingInput): Promise<import("../../modules/Order/types").OrderProduct[]>;
187
- updateProductInOrder(params: UpdateProductInOrderParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
238
+ updateOrderProduct(params: UpdateOrderProductParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
239
+ updateOrderProductQuantity(params: BaseSalesUpdateOrderProductQuantityParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
240
+ updateOrderBooking(params: UpdateOrderBookingParams): any[];
188
241
  /**
189
242
  * 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
190
243
  * 多行同 SKU 时必须传入与删除/更新一致的 unique_identification_number。
191
244
  */
192
245
  setOrderProductLineNote(identity: BaseSalesOrderProductIdentity, note: string): Promise<import("../../modules/Order/types").OrderProduct[]>;
193
246
  removeProductFromOrder(identity: BaseSalesOrderProductIdentity): Promise<import("../../modules/Order/types").OrderProduct[]>;
247
+ /**
248
+ * 注入促销评估器到底层 OrderModule。
249
+ *
250
+ * @example
251
+ * solution.setPromotionEvaluator(appHelper.utils.promotionEvaluator);
252
+ */
253
+ setPromotionEvaluator(evaluator: OrderPromotionEvaluator | null): void;
254
+ /**
255
+ * 注入赠品选择 resolver。UI 层(SalesSdk)通过 bridge 提供。
256
+ *
257
+ * @example
258
+ * solution.setGiftSelectResolver(async (ctx) => bridge.request(ctx));
259
+ */
260
+ setGiftSelectResolver(resolver: OrderGiftSelectResolver | null): void;
261
+ /**
262
+ * 为商品目录追加促销标签,供 SalesSdkProductProvider 等商品列表入口复用。
263
+ *
264
+ * @example
265
+ * const products = solution.appendPromotionTags(catalogProducts);
266
+ */
267
+ appendPromotionTags<T extends Record<string, any>>(products: T[]): T[];
268
+ /**
269
+ * 主动触发一次促销应用(一般写路径会自动触发,少数场景如客户切换后可手动调)。
270
+ */
271
+ applyPromotion(): Promise<void>;
272
+ /** 最近一次促销计算输出的未满足提示。 */
273
+ getUnfulfilledPromotions(): OrderUnfulfilledPromotion[];
274
+ /** 最近一次促销计算输出的赠品操作 diff。 */
275
+ getLastGiftActions(): OrderLastGiftActions | null;
194
276
  getProductList(): Promise<any>;
195
277
  getOtherParams(): Record<string, any>;
196
278
  setOtherParams(params: Record<string, any>, { cover }?: {