@pisell/pisellos 2.3.77 → 2.3.79

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.
@@ -1,9 +0,0 @@
1
- // 导出评估器
2
- export { PromotionEvaluator } from "./evaluator";
3
-
4
- // 导出适配器
5
- export { PromotionAdapter } from "./adapter";
6
- export { default } from "./adapter";
7
-
8
- // 导出策略配置示例常量
9
- export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
@@ -131,8 +131,9 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
131
131
  }, {
132
132
  key: "loadProducts",
133
133
  value: function () {
134
- var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
135
- var _this$otherParams;
134
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
135
+ var _this$otherParams,
136
+ _this2 = this;
136
137
  var _ref,
137
138
  _ref$category_ids,
138
139
  category_ids,
@@ -161,14 +162,16 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
161
162
  rawApplicationCode,
162
163
  mappedApplicationCode,
163
164
  queryPayload,
165
+ originalCallback,
166
+ subscriptionCallback,
164
167
  productsData,
165
168
  sortedList,
166
- _args4 = arguments;
167
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
168
- while (1) switch (_context4.prev = _context4.next) {
169
+ _args5 = arguments;
170
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
171
+ while (1) switch (_context5.prev = _context5.next) {
169
172
  case 0:
170
- _ref = _args4.length > 0 && _args4[0] !== undefined ? _args4[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;
171
- options = _args4.length > 1 ? _args4[1] : undefined;
173
+ _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;
174
+ options = _args5.length > 1 ? _args5[1] : undefined;
172
175
  // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
173
176
  // if (!schedule_ids?.length) {
174
177
  // const schedule_ids_data = this.store.schedule
@@ -228,15 +231,38 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
228
231
  extension_type: extension_type,
229
232
  strategy_context: strategy_context
230
233
  });
231
- _context4.next = 11;
234
+ originalCallback = options === null || options === void 0 ? void 0 : options.callback;
235
+ subscriptionCallback = originalCallback ? ( /*#__PURE__*/function () {
236
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(result) {
237
+ var _result$data;
238
+ var products;
239
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
240
+ while (1) switch (_context4.prev = _context4.next) {
241
+ case 0:
242
+ products = Array.isArray(result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.list) ? result.data.list : [];
243
+ _context4.next = 3;
244
+ return _this2.addProduct(products);
245
+ case 3:
246
+ originalCallback(result);
247
+ case 4:
248
+ case "end":
249
+ return _context4.stop();
250
+ }
251
+ }, _callee4);
252
+ }));
253
+ return function (_x5) {
254
+ return _ref2.apply(this, arguments);
255
+ };
256
+ }()) : undefined;
257
+ _context5.next = 13;
232
258
  return this.request.post("/product/query", queryPayload, {
233
259
  osServer: true,
234
- callback: options === null || options === void 0 ? void 0 : options.callback,
260
+ callback: subscriptionCallback,
235
261
  subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId,
236
262
  customToast: function customToast() {}
237
263
  });
238
- case 11:
239
- productsData = _context4.sent;
264
+ case 13:
265
+ productsData = _context5.sent;
240
266
  sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
241
267
  return Number(b.sort) - Number(a.sort);
242
268
  }); // if (sortedList.length) {
@@ -247,12 +273,12 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
247
273
  // })
248
274
  // }
249
275
  this.addProduct(sortedList);
250
- return _context4.abrupt("return", sortedList);
251
- case 15:
276
+ return _context5.abrupt("return", sortedList);
277
+ case 17:
252
278
  case "end":
253
- return _context4.stop();
279
+ return _context5.stop();
254
280
  }
255
- }, _callee4, this);
281
+ }, _callee5, this);
256
282
  }));
