@pisell/pisellos 2.2.181 → 2.2.183

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 (173) hide show
  1. package/dist/modules/BookingContext/index.d.ts +37 -0
  2. package/dist/modules/BookingContext/index.js +436 -0
  3. package/dist/modules/BookingContext/types.d.ts +102 -0
  4. package/dist/modules/BookingContext/types.js +51 -0
  5. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  6. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +276 -0
  7. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  8. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
  9. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
  10. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +215 -0
  11. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  12. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  13. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  14. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  15. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  16. package/dist/modules/BookingContext/utils/index.js +11 -0
  17. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  18. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  19. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  20. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  21. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  22. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  23. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  24. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  25. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  26. package/dist/modules/BookingContext/utils/resources.js +486 -0
  27. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  28. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  29. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  30. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  31. package/dist/modules/Customer/index.d.ts +6 -0
  32. package/dist/modules/Customer/index.js +129 -83
  33. package/dist/modules/Customer/types.d.ts +2 -0
  34. package/dist/modules/Discount/index.js +4 -3
  35. package/dist/modules/Discount/types.d.ts +1 -0
  36. package/dist/modules/Order/index.d.ts +100 -9
  37. package/dist/modules/Order/index.js +1447 -499
  38. package/dist/modules/Order/types.d.ts +201 -18
  39. package/dist/modules/Order/types.js +31 -0
  40. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  41. package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
  42. package/dist/modules/Order/utils.d.ts +83 -1
  43. package/dist/modules/Order/utils.js +405 -61
  44. package/dist/modules/Product/index.d.ts +1 -1
  45. package/dist/modules/Quotation/index.d.ts +0 -1
  46. package/dist/modules/Quotation/index.js +23 -21
  47. package/dist/modules/Rules/index.d.ts +4 -0
  48. package/dist/modules/Rules/index.js +43 -39
  49. package/dist/modules/Rules/types.d.ts +1 -0
  50. package/dist/modules/SalesSummary/index.js +4 -2
  51. package/dist/modules/SalesSummary/utils.js +21 -7
  52. package/dist/modules/Schedule/index.js +6 -2
  53. package/dist/modules/index.d.ts +1 -0
  54. package/dist/modules/index.js +2 -1
  55. package/dist/server/index.js +87 -29
  56. package/dist/server/modules/order/index.d.ts +23 -0
  57. package/dist/server/modules/order/index.js +123 -46
  58. package/dist/server/modules/order/utils/filterOrders.js +20 -6
  59. package/dist/server/modules/products/index.d.ts +1 -1
  60. package/dist/server/modules/products/index.js +130 -113
  61. package/dist/server/modules/schedule/index.js +13 -6
  62. package/dist/solution/BaseSales/index.d.ts +89 -7
  63. package/dist/solution/BaseSales/index.js +1504 -380
  64. package/dist/solution/BaseSales/types.d.ts +67 -1
  65. package/dist/solution/BaseSales/types.js +3 -1
  66. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +275 -0
  67. package/dist/solution/BaseSales/utils/cartPromotion.js +1258 -0
  68. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  69. package/dist/solution/BaseSales/utils/quotationPrice.js +237 -0
  70. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +68 -16
  71. package/dist/solution/BaseSales/utils.js +46 -8
  72. package/dist/solution/BookingByStep/index.d.ts +1 -1
  73. package/dist/solution/BookingTicket/index.d.ts +151 -1
  74. package/dist/solution/BookingTicket/index.js +848 -184
  75. package/dist/solution/BookingTicket/types.d.ts +2 -0
  76. package/dist/solution/BookingTicket/types.js +3 -0
  77. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
  78. package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
  79. package/dist/solution/BookingTicket/utils/cartView.js +4 -2
  80. package/dist/solution/ScanOrder/index.d.ts +9 -3
  81. package/dist/solution/ScanOrder/index.js +231 -128
  82. package/dist/solution/ScanOrder/utils.js +46 -8
  83. package/dist/solution/VenueBooking/index.d.ts +5 -2
  84. package/dist/solution/VenueBooking/index.js +103 -55
  85. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  86. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
  87. package/lib/modules/BookingContext/index.d.ts +37 -0
  88. package/lib/modules/BookingContext/index.js +297 -0
  89. package/lib/modules/BookingContext/types.d.ts +102 -0
  90. package/lib/modules/BookingContext/types.js +34 -0
  91. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  92. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +271 -0
  93. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  94. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
  95. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
  96. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +198 -0
  97. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  98. package/lib/modules/BookingContext/utils/flexible.js +80 -0
  99. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  100. package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
  101. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  102. package/lib/modules/BookingContext/utils/index.js +43 -0
  103. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  104. package/lib/modules/BookingContext/utils/noResource.js +90 -0
  105. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  106. package/lib/modules/BookingContext/utils/productExtend.js +283 -0
  107. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  108. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  109. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  110. package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
  111. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  112. package/lib/modules/BookingContext/utils/resources.js +377 -0
  113. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  114. package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
  115. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  116. package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
  117. package/lib/modules/Customer/index.d.ts +6 -0
  118. package/lib/modules/Customer/index.js +26 -11
  119. package/lib/modules/Customer/types.d.ts +2 -0
  120. package/lib/modules/Discount/index.js +5 -1
  121. package/lib/modules/Discount/types.d.ts +1 -0
  122. package/lib/modules/Order/index.d.ts +100 -9
  123. package/lib/modules/Order/index.js +751 -160
  124. package/lib/modules/Order/types.d.ts +201 -18
  125. package/lib/modules/Order/types.js +1 -0
  126. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  127. package/lib/modules/Order/utils/manualProductDiscount.js +206 -0
  128. package/lib/modules/Order/utils.d.ts +83 -1
  129. package/lib/modules/Order/utils.js +340 -22
  130. package/lib/modules/Product/index.d.ts +1 -1
  131. package/lib/modules/Quotation/index.d.ts +0 -1
  132. package/lib/modules/Quotation/index.js +18 -15
  133. package/lib/modules/Rules/index.d.ts +4 -0
  134. package/lib/modules/Rules/index.js +26 -27
  135. package/lib/modules/Rules/types.d.ts +1 -0
  136. package/lib/modules/SalesSummary/index.js +4 -2
  137. package/lib/modules/SalesSummary/utils.js +21 -7
  138. package/lib/modules/Schedule/index.js +3 -1
  139. package/lib/modules/index.d.ts +1 -0
  140. package/lib/modules/index.js +3 -1
  141. package/lib/server/index.js +41 -4
  142. package/lib/server/modules/order/index.d.ts +23 -0
  143. package/lib/server/modules/order/index.js +46 -14
  144. package/lib/server/modules/order/utils/filterOrders.js +12 -4
  145. package/lib/server/modules/products/index.d.ts +1 -1
  146. package/lib/server/modules/products/index.js +30 -20
  147. package/lib/server/modules/schedule/index.js +2 -1
  148. package/lib/solution/BaseSales/index.d.ts +89 -7
  149. package/lib/solution/BaseSales/index.js +743 -23
  150. package/lib/solution/BaseSales/types.d.ts +67 -1
  151. package/lib/solution/BaseSales/types.js +3 -1
  152. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +275 -0
  153. package/lib/solution/BaseSales/utils/cartPromotion.js +836 -0
  154. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  155. package/lib/solution/BaseSales/utils/quotationPrice.js +277 -0
  156. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +71 -12
  157. package/lib/solution/BaseSales/utils.js +46 -6
  158. package/lib/solution/BookingByStep/index.d.ts +1 -1
  159. package/lib/solution/BookingTicket/index.d.ts +151 -1
  160. package/lib/solution/BookingTicket/index.js +389 -9
  161. package/lib/solution/BookingTicket/types.d.ts +2 -0
  162. package/lib/solution/BookingTicket/types.js +6 -0
  163. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
  164. package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
  165. package/lib/solution/BookingTicket/utils/cartView.js +4 -2
  166. package/lib/solution/ScanOrder/index.d.ts +9 -3
  167. package/lib/solution/ScanOrder/index.js +147 -66
  168. package/lib/solution/ScanOrder/utils.js +46 -6
  169. package/lib/solution/VenueBooking/index.d.ts +5 -2
  170. package/lib/solution/VenueBooking/index.js +50 -14
  171. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  172. package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
  173. package/package.json +1 -1
