@pisell/pisellos 0.0.479 → 0.0.481

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 (147) hide show
  1. package/dist/core/index.d.ts +3 -2
  2. package/dist/core/index.js +7 -0
  3. package/dist/effects/index.d.ts +2 -2
  4. package/dist/effects/index.js +34 -81
  5. package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
  6. package/dist/model/strategy/adapter/walletPass/type.d.ts +9 -2
  7. package/dist/model/strategy/adapter/walletPass/utils.d.ts +6 -6
  8. package/dist/model/strategy/adapter/walletPass/utils.js +111 -72
  9. package/dist/modules/Customer/index.js +1 -1
  10. package/dist/modules/Discount/index.d.ts +6 -2
  11. package/dist/modules/Discount/index.js +14 -8
  12. package/dist/modules/Order/index.d.ts +1 -1
  13. package/dist/modules/Order/index.js +18 -13
  14. package/dist/modules/Payment/index.d.ts +4 -0
  15. package/dist/modules/Payment/index.js +774 -649
  16. package/dist/modules/Payment/walletpass.js +44 -17
  17. package/dist/modules/Product/index.d.ts +1 -1
  18. package/dist/modules/Product/types.d.ts +2 -0
  19. package/dist/modules/ProductList/index.d.ts +3 -0
  20. package/dist/modules/ProductList/index.js +9 -7
  21. package/dist/modules/Rules/index.d.ts +2 -2
  22. package/dist/modules/Rules/index.js +37 -31
  23. package/dist/modules/Rules/types.d.ts +2 -2
  24. package/dist/modules/Schedule/index.d.ts +9 -0
  25. package/dist/modules/Schedule/index.js +15 -2
  26. package/dist/plugins/app-types/app/app.d.ts +1 -0
  27. package/dist/plugins/request.d.ts +2 -0
  28. package/dist/server/index.d.ts +107 -2
  29. package/dist/server/index.js +1507 -279
  30. package/dist/server/modules/index.d.ts +6 -0
  31. package/dist/server/modules/index.js +7 -0
  32. package/dist/server/modules/menu/index.d.ts +19 -0
  33. package/dist/server/modules/menu/index.js +221 -71
  34. package/dist/server/modules/order/index.d.ts +87 -0
  35. package/dist/server/modules/order/index.js +916 -0
  36. package/dist/server/modules/order/types.d.ts +530 -0
  37. package/dist/server/modules/order/types.js +141 -0
  38. package/dist/server/modules/order/utils/filterBookings.d.ts +6 -0
  39. package/dist/server/modules/order/utils/filterBookings.js +350 -0
  40. package/dist/server/modules/order/utils/filterOrders.d.ts +15 -0
  41. package/dist/server/modules/order/utils/filterOrders.js +226 -0
  42. package/dist/server/modules/products/index.d.ts +117 -5
  43. package/dist/server/modules/products/index.js +1450 -240
  44. package/dist/server/modules/products/types.d.ts +25 -1
  45. package/dist/server/modules/products/types.js +3 -0
  46. package/dist/server/modules/resource/index.d.ts +86 -0
  47. package/dist/server/modules/resource/index.js +1128 -0
  48. package/dist/server/modules/resource/types.d.ts +121 -0
  49. package/dist/server/modules/resource/types.js +47 -0
  50. package/dist/server/modules/schedule/index.d.ts +19 -0
  51. package/dist/server/modules/schedule/index.js +229 -68
  52. package/dist/server/utils/product.d.ts +5 -0
  53. package/dist/server/utils/product.js +71 -31
  54. package/dist/solution/BookingTicket/index.d.ts +10 -2
  55. package/dist/solution/BookingTicket/index.js +41 -28
  56. package/dist/solution/BookingTicket/utils/scan/index.js +1 -1
  57. package/dist/solution/Checkout/index.d.ts +1 -0
  58. package/dist/solution/Checkout/index.js +286 -188
  59. package/dist/solution/Checkout/utils/index.d.ts +2 -1
  60. package/dist/solution/Checkout/utils/index.js +6 -4
  61. package/dist/solution/RegisterAndLogin/config.js +340 -1
  62. package/dist/solution/Sales/index.d.ts +96 -0
  63. package/dist/solution/Sales/index.js +566 -0
  64. package/dist/solution/Sales/types.d.ts +67 -0
  65. package/dist/solution/Sales/types.js +26 -0
  66. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  67. package/dist/solution/ShopDiscount/index.js +35 -22
  68. package/dist/solution/ShopDiscount/types.d.ts +6 -0
  69. package/dist/solution/ShopDiscount/utils.d.ts +9 -0
  70. package/dist/solution/ShopDiscount/utils.js +21 -27
  71. package/dist/solution/index.d.ts +2 -1
  72. package/dist/solution/index.js +2 -1
  73. package/dist/types/index.d.ts +5 -0
  74. package/lib/core/index.d.ts +3 -2
  75. package/lib/core/index.js +4 -0
  76. package/lib/effects/index.d.ts +2 -2
  77. package/lib/effects/index.js +22 -31
  78. package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
  79. package/lib/model/strategy/adapter/walletPass/type.d.ts +9 -2
  80. package/lib/model/strategy/adapter/walletPass/utils.d.ts +6 -6
  81. package/lib/model/strategy/adapter/walletPass/utils.js +115 -48
  82. package/lib/modules/Customer/index.js +1 -1
  83. package/lib/modules/Discount/index.d.ts +6 -2
  84. package/lib/modules/Discount/index.js +3 -1
  85. package/lib/modules/Order/index.d.ts +1 -1
  86. package/lib/modules/Order/index.js +20 -18
  87. package/lib/modules/Payment/index.d.ts +4 -0
  88. package/lib/modules/Payment/index.js +134 -66
  89. package/lib/modules/Payment/walletpass.js +23 -4
  90. package/lib/modules/Product/index.d.ts +1 -1
  91. package/lib/modules/Product/types.d.ts +2 -0
  92. package/lib/modules/ProductList/index.d.ts +3 -0
  93. package/lib/modules/ProductList/index.js +2 -2
  94. package/lib/modules/Rules/index.d.ts +2 -2
  95. package/lib/modules/Rules/index.js +69 -73
  96. package/lib/modules/Rules/types.d.ts +2 -2
  97. package/lib/modules/Schedule/index.d.ts +9 -0
  98. package/lib/modules/Schedule/index.js +11 -0
  99. package/lib/plugins/app-types/app/app.d.ts +1 -0
  100. package/lib/plugins/request.d.ts +2 -0
  101. package/lib/server/index.d.ts +107 -2
  102. package/lib/server/index.js +773 -51
  103. package/lib/server/modules/index.d.ts +6 -0
  104. package/lib/server/modules/index.js +16 -2
  105. package/lib/server/modules/menu/index.d.ts +19 -0
  106. package/lib/server/modules/menu/index.js +121 -2
  107. package/lib/server/modules/order/index.d.ts +87 -0
  108. package/lib/server/modules/order/index.js +543 -0
  109. package/lib/server/modules/order/types.d.ts +530 -0
  110. package/lib/server/modules/order/types.js +34 -0
  111. package/lib/server/modules/order/utils/filterBookings.d.ts +6 -0
  112. package/lib/server/modules/order/utils/filterBookings.js +320 -0
  113. package/lib/server/modules/order/utils/filterOrders.d.ts +15 -0
  114. package/lib/server/modules/order/utils/filterOrders.js +197 -0
  115. package/lib/server/modules/products/index.d.ts +117 -5
  116. package/lib/server/modules/products/index.js +799 -62
  117. package/lib/server/modules/products/types.d.ts +25 -1
  118. package/lib/server/modules/products/types.js +1 -0
  119. package/lib/server/modules/resource/index.d.ts +86 -0
  120. package/lib/server/modules/resource/index.js +557 -0
  121. package/lib/server/modules/resource/types.d.ts +121 -0
  122. package/lib/server/modules/resource/types.js +35 -0
  123. package/lib/server/modules/schedule/index.d.ts +19 -0
  124. package/lib/server/modules/schedule/index.js +141 -12
  125. package/lib/server/utils/product.d.ts +5 -0
  126. package/lib/server/utils/product.js +56 -27
  127. package/lib/solution/BookingTicket/index.d.ts +10 -2
  128. package/lib/solution/BookingTicket/index.js +10 -2
  129. package/lib/solution/BookingTicket/utils/scan/index.js +0 -1
  130. package/lib/solution/Checkout/index.d.ts +1 -0
  131. package/lib/solution/Checkout/index.js +399 -331
  132. package/lib/solution/Checkout/utils/index.d.ts +2 -1
  133. package/lib/solution/Checkout/utils/index.js +6 -4
  134. package/lib/solution/RegisterAndLogin/config.js +266 -1
  135. package/lib/solution/Sales/index.d.ts +96 -0
  136. package/lib/solution/Sales/index.js +416 -0
  137. package/lib/solution/Sales/types.d.ts +67 -0
  138. package/lib/solution/Sales/types.js +35 -0
  139. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  140. package/lib/solution/ShopDiscount/index.js +14 -6
  141. package/lib/solution/ShopDiscount/types.d.ts +6 -0
  142. package/lib/solution/ShopDiscount/utils.d.ts +9 -0
  143. package/lib/solution/ShopDiscount/utils.js +6 -10
  144. package/lib/solution/index.d.ts +2 -1
  145. package/lib/solution/index.js +4 -2
  146. package/lib/types/index.d.ts +5 -0
  147. package/package.json +1 -1