257
283
  function loadProducts() {
258
284
  return _loadProducts.apply(this, arguments);
@@ -262,13 +288,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
262
288
  }, {
263
289
  key: "loadProductsPrice",
264
290
  value: function () {
265
- var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref2) {
266
- var _ref2$ids, ids, customer_id, schedule_date, channel, productsData;
267
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
268
- while (1) switch (_context5.prev = _context5.next) {
291
+ var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref3) {
292
+ var _ref3$ids, ids, customer_id, schedule_date, channel, productsData;
293
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
294
+ while (1) switch (_context6.prev = _context6.next) {
269
295
  case 0:
270
- _ref2$ids = _ref2.ids, ids = _ref2$ids === void 0 ? [] : _ref2$ids, customer_id = _ref2.customer_id, schedule_date = _ref2.schedule_date, channel = _ref2.channel;
271
- _context5.next = 3;
296
+ _ref3$ids = _ref3.ids, ids = _ref3$ids === void 0 ? [] : _ref3$ids, customer_id = _ref3.customer_id, schedule_date = _ref3.schedule_date, channel = _ref3.channel;
297
+ _context6.next = 3;
272
298
  return this.request.post("/product/query/price", {
273
299
  ids: ids,
274
300
  customer_id: customer_id,
@@ -278,15 +304,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
278
304
  useCache: true
279
305
  });
280
306
  case 3:
281
- productsData = _context5.sent;
282
- return _context5.abrupt("return", productsData.data);
307
+ productsData = _context6.sent;
308
+ return _context6.abrupt("return", productsData.data);
283
309
  case 5:
284
310
  case "end":
285
- return _context5.stop();
311
+ return _context6.stop();
286
312
  }
287
- }, _callee5, this);
313
+ }, _callee6, this);
288
314
  }));
289
- function loadProductsPrice(_x5) {
315
+ function loadProductsPrice(_x6) {
290
316
  return _loadProductsPrice.apply(this, arguments);
291
317
  }
292
318
  return loadProductsPrice;
@@ -294,19 +320,19 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
294
320
  }, {
295
321
  key: "getProducts",
296
322
  value: function () {
297
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
298
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
299
- while (1) switch (_context6.prev = _context6.next) {
323
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
324
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
325
+ while (1) switch (_context7.prev = _context7.next) {
300
326
  case 0:
301
- _context6.next = 2;
327
+ _context7.next = 2;
302
328
  return this.core.effects.emit("".concat(this.name, ":onGetProducts"), this.store.list);
303
329
  case 2:
304
- return _context6.abrupt("return", cloneDeep(this.store.list));
330
+ return _context7.abrupt("return", cloneDeep(this.store.list));
305
331
  case 3:
306
332
  case "end":
307
- return _context6.stop();
333
+ return _context7.stop();
308
334
  }
309
- }, _callee6, this);
335
+ }, _callee7, this);
310
336
  }));
311
337
  function getProducts() {
312
338
  return _getProducts.apply(this, arguments);
@@ -316,25 +342,25 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
316
342
  }, {
317
343
  key: "getProduct",
318
344
  value: function () {
319
- var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(id) {
345
+ var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(id) {
320
346
  var product;
321
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
322
- while (1) switch (_context7.prev = _context7.next) {
347
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
348
+ while (1) switch (_context8.prev = _context8.next) {
323
349
  case 0:
324
- _context7.next = 2;
350
+ _context8.next = 2;
325
351
  return this.core.effects.emit("".concat(this.name, ":onGetProduct"), this.store.list);
326
352
  case 2:
327
353
  product = this.store.list.find(function (product) {
328
354
  return product.id === id;
329
355
  });
330
- return _context7.abrupt("return", product ? cloneDeep(product) : undefined);
356
+ return _context8.abrupt("return", product ? cloneDeep(product) : undefined);
331
357
  case 4:
332
358
  case "end":
333
- return _context7.stop();
359
+ return _context8.stop();
334
360
  }
335
- }, _callee7, this);
361
+ }, _callee8, this);
336
362
  }));
