@pisell/pisellos 2.2.178 → 2.2.179

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 (182) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  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 +18 -88
  9. package/dist/modules/Order/index.js +501 -1357
  10. package/dist/modules/Order/types.d.ts +19 -198
  11. package/dist/modules/Order/types.js +0 -31
  12. package/dist/modules/Order/utils.d.ts +1 -50
  13. package/dist/modules/Order/utils.js +32 -261
  14. package/dist/modules/Quotation/index.d.ts +1 -0
  15. package/dist/modules/Quotation/index.js +21 -23
  16. package/dist/modules/Rules/index.d.ts +0 -4
  17. package/dist/modules/Rules/index.js +10 -26
  18. package/dist/modules/SalesSummary/index.js +2 -4
  19. package/dist/modules/SalesSummary/utils.js +7 -21
  20. package/dist/modules/Schedule/index.js +2 -6
  21. package/dist/modules/index.d.ts +0 -1
  22. package/dist/modules/index.js +1 -2
  23. package/dist/server/index.js +29 -87
  24. package/dist/server/modules/order/index.d.ts +0 -23
  25. package/dist/server/modules/order/index.js +46 -123
  26. package/dist/server/modules/order/types.d.ts +2 -0
  27. package/dist/server/modules/order/utils/filterOrders.js +6 -20
  28. package/dist/server/modules/products/index.d.ts +1 -1
  29. package/dist/server/modules/products/index.js +113 -130
  30. package/dist/server/modules/schedule/index.js +6 -13
  31. package/dist/solution/BaseSales/index.d.ts +7 -89
  32. package/dist/solution/BaseSales/index.js +375 -1494
  33. package/dist/solution/BaseSales/types.d.ts +1 -67
  34. package/dist/solution/BaseSales/types.js +1 -3
  35. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
  36. package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
  37. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -68
  38. package/dist/solution/BaseSales/utils.js +8 -46
  39. package/dist/solution/BookingByStep/index.d.ts +1 -1
  40. package/dist/solution/BookingTicket/index.d.ts +1 -133
  41. package/dist/solution/BookingTicket/index.js +175 -780
  42. package/dist/solution/BookingTicket/types.d.ts +0 -2
  43. package/dist/solution/BookingTicket/types.js +0 -3
  44. package/dist/solution/BookingTicket/utils/cartView.js +2 -4
  45. package/dist/solution/ScanOrder/index.d.ts +3 -9
  46. package/dist/solution/ScanOrder/index.js +128 -231
  47. package/dist/solution/ScanOrder/utils.js +8 -46
  48. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  49. package/dist/solution/ShopDiscount/index.js +23 -18
  50. package/dist/solution/VenueBooking/index.d.ts +9 -5
  51. package/dist/solution/VenueBooking/index.js +55 -103
  52. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  53. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  54. package/lib/modules/Customer/index.d.ts +0 -6
  55. package/lib/modules/Customer/index.js +11 -26
  56. package/lib/modules/Customer/types.d.ts +0 -2
  57. package/lib/modules/Discount/index.d.ts +4 -2
  58. package/lib/modules/Discount/index.js +63 -8
  59. package/lib/modules/Discount/types.d.ts +7 -1
  60. package/lib/modules/Order/index.d.ts +18 -88
  61. package/lib/modules/Order/index.js +149 -677
  62. package/lib/modules/Order/types.d.ts +19 -198
  63. package/lib/modules/Order/types.js +0 -1
  64. package/lib/modules/Order/utils.d.ts +1 -50
  65. package/lib/modules/Order/utils.js +22 -229
  66. package/lib/modules/Quotation/index.d.ts +1 -0
  67. package/lib/modules/Quotation/index.js +15 -18
  68. package/lib/modules/Rules/index.d.ts +0 -4
  69. package/lib/modules/Rules/index.js +14 -22
  70. package/lib/modules/SalesSummary/index.js +2 -4
  71. package/lib/modules/SalesSummary/utils.js +7 -21
  72. package/lib/modules/Schedule/index.js +1 -3
  73. package/lib/modules/index.d.ts +0 -1
  74. package/lib/modules/index.js +1 -3
  75. package/lib/server/index.js +4 -41
  76. package/lib/server/modules/order/index.d.ts +0 -23
  77. package/lib/server/modules/order/index.js +14 -46
  78. package/lib/server/modules/order/types.d.ts +2 -0
  79. package/lib/server/modules/order/utils/filterOrders.js +4 -12
  80. package/lib/server/modules/products/index.d.ts +1 -1
  81. package/lib/server/modules/products/index.js +20 -30
  82. package/lib/server/modules/schedule/index.js +1 -2
  83. package/lib/solution/BaseSales/index.d.ts +7 -89
  84. package/lib/solution/BaseSales/index.js +22 -736
  85. package/lib/solution/BaseSales/types.d.ts +1 -67
  86. package/lib/solution/BaseSales/types.js +1 -3
  87. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -0
  88. package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -0
  89. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +12 -71
  90. package/lib/solution/BaseSales/utils.js +6 -46
  91. package/lib/solution/BookingByStep/index.d.ts +1 -1
  92. package/lib/solution/BookingTicket/index.d.ts +1 -133
  93. package/lib/solution/BookingTicket/index.js +8 -352
  94. package/lib/solution/BookingTicket/types.d.ts +0 -2
  95. package/lib/solution/BookingTicket/types.js +0 -6
  96. package/lib/solution/BookingTicket/utils/cartView.js +2 -4
  97. package/lib/solution/ScanOrder/index.d.ts +3 -9
  98. package/lib/solution/ScanOrder/index.js +66 -147
  99. package/lib/solution/ScanOrder/utils.js +6 -46
  100. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  101. package/lib/solution/ShopDiscount/index.js +4 -2
  102. package/lib/solution/VenueBooking/index.d.ts +9 -5
  103. package/lib/solution/VenueBooking/index.js +14 -50
  104. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  105. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  106. package/package.json +2 -2
  107. package/dist/modules/BookingContext/index.d.ts +0 -37
  108. package/dist/modules/BookingContext/index.js +0 -436
  109. package/dist/modules/BookingContext/types.d.ts +0 -102
  110. package/dist/modules/BookingContext/types.js +0 -51
  111. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  112. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
  113. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  114. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
  115. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  116. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
  117. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  118. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  119. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  120. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  121. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  122. package/dist/modules/BookingContext/utils/index.js +0 -11
  123. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  124. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  125. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  126. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  127. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  128. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  129. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  130. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  131. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  132. package/dist/modules/BookingContext/utils/resources.js +0 -486
  133. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  134. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  135. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  136. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  137. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  138. package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
  139. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
  140. package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1258
  141. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  142. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
  143. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  144. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  145. package/lib/modules/BookingContext/index.d.ts +0 -37
  146. package/lib/modules/BookingContext/index.js +0 -297
  147. package/lib/modules/BookingContext/types.d.ts +0 -102
  148. package/lib/modules/BookingContext/types.js +0 -34
  149. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  150. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
  151. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  152. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
  153. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
  154. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
  155. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  156. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  157. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  158. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  159. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  160. package/lib/modules/BookingContext/utils/index.js +0 -43
  161. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  162. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  163. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  164. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  165. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  166. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  167. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  168. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  169. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  170. package/lib/modules/BookingContext/utils/resources.js +0 -377
  171. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  172. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  173. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  174. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  175. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  176. package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
  177. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -275
  178. package/lib/solution/BaseSales/utils/cartPromotion.js +0 -836
  179. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  180. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
  181. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
  182. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