@@ -102,6 +102,11 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
102
102
  order_wait_pay_amount: walletParams.order_wait_pay_amount,
103
103
  products_count: ((_walletParams$product = walletParams.products) === null || _walletParams$product === void 0 ? void 0 : _walletParams$product.length) || 0
104
104
  });
105
+ this.walletInitData = {
106
+ transformList: [],
107
+ noApplicableVoucher: [],
108
+ products: products || []
109
+ };
105
110
  return walletParams;
106
111
  }
107
112
 
@@ -153,6 +158,15 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
153
158
  products: []
154
159
  });
155
160
  case 4:
161
+ if (![1, 0].includes((walletParams === null || walletParams === void 0 ? void 0 : walletParams.customer_id) || 0)) {
162
+ _context.next = 6;
163
+ break;
164
+ }
165
+ return _context.abrupt("return", {
166
+ walletRecommendList: [],
167
+ userIdentificationCodes: []
168
+ });
169
+ case 6:
156
170
  // 发送初始化开始事件
157
171
  this.emitEvent(WalletPassHooks.OnWalletInitializationStarted, {
158
172
  businessData: businessData,
@@ -165,10 +179,10 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
165
179
  order_wait_pay_amount: businessData.order_wait_pay_amount,
166
180
  products_count: ((_businessData$product = businessData.products) === null || _businessData$product === void 0 ? void 0 : _businessData$product.length) || 0
167
181
  });