337
- function getProduct(_x6) {
363
+ function getProduct(_x7) {
338
364
  return _getProduct.apply(this, arguments);
339
365
  }
340
366
  return getProduct;
@@ -342,25 +368,25 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
342
368
  }, {
343
369
  key: "getProductByIds",
344
370
  value: function () {
345
- var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(ids) {
371
+ var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(ids) {
346
372
  var products;
347
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
348
- while (1) switch (_context8.prev = _context8.next) {
373
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
374
+ while (1) switch (_context9.prev = _context9.next) {
349
375
  case 0:
350
- _context8.next = 2;
376
+ _context9.next = 2;
351
377
  return this.core.effects.emit("".concat(this.name, ":onGetProductByIds"), this.store.list);
352
378
  case 2:
353
379
  products = this.store.list.filter(function (product) {
354
380
  return ids.includes(product.id);
355
381
  });
356
- return _context8.abrupt("return", products);
382
+ return _context9.abrupt("return", products);
357
383
  case 4:
358
384
  case "end":
359
- return _context8.stop();
385
+ return _context9.stop();
360
386
  }
361
- }, _callee8, this);
387
+ }, _callee9, this);
362
388
  }));
363
- function getProductByIds(_x7) {
389
+ function getProductByIds(_x8) {
364
390
  return _getProductByIds.apply(this, arguments);
365
391
  }
366
392
  return getProductByIds;
@@ -368,23 +394,23 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
368
394
  }, {
369
395
  key: "addProduct",
370
396
  value: function () {
371
- var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(products) {
372
- var _this2 = this;
373
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
374
- while (1) switch (_context9.prev = _context9.next) {
397
+ var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(products) {
398
+ var _this3 = this;
399
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
400
+ while (1) switch (_context10.prev = _context10.next) {
375
401
  case 0:
376
402
  // list 需要根据 id 去重
377
403
  if (!this.store.list) {
378
404
  this.store.list = [];
379
405
  }
380
406
  products.forEach(function (n) {
381
- var index = _this2.store.list.findIndex(function (m) {
407
+ var index = _this3.store.list.findIndex(function (m) {
382
408
  return m.id === n.id;
383
409
  });
384
410
  if (index === -1) {
385
- _this2.store.list.push(n);
411
+ _this3.store.list.push(n);
386
412
  } else {
387
- _this2.store.list[index] = n;
413
+ _this3.store.list[index] = n;
388
414
  }
389
415
  });
390
416
  // 根据 sort 值做降序排序(数字越大越靠前)
@@ -394,11 +420,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
394
420
  this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
395
421
  case 4:
396
422
  case "end":
397
- return _context9.stop();
423
+ return _context10.stop();
398
424
  }
399
- }, _callee9, this);
425
+ }, _callee10, this);
400
426
  }));
401
- function addProduct(_x8) {
427
+ function addProduct(_x9) {
402
428
  return _addProduct.apply(this, arguments);
403
429
  }
404
430
  return addProduct;
@@ -406,18 +432,18 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
406
432
  }, {
407
433
  key: "selectProducts",
408
434
  value: function () {
409
- var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(products) {
410
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
411
- while (1) switch (_context10.prev = _context10.next) {
435
+ var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(products) {
436
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
437
+ while (1) switch (_context11.prev = _context11.next) {
412
438
  case 0:
413
439
  this.store.selectProducts = products;
414
440
  case 1:
415
441
  case "end":
416
- return _context10.stop();
442
+ return _context11.stop();
417
443
  }
418
- }, _callee10, this);
444
+ }, _callee11, this);
419
445
  }));
420
- function selectProducts(_x9) {
446
+ function selectProducts(_x10) {
421
447
  return _selectProducts.apply(this, arguments);
422
448
  }
423
449
  return selectProducts;
@@ -1525,14 +1525,16 @@ function evaluateCandidate(projection, candidate, request) {
1525
1525
  });
1526
1526
  });
