@pisell/pisellos 0.10.56 → 0.10.58

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 (118) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/OpenData/index.js +2 -1
  3. package/dist/modules/Order/index.d.ts +1 -0
  4. package/dist/modules/Order/index.js +118 -59
  5. package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
  6. package/dist/modules/Order/utils/weighedProduct.js +94 -0
  7. package/dist/modules/Order/utils.d.ts +6 -4
  8. package/dist/modules/Order/utils.js +40 -16
  9. package/dist/modules/Payment/index.d.ts +0 -5
  10. package/dist/modules/Payment/index.js +35 -85
  11. package/dist/modules/ProductList/index.d.ts +3 -1
  12. package/dist/modules/ProductList/index.js +203 -95
  13. package/dist/modules/ProductList/types.d.ts +8 -0
  14. package/dist/modules/ProductList/types.js +2 -0
  15. package/dist/modules/ResourcePlanner/planner.js +10 -8
  16. package/dist/modules/Rules/index.js +16 -14
  17. package/dist/modules/Rules/types.d.ts +2 -0
  18. package/dist/server/index.js +122 -69
  19. package/dist/server/modules/floor-plan/index.js +34 -3
  20. package/dist/server/modules/payment/index.d.ts +25 -6
  21. package/dist/server/modules/payment/index.js +660 -133
  22. package/dist/server/test.json +1 -1
  23. package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  24. package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
  25. package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +5 -0
  26. package/dist/shared/receipt/loadCustomerInvoiceLayout.js +46 -4
  27. package/dist/shared/receipt/small-ticket.d.ts +11 -0
  28. package/dist/shared/receipt/small-ticket.js +430 -255
  29. package/dist/shared/receipt/templateVisibility.d.ts +23 -0
  30. package/dist/shared/receipt/templateVisibility.js +64 -0
  31. package/dist/solution/BaseSales/index.d.ts +4 -2
  32. package/dist/solution/BaseSales/index.js +1328 -1214
  33. package/dist/solution/BaseSales/types.d.ts +5 -1
  34. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +40 -25
  35. package/dist/solution/BaseSales/utils.js +3 -2
  36. package/dist/solution/BookingTicket/index.d.ts +4 -1
  37. package/dist/solution/BookingTicket/index.js +120 -80
  38. package/dist/solution/OrderInvoicePreview/index.d.ts +10 -0
  39. package/dist/solution/OrderInvoicePreview/index.js +85 -14
  40. package/dist/solution/RegisterAndLogin/config.js +54 -11
  41. package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
  42. package/dist/solution/RegisterAndLogin/index.js +1 -1
  43. package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
  44. package/dist/solution/RegisterAndLogin/utils.js +36 -16
  45. package/dist/solution/Sales/index.d.ts +2 -0
  46. package/dist/solution/Sales/index.js +15 -1
  47. package/dist/solution/ScanOrder/utils.js +3 -2
  48. package/dist/solution/UnifiedBookingSales/index.d.ts +7 -1
  49. package/dist/solution/UnifiedBookingSales/index.js +560 -401
  50. package/dist/solution/VenueBooking/index.d.ts +15 -2
  51. package/dist/solution/VenueBooking/index.js +1062 -785
  52. package/dist/solution/VenueBooking/types.d.ts +2 -1
  53. package/dist/solution/VenueBooking/types.js +1 -0
  54. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  55. package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
  56. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  57. package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
  58. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  59. package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
  60. package/lib/modules/OpenData/index.js +2 -1
  61. package/lib/modules/Order/index.d.ts +1 -0
  62. package/lib/modules/Order/index.js +71 -11
  63. package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
  64. package/lib/modules/Order/utils/weighedProduct.js +89 -0
  65. package/lib/modules/Order/utils.d.ts +6 -4
  66. package/lib/modules/Order/utils.js +34 -13
  67. package/lib/modules/Payment/index.d.ts +0 -5
  68. package/lib/modules/Payment/index.js +3 -28
  69. package/lib/modules/ProductList/index.d.ts +3 -1
  70. package/lib/modules/ProductList/index.js +45 -6
  71. package/lib/modules/ProductList/types.d.ts +8 -0
  72. package/lib/modules/ProductList/types.js +1 -0
  73. package/lib/modules/ResourcePlanner/planner.js +10 -8
  74. package/lib/modules/Rules/index.js +16 -14
  75. package/lib/modules/Rules/types.d.ts +2 -0
  76. package/lib/server/index.js +72 -28
  77. package/lib/server/modules/floor-plan/index.js +29 -1
  78. package/lib/server/modules/payment/index.d.ts +25 -6
  79. package/lib/server/modules/payment/index.js +350 -78
  80. package/lib/server/test.json +1 -1
  81. package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
  82. package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
  83. package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +5 -0
  84. package/lib/shared/receipt/loadCustomerInvoiceLayout.js +42 -4
  85. package/lib/shared/receipt/small-ticket.d.ts +11 -0
  86. package/lib/shared/receipt/small-ticket.js +234 -30
  87. package/lib/shared/receipt/templateVisibility.d.ts +23 -0
  88. package/lib/shared/receipt/templateVisibility.js +63 -0
  89. package/lib/solution/BaseSales/index.d.ts +4 -2
  90. package/lib/solution/BaseSales/index.js +79 -18
  91. package/lib/solution/BaseSales/types.d.ts +5 -1
  92. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -9
  93. package/lib/solution/BaseSales/utils.js +2 -1
  94. package/lib/solution/BookingTicket/index.d.ts +4 -1
  95. package/lib/solution/BookingTicket/index.js +14 -2
  96. package/lib/solution/OrderInvoicePreview/index.d.ts +10 -0
  97. package/lib/solution/OrderInvoicePreview/index.js +61 -7
  98. package/lib/solution/RegisterAndLogin/config.js +57 -11
  99. package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
  100. package/lib/solution/RegisterAndLogin/index.js +9 -1
  101. package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
  102. package/lib/solution/RegisterAndLogin/utils.js +24 -17
  103. package/lib/solution/Sales/index.d.ts +2 -0
  104. package/lib/solution/Sales/index.js +10 -1
  105. package/lib/solution/ScanOrder/utils.js +2 -1
  106. package/lib/solution/UnifiedBookingSales/index.d.ts +7 -1
  107. package/lib/solution/UnifiedBookingSales/index.js +85 -7
  108. package/lib/solution/VenueBooking/index.d.ts +15 -2
  109. package/lib/solution/VenueBooking/index.js +243 -96
  110. package/lib/solution/VenueBooking/types.d.ts +2 -1
  111. package/lib/solution/VenueBooking/types.js +1 -0
  112. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  113. package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
  114. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  115. package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
  116. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
  117. package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
  118. package/package.json +1 -1