168
- _context.prev = 6;
169
- _context.next = 9;
182
+ _context.prev = 8;
183
+ _context.next = 11;
170
184
  return this.initializeWalletDataAsync(walletParams);
171
- case 9:
185
+ case 11:
172
186
  result = _context.sent;
173
187
  endTime = Date.now();
174
188
  duration = endTime - startTime; // 发送初始化完成事件
@@ -185,9 +199,9 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
185
199
  userIdentificationCodes_count: ((_result$userIdentific = result.userIdentificationCodes) === null || _result$userIdentific === void 0 ? void 0 : _result$userIdentific.length) || 0
186
200
  });
187
201
  return _context.abrupt("return", result);
188
- case 17:
189
- _context.prev = 17;
190
- _context.t0 = _context["catch"](6);
202
+ case 19:
203
+ _context.prev = 19;
204
+ _context.t0 = _context["catch"](8);
191
205
  _endTime = Date.now();
192
206
  _duration = _endTime - startTime; // 发送初始化失败事件
193
207
  this.emitEvent(WalletPassHooks.OnWalletInitializationFailed, {
@@ -203,11 +217,11 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
203
217
  totalAmount: (_businessData$amountI5 = businessData.amountInfo) === null || _businessData$amountI5 === void 0 ? void 0 : _businessData$amountI5.totalAmount
204
218
  });
205
219
  throw _context.t0;
206
- case 24:
220
+ case 26:
207
221
  case "end":
208
222
  return _context.stop();
209
223
  }
210
- }, _callee, this, [[6, 17]]);
224
+ }, _callee, this, [[8, 19]]);
211
225
  }));
212
226
  function initializeWalletDataFromBusinessAsync(_x) {
213
227
  return _initializeWalletDataFromBusinessAsync.apply(this, arguments);
@@ -468,6 +482,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
468
482
  value: (function () {
469
483
  var _searchIdentificationCodeAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
470
484
  var config,
485
+ _ref,
486
+ _response2,
471
487
  code,
472
488
  isWalletCode,
473
489
  walletDetailParams,
@@ -550,20 +566,31 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
550
566
  multiple: searchParams.multiple,
551
567
  payment_order_id: baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.payment_order_id
552
568
  });
553
- _context6.next = 19;
569
+ if (!(!searchParams.products || ((_ref = searchParams.products || []) === null || _ref === void 0 ? void 0 : _ref.length) === 0)) {
570
+ _context6.next = 21;
571
+ break;
572
+ }
573
+ response = {
574
+ data: []
575
+ };
576
+ _context6.next = 24;
577
+ break;
578
+ case 21:
579
+ _context6.next = 23;
554
580
  return this.paymentModule.request.post('/machinecode/prepare/deduction/search', searchParams);
555
- case 19:
581
+ case 23:
556
582
  response = _context6.sent;
557
- searchResults = (response === null || response === void 0 ? void 0 : response.data) || [];
583
+ case 24:
584
+ searchResults = ((_response2 = response) === null || _response2 === void 0 ? void 0 : _response2.data) || [];
558
585
  if (!config.noCache) {
559
- _context6.next = 23;
586
+ _context6.next = 27;
560
587
  break;
561
588
  }
562
589
  return _context6.abrupt("return", {
563
590
  type: 'normalCode',
564
591
  data: searchResults
565
592
  });
566
- case 23:
593
+ case 27:
567
594
  // 将搜索结果存储到缓存数组中
568
595
  if (searchResults.length > 0) {
569
596
  // 避免重复存储相同的识别码
@@ -593,8 +620,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
593
620
  type: 'normalCode',
594
621
  data: searchResults
595
622
  });
596
- case 29:
597
- _context6.prev = 29;
623
+ case 33:
624
+ _context6.prev = 33;
598
625
  _context6.t0 = _context6["catch"](1);
599
626
  this.paymentModule.logError('[WalletPass] 搜索识别码信息失败', _context6.t0, {
600
627
  code: params.code,
@@ -602,11 +629,11 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
602
629
  order_expect_amount: params.order_expect_amount
603
630
  });
