@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
@@ -280,7 +280,6 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
280
280
  isChargeTax: (_product$is_charge_ta2 = product.is_charge_tax) !== null && _product$is_charge_ta2 !== void 0 ? _product$is_charge_ta2 : 0
281
281
  });
282
282
  var mainTaxRounded = mainTaxPrecise.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
283
- product.main_product_attached_bundle_tax_fee = mainTaxRounded.toFixed(2);
284
283
  if (mainTaxPrecise.gt(0)) {
285
284
  lastTaxableItem = {
286
285
  type: 'main',
@@ -314,16 +313,15 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
314
313
  var bundleQuantity = new Decimal(getSafeNum((_bundleItem$num2 = bundleItem.num) !== null && _bundleItem$num2 !== void 0 ? _bundleItem$num2 : bundleItem.quantity));
315
314
  var bundlePrice = toDecimal((_ref4 = (_bundleItem$bundle_se2 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se2 !== void 0 ? _bundleItem$bundle_se2 : bundleItem.price) !== null && _ref4 !== void 0 ? _ref4 : 0);
316
315
  var bundleOriginalPrice = toDecimal((_ref5 = (_ref6 = (_bundleItem$original_ = bundleItem.original_price) !== null && _bundleItem$original_ !== void 0 ? _bundleItem$original_ : bundleItem.product_price) !== null && _ref6 !== void 0 ? _ref6 : bundleItem.price) !== null && _ref5 !== void 0 ? _ref5 : 0);
317
- var bundleSurchargeFee = toDecimal(bundleItem.surcharge_fee);
318
316
  var bundleTaxPrecise = calculateSingleItemTax({
319
- price: bundlePrice.plus(bundleSurchargeFee),
317
+ price: bundlePrice,
320
318
  taxRate: rate,
321
319
  isPriceIncludeTax: isPriceIncludeTax,
322
320
  isChargeTax: (_ref7 = (_bundleItem$is_charge = bundleItem.is_charge_tax) !== null && _bundleItem$is_charge !== void 0 ? _bundleItem$is_charge : product.is_charge_tax) !== null && _ref7 !== void 0 ? _ref7 : 0
323
321
  });
324
322
  var bundleTaxRounded = bundleTaxPrecise.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
325
323
  var bundleOrigTaxPrecise = calculateSingleItemTax({
326
- price: bundleOriginalPrice.plus(bundleSurchargeFee),
324
+ price: bundleOriginalPrice,
327
325
  taxRate: rate,
328
326
  isPriceIncludeTax: isPriceIncludeTax,
329
327
  isChargeTax: (_ref8 = (_bundleItem$is_charge2 = bundleItem.is_charge_tax) !== null && _bundleItem$is_charge2 !== void 0 ? _bundleItem$is_charge2 : product.is_charge_tax) !== null && _ref8 !== void 0 ? _ref8 : 0
@@ -446,20 +444,8 @@ export function calculateSalesSummary(params) {
446
444
  isEdit: false
447
445
  }) || 0);
448
446
  for (var i = 0; i < products.length; i++) {
449
- var sourceItem = surchargeServiceItems[i] || {};
450
- var product = products[i];
451
- product.surcharge_fee = sourceItem.surcharge_fee || 0;
452
- var relationSurchargeIds = Array.isArray(sourceItem.relation_surcharge_ids) ? sourceItem.relation_surcharge_ids : [];
453
- var hasSurcharge = new Decimal(product.surcharge_fee || 0).gt(0) || relationSurchargeIds.length > 0;
454
- if (hasSurcharge) {
455
- product.main_product_attached_bundle_surcharge_fee = toFixed2(product.surcharge_fee);
456
- }
457
- if (relationSurchargeIds.length > 0) {
458
- product.relation_surcharge_ids = sourceItem.relation_surcharge_ids;
459
- }
460
- if (hasSurcharge && sourceItem.surcharge_rounding_remainder !== undefined) {
461
- product.surcharge_rounding_remainder = sourceItem.surcharge_rounding_remainder;
462
- }
447
+ var _surchargeServiceItem;
448
+ products[i].surcharge_fee = ((_surchargeServiceItem = surchargeServiceItems[i]) === null || _surchargeServiceItem === void 0 ? void 0 : _surchargeServiceItem.surcharge_fee) || 0;
463
449
  }
464
450
  var hasTaxRate = taxRate !== undefined && taxRate !== null && taxRate > 0;
465
451
  var productTaxFee;
@@ -472,8 +458,8 @@ export function calculateSalesSummary(params) {
472
458
  }, new Decimal(0));
473
459
  }
474
460
  var shopDiscountAmount = Decimal.max(new Decimal(Number(shopDiscount) || 0), 0);
475
- var preTaxExpectAmount = Decimal.max(0, productAmount.plus(surchargeAmount).minus(shopDiscountAmount));
476
- var totalAmount = isPriceIncludeTax === 1 ? preTaxExpectAmount : preTaxExpectAmount.plus(productTaxFee);
461
+ var expectAmount = Decimal.max(0, productAmount.plus(surchargeAmount).minus(shopDiscountAmount));
462
+ var totalAmount = isPriceIncludeTax === 1 ? expectAmount : expectAmount.plus(productTaxFee);
477
463
  var deposit = calculateProductsDeposit(products);
478
464
  return {
479
465
  product_quantity: productQuantity,
@@ -489,7 +475,7 @@ export function calculateSalesSummary(params) {
489
475
  discount_amount: toFixed2(Decimal.max(productOriginalAmount.minus(productAmount), 0).plus(shopDiscountAmount)),
490
476
  deposit_amount: deposit ? deposit.total : '0.00',
491
477
  deposit: deposit,
492
- expect_amount: toFixed2(totalAmount),
478
+ expect_amount: toFixed2(expectAmount),
493
479
  total_amount: toFixed2(totalAmount),
494
480
  total_refund_amount: '0.00',
495
481
  customer_paid_amount: '0.00',
@@ -205,13 +205,9 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
205
205
  }, {
206
206
  key: "getScheduleListByIds",
207
207
  value: function getScheduleListByIds(ids) {
208
- var idSet = new Set(ids.map(function (id) {
209
- return String(id);
210
- }));
211
- var list = this.store.scheduleList.filter(function (n) {
212
- return idSet.has(String(n.id));
208
+ return this.store.scheduleList.filter(function (n) {
209
+ return ids.includes(n.id);
213
210
  });
214
- return list;
215
211
  }
216
212
  }, {
217
213
  key: "setAvailabilityScheduleDateList",
@@ -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';
@@ -15,5 +15,4 @@ export * from "./SalesSummary";
15
15
  export * from "./Schedule";
16
16
  export * from "./Quotation";
17
17
  export * from "./ScanOrderLogger";
18
- export * from "./OpenData";
19
- export * from "./BookingContext";
18
+ export * from "./OpenData";
@@ -168,17 +168,16 @@ var Server = /*#__PURE__*/function () {
168
168
  */
169
169
  _defineProperty(this, "handleProductQuery", /*#__PURE__*/function () {
170
170
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
171
- var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, _ref3, callback, subscriberId;
171
+ var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, _ref3, callback, subscriberId;
172
172
  return _regeneratorRuntime().wrap(function _callee$(_context) {
173
173
  while (1) switch (_context.prev = _context.next) {
174
174
  case 0:
175
175
  url = _ref.url, method = _ref.method, data = _ref.data, config = _ref.config;
176
176
  console.log('[Server] handleProductQuery:', url, method, data, config);
177
- menu_list_ids = data.menu_list_ids, schedule_datetime = data.schedule_datetime, schedule_date = data.schedule_date, customer_id = data.customer_id, ids = data.ids;
177
+ menu_list_ids = data.menu_list_ids, schedule_datetime = data.schedule_datetime, schedule_date = data.schedule_date, customer_id = data.customer_id;
178
178
  _ref3 = config || {}, callback = _ref3.callback, subscriberId = _ref3.subscriberId;
179
179
  _this.logInfo('handleProductQuery: 开始处理商品查询请求', {
180
180
  menu_list_ids: menu_list_ids,
181
- ids: ids,
182
181
  schedule_datetime: schedule_datetime,
183
182
  schedule_date: schedule_date,
184
183
  customer_id: customer_id
@@ -190,7 +189,6 @@ var Server = /*#__PURE__*/function () {
190
189
  callback: callback,
191
190
  context: {
192
191
  menu_list_ids: menu_list_ids,
193
- ids: ids,
194
192
  schedule_date: schedule_date,
195
193
  schedule_datetime: schedule_datetime,
196
194
  customer_id: customer_id
@@ -203,7 +201,6 @@ var Server = /*#__PURE__*/function () {
203
201
  }
204
202
  return _context.abrupt("return", _this.computeProductQueryResult({
205
203
  menu_list_ids: menu_list_ids,
206
- ids: ids,
207
204
  schedule_date: schedule_date,
208
205
  schedule_datetime: schedule_datetime,
209
206
  customer_id: customer_id
@@ -1611,30 +1608,26 @@ var Server = /*#__PURE__*/function () {
1611
1608
  case 6:
1612
1609
  _context18.prev = 6;
1613
1610
  _context18.next = 9;
1614
- return this.schedule.loadAllSchedule();
1615
- case 9:
1616
- this.products.clearPriceCache();
1617
- _context18.next = 12;
1618
1611
  return this.products.setupQuotationPriceBridge({
1619
1612
  scheduleModule: this.schedule,
1620
1613
  channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel
1621
1614
  });
1622
- case 12:
1615
+ case 9:
1623
1616
  this.logInfo('Products 报价单价格桥接初始化完成');
1624
- _context18.next = 19;
1617
+ _context18.next = 16;
1625
1618
  break;
1626
- case 15:
1627
- _context18.prev = 15;
1619
+ case 12:
1620
+ _context18.prev = 12;
1628
1621
  _context18.t0 = _context18["catch"](6);
1629
1622
  errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
1630
1623
  this.logError('Products 报价单价格桥接初始化失败', {
1631
1624
  error: errorMessage
1632
1625
  });
1633
- case 19:
1626
+ case 16:
1634
1627
  case "end":
1635
1628
  return _context18.stop();
1636
1629
  }
1637
- }, _callee18, this, [[6, 15]]);
1630
+ }, _callee18, this, [[6, 12]]);
1638
1631
  }));
1639
1632
  function setupProductsQuotationPriceBridge() {
1640
1633
  return _setupProductsQuotationPriceBridge.apply(this, arguments);
@@ -3310,20 +3303,14 @@ var Server = /*#__PURE__*/function () {
3310
3303
  var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(context, options) {
3311
3304
  var _menu_list_ids$length3,
3312
3305
  _this6 = this;
3313
- var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, product_id, queryIds, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tSort;
3306
+ var tTotal, menu_list_ids, schedule_date, schedule_datetime, customer_id, product_id, _published$find, pid, _tPrice, allProductsWithPrice, published, item, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tSort;
3314
3307
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3315
3308
  while (1) switch (_context29.prev = _context29.next) {
3316
3309
  case 0:
3317
3310
  tTotal = performance.now();
3318
- menu_list_ids = context.menu_list_ids, ids = context.ids, schedule_date = context.schedule_date, schedule_datetime = context.schedule_datetime, customer_id = context.customer_id, product_id = context.product_id;
3319
- queryIds = Array.isArray(ids) ? ids.map(function (id) {
3320
- return Number(id);
3321
- }).filter(function (id) {
3322
- return Number.isFinite(id);
3323
- }) : [];
3311
+ menu_list_ids = context.menu_list_ids, schedule_date = context.schedule_date, schedule_datetime = context.schedule_datetime, customer_id = context.customer_id, product_id = context.product_id;
3324
3312
  this.logInfo('computeProductQueryResult 开始', {
3325
3313
  menuListIdsCount: (_menu_list_ids$length3 = menu_list_ids === null || menu_list_ids === void 0 ? void 0 : menu_list_ids.length) !== null && _menu_list_ids$length3 !== void 0 ? _menu_list_ids$length3 : 0,
3326
- ids: queryIds,
3327
3314
  schedule_datetime: schedule_datetime,
3328
3315
  schedule_date: schedule_date,
3329
3316
  customer_id: customer_id,
@@ -3331,7 +3318,7 @@ var Server = /*#__PURE__*/function () {
3331
3318
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
3332
3319
  });
3333
3320
  if (this.products) {
3334
- _context29.next = 7;
3321
+ _context29.next = 6;
3335
3322
  break;
3336
3323
  }
3337
3324
  this.logError('computeProductQueryResult: Products 模块未注册');
@@ -3342,67 +3329,22 @@ var Server = /*#__PURE__*/function () {
3342
3329
  count: 0
3343
3330
  }
3344
3331
  });
3345
- case 7:
3346
- if (!(queryIds.length > 0)) {
3347
- _context29.next = 18;
3348
- break;
3349
- }
3350
- uniqueIds = Array.from(new Set(queryIds));
3351
- _tPrice = performance.now();
3352
- _context29.next = 12;
3353
- return this.products.getProductsWithPrice(schedule_date, {
3354
- scheduleModule: this.getSchedule(),
3355
- schedule_datetime: schedule_datetime,
3356
- customer_id: customer_id
3357
- }, {
3358
- changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
3359
- productIds: uniqueIds
3360
- });
3361
- case 12:
3362
- productsWithPrice = _context29.sent;
3363
- perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
3364
- count: productsWithPrice.length,
3365
- ids: uniqueIds
3366
- });
3367
- _filteredProducts = productsWithPrice.filter(function (p) {
3368
- return uniqueIds.includes(Number(p === null || p === void 0 ? void 0 : p.id));
3369
- }).filter(function (p) {
3370
- return ((p === null || p === void 0 ? void 0 : p.status) || 'published') === 'published';
3371
- });
3372
- perfMark('computeProductQueryResult', performance.now() - tTotal, {
3373
- mode: 'ids',
3374
- ids: uniqueIds,
3375
- count: _filteredProducts.length
3376
- });
3377
- this.logInfo('computeProductQueryResult 完成(ids)', {
3378
- ids: uniqueIds,
3379
- count: _filteredProducts.length
3380
- });
3381
- return _context29.abrupt("return", {
3382
- code: 200,
3383
- data: {
3384
- list: _filteredProducts,
3385
- count: _filteredProducts.length
3386
- },
3387
- message: '',
3388
- status: true
3389
- });
3390
- case 18:
3332
+ case 6:
3391
3333
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
3392
- _context29.next = 30;
3334
+ _context29.next = 18;
3393
3335
  break;
3394
3336
  }
3395
3337
  pid = Number(product_id);
3396
- _tPrice2 = performance.now();
3397
- _context29.next = 23;
3338
+ _tPrice = performance.now();
3339
+ _context29.next = 11;
3398
3340
  return this.products.getProductsWithPrice(schedule_date, {
3399
3341
  scheduleModule: this.getSchedule()
3400
3342
  }, {
3401
3343
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
3402
3344
  });
3403
- case 23:
3345
+ case 11:
3404
3346
  allProductsWithPrice = _context29.sent;
3405
- perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
3347
+ perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice, {
3406
3348
  count: allProductsWithPrice.length,
3407
3349
  productId: pid
3408
3350
  });
@@ -3427,9 +3369,9 @@ var Server = /*#__PURE__*/function () {
3427
3369
  message: item ? '' : '商品不存在或未发布',
3428
3370
  status: true
3429
3371
  });
3430
- case 30:
3372
+ case 18:
3431
3373
  if (this.menu) {
3432
- _context29.next = 33;
3374
+ _context29.next = 21;
3433
3375
  break;
3434
3376
  }
3435
3377
  this.logError('computeProductQueryResult: Menu 模块未注册');
@@ -3440,9 +3382,9 @@ var Server = /*#__PURE__*/function () {
3440
3382
  count: 0
3441
3383
  }
3442
3384
  });
3443
- case 33:
3385
+ case 21:
3444
3386
  if (this.schedule) {
3445
- _context29.next = 36;
3387
+ _context29.next = 24;
3446
3388
  break;
3447
3389
  }
3448
3390
  this.logError('computeProductQueryResult: Schedule 模块未注册');
@@ -3453,7 +3395,7 @@ var Server = /*#__PURE__*/function () {
3453
3395
  count: 0
3454
3396
  }
3455
3397
  });
3456
- case 36:
3398
+ case 24:
3457
3399
  activeMenuList = [];
3458
3400
  if (menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0) {
3459
3401
  tMenu = performance.now();
@@ -3477,10 +3419,10 @@ var Server = /*#__PURE__*/function () {
3477
3419
  });
3478
3420
  tPrice = performance.now();
3479
3421
  if (!(scopedProductIds.length > 0)) {
3480
- _context29.next = 49;
3422
+ _context29.next = 37;
3481
3423
  break;
3482
3424
  }
3483
- _context29.next = 46;
3425
+ _context29.next = 34;
3484
3426
  return this.products.getProductsWithPrice(schedule_date, {
3485
3427
  scheduleModule: this.getSchedule(),
3486
3428
  schedule_datetime: schedule_datetime,
@@ -3489,13 +3431,13 @@ var Server = /*#__PURE__*/function () {
3489
3431
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
3490
3432
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
3491
3433
  });
3492
- case 46:
3434
+ case 34:
3493
3435
  _context29.t0 = _context29.sent;
3494
- _context29.next = 50;
3436
+ _context29.next = 38;
3495
3437
  break;
3496
- case 49:
3438
+ case 37:
3497
3439
  _context29.t0 = [];
3498
- case 50:
3440
+ case 38:
3499
3441
  filteredProducts = _context29.t0;
3500
3442
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
3501
3443
  count: filteredProducts.length,
@@ -3538,7 +3480,7 @@ var Server = /*#__PURE__*/function () {
3538
3480
  message: '',
3539
3481
  status: true
3540
3482
  });
3541
- case 62:
3483
+ case 50:
3542
3484
  case "end":
3543
3485
  return _context29.stop();
3544
3486
  }
@@ -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
  }
@@ -63,7 +63,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
63
63
  _defineProperty(_assertThisInitialized(_this), "logger", void 0);
64
64
  // LoggerManager 实例
65
65
  _defineProperty(_assertThisInitialized(_this), "storage", void 0);
66
- _defineProperty(_assertThisInitialized(_this), "orderSQLiteSaveQueue", Promise.resolve());
67
66
  return _this;
68
67
  }
69
68
  _createClass(OrderModule, [{
@@ -1277,168 +1276,92 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1277
1276
  }
1278
1277
  return loadOrdersFromSQLite;
1279
1278
  }()
1280
- /**
1281
- * 串行执行订单 SQLite 保存任务,保证 clear + bulkAdd 组合不会被其它订单保存插入。
1282
- *
1283
- * @example
1284
- * await this.runInOrderSQLiteSaveQueue(async () => {
1285
- * await this.dbManager.clear(INDEXDB_STORE_NAME)
1286
- * await this.dbManager.bulkAdd(INDEXDB_STORE_NAME, orders)
1287
- * })
1288
- */
1289
1279
  }, {
1290
- key: "runInOrderSQLiteSaveQueue",
1291
- value: (function () {
1292
- var _runInOrderSQLiteSaveQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(task) {
1293
- var queuedTask;
1280
+ key: "saveOrdersToSQLite",
1281
+ value: function () {
1282
+ var _saveOrdersToSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderList) {
1294
1283
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1295
1284
  while (1) switch (_context15.prev = _context15.next) {
1296
- case 0:
1297
- queuedTask = this.orderSQLiteSaveQueue.then(task, task);
1298
- this.orderSQLiteSaveQueue = queuedTask.then(function () {
1299
- return undefined;
1300
- }, function () {
1301
- return undefined;
1302
- });
1303
- return _context15.abrupt("return", queuedTask);
1304
- case 3:
1305
- case "end":
1306
- return _context15.stop();
1307
- }
1308
- }, _callee15, this);
1309
- }));
1310
- function runInOrderSQLiteSaveQueue(_x8) {
1311
- return _runInOrderSQLiteSaveQueue.apply(this, arguments);
1312
- }
1313
- return runInOrderSQLiteSaveQueue;
1314
- }()
1315
- /**
1316
- * 保存订单列表到 SQLite,内部会先清空 orders 表再批量写入当前快照。
1317
- *
1318
- * @example
1319
- * await this.saveOrdersToSQLite(this.store.list)
1320
- */
1321
- )
1322
- }, {
1323
- key: "saveOrdersToSQLite",
1324
- value: (function () {
1325
- var _saveOrdersToSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orderList) {
1326
- var _this10 = this;
1327
- var orderListSnapshot;
1328
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1329
- while (1) switch (_context17.prev = _context17.next) {
1330
1285
  case 0:
1331
1286
  if (this.dbManager) {
1332
- _context17.next = 2;
1287
+ _context15.next = 2;
1333
1288
  break;
1334
1289
  }
1335
- return _context17.abrupt("return");
1290
+ return _context15.abrupt("return");
1336
1291
  case 2:
1337
- orderListSnapshot = cloneDeep(orderList);
1338
- _context17.prev = 3;
1339
- _context17.next = 6;
1340
- return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1341
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1342
- while (1) switch (_context16.prev = _context16.next) {
1343
- case 0:
1344
- _this10.logInfo('saveOrdersToSQLite-开始', {
1345
- count: orderListSnapshot.length
1346
- });
1347
- _context16.next = 3;
1348
- return _this10.dbManager.clear(INDEXDB_STORE_NAME);
1349
- case 3:
1350
- _this10.logInfo('saveOrdersToSQLite-clear完成', {
1351
- count: orderListSnapshot.length
1352
- });
1353
- if (!(orderListSnapshot.length === 0)) {
1354
- _context16.next = 6;
1355
- break;
1356
- }
1357
- return _context16.abrupt("return");
1358
- case 6:
1359
- _context16.next = 8;
1360
- return _this10.dbManager.bulkAdd(INDEXDB_STORE_NAME, orderListSnapshot);
1361
- case 8:
1362
- _this10.logInfo('saveOrdersToSQLite-bulkAdd完成', {
1363
- count: orderListSnapshot.length
1364
- });
1365
- case 9:
1366
- case "end":
1367
- return _context16.stop();
1368
- }
1369
- }, _callee16);
1370
- })));
1292
+ _context15.prev = 2;
1293
+ this.logInfo('saveOrdersToSQLite-开始', {
1294
+ count: orderList.length
1295
+ });
1296
+ _context15.next = 6;
1297
+ return this.dbManager.clear(INDEXDB_STORE_NAME);
1371
1298
  case 6:
1372
- _context17.next = 11;
1299
+ this.logInfo('saveOrdersToSQLite-clear完成', {
1300
+ count: orderList.length
1301
+ });
1302
+ if (!(orderList.length === 0)) {
1303
+ _context15.next = 9;
1304
+ break;
1305
+ }
1306
+ return _context15.abrupt("return");
1307
+ case 9:
1308
+ _context15.next = 11;
1309
+ return this.dbManager.bulkAdd(INDEXDB_STORE_NAME, orderList);
1310
+ case 11:
1311
+ this.logInfo('saveOrdersToSQLite-bulkAdd完成', {
1312
+ count: orderList.length
1313
+ });
1314
+ _context15.next = 17;
1373
1315
  break;
1374
- case 8:
1375
- _context17.prev = 8;
1376
- _context17.t0 = _context17["catch"](3);
1316
+ case 14:
1317
+ _context15.prev = 14;
1318
+ _context15.t0 = _context15["catch"](2);
1377
1319
  // SQLite 异常,避免影响主流程
1378
1320
  this.logError('保存订单到 SQLite 失败', {
1379
- error: _context17.t0 instanceof Error ? _context17.t0.message : String(_context17.t0),
1380
- orderList: orderListSnapshot.length
1321
+ error: _context15.t0 instanceof Error ? _context15.t0.message : String(_context15.t0),
1322
+ orderList: orderList.length
1381
1323
  });