1527
1527
  var options = matchedResources.map(function (resource) {
1528
- var _request$cellIndex;
1528
+ var _request$cellIndex, _resource$raw2;
1529
1529
  var matchedCell = aggregateMatchedCells(product.id, requirementGroup.id, resource.id, candidateRange, ((_request$cellIndex = request.cellIndex) === null || _request$cellIndex === void 0 ? void 0 : _request$cellIndex.get([String(product.id), requirementGroup.id, String(resource.id)].join(':'))) || []);
1530
1530
  if (!matchedCell) {
1531
+ var _resource$raw;
1531
1532
  var _isPast = candidateRange.endMs <= evaluationContext.evaluatedAtMs;
1532
1533
  return {
1533
1534
  resourceId: resource.id,
1534
1535
  resourceName: resource.name,
1535
1536
  resourceFormId: resource.formId,
1537
+ policyId: (_resource$raw = resource.raw) === null || _resource$raw === void 0 ? void 0 : _resource$raw.policy_id,
1536
1538
  resourceType: resource.resourceType,
1537
1539
  status: _isPast ? 'past' : 'unavailable',
1538
1540
  maxPartySize: 0,
@@ -1555,6 +1557,7 @@ function evaluateCandidate(projection, candidate, request) {
1555
1557
  resourceId: resource.id,
1556
1558
  resourceName: resource.name,
1557
1559
  resourceFormId: resource.formId,
1560
+ policyId: (_resource$raw2 = resource.raw) === null || _resource$raw2 === void 0 ? void 0 : _resource$raw2.policy_id,
1558
1561
  resourceType: resource.resourceType,
1559
1562
  status: status,
1560
1563
  remainingCapacity: remainingCapacity,
@@ -258,6 +258,7 @@ export interface AvailabilityResourceOption {
258
258
  resourceId: AvailabilityId;
259
259
  resourceName?: string;
260
260
  resourceFormId?: AvailabilityId;
261
+ policyId?: AvailabilityId;
261
262
  resourceType: AvailabilityResourceType;
262
263
  status: AvailabilityStatus;
263
264
  remainingCapacity?: number;
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
329
+ weekNum: 0 | 1 | 2 | 5 | 3 | 4 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -334,7 +334,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
334
334
  * 获取当前的客户搜索条件
335
335
  * @returns 当前搜索条件
336
336
  */
337
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
337
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
338
338
  /**
339
339
  * 获取客户列表状态(包含滚动加载相关状态)
340
340
  * @returns 客户状态
@@ -453,7 +453,19 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
453
453
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
454
454
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
455
455
  */
456
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
456
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
457
+ action: "reloadCatalog";
458
+ } | {
459
+ action: "add";
460
+ cacheItem: any;
461
+ } | {
462
+ action: "requiresDetail";
463
+ payload: AddProductRequiresDetailPayload;
464
+ } | {
465
+ action: "requiresBookingEdit";
466
+ cacheItem: any;
467
+ payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
468
+ };
457
469
  /** 规格弹窗 callback 后的第二段决策。 */
458
470
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
459
471
  /**
@@ -4,7 +4,7 @@ import type { OpenDataConfig } from '../../modules/OpenData';
4
4
  import type { LoadScheduleAvailableDateParams, ScheduleItem } from '../../modules/Schedule/types';
5
5
  import type { ProductListLoadProductsParams } from '../../modules/ProductList';
6
6
  import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
7
- import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
7
+ import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
8
8
  import { BookingTicket } from '../BookingTicket';
9
9
  export * from './types';
10
10
  export { AvailabilityError } from '../../modules/ResourcePlanner';
@@ -147,6 +147,10 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
147
147
  */
148
148
  loadOpenData(params: UnifiedBookingSalesLoadOpenDataParams): Promise<OpenDataConfig>;
149
149
  getOpenData(): Promise<OpenDataConfig | null>;
150
+ /**
151
+ * Load a resource policy without depending on the legacy appointmentBooking solution.
152
+ */
153
+ getProtocol(policyId: string | number): Promise<UnifiedBookingSalesPolicyResponse>;
150
154
  /**
151
155
  * Loads the product catalog used by both UI and Planner. Schedule data is requested with each
152
156
  * product because session products carry their fixed intervals there.