@@ -102,18 +102,102 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
102
102
  this.otherParams = params || {};
103
103
  }
104
104
  }, {
105
- key: "storeChange",
105
+ key: "enrichProducts",
106
106
  value: function () {
107
- var _storeChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(path, value) {
107
+ var _enrichProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(products, context) {
108
+ var _context$signal, _context$signal2;
109
+ var enrich, result;
108
110
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
109
111
  while (1) switch (_context2.prev = _context2.next) {
110
112
  case 0:
113
+ enrich = this.otherParams.enrichProducts;
114
+ if (enrich) {
115
+ _context2.next = 3;
116
+ break;
117
+ }
118
+ return _context2.abrupt("return", products);
119
+ case 3:
120
+ if (!((_context$signal = context.signal) !== null && _context$signal !== void 0 && _context$signal.aborted)) {
121
+ _context2.next = 5;
122
+ break;
123
+ }
124
+ throw new Error('Product enrichment cancelled');
125
+ case 5:
126
+ _context2.next = 7;
127
+ return enrich(cloneDeep(products), _objectSpread({
128
+ businessCode: this.otherParams.businessCode,
129
+ channel: this.otherParams.channel
130
+ }, context));
131
+ case 7:
132
+ result = _context2.sent;
133
+ if (!((_context$signal2 = context.signal) !== null && _context$signal2 !== void 0 && _context$signal2.aborted)) {
134
+ _context2.next = 10;
135
+ break;
136
+ }
137
+ throw new Error('Product enrichment cancelled');
138
+ case 10:
139
+ if (Array.isArray(result)) {
140
+ _context2.next = 12;
141
+ break;
142
+ }
143
+ throw new Error('Product enrichment must return an array');
144
+ case 12:
145
+ return _context2.abrupt("return", result);
146
+ case 13:
111
147
  case "end":
112
148
  return _context2.stop();
113
149
  }
114
- }, _callee2);
150
+ }, _callee2, this);
151
+ }));
152
+ function enrichProducts(_x3, _x4) {
153
+ return _enrichProducts.apply(this, arguments);
154
+ }
155
+ return enrichProducts;
156
+ }()
157
+ }, {
158
+ key: "enrichCatalog",
159
+ value: function () {
160
+ var _enrichCatalog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(products, reason) {
161
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
162
+ while (1) switch (_context3.prev = _context3.next) {
163
+ case 0:
164
+ _context3.prev = 0;
165
+ _context3.next = 3;
166
+ return this.enrichProducts(products, {
167
+ reason: reason
168
+ });
169
+ case 3:
170
+ return _context3.abrupt("return", _context3.sent);
171
+ case 6:
172
+ _context3.prev = 6;
173
+ _context3.t0 = _context3["catch"](0);
174
+ // An unavailable supplementary source is not zero stock or an empty catalog.
175
+ console.warn('[ProductList] Supplementary product data could not be refreshed');
176
+ return _context3.abrupt("return", products);
177
+ case 10:
178
+ case "end":
179
+ return _context3.stop();
180
+ }
181
+ }, _callee3, this, [[0, 6]]);
115
182
  }));