@@ -78,22 +78,21 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
78
78
  case 0:
79
79
  query = {};
80
80
  if (params !== null && params !== void 0 && params.channel) query.channel = params.channel;
81
- if (params !== null && params !== void 0 && params.customer_id) query.customer_id = String(params.customer_id);
82
81
  if ((params === null || params === void 0 ? void 0 : params.channel) === 'online_store') {
83
82
  query.channel = 'online-store';
84
83
  }
85
- _context2.next = 6;
84
+ _context2.next = 5;
86
85
  return this.request.get('/quotation/available', query, {
87
86
  useCache: false
88
87
  });
89
- case 6:
88
+ case 5:
90
89
  res = _context2.sent;
91
- list = this.filterQuotationsByCustomer((res === null || res === void 0 || (_data = res.data) === null || _data === void 0 ? void 0 : _data.list) || (res === null || res === void 0 ? void 0 : res.list) || [], params === null || params === void 0 ? void 0 : params.customer_id);
90
+ list = (res === null || res === void 0 || (_data = res.data) === null || _data === void 0 ? void 0 : _data.list) || (res === null || res === void 0 ? void 0 : res.list) || [];
92
91
  list.sort(function (a, b) {
93
92
  return a.sort - b.sort;
94
93
  });
95
94
  this.store.list = list;
96
- case 10:
95
+ case 9:
97
96
  case "end":