604
631
  throw _context6.t0;
605
- case 33:
632
+ case 37:
606
633
  case "end":
607
634
  return _context6.stop();
608
635
  }
609
- }, _callee6, this, [[1, 29]]);
636
+ }, _callee6, this, [[1, 33]]);
610
637
  }));
611
638
  function searchIdentificationCodeAsync(_x6) {
612
639
  return _searchIdentificationCodeAsync.apply(this, arguments);
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -162,6 +162,8 @@ export interface ProductData {
162
162
  categories: ProductCategory[];
163
163
  /** 套餐组 */
164
164
  bundle_groups: ProductBundleGroup[];
165
+ /** 套餐组 */
166
+ bundle_group: ProductBundleGroup[];
165
167
  /** 商品资源 */
166
168
  product_resource?: {
167
169
  resources?: ProductResourceItem[];
@@ -22,6 +22,9 @@ export declare class ProductList extends BaseModule implements Module {
22
22
  schedule_datetime?: string;
23
23
  with_count?: string[];
24
24
  with_schedule?: number;
25
+ }, options?: {
26
+ callback?: (result: any) => void;
27
+ subscriberId?: string;
25
28
  }): Promise<any>;
26
29
  loadProductsPrice({ ids, customer_id, schedule_date, channel, }: {
27
30
  ids?: number[];
@@ -84,7 +84,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
84
84
  }, {
85
85
  key: "loadProducts",
86
86
  value: function () {
87
- var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
87
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref, options) {
88
88
  var _this$otherParams;
89
89
  var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$menu_list_ids, menu_list_ids, paramsCustomerId, _ref$with_count, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, userPlugin, customer_id, _userPlugin$get, productsData, sortedList;
90
90
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
@@ -134,7 +134,9 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
134
134
  application_code: (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel,
135
135
  is_eject: 1
136
136
  }, {
137
- osServer: true
137
+ osServer: true,
138
+ callback: options === null || options === void 0 ? void 0 : options.callback,
139
+ subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId
138
140
  });
139
141
  case 6:
140
142
  productsData = _context3.sent;
@@ -155,7 +157,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
155
157
  }
156
158
  }, _callee3, this);
157
159
  }));
158
- function loadProducts(_x5) {
160
+ function loadProducts(_x5, _x6) {
159
161
  return _loadProducts.apply(this, arguments);
160
162
  }
161
163
  return loadProducts;
@@ -187,7 +189,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
187
189
  }
188
190
  }, _callee4, this);
189
191
  }));
190
- function loadProductsPrice(_x6) {
192
+ function loadProductsPrice(_x7) {
191
193
  return _loadProductsPrice.apply(this, arguments);
192
194
  }
193
195
  return loadProductsPrice;
@@ -235,7 +237,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
235
237
  }
236
238
  }, _callee6, this);
237
239
  }));
238
- function getProduct(_x7) {
240
+ function getProduct(_x8) {
239
241
  return _getProduct.apply(this, arguments);
240
242
  }
241
243
  return getProduct;
@@ -273,7 +275,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
273
275
  }
274
276
  }, _callee7, this);
275
277
  }));
276
- function addProduct(_x8) {
278
+ function addProduct(_x9) {
277
279
  return _addProduct.apply(this, arguments);
278
280
  }
279
281
  return addProduct;
@@ -292,7 +294,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
292
294
  }
293
295
  }, _callee8, this);
294
296
  }));
295
- function selectProducts(_x9) {
297
+ function selectProducts(_x10) {
296
298
  return _selectProducts.apply(this, arguments);
297
299
  }
298
300
  return selectProducts;
@@ -33,14 +33,14 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
33
33
  };
34
34
  filterDiscountListByType(discountList: Discount[], type: string): Discount[];
35
35
  private getUnavailableReason;