@@ -236,7 +236,6 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
236
236
  isChargeTax: product.is_charge_tax ?? 0
237
237
  });
238
238
  const mainTaxRounded = mainTaxPrecise.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
239
- product.main_product_attached_bundle_tax_fee = mainTaxRounded.toFixed(2);
240
239
  if (mainTaxPrecise.gt(0)) {
241
240
  lastTaxableItem = { type: "main", item: product };
242
241
  }
@@ -259,16 +258,15 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
259
258
  const bundleQuantity = new import_decimal.default(getSafeNum(bundleItem.num ?? bundleItem.quantity));
260
259
  const bundlePrice = toDecimal(bundleItem.bundle_selling_price ?? bundleItem.price ?? 0);
261
260
  const bundleOriginalPrice = toDecimal(bundleItem.original_price ?? bundleItem.product_price ?? bundleItem.price ?? 0);
262
- const bundleSurchargeFee = toDecimal(bundleItem.surcharge_fee);
263
261
  const bundleTaxPrecise = calculateSingleItemTax({
264
- price: bundlePrice.plus(bundleSurchargeFee),
262
+ price: bundlePrice,
265
263
  taxRate: rate,
266
264
  isPriceIncludeTax,
267
265
  isChargeTax: bundleItem.is_charge_tax ?? product.is_charge_tax ?? 0
268
266
  });