98
97
  return _context2.stop();
99
98
  }
@@ -130,8 +129,10 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
130
129
  try {
131
130
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
132
131
  var quotation = _step.value;
133
- if (!this.isQuotationVisibleForCustomer(quotation, customer_id)) continue;
134
- if (!this.isQuotationActiveAt(quotation, datetime)) continue;
132
+ var visible = this.isQuotationVisibleForCustomer(quotation, customer_id);
133
+ if (!visible) continue;
134
+ var active = this.isQuotationActiveAt(quotation, datetime);
135
+ if (!active) continue;
135
136
  var match = this.findProductData(quotation.product_data, productId, variantId);
136
137
  if (!match) continue;
137
138
  if (match.value === 0) continue;
@@ -218,14 +219,6 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
218
219
  value: function setScheduleResolver(resolver) {
219
220
  this.scheduleResolver = resolver;
220
221
  }
221
- }, {
222
- key: "filterQuotationsByCustomer",
223
- value: function filterQuotationsByCustomer(list, customerId) {
224
- var _this2 = this;
225
- return list.filter(function (quotation) {
226
- return _this2.isQuotationVisibleForCustomer(quotation, customerId);
227
- });
228
- }
229
222
  }, {
230
223
  key: "isQuotationVisibleForCustomer",
231
224
  value: function isQuotationVisibleForCustomer(quotation, customerId) {
@@ -246,18 +239,27 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
246
239
  key: "isQuotationActiveAt",
247
240
  value: function isQuotationActiveAt(quotation, datetime) {
248
241
  var _quotation$schedule,
249
- _this3 = this;
242
+ _this2 = this;
250
243
  if (!((_quotation$schedule = quotation.schedule) !== null && _quotation$schedule !== void 0 && _quotation$schedule.length)) return false;
251
- var scheduleItems = quotation.schedule.map(function (s) {
252
- var _this3$scheduleResolv;
253
- var full = (_this3$scheduleResolv = _this3.scheduleResolver) === null || _this3$scheduleResolv === void 0 ? void 0 : _this3$scheduleResolv.call(_this3, s.id);
254
- if (full) return full;
255
- return _objectSpread(_objectSpread({}, s), {}, {
244
+ var scheduleItems = [];
245
+ quotation.schedule.forEach(function (s) {
246
+ var _this2$scheduleResolv;
247
+ var full = (_this2$scheduleResolv = _this2.scheduleResolver) === null || _this2$scheduleResolv === void 0 ? void 0 : _this2$scheduleResolv.call(_this2, s.id);
248
+ if (full) {
249
+ scheduleItems.push(full);
250
+ return;
251
+ }
252
+ if (_this2.scheduleResolver) {
253
+ return;
254
+ }
255
+ var fallbackSchedule = _objectSpread(_objectSpread({}, s), {}, {
256
256
  repeat_type: s.repeat_type || 'none',
257
257
  repeat_rule: s.repeat_rule || null,
258
258
  time_slot: s.time_slot || []
259
259
  });
260
+ scheduleItems.push(fallbackSchedule);
260
261
  });
262
+ if (!scheduleItems.length) return false;
261
263
  return getDateIsInSchedule(datetime, scheduleItems);
262
264
  }
263
265
  }, {
@@ -32,6 +32,10 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
32
32
  unavailableReason?: UnavailableReason;
33
33
  };
34
34
  filterDiscountListByType(discountList: Discount[], type: string): Discount[];
35
+ /** 剔除指定 type/tag 的折扣项,保留手动改价(type=product) / 券等 */
36
+ excludeDiscountListByType(discountList: Discount[], type: string): Discount[];
37
+ /** 手动改价场景:去掉 promotion,保留 type=product 等行内折扣 */
38
+ resolveDiscountListForManualOverride(discountList: Discount[]): Discount[];
35
39
  private getUnavailableReason;
36
40
  calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
37
41
  discountList: Discount[];
@@ -222,6 +222,22 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
222
222
  return item.type === type || item.tag === type;
223
223
  });
224
224
  }
225
+
226
+ /** 剔除指定 type/tag 的折扣项,保留手动改价(type=product) / 券等 */
227
+ }, {
228
+ key: "excludeDiscountListByType",
229
+ value: function excludeDiscountListByType(discountList, type) {
230
+ return (discountList || []).filter(function (item) {
231
+ return item.type !== type && item.tag !== type;
232
+ });
233
+ }
234
+
235
+ /** 手动改价场景:去掉 promotion,保留 type=product 等行内折扣 */
236
+ }, {
237
+ key: "resolveDiscountListForManualOverride",
238
+ value: function resolveDiscountListForManualOverride(discountList) {
239
+ return this.excludeDiscountListByType(discountList, 'promotion');
240
+ }
225
241
  // 获取券不可用的原因
226
242
  }, {
227
243
  key: "getUnavailableReason",
@@ -760,7 +776,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
760
776
  }
761
777
  }