116
- function storeChange(_x3, _x4) {
183
+ function enrichCatalog(_x5, _x6) {
184
+ return _enrichCatalog.apply(this, arguments);
185
+ }
186
+ return enrichCatalog;
187
+ }()
188
+ }, {
189
+ key: "storeChange",
190
+ value: function () {
191
+ var _storeChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(path, value) {
192
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
193
+ while (1) switch (_context4.prev = _context4.next) {
194
+ case 0:
195
+ case "end":
196
+ return _context4.stop();
197
+ }
198
+ }, _callee4);
199
+ }));
200
+ function storeChange(_x7, _x8) {
117
201
  return _storeChange.apply(this, arguments);
118
202
  }
119
203
  return storeChange;
@@ -127,14 +211,14 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
127
211
  }, {
128
212
  key: "getAddTimeProducts",
129
213
  value: (function () {
130
- var _getAddTimeProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
214
+ var _getAddTimeProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
131
215
  var params,
132
- _args3 = arguments;
133
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
134
- while (1) switch (_context3.prev = _context3.next) {
216
+ _args5 = arguments;
217
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
218
+ while (1) switch (_context5.prev = _context5.next) {
135
219
  case 0:
136
- params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
137
- return _context3.abrupt("return", this.loadProducts(_objectSpread(_objectSpread({
220
+ params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
221
+ return _context5.abrupt("return", this.loadProducts(_objectSpread(_objectSpread({
138
222
  schedule_date: dayjs().format('YYYY-MM-DD'),
139
223
  status: 'published'
140
224
  }, params), {}, {
@@ -142,9 +226,9 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
142
226
  })));
143
227
  case 2:
144
228
  case "end":
145
- return _context3.stop();
229
+ return _context5.stop();
146
230
  }
147
- }, _callee3, this);
231
+ }, _callee5, this);
148
232
  }));
149
233
  function getAddTimeProducts() {
150
234
  return _getAddTimeProducts.apply(this, arguments);
@@ -154,9 +238,12 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
154
238
  }, {
155
239
  key: "loadProducts",
156
240
  value: function () {
157
- var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
241
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
158
242
  var _this$otherParams,
243
+ _this$otherParams$bus,
159
244
  _this$otherParams2,
245
+ _this$otherParams3,
246
+ _this$otherParams4,
160
247
  _this2 = this;
161
248
  var _ref,
162
249
  _ref$category_ids,
@@ -185,19 +272,22 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
185
272
  channelMap,
186
273
  rawApplicationCode,
187
274
  mappedApplicationCode,
275
+ configuredBusinessCode,
276
+ resolvedStrategyContext,
188
277
  queryPayload,
189
278
  handledByOsServer,
190
279
  originalCallback,
191
280
  subscriptionCallback,
192
281
  productsData,
193
282
  resolvedList,
283
+ enrichedList,
194
284
  sortedList,
195
- _args5 = arguments;
196
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
197
- while (1) switch (_context5.prev = _context5.next) {
285
+ _args7 = arguments;
286
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
287
+ while (1) switch (_context7.prev = _context7.next) {
198
288
  case 0:
199
- _ref = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {}, _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$menu_list_ids = _ref.menu_list_ids, menu_list_ids = _ref$menu_list_ids === void 0 ? [] : _ref$menu_list_ids, paramsCustomerId = _ref.customer_id, _ref$with_count = _ref.with_count, with_count = _ref$with_count === void 0 ? [] : _ref$with_count, schedule_datetime = _ref.schedule_datetime, schedule_date = _ref.schedule_date, cacheId = _ref.cacheId, with_schedule = _ref.with_schedule, extension_type = _ref.extension_type, _ref$status = _ref.status, status = _ref$status === void 0 ? 'published' : _ref$status, strategy_context = _ref.strategy_context;
200
- options = _args5.length > 1 ? _args5[1] : undefined;
289
+ _ref = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {}, _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$menu_list_ids = _ref.menu_list_ids, menu_list_ids = _ref$menu_list_ids === void 0 ? [] : _ref$menu_list_ids, paramsCustomerId = _ref.customer_id, _ref$with_count = _ref.with_count, with_count = _ref$with_count === void 0 ? [] : _ref$with_count, schedule_datetime = _ref.schedule_datetime, schedule_date = _ref.schedule_date, cacheId = _ref.cacheId, with_schedule = _ref.with_schedule, extension_type = _ref.extension_type, _ref$status = _ref.status, status = _ref$status === void 0 ? 'published' : _ref$status, strategy_context = _ref.strategy_context;
290
+ options = _args7.length > 1 ? _args7[1] : undefined;
201
291
  // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
202
292
  // if (!schedule_ids?.length) {
203
293
  // const schedule_ids_data = this.store.schedule
@@ -227,7 +317,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
227
317
  };
228
318
  rawApplicationCode = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel;
229
319
  mappedApplicationCode = typeof rawApplicationCode === 'string' ? channelMap[rawApplicationCode] || rawApplicationCode : rawApplicationCode;
230
- queryPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, isCustomerUserPlatform((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform) ? {} : {
320
+ configuredBusinessCode = (_this$otherParams$bus = (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.business_code; // application_code 是后端商品筛选字段;智能定价评估器则只读取
321
+ // strategy_context 中的 channel / business_code。默认补齐两者,
322
+ // 但允许调用方显式传入的上下文覆盖默认值。
323
+ resolvedStrategyContext = _objectSpread(_objectSpread(_objectSpread({}, mappedApplicationCode ? {
324
+ channel: mappedApplicationCode
325
+ } : {}), configuredBusinessCode ? {
326
+ business_code: configuredBusinessCode
327
+ } : {}), strategy_context || {});
328
+ queryPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, isCustomerUserPlatform((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform) ? {} : {
231
329
  open_quotation: 1
232
330
  }), {}, {
233
331
  open_bundle: 0,
@@ -256,24 +354,24 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
256
354
  with_schedule: with_schedule,
257
355
  schedule_datetime: schedule_datetime,
258
356
  extension_type: extension_type,
259
- strategy_context: strategy_context
357
+ strategy_context: Object.keys(resolvedStrategyContext).length ? resolvedStrategyContext : undefined
260
358
  });
261
359
  handledByOsServer = isProductQueryHandledByOsServer(this.core, this.request);
262
360
  originalCallback = typeof (options === null || options === void 0 ? void 0 : options.callback) === 'function' ? options.callback : undefined;
263
361
  subscriptionCallback = originalCallback ? ( /*#__PURE__*/function () {
264
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(result) {
362
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(result) {
265
363
  var _result$data;
266
- var callbackList, resolvedCallbackList;
267
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
268
- while (1) switch (_context4.prev = _context4.next) {
364
+ var callbackList, resolvedCallbackList, enrichedCallbackList;
365
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
366
+ while (1) switch (_context6.prev = _context6.next) {
269
367
  case 0:
270
368
  callbackList = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.list;
271
369
  if (Array.isArray(callbackList)) {
272
- _context4.next = 4;
370
+ _context6.next = 4;
273
371
  break;
274
372
  }
275
373
  originalCallback(result);
276
- return _context4.abrupt("return");
374
+ return _context6.abrupt("return");
277
375
  case 4:
278
376
  if (!handledByOsServer) {
279
377
  // Subscription payloads may contain only changed products, so keep
@@ -287,33 +385,37 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
287
385
  queryPayload: queryPayload,
288
386
  handledByOsServer: handledByOsServer
289
387
  });
290
- _context4.next = 8;
291
- return _this2.addProduct(resolvedCallbackList);
388
+ _context6.next = 8;
389
+ return _this2.enrichCatalog(resolvedCallbackList, 'catalog-update');
292
390
  case 8:
293
- originalCallback(resolvedCallbackList === callbackList ? result : _objectSpread(_objectSpread({}, result), {}, {
391
+ enrichedCallbackList = _context6.sent;
392
+ _context6.next = 11;
393
+ return _this2.addProduct(enrichedCallbackList);
394
+ case 11:
395
+ originalCallback(enrichedCallbackList === callbackList ? result : _objectSpread(_objectSpread({}, result), {}, {
294
396
  data: _objectSpread(_objectSpread({}, result.data), {}, {
295
- list: resolvedCallbackList
397
+ list: enrichedCallbackList
296
398
  })
297
399
  }));
298
- case 9:
400
+ case 12:
299
401
  case "end":
300
- return _context4.stop();
402
+ return _context6.stop();
301
403
  }
302
- }, _callee4);
404
+ }, _callee6);
303
405
  }));
304
- return function (_x5) {
406
+ return function (_x9) {
305
407
  return _ref2.apply(this, arguments);
306
408
  };
307
409
  }()) : undefined;
308
- _context5.next = 14;
410
+ _context7.next = 16;
309
411
  return this.request.post("/product/query", queryPayload, {
310
412
  osServer: true,
311
413
  callback: subscriptionCallback,
312
414
  subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId,
313
415
  customToast: function customToast() {}
314
416
  });
315
- case 14:
316
- productsData = _context5.sent;
417
+ case 16:
418
+ productsData = _context7.sent;
317
419
  if (!handledByOsServer && Array.isArray(productsData.data.list)) {
318
420
  this.replaceRawProductQueryResult(productsData.data.list, product_ids);
319
421
  }
@@ -324,7 +426,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
324
426
  queryPayload: queryPayload,
325
427
  handledByOsServer: handledByOsServer
326
428
  });
327
- sortedList = resolvedList.slice().sort(function (a, b) {
429
+ _context7.next = 21;
430
+ return this.enrichCatalog(resolvedList, 'catalog');
431
+ case 21:
432
+ enrichedList = _context7.sent;
433
+ sortedList = enrichedList.slice().sort(function (a, b) {
328
434
  return Number(b.sort) - Number(a.sort);
329
435
  }); // if (sortedList.length) {
330
436
  // sortedList.forEach((n: any) => {
@@ -333,13 +439,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
333
439
  // }
334
440
  // })
335
441
  // }
336
- this.addProduct(sortedList);
337
- return _context5.abrupt("return", sortedList);
338
- case 20:
442
+ _context7.next = 25;
443
+ return this.addProduct(sortedList);
444
+ case 25:
445
+ return _context7.abrupt("return", sortedList);
446
+ case 26:
339
447
  case "end":
340
- return _context5.stop();
448
+ return _context7.stop();
341
449
  }
342
- }, _callee5, this);
450
+ }, _callee7, this);
343
451
  }));