36
- calcDiscount({ discountList, productList, orderTotalAmount, holders, isFormSubject, }: {
36
+ calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
37
37
  discountList: Discount[];
38
38
  productList: any[];
39
- orderTotalAmount: number;
40
39
  holders: {
41
40
  form_record_id: number;
42
41
  }[];
43
42
  isFormSubject: boolean;
43
+ orderTotalAmount: number;
44
44
  }, options?: {
45
45
  isSelected?: boolean;
46
46
  discountId?: number;
@@ -26,13 +26,13 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
26
26
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
27
27
  import { BaseModule } from "../BaseModule";
28
28
  import { UnavailableReason } from "./types";
29
- import { uniqueById, getDiscountAmount, getDiscountListAmountTotal, getDiscountListAmount, filterDiscountListByBookingTime, isOrderLevelFixedAmountDiscount, calculateOrderLevelDiscountAllocation } from "../../solution/ShopDiscount/utils";
29
+ import { uniqueById, getDiscountAmount, getDiscountListAmountTotal, getDiscountListAmount, filterDiscountListByBookingTime } from "../../solution/ShopDiscount/utils";
30
30
  import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
31
31
  import Decimal from 'decimal.js';
32
32
  import { isBoolean } from 'lodash-es';
33
33
  import dayjs from 'dayjs';
34
- // 临时变量
35
- var flatItem;
34
+ import { isOrderLevelFixedAmountDiscount } from "../../solution/ShopDiscount/utils";
35
+ import { calculateOrderLevelDiscountAllocation } from "../../solution/ShopDiscount/utils";
36
36
  export var RulesModule = /*#__PURE__*/function (_BaseModule) {
37
37
  _inherits(RulesModule, _BaseModule);
38
38
  var _super = _createSuper(RulesModule);
@@ -118,7 +118,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
118
118
  if (!product.isNeedHolder) return true;
119
119
  // 商品需要holder,但父预约及商品都无holder,返回false
120
120
  if (!orderHolderId && !productHolderId) return false;
121
-
122
121
  // 最终直接匹配 holder 是否相同
123
122
  return (productHolderId || orderHolderId) === discount.holder.holder_id;
124
123
  }
@@ -166,8 +165,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
166
165
  var result = this.calcDiscount({
167
166
  discountList: mergedDiscountList,
168
167
  productList: _toConsumableArray(productList),
169
- orderTotalAmount: orderTotalAmount,
170
168
  holders: holders,
169
+ orderTotalAmount: orderTotalAmount,
171
170
  isFormSubject: isFormSubject
172
171
  }, {
173
172
  scan: true
@@ -299,9 +298,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
299
298
  var _this3 = this;
300
299
  var discountList = _ref2.discountList,
301
300
  productList = _ref2.productList,
302
- orderTotalAmount = _ref2.orderTotalAmount,
303
301
  holders = _ref2.holders,
304
- isFormSubject = _ref2.isFormSubject;
302
+ isFormSubject = _ref2.isFormSubject,
303
+ orderTotalAmount = _ref2.orderTotalAmount;
305
304
  var editModeDiscount = [];
306
305
  var addModeDiscount = [];
307
306
  discountList.forEach(function (discount) {
@@ -1024,11 +1023,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1024
1023
  }
1025
1024
  }
1026
1025
  var limitedData = discount.limited_relation_product_data;
1027
- var timeLimit = true;
1028
- timeLimit = !!filterDiscountListByBookingTime([discount], (product.startDate || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
1029
- if (!timeLimit) {
1030
- return false;
1031
- }
1026
+
1032
1027
  // 拿到discount配置的holder信息 product信息 product.holder 不可用return false
1033
1028
  var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
1034
1029
  var isHolderMatch = _this3.checkHolderMatch(discount, {
@@ -1037,6 +1032,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1037
1032
  }, holders);
1038
1033
  // 如果 holder 不匹配,则不适用
1039
1034
  if (!isHolderMatch) return false;
1035
+ var timeLimit = true;
1036
+ timeLimit = !!filterDiscountListByBookingTime([discount], (product.startDate || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
1037
+ if (!timeLimit) {
1038
+ return false;
1039
+ }
1040
1040
 
1041
1041
  // 判断优惠券是否适用于该商品
1042
1042
  if (limitedData.type === 'product_all') {
@@ -1253,15 +1253,23 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1253
1253
  if (flatItem.type === 'main') {
1254
1254
  // 主商品:保持原有逻辑
1255
1255
  if (splitCount < totalQuantity && isNeedSplit) {
1256
+ var _product$origin_total2;
1257
+ var _total = (_product$origin_total2 = product.origin_total) !== null && _product$origin_total2 !== void 0 ? _product$origin_total2 : product.total;
1258
+ if ((product.discount_list || []).some(function (item) {
1259
+ return item.type === 'promotion';
1260
+ })) {
1261
+ var _product$total2;
1262
+ _total = (_product$total2 = product.total) !== null && _product$total2 !== void 0 ? _product$total2 : product.origin_total;
1263
+ }
1256
1264
  arr.push(_this3.hooks.setProduct(originProduct, {
1257
1265
  discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion'),
1258
1266
  quantity: totalQuantity - splitCount,
1259
1267
  _id: product._id.split('___')[0],
1260
- total: product.origin_total || product.total
1268
+ total: _total
1261
1269
  }));
1262
1270
  }
1263
1271
  for (var i = 0; i < splitCount; i++) {
1264
- var _originProduct, _currentSelectedDisco, _currentSelectedDisco2;
1272
+ var _originProduct, _selectedDiscount$met, _selectedDiscount$met2;
1265
1273
  // 商品券:每个拆分商品使用不同的商品券(从 applicableDiscounts 按索引取)
1266
1274
  // 折扣卡:所有拆分商品使用同一张折扣卡(selectedDiscountCard 或 applicableDiscounts[0])
1267
1275
  var currentSelectedDiscount = isGoodPass ? selectedDiscountCard || applicableDiscounts[i] : selectedDiscountCard || applicableDiscounts[0];
@@ -1312,19 +1320,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1312
1320
  amount = new Decimal(product.price).minus(new Decimal(targetProductTotal)).toNumber();
1313
1321
  }
1314
1322
  var currentDiscountType = currentSelectedDiscount.tag === 'product_discount_card' ? 'discount_card' : currentSelectedDiscount.tag;
1315
-
1316
- // 计算实际折扣金额
1317
- var actualDiscountAmount = new Decimal(product.price).minus(new Decimal(targetProductTotal)).toNumber();
1323
+ var _discountType = selectedDiscount.tag || selectedDiscount.type;
1318
1324
  var currentIsGoodPass = currentDiscountType === 'good_pass';
1319
1325
  var discountDetail = {
1320
- amount: actualDiscountAmount,
1321
- type: currentDiscountType,
1326
+ amount: amount,
1327
+ type: selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : _discountType,
1322
1328
  discount: {
1323
- discount_card_type: currentSelectedDiscount === null || currentSelectedDiscount === void 0 || (_currentSelectedDisco = currentSelectedDiscount.metadata) === null || _currentSelectedDisco === void 0 ? void 0 : _currentSelectedDisco.discount_card_type,
1324
- fixed_amount: actualDiscountAmount,
1325
- discount_calculation_mode: currentSelectedDiscount === null || currentSelectedDiscount === void 0 || (_currentSelectedDisco2 = currentSelectedDiscount.metadata) === null || _currentSelectedDisco2 === void 0 ? void 0 : _currentSelectedDisco2.discount_calculation_mode,
1326
- resource_id: currentSelectedDiscount.id,
1327
- title: currentSelectedDiscount.format_title,
1329
+ discount_card_type: selectedDiscount === null || selectedDiscount === void 0 || (_selectedDiscount$met = selectedDiscount.metadata) === null || _selectedDiscount$met === void 0 ? void 0 : _selectedDiscount$met.discount_card_type,
1330
+ fixed_amount: amount,
1331
+ discount_calculation_mode: selectedDiscount === null || selectedDiscount === void 0 || (_selectedDiscount$met2 = selectedDiscount.metadata) === null || _selectedDiscount$met2 === void 0 ? void 0 : _selectedDiscount$met2.discount_calculation_mode,
1332
+ resource_id: selectedDiscount.id,
1333
+ title: selectedDiscount.format_title,
1328
1334
  original_amount: product.price,
1329
1335
  product_id: originProduct.id,
1330
1336
  percent: currentSelectedDiscount.par_value,
@@ -1342,13 +1348,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1342
1348
  };
1343
1349
  appliedProducts.push(discountDetail);
1344
1350
  appliedDiscountProducts.set(currentSelectedDiscount.id, appliedProducts);
1345
- var _total = targetProductTotal;
1351
+ var _total2 = targetProductTotal;
1346
1352
  if (product.options) {
1347
- _total = product.options.reduce(function (accumulator, currentValue) {
1353
+ _total2 = product.options.reduce(function (accumulator, currentValue) {
1348
1354
  var currentPrice = new Decimal(currentValue.price || 0);
1349
1355
  var currentNum = new Decimal(currentValue.num || 0);
1350
1356
  return accumulator.add(currentPrice.mul(currentNum));
1351
- }, new Decimal(_total)).toNumber();
1357
+ }, new Decimal(_total2)).toNumber();
1352
1358
  }
1353
1359
 
1354
1360
  // 记录应用了优惠券的商品
@@ -1367,7 +1373,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1367
1373
  }),
1368
1374
  variant: originProduct._productInit.variant,
1369
1375
  original_price: new Decimal(product.price || 0).toNumber(),
1370
- total: targetProductTotal
1376
+ total: _total2
1371
1377
  }));
1372
1378
  } else {
1373
1379
  arr.push(_this3.hooks.setProduct(originProduct, {
@@ -1375,7 +1381,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1375
1381
  _id: product._id.split('___')[0] + '___' + currentSelectedDiscount.id + '_' + i + '_' + index,
1376
1382
  price: currentIsGoodPass ? 0 : product.price,
1377
1383
  quantity: isNeedSplit ? 1 : product.quantity,
1378
- total: targetProductTotal,
1384
+ total: _total2,
1379
1385
  origin_total: productOriginTotal,
1380
1386
  main_product_selling_price: targetProductTotal
1381
1387
  }));
@@ -2090,8 +2096,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2090
2096
  product_id: bundleItem.product_id,
2091
2097
  price: item.price,
2092
2098
  num: item.num,
2093
- quantity: item.num,
2094
- discount_list: updatedDiscountList
2099
+ discount_list: updatedDiscountList,
2100
+ bundle_selling_price: bundleItem.bundle_selling_price !== undefined ? item.price : undefined
2095
2101
  }));
2096
2102
  });
2097
2103
  }