762
778
  });
763
- console.log('occupiedItems', occupiedItems, 'orderLevelDiscountApplicableItems', orderLevelDiscountApplicableItems);
764
779
 
765
780
  // 🔥 第三步:识别 order_level 折扣卡并预计算分摊(排除被其他专属折扣卡占用的商品)
766
781
  sortedDiscountList.forEach(function (discount) {
@@ -1208,7 +1223,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1208
1223
  price: product.price,
1209
1224
  options: restoredOptions
1210
1225
  }), {}, {
1211
- discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
1226
+ discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(product.discount_list) : _this3.filterDiscountListByType(product.discount_list, 'promotion')
1212
1227
  }))]);
1213
1228
  } else {
1214
1229
  var _ref13, _product$_promotion$f, _product13, _product$origin_total;
@@ -1231,14 +1246,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1231
1246
  main_product_selling_price: main_product_selling_price,
1232
1247
  options: restoredOptions
1233
1248
  }), {}, {
1234
- discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
1249
+ discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(product.discount_list) : _this3.filterDiscountListByType(product.discount_list, 'promotion')
1235
1250
  }))]);
1236
1251
  }
1237
1252
  } else {
1238
- var _flatItem$bundleItem8;
1253
+ var _flatItem$bundleItem8, _flatItem$bundleItem9;
1239
1254
  // bundle子商品:保存到扁平化Map
1240
1255
  processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
1241
- discount_list: _this3.filterDiscountListByType(((_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.discount_list) || [], 'promotion'),
1256
+ discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(((_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.discount_list) || []) : _this3.filterDiscountListByType(((_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.discount_list) || [], 'promotion'),
1242
1257
  price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
1243
1258
  processed: true
1244
1259
  })]);
@@ -1847,7 +1862,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1847
1862
  } else {
1848
1863
  // 🔥 没有子商品被拆分,使用原有逻辑
1849
1864
  mainProductArr.forEach(function (mainProduct) {
1850
- var _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
1865
+ var _ref14, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
1851
1866
  var mainProductData = _this3.hooks.getProduct(mainProduct);
1852
1867
 
1853
1868
  // 重组bundle
@@ -1886,8 +1901,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1886
1901
  });
1887
1902
  }
1888
1903
 
1889
- // 🔥 重新计算主商品的总价(包含bundle
1890
- var newTotal = Number(mainProductData.price || 0);
1904
+ // 主商品已经在前面的 setProduct 中应用过折扣;这里只替换 bundle
1905
+ // 避免把主商品 discount_list 再扣一次。
1906
+ var mainSellingPrice = (_ref14 = (_mainProductData$main = mainProductData.main_product_selling_price) !== null && _mainProductData$main !== void 0 ? _mainProductData$main : mainProductData.price) !== null && _ref14 !== void 0 ? _ref14 : 0;
1907
+ var newTotal = Number(mainSellingPrice || 0);
1891
1908
  var newOriginTotal = Number(mainProductData.original_price || mainProductData.price || 0);
1892
1909
 
1893
1910
  // 判断是否是手动折扣
@@ -1901,24 +1918,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1901
1918
  newTotal = (_mainProductData$tota = mainProductData.total) !== null && _mainProductData$tota !== void 0 ? _mainProductData$tota : newTotal;
1902
1919
  newOriginTotal = (_mainProductData$orig3 = mainProductData.origin_total) !== null && _mainProductData$orig3 !== void 0 ? _mainProductData$orig3 : newOriginTotal;
1903
1920
  } else {
1904
- // 不是手动折扣时,才重新计算
1905
- var _mainDiscountList = mainProductData.discount_list.filter(function (item) {
1906
- var _item$metadata5;
1907
- return !(item !== null && item !== void 0 && (_item$metadata5 = item.metadata) !== null && _item$metadata5 !== void 0 && _item$metadata5.custom_product_bundle_map_id);
1908
- });
1909
-
1910
- // 如果主商品本身有折扣,需要重新计算主商品价格
1911
- if (_mainDiscountList && _mainDiscountList.length > 0) {
1912
- var _Decimal$minus$toNumb3, _mainProductData$orig4;
1913
- var _allDiscountAmount2 = getDiscountListAmount(_mainDiscountList);
1914
- newTotal = (_Decimal$minus$toNumb3 = new Decimal(mainProductData.price || 0).minus(_allDiscountAmount2).toNumber()) !== null && _Decimal$minus$toNumb3 !== void 0 ? _Decimal$minus$toNumb3 : newTotal;
1915
- newOriginTotal = (_mainProductData$orig4 = mainProductData.origin_total) !== null && _mainProductData$orig4 !== void 0 ? _mainProductData$orig4 : newOriginTotal;
1916
- }
1917
-
1918
- // 累加bundle的价格(只累加一次)
1921
+ // 累加 bundle 的折后价格(只累加一次)
1919
1922
  if (newBundle.length > 0) {
1920
1923
  newBundle.forEach(function (item) {
1921
- newTotal += Number(item.price) * Number(item.num);
1924
+ var _item$bundle_selling_;
1925
+ var bundleSellingPrice = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price;
1926
+ newTotal += Number(bundleSellingPrice) * Number(item.num);
1922
1927
  });
1923
1928
 
1924
1929
  // 计算原始总价(不考虑折扣)
@@ -2020,7 +2025,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2020
2025
  appliedProductDetails: []
2021
2026
  });