269
267
  const bundleTaxRounded = bundleTaxPrecise.toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
270
268
  const bundleOrigTaxPrecise = calculateSingleItemTax({
271
- price: bundleOriginalPrice.plus(bundleSurchargeFee),
269
+ price: bundleOriginalPrice,
272
270
  taxRate: rate,
273
271
  isPriceIncludeTax,
274
272
  isChargeTax: bundleItem.is_charge_tax ?? product.is_charge_tax ?? 0
@@ -334,6 +332,7 @@ function createEmptySalesSummary() {
334
332
  };
335
333
  }
336
334
  function calculateSalesSummary(params) {
335
+ var _a;
337
336
  const {
338
337
  products,
339
338
  isPriceIncludeTax,
@@ -380,20 +379,7 @@ function calculateSalesSummary(params) {
380
379
  ) || 0
381
380
  );
382
381
  for (let i = 0; i < products.length; i++) {
383
- const sourceItem = surchargeServiceItems[i] || {};
384
- const product = products[i];
385
- product.surcharge_fee = sourceItem.surcharge_fee || 0;
386
- const relationSurchargeIds = Array.isArray(sourceItem.relation_surcharge_ids) ? sourceItem.relation_surcharge_ids : [];
387
- const hasSurcharge = new import_decimal.default(product.surcharge_fee || 0).gt(0) || relationSurchargeIds.length > 0;
388
- if (hasSurcharge) {
389
- product.main_product_attached_bundle_surcharge_fee = toFixed2(product.surcharge_fee);
390
- }
391
- if (relationSurchargeIds.length > 0) {
392
- product.relation_surcharge_ids = sourceItem.relation_surcharge_ids;
393
- }
394
- if (hasSurcharge && sourceItem.surcharge_rounding_remainder !== void 0) {
395
- product.surcharge_rounding_remainder = sourceItem.surcharge_rounding_remainder;
396
- }
382
+ products[i].surcharge_fee = ((_a = surchargeServiceItems[i]) == null ? void 0 : _a.surcharge_fee) || 0;
397
383
  }
398
384
  const hasTaxRate = taxRate !== void 0 && taxRate !== null && taxRate > 0;
399
385
  let productTaxFee;
@@ -407,8 +393,8 @@ function calculateSalesSummary(params) {
407
393
  );
408
394
  }
409
395
  const shopDiscountAmount = import_decimal.default.max(new import_decimal.default(Number(shopDiscount) || 0), 0);
410
- const preTaxExpectAmount = import_decimal.default.max(0, productAmount.plus(surchargeAmount).minus(shopDiscountAmount));
411
- const totalAmount = isPriceIncludeTax === 1 ? preTaxExpectAmount : preTaxExpectAmount.plus(productTaxFee);
396
+ const expectAmount = import_decimal.default.max(0, productAmount.plus(surchargeAmount).minus(shopDiscountAmount));
397
+ const totalAmount = isPriceIncludeTax === 1 ? expectAmount : expectAmount.plus(productTaxFee);
412
398
  const deposit = calculateProductsDeposit(products);
413
399
  return {
414
400
  product_quantity: productQuantity,
@@ -426,7 +412,7 @@ function calculateSalesSummary(params) {
426
412
  ),
427
413
  deposit_amount: deposit ? deposit.total : "0.00",
428
414
  deposit,
429
- expect_amount: toFixed2(totalAmount),
415
+ expect_amount: toFixed2(expectAmount),
430
416
  total_amount: toFixed2(totalAmount),
431
417
  total_refund_amount: "0.00",
432
418
  customer_paid_amount: "0.00",
@@ -135,9 +135,7 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
135
135
  return dates;
136
136
  }
137
137
  getScheduleListByIds(ids) {
138
- const idSet = new Set(ids.map((id) => String(id)));
139
- const list = this.store.scheduleList.filter((n) => idSet.has(String(n.id)));
140
- return list;
138
+ return this.store.scheduleList.filter((n) => ids.includes(n.id));
141
139
  }
142
140
  setAvailabilityScheduleDateList(list) {
143
141
  this.store.availabilityDateList = list;
@@ -16,4 +16,3 @@ export * from './Schedule';
16
16
  export * from './Quotation';
17
17
  export * from './ScanOrderLogger';
18
18
  export * from './OpenData';
19
- export * from './BookingContext';
@@ -34,7 +34,6 @@ __reExport(modules_exports, require("./Schedule"), module.exports);
34
34
  __reExport(modules_exports, require("./Quotation"), module.exports);
35
35
  __reExport(modules_exports, require("./ScanOrderLogger"), module.exports);
36
36
  __reExport(modules_exports, require("./OpenData"), module.exports);
37
- __reExport(modules_exports, require("./BookingContext"), module.exports);
38
37
  // Annotate the CommonJS export names for ESM import in node:
39
38
  0 && (module.exports = {
40
39
  ...require("./Product"),
@@ -54,6 +53,5 @@ __reExport(modules_exports, require("./BookingContext"), module.exports);
54
53
  ...require("./Schedule"),
55
54
  ...require("./Quotation"),
56
55
  ...require("./ScanOrderLogger"),
57
- ...require("./OpenData"),
58
- ...require("./BookingContext")
56
+ ...require("./OpenData")
59
57
  });
@@ -149,11 +149,10 @@ var Server = class {
149
149
  */
150
150
  this.handleProductQuery = async ({ url, method, data, config }) => {
151
151
  console.log("[Server] handleProductQuery:", url, method, data, config);
152
- const { menu_list_ids, schedule_datetime, schedule_date, customer_id, ids } = data;
152
+ const { menu_list_ids, schedule_datetime, schedule_date, customer_id } = data;
153
153
  const { callback, subscriberId } = config || {};
154
154
  this.logInfo("handleProductQuery: 开始处理商品查询请求", {
155
155
  menu_list_ids,
156
- ids,
157
156
  schedule_datetime,
158
157
  schedule_date,
159
158
  customer_id
@@ -161,14 +160,14 @@ var Server = class {
161
160
  if (subscriberId && typeof callback === "function") {
162
161
  this.productQuerySubscribers.set(subscriberId, {
163
162
  callback,
164
- context: { menu_list_ids, ids, schedule_date, schedule_datetime, customer_id }
163
+ context: { menu_list_ids, schedule_date, schedule_datetime, customer_id }
165
164
  });
166
165
  this.logInfo("handleProductQuery: 已注册订阅者", {
167
166
  subscriberId,
168
167
  totalSubscribers: this.productQuerySubscribers.size
169
168
  });
170
169
  }
171
- return this.computeProductQueryResult({ menu_list_ids, ids, schedule_date, schedule_datetime, customer_id });
170
+ return this.computeProductQueryResult({ menu_list_ids, schedule_date, schedule_datetime, customer_id });
172
171
  };
173
172
  /**
174
173
  * 按商品 id 查询单条(GET /shop/product/query/:productId)
@@ -932,8 +931,6 @@ var Server = class {
932
931
  return;
933
932
  }
934
933
  try {
935
- await this.schedule.loadAllSchedule();
936
- this.products.clearPriceCache();
937
934
  await this.products.setupQuotationPriceBridge({
938
935
  scheduleModule: this.schedule,
939
936
  channel: (_a = this.core.context) == null ? void 0 : _a.channel
@@ -2052,11 +2049,9 @@ var Server = class {
2052
2049
  */
2053
2050
  async computeProductQueryResult(context, options) {
2054
2051
  const tTotal = performance.now();
2055
- const { menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, product_id } = context;
2056
- const queryIds = Array.isArray(ids) ? ids.map((id) => Number(id)).filter((id) => Number.isFinite(id)) : [];
2052
+ const { menu_list_ids, schedule_date, schedule_datetime, customer_id, product_id } = context;
2057
2053
  this.logInfo("computeProductQueryResult 开始", {
2058
2054
  menuListIdsCount: (menu_list_ids == null ? void 0 : menu_list_ids.length) ?? 0,
2059
- ids: queryIds,
2060
2055
  schedule_datetime,
2061
2056
  schedule_date,
2062
2057
  customer_id,
@@ -2067,38 +2062,6 @@ var Server = class {
2067
2062
  this.logError("computeProductQueryResult: Products 模块未注册");
2068
2063
  return { message: "Products 模块未注册", data: { list: [], count: 0 } };
2069
2064
  }
2070
- if (queryIds.length > 0) {
2071
- const uniqueIds = Array.from(new Set(queryIds));
2072
- const tPrice2 = performance.now();
2073
- const productsWithPrice = await this.products.getProductsWithPrice(schedule_date, {
2074
- scheduleModule: this.getSchedule(),
2075
- schedule_datetime,
2076
- customer_id
2077
- }, {
2078
- changedIds: options == null ? void 0 : options.changedIds,
2079
- productIds: uniqueIds
2080
- });
2081
- (0, import_product.perfMark)("computeQuery.getProductsWithPrice(ids)", performance.now() - tPrice2, {
2082
- count: productsWithPrice.length,
2083
- ids: uniqueIds
2084
- });
2085
- const filteredProducts2 = productsWithPrice.filter((p) => uniqueIds.includes(Number(p == null ? void 0 : p.id))).filter((p) => ((p == null ? void 0 : p.status) || "published") === "published");
2086
- (0, import_product.perfMark)("computeProductQueryResult", performance.now() - tTotal, {
2087
- mode: "ids",
2088
- ids: uniqueIds,
2089
- count: filteredProducts2.length
2090
- });
2091
- this.logInfo("computeProductQueryResult 完成(ids)", {
2092
- ids: uniqueIds,
2093
- count: filteredProducts2.length
2094
- });
2095
- return {
2096
- code: 200,
2097
- data: { list: filteredProducts2, count: filteredProducts2.length },
2098
- message: "",
2099
- status: true
2100
- };
2101
- }
2102
2065
  if (product_id != null && Number.isFinite(Number(product_id))) {
2103
2066
  const pid = Number(product_id);
2104
2067
  const tPrice2 = performance.now();
@@ -18,7 +18,6 @@ export declare class OrderModule extends BaseModule implements Module {
18
18
  private resourceIdIndex;
19
19
  private logger;
20
20
  private storage;
21
- private orderSQLiteSaveQueue;
22
21
  constructor(name?: string, version?: string);
23
22
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
24
23
  /**
@@ -131,28 +130,6 @@ export declare class OrderModule extends BaseModule implements Module {
131
130
  private getStorageItem;
132
131
  private setStorageItem;
133
132
  private loadOrdersFromSQLite;
134
- /**
135
- * 串行执行订单 SQLite 保存任务,保证 clear + bulkAdd 组合不会被其它订单保存插入。
136
- *
137
- * @example
138
- * await this.runInOrderSQLiteSaveQueue(async () => {
139
- * await this.dbManager.clear(INDEXDB_STORE_NAME)
140
- * await this.dbManager.bulkAdd(INDEXDB_STORE_NAME, orders)
141
- * })
142
- */
143
- private runInOrderSQLiteSaveQueue;
144
- /**
145
- * 保存订单列表到 SQLite,内部会先清空 orders 表再批量写入当前快照。
146
- *
147
- * @example
148
- * await this.saveOrdersToSQLite(this.store.list)
149
- */
150
133
  private saveOrdersToSQLite;
151
- /**
152
- * 清空订单模块的内存数据和本地 SQLite 订单表。
153
- *
154
- * @example
155
- * await orderModule.clear()
156
- */
157
134
  clear(): Promise<void>;
158
135
  }
@@ -50,7 +50,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
50
50
  this.isIdlePhase = true;
51
51
  // Map<resource_id, OrderId[]> 资源到订单的倒排索引
52
52
  this.resourceIdIndex = /* @__PURE__ */ new Map();
53
- this.orderSQLiteSaveQueue = Promise.resolve();
54
53
  }
55
54
  async initialize(core, options) {
56
55
  var _a, _b;
@@ -744,67 +743,36 @@ var OrderModule = class extends import_BaseModule.BaseModule {
744
743
  return [];
745
744
  }
746
745
  }
747
- /**
748
- * 串行执行订单 SQLite 保存任务,保证 clear + bulkAdd 组合不会被其它订单保存插入。
749
- *
750
- * @example
751
- * await this.runInOrderSQLiteSaveQueue(async () => {
752
- * await this.dbManager.clear(INDEXDB_STORE_NAME)
753
- * await this.dbManager.bulkAdd(INDEXDB_STORE_NAME, orders)
754
- * })
755
- */
756
- async runInOrderSQLiteSaveQueue(task) {
757
- const queuedTask = this.orderSQLiteSaveQueue.then(task, task);
758
- this.orderSQLiteSaveQueue = queuedTask.then(() => void 0, () => void 0);
759
- return queuedTask;
760
- }
761
- /**
762
- * 保存订单列表到 SQLite,内部会先清空 orders 表再批量写入当前快照。
763
- *
764
- * @example
765
- * await this.saveOrdersToSQLite(this.store.list)
766
- */
767
746
  async saveOrdersToSQLite(orderList) {
768
747
  if (!this.dbManager)
769
748
  return;
770
- const orderListSnapshot = (0, import_lodash_es.cloneDeep)(orderList);
771
749
  try {
772
- await this.runInOrderSQLiteSaveQueue(async () => {
773
- this.logInfo("saveOrdersToSQLite-开始", {
774
- count: orderListSnapshot.length
775
- });
776
- await this.dbManager.clear(INDEXDB_STORE_NAME);
777
- this.logInfo("saveOrdersToSQLite-clear完成", {
778
- count: orderListSnapshot.length
779
- });
780
- if (orderListSnapshot.length === 0)
781
- return;
782
- await this.dbManager.bulkAdd(INDEXDB_STORE_NAME, orderListSnapshot);
783
- this.logInfo("saveOrdersToSQLite-bulkAdd完成", {
784
- count: orderListSnapshot.length
785
- });
750
+ this.logInfo("saveOrdersToSQLite-开始", {
751
+ count: orderList.length
752
+ });
753
+ await this.dbManager.clear(INDEXDB_STORE_NAME);
754
+ this.logInfo("saveOrdersToSQLite-clear完成", {
755
+ count: orderList.length
756
+ });
757
+ if (orderList.length === 0)
758
+ return;
759
+ await this.dbManager.bulkAdd(INDEXDB_STORE_NAME, orderList);
760
+ this.logInfo("saveOrdersToSQLite-bulkAdd完成", {
761
+ count: orderList.length
786
762
  });
787
763
  } catch (error) {
788
764
  this.logError("保存订单到 SQLite 失败", {
789
765
  error: error instanceof Error ? error.message : String(error),
790
- orderList: orderListSnapshot.length
766
+ orderList: orderList.length
791
767
  });
792
768
  }
793
769
  }
794
- /**
795
- * 清空订单模块的内存数据和本地 SQLite 订单表。
796
- *
797
- * @example
798
- * await orderModule.clear()
799
- */
800
770
  async clear() {
801
771
  this.store.list = [];
802
772
  this.store.map = /* @__PURE__ */ new Map();
803
773
  this.resourceIdIndex.clear();
804
774
  if (this.dbManager) {
805
- await this.runInOrderSQLiteSaveQueue(async () => {
806
- await this.dbManager.clear(INDEXDB_STORE_NAME);
807
- });
775
+ await this.dbManager.clear(INDEXDB_STORE_NAME);
808
776
  }
809
777
  this.setStorageItem(ORDER_LAST_FULL_FETCH_AT_STORAGE_KEY, "");
810
778
  this.core.effects.emit(import_types.OrderHooks.onOrdersChanged, this.store.list);
@@ -324,6 +324,8 @@ export interface OrderData {
324
324
  payment_status?: OrderPaymentStatus;
325
325
  /** 发货状态(仅输出)。来源:Order.shipping_status */
326
326
  shipping_status?: OrderShippingStatus;
327
+ /** 券列表。来源:Order.vouchers */
328
+ vouchers?: any[];
327
329
  /**
328
330
  * 客户 ID(设备端从本地客户数据取详情)。
329
331
  * 来源:Order.customer_id
@@ -33,13 +33,6 @@ __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
- }
43
36
  function filterOrders(orders, filters) {
44
37
  const safeFilters = filters || {};
45
38
  if (!orders || !Array.isArray(orders)) {
@@ -140,27 +133,26 @@ function filterOrders(orders, filters) {
140
133
  }
141
134
  }
142
135
  if (safeFilters.payment_methods && safeFilters.payment_methods.length > 0) {
143
- const orderPaymentCodes = getOrderPaymentCodes(order);
144
- if (orderPaymentCodes.length === 0) {
136
+ if (!order.payment_methods || !Array.isArray(order.payment_methods) || order.payment_methods.length === 0) {
145
137
  rejected.push({
146
138
  order_id: order.order_id,
147
139
  order_number: order.order_number,
148
140
  reason: {
149
141
  field: "payment_methods",
150
- actual: order.payments,
142
+ actual: order.payment_methods,
151
143
  expected: safeFilters.payment_methods
152
144
  }
153
145
  });
154
146
  return false;
155
147
  }
156
- const hasMatch = orderPaymentCodes.some((code) => safeFilters.payment_methods.includes(code));
148
+ const hasMatch = order.payment_methods.some((pm) => safeFilters.payment_methods.includes(pm));
157
149
  if (!hasMatch) {
158
150
  rejected.push({
159
151
  order_id: order.order_id,
160
152
  order_number: order.order_number,
161
153
  reason: {
162
154
  field: "payment_methods",
163
- actual: orderPaymentCodes,
155
+ actual: order.payment_methods,
164
156
  expected: safeFilters.payment_methods
165
157
  }
166
158
  });
@@ -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 quotationBridgeLoadedKey?;
24
+ private quotationBridgeCustomerId?;
25
25
  private quotationBridgeRefreshPromise?;
26
26
  private quotationBridgeRefreshKey?;
27
27
  private productDataSource;
@@ -44,7 +44,6 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
44
44
  this.formatters = [];
45
45
  // 是否已注册内置价格格式化器
46
46
  this.isPriceFormatterRegistered = false;
47
- this.quotationBridgeLoadedKey = "";
48
47
  this.pendingSyncMessages = [];
49
48
  }
50
49
  async initialize(core, options) {
@@ -178,7 +177,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
178
177
  * Server 层负责传入完整 schedule 模块,Products 只负责把报价单计算结果转成价格响应形状。
179
178
  */
180
179
  async setupQuotationPriceBridge(params) {
181
- var _a;
180
+ var _a, _b, _c;
182
181
  if (!this.core) {
183
182
  this.logWarning("setupQuotationPriceBridge: core 尚未初始化");
184
183
  return;
@@ -191,25 +190,15 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
191
190
  this.quotationPriceBridge = quotation;
192
191
  }
193
192
  if (params.scheduleModule) {
194
- const scheduleCache = /* @__PURE__ */ new Map();
195
- let hasLoadedScheduleList = false;
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
+ );
196
197
  this.quotationPriceBridge.setScheduleResolver((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]);
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])) || [];
213
202
  return schedules[0];
214
203
  });
215
204
  }
@@ -221,7 +210,8 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
221
210
  async refreshQuotationPriceBridge(params) {
222
211
  if (!this.quotationPriceBridge)
223
212
  return;
224
- const refreshKey = this.getQuotationBridgeScopeKey();
213
+ const customerId = params && "customer_id" in params ? params.customer_id : this.quotationBridgeCustomerId;
214
+ const refreshKey = this.getQuotationBridgeScopeKey(customerId);
225
215
  if (this.quotationBridgeRefreshPromise && this.quotationBridgeRefreshKey === refreshKey) {
226
216
  await this.quotationBridgeRefreshPromise;
227
217
  return;
@@ -231,9 +221,10 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
231
221
  }
232
222
  this.quotationBridgeRefreshKey = refreshKey;
233
223
  this.quotationBridgeRefreshPromise = this.quotationPriceBridge.loadQuotations({
234
- channel: this.quotationBridgeChannel
224
+ channel: this.quotationBridgeChannel,
225
+ customer_id: customerId
235
226
  }).then(() => {
236
- this.quotationBridgeLoadedKey = refreshKey;
227
+ this.quotationBridgeCustomerId = customerId;
237
228
  }).finally(() => {
238
229
  this.quotationBridgeRefreshPromise = void 0;
239
230
  this.quotationBridgeRefreshKey = void 0;
@@ -252,12 +243,12 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
252
243
  if (this.quotationBridgeRefreshPromise) {
253
244
  await this.quotationBridgeRefreshPromise;
254
245
  }
255
- if (this.getQuotationBridgeScopeKey() !== this.quotationBridgeLoadedKey) {
246
+ if (this.getQuotationBridgeScopeKey(customerId) !== this.getQuotationBridgeScopeKey(this.quotationBridgeCustomerId)) {
256
247
  await this.refreshQuotationPriceBridge({ customer_id: customerId });
257
248
  }
258
249
  }
259
- getQuotationBridgeScopeKey() {
260
- return this.quotationBridgeChannel || "";
250
+ getQuotationBridgeScopeKey(customerId) {
251
+ return `${this.quotationBridgeChannel || ""}:${customerId ?? ""}`;
261
252
  }
262
253
  buildPriceDataFromQuotation(product, datetime, customerId) {
263
254
  var _a;
@@ -267,11 +258,10 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
267
258
  customer_id: customerId
268
259
  });
269
260
  const productPrice = quotedPrice ?? product.price;
270
- const productBasePrice = quotedPrice ?? product.base_price ?? product.price ?? 0;
271
261
  return {
272
262
  id: product.id,
273
263
  price: String(productPrice ?? 0),
274
- base_price: String(productBasePrice),
264
+ base_price: String(product.base_price ?? product.price ?? 0),
275
265
  variant: this.buildVariantPriceData(product, datetime, customerId),
276
266
  bundle_group: this.buildBundleGroupPriceData(product, datetime, customerId)
277
267
  };
@@ -288,7 +278,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
288
278
  customer_id: customerId
289
279
  });
290
280
  const price = quotedPrice ?? variant.price ?? product.price ?? 0;
291
- const basePrice = quotedPrice ?? variant.base_price ?? variant.price ?? product.base_price ?? product.price ?? 0;
281
+ const basePrice = variant.base_price ?? variant.price ?? product.base_price ?? product.price ?? 0;
292
282
  return {
293
283
  id: Number(variant.id),
294
284
  product_id: Number(variant.product_id ?? product.id),
@@ -313,7 +303,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
313
303
  customer_id: customerId
314
304
  });
315
305
  const price = quotedPrice ?? item.price ?? 0;
316
- const basePrice = quotedPrice ?? item.base_price ?? item.price ?? 0;
306
+ const basePrice = item.base_price ?? item.price ?? 0;
317
307
  return {
318
308
  id: Number(item.id),
319
309
  product_id: Number(item.product_id ?? product.id),
@@ -183,9 +183,8 @@ var ScheduleModuleEx = class extends import_BaseModule.BaseModule {
183
183
  return [];
184
184
  }
185
185
  const result = [];
186
- const scheduleList = this.store.scheduleList || [];
187
186
  for (const id of ids) {
188
- const schedule = this.store.map.get(id) || scheduleList.find((item) => String(item.id) === String(id));
187
+ const schedule = this.store.map.get(id);
189
188
  if (schedule) {
190
189
  result.push(schedule);
191
190
  }