@@ -28,11 +28,11 @@ export interface RulesModuleAPI {
28
28
  calcDiscount: (params: {
29
29
  discountList: any[];
30
30
  productList: any[];
31
- orderTotalAmount: number;
32
31
  holders: {
33
32
  form_record_id: number;
34
33
  }[];
35
34
  isFormSubject: boolean;
35
+ orderTotalAmount: number;
36
36
  }) => DiscountResult;
37
37
  }
38
38
  type ProductDetail = {
@@ -51,8 +51,8 @@ type ProductDetail = {
51
51
  num?: number;
52
52
  quantity: number;
53
53
  vouchersApplicable?: boolean;
54
- startDate?: any;
55
54
  holder_id?: number | string;
55
+ startDate?: any;
56
56
  };
57
57
  export interface RulesParamsHooks {
58
58
  getProduct: (product: Record<string, any>) => ProductDetail;
@@ -25,6 +25,15 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
25
25
  setOtherProductsIds(ids: number[]): void;
26
26
  getOtherProductsIds(): number[];
27
27
  storeChange(): void;
28
+ /**
29
+ * 传入一个时间, 判断改时间是否在schedule 内
30
+ * @param param0 { date: string, schedule: any } date: 日期, schedule: schedule
31
+ * @returns
32
+ */
33
+ isInScheduleByDate({ date, schedule, }: {
34
+ date: string;
35
+ schedule: any;
36
+ }): boolean;
28
37
  /**
29
38
  * 传入一个时间, 判断改时间是否在schedule 内
30
39
  * @param param0 { date: string, schedule: any } date: 日期, schedule: schedule
@@ -249,13 +249,26 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
249
249
  * @param param0 { date: string, schedule: any } date: 日期, schedule: schedule
250
250
  * @returns
251
251
  */
252
- }], [{
252
+ }, {
253
253
  key: "isInScheduleByDate",
254
254
  value: function isInScheduleByDate(_ref2) {
255
- var _schedule$repeat_rule, _schedule$repeat_rule2;
256
255
  var date = _ref2.date,
257
256
  schedule = _ref2.schedule;
258
257
  return getDateIsInSchedule(date, [schedule]);
258
+ }
259
+
260
+ /**
261
+ * 传入一个时间, 判断改时间是否在schedule 内
262
+ * @param param0 { date: string, schedule: any } date: 日期, schedule: schedule
263
+ * @returns
264
+ */
265
+ }], [{
266
+ key: "isInScheduleByDate",
267
+ value: function isInScheduleByDate(_ref3) {
268
+ var _schedule$repeat_rule, _schedule$repeat_rule2;
269
+ var date = _ref3.date,
270
+ schedule = _ref3.schedule;
271
+ return getDateIsInSchedule(date, [schedule]);
259
272
  if (schedule.start_time && schedule.end_time) {
260
273
  var isBeforeStartTime = dayjs(date).isBefore(dayjs(schedule.start_time));
261
274
  var isAfterEndTime = dayjs(date).isAfter(dayjs(schedule.end_time));
@@ -63,6 +63,7 @@ declare class App {
63
63
  pubsub: import("../pubsub").PubSub;
64
64
  tasksManager: TasksManager;
65
65
  dbManager: IndexDBManager | null;
66
+ sqlite: any;
66
67
  constants: {
67
68
  channel: string;
68
69
  [key: string]: string;
@@ -69,6 +69,8 @@ export interface RequestOptions {
69
69
  customToast?: () => void;
70
70
  cache?: CacheProps;
71
71
  osServer?: boolean;
72
+ callback?: (res: any) => void;
73
+ subscriberId?: string;
72
74
  }
73
75
  /**
74
76
  * 响应接口
@@ -2,8 +2,10 @@ import { ProductsModule } from './modules/products';
2
2
  import { MenuModule } from './modules/menu';
3
3
  import { QuotationModule } from './modules/quotation';
4
4
  import { ScheduleModuleEx } from './modules/schedule';
5
+ import { ResourceModule } from './modules/resource';
5
6
  import { PisellCore, ServerModuleConfig, InitializeServerOptions } from '../types';
6
7
  import type { RouteHandler, HttpMethod, RouteDefinition, Router, ModuleRegistryConfig, RequestSetting } from './types';
8
+ import { OrderModule } from './modules/order';
7
9
  export type { RouteHandler, HttpMethod, RouteDefinition, Router, ModuleRegistryConfig, };
8
10
  /**
9
11
  * Server 类
@@ -11,11 +13,18 @@ export type { RouteHandler, HttpMethod, RouteDefinition, Router, ModuleRegistryC
11
13
  */
12
14
  declare class Server {
13
15
  private core;
16
+ private app;
17
+ private logger;
14
18
  products?: ProductsModule;
15
19
  menu?: MenuModule;
16
20
  quotation?: QuotationModule;
17
21
  schedule?: ScheduleModuleEx;
22
+ resource?: ResourceModule;
23
+ order?: OrderModule;
18
24
  router: Router;
25
+ private productQuerySubscribers;
26
+ private orderQuerySubscribers;
27
+ private bookingQuerySubscribers;
19
28
  private moduleRegistry;
20
29
  constructor(core: PisellCore);
21
30
  /**
@@ -83,6 +92,12 @@ declare class Server {
83
92
  * 获取所有已注册的模块列表
84
93
  */
85
94
  getRegisteredModules(): string[];
95
+ /**
96
+ * 后台静默刷新商品数据
97
+ * 重新拉取全量 SSE 接口,更新本地数据后触发 onProductsSyncCompleted
98
+ * 不影响当前界面展示,适用于切回前台、定时刷新等场景
99
+ */
100
+ refreshProductsInBackground(): Promise<void>;
86
101
  /**
87
102
  * 清空所有server模块的IndexedDB缓存
88
103
  * @returns Promise<void>
@@ -130,10 +145,82 @@ declare class Server {
130
145
  */
131
146
  private registerServerRoutes;
132
147
  /**
133
- * 处理商品查询请求(编排 Products、Menu、Schedule 模块)
134
- * 这是一个业务编排方法,协调多个模块完成复杂的业务需求
148
+ * 根据 subscriberId 移除商品查询订阅者
149
+ */
150
+ removeProductQuerySubscriber(subscriberId?: string): void;
151
+ /**
152
+ * 处理商品查询请求
153
+ * 存储订阅者信息,便于数据变更时推送最新结果
135
154
  */
136
155
  private handleProductQuery;
156
+ /**
157
+ * 取消商品查询订阅(HTTP 路由入口)
158
+ */
159
+ private handleUnsubscribeProductQuery;
160
+ /**
161
+ * 处理订单列表查询
162
+ * 存储订阅者信息,本地计算结果;数据变更时通过 callback 推送
163
+ */
164
+ private handleOrderList;
165
+ /**
166
+ * 取消订单列表查询订阅(HTTP 路由入口)
167
+ */
168
+ private handleUnsubscribeOrderQuery;
169
+ /**
170
+ * 判断预约查询的 sales_time_between 起始日期是否为今天
171
+ */
172
+ private isBookingQueryForToday;
173
+ /**
174
+ * 非今天的预约查询:通过真实 API 获取数据,再做 flattenOrdersToBookings 拆分
175
+ */
176
+ private fetchBookingListFromAPI;
177
+ /**
178
+ * 处理预约列表查询
179
+ * 今天:注册订阅者 + 本地数据筛选;非今天:清理订阅者 + 走真实 API
180
+ */
181
+ private handleBookingList;
182
+ /**
183
+ * 处理资源列表查询
184
+ * 转发到资源模块去
185
+ */
186
+ private handleResourceList;
187
+ /**
188
+ * 取消预约列表查询订阅(HTTP 路由入口)
189
+ */
190
+ private handleUnsubscribeBookingQuery;
191
+ /**
192
+ * 订单列表本地计算(编排 Order 模块)
193
+ * filter 逻辑暂为 mock,仅记录参数
194
+ */
195
+ private computeOrderQueryResult;
196
+ /**
197
+ * 预约列表本地计算(编排 Order 模块)
198
+ * 从订单中展开 bookings,再按条件筛选 + 分页
199
+ */
200
+ private computeBookingQueryResult;
201
+ /**
202
+ * 商品查询的核心计算逻辑(编排 Products、Menu、Schedule 模块)
203
+ * 供 handleProductQuery 首次返回及 pubsub 变更推送复用
204
+ * @param context 查询上下文
205
+ * @param options 可选参数
206
+ * @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
207
+ */
208
+ private computeProductQueryResult;
209
+ /**
210
+ * 数据变更后,遍历所有订阅者重新计算查询结果并通过 callback 推送
211
+ * 由 ProductsModule 的 onProductsSyncCompleted 事件触发
212
+ * @param options 可选参数
213
+ * @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
214
+ */
215
+ private recomputeAndNotifyProductQuery;
216
+ /**
217
+ * 订单数据变更后,遍历订阅者重新计算并通过 callback 推送
218
+ */
219
+ private recomputeAndNotifyOrderQuery;
220
+ /**
221
+ * 预约数据变更后,遍历订阅者重新计算并通过 callback 推送
222
+ */
223
+ private recomputeAndNotifyBookingQuery;
137
224
  /**
138
225
  * 根据餐牌配置过滤商品
139
226
  * @param products 所有商品列表
@@ -142,6 +229,24 @@ declare class Server {
142
229
  * @private
143
230
  */
144
231
  private filterProductsByMenuConfig;
232
+ /**
233
+ * 记录信息日志
234
+ * @param title 日志标题
235
+ * @param metadata 日志元数据
236
+ */
237
+ private logInfo;
238
+ /**
239
+ * 记录警告日志
240
+ * @param title 日志标题
241
+ * @param metadata 日志元数据
242
+ */
243
+ private logWarning;
244
+ /**
245
+ * 记录错误日志
246
+ * @param title 日志标题
247
+ * @param metadata 日志元数据
248
+ */
249
+ private logError;
145
250
  /**
146
251
  * 处理获取日程时间段点的请求
147
252
  * 通过餐牌ID列表获取所有相关日程的时间段点