2022
2027
  });
2023
- console.log(processedProductList, 'processedProductList');
2024
2028
  return {
2025
2029
  productList: processedProductList,
2026
2030
  discountList: [].concat(editModeDiscount, _toConsumableArray(updatedDiscountList))
@@ -2047,14 +2051,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2047
2051
  var ruleType = usageRules.type;
2048
2052
  // 套餐适用范围配置
2049
2053
  var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
2050
- var _ref14 = packageScope || {},
2051
- scopeType = _ref14.type,
2052
- _ref14$exclude_bundle = _ref14.exclude_bundle_product_ids,
2053
- exclude_bundle_product_ids = _ref14$exclude_bundle === void 0 ? [] : _ref14$exclude_bundle,
2054
- _ref14$include_bundle = _ref14.include_bundle_product_ids,
2055
- include_bundle_product_ids = _ref14$include_bundle === void 0 ? [] : _ref14$include_bundle,
2056
- _ref14$filter = _ref14.filter,
2057
- filter = _ref14$filter === void 0 ? 0 : _ref14$filter;
2054
+ var _ref15 = packageScope || {},
2055
+ scopeType = _ref15.type,
2056
+ _ref15$exclude_bundle = _ref15.exclude_bundle_product_ids,
2057
+ exclude_bundle_product_ids = _ref15$exclude_bundle === void 0 ? [] : _ref15$exclude_bundle,
2058
+ _ref15$include_bundle = _ref15.include_bundle_product_ids,
2059
+ include_bundle_product_ids = _ref15$include_bundle === void 0 ? [] : _ref15$include_bundle,
2060
+ _ref15$filter = _ref15.filter,
2061
+ filter = _ref15$filter === void 0 ? 0 : _ref15$filter;
2058
2062
  var isMainProduct = flatItem.type === 'main'; // 单独购买
2059
2063
  var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
2060
2064
 
@@ -2069,10 +2073,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2069
2073
  return true; // 单独购买时可用
2070
2074
  }