344
452
  function loadProducts() {
345
453
  return _loadProducts.apply(this, arguments);
@@ -349,13 +457,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
349
457
  }, {
350
458
  key: "loadProductsPrice",
351
459
  value: function () {
352
- var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref3) {
460
+ var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_ref3) {
353
461
  var _ref3$ids, ids, customer_id, schedule_date, channel, productsData;
354
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
355
- while (1) switch (_context6.prev = _context6.next) {
462
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
463
+ while (1) switch (_context8.prev = _context8.next) {
356
464
  case 0:
357
465
  _ref3$ids = _ref3.ids, ids = _ref3$ids === void 0 ? [] : _ref3$ids, customer_id = _ref3.customer_id, schedule_date = _ref3.schedule_date, channel = _ref3.channel;
358
- _context6.next = 3;
466
+ _context8.next = 3;
359
467
  return this.request.post("/product/query/price", {
360
468
  ids: ids,
361
469
  customer_id: customer_id,
@@ -365,15 +473,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
365
473
  useCache: true
366
474
  });
367
475
  case 3:
368
- productsData = _context6.sent;
369
- return _context6.abrupt("return", productsData.data);
476
+ productsData = _context8.sent;
477
+ return _context8.abrupt("return", productsData.data);
370
478
  case 5:
371
479
  case "end":
372
- return _context6.stop();
480
+ return _context8.stop();
373
481
  }
374
- }, _callee6, this);
482
+ }, _callee8, this);
375
483
  }));