1382
- case 11:
1324
+ case 17:
1383
1325
  case "end":
1384
- return _context17.stop();
1326
+ return _context15.stop();
1385
1327
  }
1386
- }, _callee17, this, [[3, 8]]);
1328
+ }, _callee15, this, [[2, 14]]);
1387
1329
  }));
1388
- function saveOrdersToSQLite(_x9) {
1330
+ function saveOrdersToSQLite(_x8) {
1389
1331
  return _saveOrdersToSQLite.apply(this, arguments);
1390
1332
  }
1391
1333
  return saveOrdersToSQLite;
1392
1334
  }()
1393
- /**
1394
- * 清空订单模块的内存数据和本地 SQLite 订单表。
1395
- *
1396
- * @example
1397
- * await orderModule.clear()
1398
- */
1399
- )
1400
1335
  }, {
1401
1336
  key: "clear",
1402
- value: (function () {
1403
- var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1404
- var _this11 = this;
1405
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1406
- while (1) switch (_context19.prev = _context19.next) {
1337
+ value: function () {
1338
+ var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1339
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1340
+ while (1) switch (_context16.prev = _context16.next) {
1407
1341
  case 0:
1408
1342
  this.store.list = [];
1409
1343
  this.store.map = new Map();
1410
1344
  this.resourceIdIndex.clear();
1411
1345
  if (!this.dbManager) {
1412
- _context19.next = 6;
1346
+ _context16.next = 6;
1413
1347
  break;
1414
1348
  }
1415
- _context19.next = 6;
1416
- return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1417
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1418
- while (1) switch (_context18.prev = _context18.next) {
1419
- case 0:
1420
- _context18.next = 2;
1421
- return _this11.dbManager.clear(INDEXDB_STORE_NAME);
1422
- case 2:
1423
- case "end":
1424
- return _context18.stop();
1425
- }
1426
- }, _callee18);
1427
- })));
1349
+ _context16.next = 6;
1350
+ return this.dbManager.clear(INDEXDB_STORE_NAME);
1428
1351
  case 6:
1429
1352
  this.setStorageItem(ORDER_LAST_FULL_FETCH_AT_STORAGE_KEY, '');
1430
1353
  this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
1431
1354
  case 8:
1432
1355
  case "end":
1433
- return _context19.stop();
1356
+ return _context16.stop();
1434
1357
  }
1435
- }, _callee19, this);
1358
+ }, _callee16, this);
1436
1359
  }));
1437
1360
  function clear() {
1438
1361
  return _clear.apply(this, arguments);
1439
1362
  }
1440
1363
  return clear;
1441
- }())
1364
+ }()
1442
1365
  }]);
1443
1366
  return OrderModule;
1444
1367
  }(BaseModule);
@@ -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