2071
2075
  if (isBundleItem) {
2072
- var _flatItem$bundleItem9, _flatItem$bundleItem10, _flatItem$originProdu, _flatItem$parentProdu10;
2076
+ var _flatItem$bundleItem10, _flatItem$bundleItem11, _flatItem$originProdu, _flatItem$parentProdu10;
2073
2077
  // 套餐中购买时,判断是否为原价
2074
- var priceType = (_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.price_type;
2075
- var priceTypeExt = (_flatItem$bundleItem10 = flatItem.bundleItem) === null || _flatItem$bundleItem10 === void 0 ? void 0 : _flatItem$bundleItem10.price_type_ext;
2078
+ var priceType = (_flatItem$bundleItem10 = flatItem.bundleItem) === null || _flatItem$bundleItem10 === void 0 ? void 0 : _flatItem$bundleItem10.price_type;
2079
+ var priceTypeExt = (_flatItem$bundleItem11 = flatItem.bundleItem) === null || _flatItem$bundleItem11 === void 0 ? void 0 : _flatItem$bundleItem11.price_type_ext;
2076
2080
  // 主商品id
2077
2081
  var mainProductId = (flatItem === null || flatItem === void 0 || (_flatItem$originProdu = flatItem.originProduct) === null || _flatItem$originProdu === void 0 || (_flatItem$originProdu = _flatItem$originProdu._productOrigin) === null || _flatItem$originProdu === void 0 ? void 0 : _flatItem$originProdu.id) || (flatItem === null || flatItem === void 0 || (_flatItem$parentProdu10 = flatItem.parentProduct) === null || _flatItem$parentProdu10 === void 0 ? void 0 : _flatItem$parentProdu10.id) || 0;
2078
2082
  // original_price 对应:
@@ -2139,10 +2143,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2139
2143
  return false; // 单独购买时不可用
2140
2144
  }
2141
2145
  if (isBundleItem) {
2142
- var _flatItem$bundleItem11, _flatItem$bundleItem12;
2146
+ var _flatItem$bundleItem12, _flatItem$bundleItem13;
2143
2147
  // 套餐中购买时,判断是否为原价
2144
- var _priceType = (_flatItem$bundleItem11 = flatItem.bundleItem) === null || _flatItem$bundleItem11 === void 0 ? void 0 : _flatItem$bundleItem11.price_type;
2145
- var _priceTypeExt = (_flatItem$bundleItem12 = flatItem.bundleItem) === null || _flatItem$bundleItem12 === void 0 ? void 0 : _flatItem$bundleItem12.price_type_ext;
2148
+ var _priceType = (_flatItem$bundleItem12 = flatItem.bundleItem) === null || _flatItem$bundleItem12 === void 0 ? void 0 : _flatItem$bundleItem12.price_type;
2149
+ var _priceTypeExt = (_flatItem$bundleItem13 = flatItem.bundleItem) === null || _flatItem$bundleItem13 === void 0 ? void 0 : _flatItem$bundleItem13.price_type_ext;
2146
2150
 
2147
2151
  // original_price 对应:
2148
2152
  // 1. price_type: "markup" && price_type_ext: "product_price"
@@ -53,6 +53,7 @@ type ProductDetail = {
53
53
  vouchersApplicable?: boolean;
54
54
  holder_id?: number;
55
55
  startDate?: any;
56
+ main_product_selling_price?: number | string;
56
57
  };
57
58
  export interface RulesParamsHooks {
58
59
  getProduct: (product: Record<string, any>) => ProductDetail;
@@ -27,7 +27,8 @@ export * from "./types";
27
27
  var salesSummaryDataKeys = {
28
28
  isPriceIncludeTax: 'is_price_include_tax',
29
29
  taxRate: 'tax_rate',
30
- taxTitle: 'tax_title'
30
+ taxTitle: 'tax_title',
31
+ taxCountryCode: 'tax_country_code'
31
32
  };
32
33
  export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
33
34
  _inherits(SalesSummaryModule, _BaseModule);
@@ -135,7 +136,8 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
135
136
  return {
136
137
  isPriceIncludeTax: this.getAppData(salesSummaryDataKeys.isPriceIncludeTax),
137
138
  taxRate: this.getAppData(salesSummaryDataKeys.taxRate),
138
- taxTitle: this.getAppData(salesSummaryDataKeys.taxTitle)
139
+ taxTitle: this.getAppData(salesSummaryDataKeys.taxTitle),
140
+ taxCountryCode: this.getAppData(salesSummaryDataKeys.taxCountryCode)
139
141
  };
140
142
  }
141
143
  }, {
@@ -280,6 +280,7 @@ 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);
283
284
  if (mainTaxPrecise.gt(0)) {
284
285
  lastTaxableItem = {
285
286
  type: 'main',
@@ -313,15 +314,16 @@ function calculateProductsTax(products, taxRate, isPriceIncludeTax) {
313
314
  var bundleQuantity = new Decimal(getSafeNum((_bundleItem$num2 = bundleItem.num) !== null && _bundleItem$num2 !== void 0 ? _bundleItem$num2 : bundleItem.quantity));
314
315
  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);
315
316
  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);
316
318
  var bundleTaxPrecise = calculateSingleItemTax({
317
- price: bundlePrice,
319
+ price: bundlePrice.plus(bundleSurchargeFee),
318
320
  taxRate: rate,
319
321
  isPriceIncludeTax: isPriceIncludeTax,
320
322
  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
321
323
  });
322
324
  var bundleTaxRounded = bundleTaxPrecise.toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
323
325
  var bundleOrigTaxPrecise = calculateSingleItemTax({
324
- price: bundleOriginalPrice,
326
+ price: bundleOriginalPrice.plus(bundleSurchargeFee),
325
327
  taxRate: rate,
326
328
  isPriceIncludeTax: isPriceIncludeTax,
327
329
  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
@@ -444,8 +446,20 @@ export function calculateSalesSummary(params) {
444
446
  isEdit: false
445
447
  }) || 0);
446
448
  for (var i = 0; i < products.length; i++) {
447
- var _surchargeServiceItem;
448
- products[i].surcharge_fee = ((_surchargeServiceItem = surchargeServiceItems[i]) === null || _surchargeServiceItem === void 0 ? void 0 : _surchargeServiceItem.surcharge_fee) || 0;
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
+ }
449
463
  }
450
464
  var hasTaxRate = taxRate !== undefined && taxRate !== null && taxRate > 0;
451
465
  var productTaxFee;
@@ -458,8 +472,8 @@ export function calculateSalesSummary(params) {
458
472
  }, new Decimal(0));
459
473
  }
460
474
  var shopDiscountAmount = Decimal.max(new Decimal(Number(shopDiscount) || 0), 0);
461
- var expectAmount = Decimal.max(0, productAmount.plus(surchargeAmount).minus(shopDiscountAmount));
462
- var totalAmount = isPriceIncludeTax === 1 ? expectAmount : expectAmount.plus(productTaxFee);
475
+ var preTaxExpectAmount = Decimal.max(0, productAmount.plus(surchargeAmount).minus(shopDiscountAmount));
476
+ var totalAmount = isPriceIncludeTax === 1 ? preTaxExpectAmount : preTaxExpectAmount.plus(productTaxFee);
463
477
  var deposit = calculateProductsDeposit(products);