376
- function loadProductsPrice(_x6) {
484
+ function loadProductsPrice(_x10) {
377
485
  return _loadProductsPrice.apply(this, arguments);
378
486
  }
379
487
  return loadProductsPrice;
@@ -435,19 +543,19 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
435
543
  }, {
436
544
  key: "getProducts",
437
545
  value: function () {
438
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
439
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
440
- while (1) switch (_context7.prev = _context7.next) {
546
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
547
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
548
+ while (1) switch (_context9.prev = _context9.next) {
441
549
  case 0:
442
- _context7.next = 2;
550
+ _context9.next = 2;
443
551
  return this.core.effects.emit("".concat(this.name, ":onGetProducts"), this.store.list);
444
552
  case 2:
445
- return _context7.abrupt("return", cloneDeep(this.store.list));
553
+ return _context9.abrupt("return", cloneDeep(this.store.list));
446
554
  case 3:
447
555
  case "end":
448
- return _context7.stop();
556
+ return _context9.stop();
449
557
  }
450
- }, _callee7, this);
558
+ }, _callee9, this);
451
559
  }));
452
560
  function getProducts() {
453
561
  return _getProducts.apply(this, arguments);
@@ -457,25 +565,25 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
457
565
  }, {
458
566
  key: "getProduct",
459
567
  value: function () {
460
- var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(id) {
568
+ var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(id) {
461
569
  var product;
462
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
463
- while (1) switch (_context8.prev = _context8.next) {
570
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
571
+ while (1) switch (_context10.prev = _context10.next) {
464
572
  case 0:
465
- _context8.next = 2;
573
+ _context10.next = 2;
466
574
  return this.core.effects.emit("".concat(this.name, ":onGetProduct"), this.store.list);
467
575
  case 2:
468
576
  product = this.store.list.find(function (product) {
469
577
  return product.id === id;
470
578
  });
471
- return _context8.abrupt("return", product ? cloneDeep(product) : undefined);
579
+ return _context10.abrupt("return", product ? cloneDeep(product) : undefined);
472
580
  case 4:
473
581
  case "end":
474
- return _context8.stop();
582
+ return _context10.stop();
475
583
  }
476
- }, _callee8, this);
584
+ }, _callee10, this);
477
585
  }));
478
- function getProduct(_x7) {
586
+ function getProduct(_x11) {
479
587
  return _getProduct.apply(this, arguments);
480
588
  }
481
589
  return getProduct;
@@ -483,7 +591,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
483
591
  }, {
484
592
  key: "queryProducts",
485
593
  value: function () {
486
- var _queryProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
594
+ var _queryProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
487
595
  var params,
488
596
  includeIds,
489
597
  excludeIds,
@@ -494,11 +602,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
494
602
  channelApplications,
495
603
  codeOrBarcode,
496
604
  products,
497
- _args9 = arguments;
498
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
499
- while (1) switch (_context9.prev = _context9.next) {
605
+ _args11 = arguments;
606
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
607
+ while (1) switch (_context11.prev = _context11.next) {
500
608
  case 0:
501
- params = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
609
+ params = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
502
610
  includeIds = normalizeQuerySet(params.includeIds);
503
611
  excludeIds = normalizeQuerySet(params.excludeIds);
504
612
  categoryIds = normalizeQuerySet(params.categoryIds);
@@ -537,12 +645,12 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
537
645
  }
538
646
  return true;
539
647
  });
540
- return _context9.abrupt("return", cloneDeep(products));
648
+ return _context11.abrupt("return", cloneDeep(products));
541
649
  case 11:
542
650
  case "end":
543
- return _context9.stop();
651
+ return _context11.stop();
544
652
  }
545
- }, _callee9, this);
653
+ }, _callee11, this);
546
654
  }));