464
478
  return {
465
479
  product_quantity: productQuantity,
@@ -475,7 +489,7 @@ export function calculateSalesSummary(params) {
475
489
  discount_amount: toFixed2(Decimal.max(productOriginalAmount.minus(productAmount), 0).plus(shopDiscountAmount)),
476
490
  deposit_amount: deposit ? deposit.total : '0.00',
477
491
  deposit: deposit,
478
- expect_amount: toFixed2(expectAmount),
492
+ expect_amount: toFixed2(totalAmount),
479
493
  total_amount: toFixed2(totalAmount),
480
494
  total_refund_amount: '0.00',
481
495
  customer_paid_amount: '0.00',
@@ -205,9 +205,13 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
205
205
  }, {
206
206
  key: "getScheduleListByIds",
207
207
  value: function getScheduleListByIds(ids) {
208
- return this.store.scheduleList.filter(function (n) {
209
- return ids.includes(n.id);
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));
210
213
  });
214
+ return list;
211
215
  }
212
216
  }, {
213
217
  key: "setAvailabilityScheduleDateList",
@@ -16,3 +16,4 @@ export * from './Schedule';
16
16
  export * from './Quotation';
17
17
  export * from './ScanOrderLogger';
18
18
  export * from './OpenData';
19
+ export * from './BookingContext';
@@ -15,4 +15,5 @@ export * from "./SalesSummary";
15
15
  export * from "./Schedule";
16
16
  export * from "./Quotation";
17
17
  export * from "./ScanOrderLogger";
18
- export * from "./OpenData";
18
+ export * from "./OpenData";
19
+ export * from "./BookingContext";
@@ -168,16 +168,17 @@ 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, _ref3, callback, subscriberId;
171
+ var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, _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;
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;
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,
181
182
  schedule_datetime: schedule_datetime,
182
183
  schedule_date: schedule_date,
183
184
  customer_id: customer_id
@@ -189,6 +190,7 @@ var Server = /*#__PURE__*/function () {
189
190
  callback: callback,
190
191
  context: {
191
192
  menu_list_ids: menu_list_ids,
193
+ ids: ids,
192
194
  schedule_date: schedule_date,
193
195
  schedule_datetime: schedule_datetime,
194
196
  customer_id: customer_id
@@ -201,6 +203,7 @@ var Server = /*#__PURE__*/function () {
201
203
  }
202
204
  return _context.abrupt("return", _this.computeProductQueryResult({
203
205
  menu_list_ids: menu_list_ids,
206
+ ids: ids,
204
207
  schedule_date: schedule_date,
205
208
  schedule_datetime: schedule_datetime,
206
209
  customer_id: customer_id
@@ -1608,26 +1611,30 @@ var Server = /*#__PURE__*/function () {
1608
1611
  case 6:
1609
1612
  _context18.prev = 6;
1610
1613
  _context18.next = 9;
1614
+ return this.schedule.loadAllSchedule();
1615
+ case 9:
1616
+ this.products.clearPriceCache();
1617
+ _context18.next = 12;
1611
1618
  return this.products.setupQuotationPriceBridge({
1612
1619
  scheduleModule: this.schedule,
1613
1620
  channel: (_this$core$context = this.core.context) === null || _this$core$context === void 0 ? void 0 : _this$core$context.channel
1614
1621
  });
1615
- case 9:
1622
+ case 12:
1616
1623
  this.logInfo('Products 报价单价格桥接初始化完成');
1617
- _context18.next = 16;
1624
+ _context18.next = 19;
1618
1625
  break;
1619
- case 12:
1620
- _context18.prev = 12;
1626
+ case 15:
1627
+ _context18.prev = 15;
1621
1628
  _context18.t0 = _context18["catch"](6);
1622
1629
  errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
1623
1630
  this.logError('Products 报价单价格桥接初始化失败', {
1624
1631
  error: errorMessage
1625
1632
  });
1626
- case 16:
1633
+ case 19:
1627
1634
  case "end":
1628
1635
  return _context18.stop();
1629
1636
  }
1630
- }, _callee18, this, [[6, 12]]);
1637
+ }, _callee18, this, [[6, 15]]);
1631
1638
  }));