547
655
  function queryProducts() {
548
656
  return _queryProducts.apply(this, arguments);
@@ -552,23 +660,23 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
552
660
  }, {
553
661
  key: "getProductByIds",
554
662
  value: function () {
555
- var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(ids) {
556
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
557
- while (1) switch (_context10.prev = _context10.next) {
663
+ var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(ids) {
664
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
665
+ while (1) switch (_context12.prev = _context12.next) {
558
666
  case 0:
559
- _context10.next = 2;
667
+ _context12.next = 2;
560
668
  return this.core.effects.emit("".concat(this.name, ":onGetProductByIds"), this.store.list);
561
669
  case 2:
562
- return _context10.abrupt("return", this.queryProducts({
670
+ return _context12.abrupt("return", this.queryProducts({
563
671
  includeIds: ids
564
672
  }));
565
673
  case 3:
566
674
  case "end":
567
- return _context10.stop();
675
+ return _context12.stop();
568
676
  }
569
- }, _callee10, this);
677
+ }, _callee12, this);
570
678
  }));
571
- function getProductByIds(_x8) {
679
+ function getProductByIds(_x12) {
572
680
  return _getProductByIds.apply(this, arguments);
573
681
  }
574
682
  return getProductByIds;
@@ -576,10 +684,10 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
576
684
  }, {
577
685
  key: "addProduct",
578
686
  value: function () {
579
- var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(products) {
687
+ var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(products) {
580
688
  var _this6 = this;
581
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
582
- while (1) switch (_context11.prev = _context11.next) {
689
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
690
+ while (1) switch (_context13.prev = _context13.next) {
583
691
  case 0:
584
692
  // list 需要根据 id 去重
585
693
  if (!this.store.list) {
@@ -602,11 +710,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
602
710
  this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
603
711
  case 4:
604
712
  case "end":
605
- return _context11.stop();
713
+ return _context13.stop();
606
714
  }
607
- }, _callee11, this);
715
+ }, _callee13, this);
608
716
  }));
609
- function addProduct(_x9) {
717
+ function addProduct(_x13) {
610
718
  return _addProduct.apply(this, arguments);
611
719
  }
612
720
  return addProduct;
@@ -614,18 +722,18 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
614
722
  }, {
615
723
  key: "selectProducts",
616
724
  value: function () {
617
- var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(products) {
618
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
619
- while (1) switch (_context12.prev = _context12.next) {
725
+ var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(products) {
726
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
727
+ while (1) switch (_context14.prev = _context14.next) {
620
728
  case 0:
621
729
  this.store.selectProducts = products;
622
730
  case 1:
623
731
  case "end":
624
- return _context12.stop();
732
+ return _context14.stop();
625
733
  }
626
- }, _callee12, this);
734
+ }, _callee14, this);
627
735
  }));
628
- function selectProducts(_x10) {
736
+ function selectProducts(_x14) {
629
737
  return _selectProducts.apply(this, arguments);
630
738
  }
631
739
  return selectProducts;
@@ -1,4 +1,12 @@
1
1
  import { ProductData } from '../Product/types';
2
+ /** Runtime-only enrichment; never serialized into a product query. */
3
+ export interface ProductEnrichmentContext {
4
+ reason: 'catalog' | 'catalog-update' | 'detail-open';
5
+ businessCode?: string;
6
+ channel?: string;
7
+ signal?: AbortSignal;
8
+ }
9
+ export type ProductEnricher = (products: ProductData[], context: ProductEnrichmentContext) => Promise<ProductData[]>;
2
10
  export interface ProductListLoadProductsParams {
3
11
  category_ids?: number[];
4
12
  product_ids?: number[];
@@ -1,3 +1,5 @@
1
+ /** Runtime-only enrichment; never serialized into a product query. */
2
+
1
3
  export var ProductListHooks = /*#__PURE__*/function (ProductListHooks) {
2
4
  ProductListHooks["onGetProducts"] = "productList:onGetProducts";
3
5
  ProductListHooks["onGetProduct"] = "productList:onGetProduct";
@@ -436,7 +436,7 @@ function normalizeOccupancy(occupancy, coverage, timezoneName, fixedOffsetMinute
436
436
  }
437
437
  function normalizeRequirementGroup(product, requirementGroup) {
438
438
  var _requirementGroup$for;
439
- var resourceType = 'single';
439
+ var resourceType = requirementGroup.resourceType === 'multiple' || requirementGroup.resourceType === 'capacity' ? requirementGroup.resourceType : 'single';
440
440
  var required = requirementGroup.required !== false;
441
441
  var min = required ? 1 : 0;
442
442
  return _objectSpread(_objectSpread({}, requirementGroup), {}, {
@@ -482,7 +482,7 @@ function normalizeProducts(products) {
482
482
  function normalizeResources(resources) {
483
483
  return resources.map(function (resource) {
484
484
  return _objectSpread(_objectSpread({}, resource), {}, {
485
- resourceType: 'single',
485
+ resourceType: resource.resourceType === 'multiple' || resource.resourceType === 'capacity' ? resource.resourceType : 'single',
486
486
  capacity: Math.max(1, Number(resource.capacity || 1) || 1),
487
487
  windows: (resource.windows || []).map(function (window) {
488
488
  return _objectSpread({}, window);
@@ -637,7 +637,8 @@ function buildCells(projection) {
637
637
  var usedCapacity = segmentOccupancies.reduce(function (sum, occupancy) {
638
638
  return sum + Math.max(1, Number(occupancy.pax || 1) || 1);
639
639
  }, 0);
640
- var remainingCapacity = Math.max(0, resource.capacity - usedCapacity);
640
+ // 预约模式来自商品资源组;v2 资源记录可能不包含 type。
641
+ var remainingCapacity = requirementGroup.resourceType === 'single' && segmentOccupancies.length > 0 ? 0 : Math.max(0, resource.capacity - usedCapacity);
641
642
  var requiredCapacity = resolveRequiredCapacity(requirementGroup, product);
642
643
  var reasonCodes = Array.from(new Set(segmentOccupancies.flatMap(function (occupancy) {
643
644
  var source = occupancy.source || 'remote';
@@ -671,7 +672,7 @@ function buildCells(projection) {
671
672
  requirementFormId: requirementGroup.formId,
672
673
  resourceId: resource.id,
673
674
  resourceName: resource.name,
674
- resourceType: resource.resourceType,
675
+ resourceType: requirementGroup.resourceType,
675
676
  startAt: formatDateTime(start, timezoneName, fixedOffsetMinutes),
676
677
  endAt: formatDateTime(end, timezoneName, fixedOffsetMinutes),
677
678
  date: formatDate(start, timezoneName),
@@ -679,7 +680,7 @@ function buildCells(projection) {
679
680
  endTime: formatTime(end, timezoneName),
680
681
  timezone: projection.meta.timezone,
681
682
  status: status,
682
- // 资源组当前统一单选;具体资源仍用 capacity 表达可承载的预约数量。
683
+ // capacity 表示人数;single 被占用时不再贡献可用容量。
683
684
  remainingCapacity: remainingCapacity,
684
685
  maxCapacity: resource.capacity,
685
686
  reasonCodes: Array.from(new Set(reasonCodes)),
@@ -1739,7 +1740,7 @@ function evaluateCandidate(projection, candidate, request) {
1739
1740
  resourceName: resource.name,
1740
1741
  resourceFormId: resource.formId,
1741
1742
  policyId: (_resource$raw = resource.raw) === null || _resource$raw === void 0 ? void 0 : _resource$raw.policy_id,
1742
- resourceType: resource.resourceType,
1743
+ resourceType: requirementGroup.resourceType,
1743
1744
  status: _isPast ? 'past' : 'unavailable',
1744
1745
  maxPartySize: 0,
1745
1746
  reasonCodes: _isPast ? ['past'] : [].concat(_toConsumableArray(isExcludedScheduleDate ? ['schedule_excluded_date'] : []), ['outside_resource_window'])
@@ -1763,7 +1764,7 @@ function evaluateCandidate(projection, candidate, request) {
1763
1764
  resourceName: resource.name,
1764
1765
  resourceFormId: resource.formId,
1765
1766
  policyId: (_resource$raw2 = resource.raw) === null || _resource$raw2 === void 0 ? void 0 : _resource$raw2.policy_id,
1766
- resourceType: resource.resourceType,
1767
+ resourceType: requirementGroup.resourceType,
1767
1768
  status: status,
1768
1769
  remainingCapacity: remainingCapacity,
1769
1770
  maxCapacity: maxCapacity,
@@ -2330,7 +2331,8 @@ export function validateAvailabilitySelection(projection, params) {
2330
2331
  var remainingCapacity = matchedCell === null || matchedCell === void 0 ? void 0 : matchedCell.remainingCapacity;
2331
2332
  if (option && (option.status === 'available' || option.status === 'limited') && remainingCapacity !== undefined) {
2332
2333
  var capacityPerBooking = normalizedPartySize !== null && normalizedPartySize !== void 0 ? normalizedPartySize : 1;
2333
- var availableQuantity = Math.max(0, Math.floor(remainingCapacity / capacityPerBooking));
2334
+ var capacityQuantity = Math.max(0, Math.floor(remainingCapacity / capacityPerBooking));
2335
+ var availableQuantity = matchedGroup.resourceType === 'single' ? Math.min(1, capacityQuantity) : capacityQuantity;
2334
2336
  if (normalizedBookingCount > availableQuantity) {
2335
2337
  conflicts.push({
2336
2338
  code: 'resource_capacity_exceeded',