1632
1639
  function setupProductsQuotationPriceBridge() {
1633
1640
  return _setupProductsQuotationPriceBridge.apply(this, arguments);
@@ -3303,14 +3310,20 @@ var Server = /*#__PURE__*/function () {
3303
3310
  var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(context, options) {
3304
3311
  var _menu_list_ids$length3,
3305
3312
  _this6 = this;
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;
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;
3307
3314
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3308
3315
  while (1) switch (_context29.prev = _context29.next) {
3309
3316
  case 0:
3310
3317
  tTotal = performance.now();
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;
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
+ }) : [];
3312
3324
  this.logInfo('computeProductQueryResult 开始', {
3313
3325
  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,
3314
3327
  schedule_datetime: schedule_datetime,
3315
3328
  schedule_date: schedule_date,
3316
3329
  customer_id: customer_id,
@@ -3318,7 +3331,7 @@ var Server = /*#__PURE__*/function () {
3318
3331
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
3319
3332
  });
3320
3333
  if (this.products) {
3321
- _context29.next = 6;
3334
+ _context29.next = 7;
3322
3335
  break;
3323
3336
  }
3324
3337
  this.logError('computeProductQueryResult: Products 模块未注册');
@@ -3329,22 +3342,67 @@ var Server = /*#__PURE__*/function () {
3329
3342
  count: 0
3330
3343
  }
3331
3344
  });
3332
- case 6:
3333
- if (!(product_id != null && Number.isFinite(Number(product_id)))) {
3345
+ case 7:
3346
+ if (!(queryIds.length > 0)) {
3334
3347
  _context29.next = 18;
3335
3348
  break;
3336
3349
  }
3337
- pid = Number(product_id);
3350
+ uniqueIds = Array.from(new Set(queryIds));
3338
3351
  _tPrice = performance.now();
3339
- _context29.next = 11;
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:
3391
+ if (!(product_id != null && Number.isFinite(Number(product_id)))) {
3392
+ _context29.next = 30;
3393
+ break;
3394
+ }
3395
+ pid = Number(product_id);
3396
+ _tPrice2 = performance.now();
3397
+ _context29.next = 23;
3340
3398
  return this.products.getProductsWithPrice(schedule_date, {
3341
3399
  scheduleModule: this.getSchedule()
3342
3400
  }, {
3343
3401
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
3344
3402
  });
3345
- case 11:
3403
+ case 23:
3346
3404
  allProductsWithPrice = _context29.sent;
3347
- perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice, {
3405
+ perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
3348
3406
  count: allProductsWithPrice.length,
3349
3407
  productId: pid
3350
3408
  });
@@ -3369,9 +3427,9 @@ var Server = /*#__PURE__*/function () {
3369
3427
  message: item ? '' : '商品不存在或未发布',
3370
3428
  status: true
3371
3429
  });
3372
- case 18:
3430
+ case 30:
3373
3431
  if (this.menu) {
3374
- _context29.next = 21;
3432
+ _context29.next = 33;
3375
3433
  break;
3376
3434
  }
3377
3435
  this.logError('computeProductQueryResult: Menu 模块未注册');
@@ -3382,9 +3440,9 @@ var Server = /*#__PURE__*/function () {
3382
3440
  count: 0
3383
3441
  }
3384
3442
  });
3385
- case 21:
3443
+ case 33:
3386
3444
  if (this.schedule) {
3387
- _context29.next = 24;
3445
+ _context29.next = 36;
3388
3446
  break;
3389
3447
  }
3390
3448
  this.logError('computeProductQueryResult: Schedule 模块未注册');
@@ -3395,7 +3453,7 @@ var Server = /*#__PURE__*/function () {
3395
3453
  count: 0
3396
3454
  }
3397
3455
  });
3398
- case 24:
3456
+ case 36:
3399
3457
  activeMenuList = [];
3400
3458
  if (menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0) {
3401
3459
  tMenu = performance.now();
@@ -3419,10 +3477,10 @@ var Server = /*#__PURE__*/function () {
3419
3477
  });
3420
3478
  tPrice = performance.now();
3421
3479
  if (!(scopedProductIds.length > 0)) {
3422
- _context29.next = 37;
3480
+ _context29.next = 49;
3423
3481
  break;
3424
3482
  }
3425
- _context29.next = 34;
3483
+ _context29.next = 46;
3426
3484
  return this.products.getProductsWithPrice(schedule_date, {
3427
3485
  scheduleModule: this.getSchedule(),
3428
3486
  schedule_datetime: schedule_datetime,
@@ -3431,13 +3489,13 @@ var Server = /*#__PURE__*/function () {
3431
3489
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
3432
3490
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
3433
3491
  });
3434
- case 34:
3492
+ case 46:
3435
3493
  _context29.t0 = _context29.sent;
3436
- _context29.next = 38;
3494
+ _context29.next = 50;
3437
3495
  break;
3438
- case 37:
3496
+ case 49:
3439
3497
  _context29.t0 = [];
3440
- case 38:
3498
+ case 50:
3441
3499
  filteredProducts = _context29.t0;
3442
3500
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
3443
3501
  count: filteredProducts.length,
@@ -3480,7 +3538,7 @@ var Server = /*#__PURE__*/function () {
3480
3538
  message: '',
3481
3539
  status: true
3482
3540
  });
3483
- case 50:
3541
+ case 62:
3484
3542
  case "end":
3485
3543
  return _context29.stop();
3486
3544
  }