@pisell/pisellos 0.0.559 → 0.0.561

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 (41) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +1 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +15 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +25 -0
  5. package/dist/model/strategy/adapter/dataVariant/type.d.ts +2 -0
  6. package/dist/modules/Discount/index.d.ts +5 -2
  7. package/dist/modules/Discount/index.js +21 -1
  8. package/dist/modules/Discount/types.d.ts +4 -0
  9. package/dist/modules/Order/index.d.ts +1 -0
  10. package/dist/modules/Order/index.js +16 -4
  11. package/dist/modules/Order/types.d.ts +2 -0
  12. package/dist/modules/ProductList/index.js +18 -10
  13. package/dist/modules/Rules/index.js +10 -1
  14. package/dist/modules/Schedule/getDateIsInSchedule.js +5 -0
  15. package/dist/modules/Summary/utils.js +42 -21
  16. package/dist/solution/ShopDiscount/index.js +16 -15
  17. package/dist/solution/VenueBooking/index.d.ts +1 -0
  18. package/dist/solution/VenueBooking/index.js +52 -36
  19. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +1 -0
  20. package/dist/solution/VenueBooking/utils/smartPricing.js +6 -6
  21. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +1 -0
  22. package/lib/model/strategy/adapter/dataVariant/adapter.js +10 -0
  23. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -0
  24. package/lib/model/strategy/adapter/dataVariant/evaluator.js +20 -1
  25. package/lib/model/strategy/adapter/dataVariant/type.d.ts +2 -0
  26. package/lib/modules/Discount/index.d.ts +5 -2
  27. package/lib/modules/Discount/index.js +11 -1
  28. package/lib/modules/Discount/types.d.ts +4 -0
  29. package/lib/modules/Order/index.d.ts +1 -0
  30. package/lib/modules/Order/index.js +11 -1
  31. package/lib/modules/Order/types.d.ts +2 -0
  32. package/lib/modules/ProductList/index.js +9 -2
  33. package/lib/modules/Rules/index.js +6 -1
  34. package/lib/modules/Schedule/getDateIsInSchedule.js +4 -0
  35. package/lib/modules/Summary/utils.js +23 -3
  36. package/lib/solution/ShopDiscount/index.js +3 -2
  37. package/lib/solution/VenueBooking/index.d.ts +1 -0
  38. package/lib/solution/VenueBooking/index.js +15 -3
  39. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +1 -0
  40. package/lib/solution/VenueBooking/utils/smartPricing.js +1 -1
  41. package/package.json +1 -1
@@ -527,7 +527,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
527
527
  try {
528
528
  const orderId = this.store.orderId;
529
529
  const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
530
- const goodPassList = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
530
+ const prepareConfig = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
531
531
  customer_id: customerId,
532
532
  action: orderId ? "edit" : "create",
533
533
  with_good_pass: 1,
@@ -536,11 +536,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
536
536
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
537
537
  ...orderId ? { order_id: orderId } : {}
538
538
  }));
539
+ const goodPassList = (prepareConfig == null ? void 0 : prepareConfig.discountList) || [];
539
540
  const scanDiscount = (_c = this.getDiscountList()) == null ? void 0 : _c.filter(
540
541
  (item) => item.isScan
541
542
  );
542
543
  const scanDiscountIds = scanDiscount.map((n) => n.id);
543
- const newGoodPassList = goodPassList == null ? void 0 : goodPassList.filter((n) => !scanDiscountIds.includes(n.id));
544
+ const newGoodPassList = goodPassList.filter((n) => !scanDiscountIds.includes(n.id));
544
545
  const newDiscountList = [...scanDiscount, ...newGoodPassList || []];
545
546
  this.store.originalDiscountList = newDiscountList;
546
547
  await ((_d = this.store.discount) == null ? void 0 : _d.setOriginalDiscountList(newDiscountList));
@@ -84,6 +84,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
84
84
  private clearSlotPriceMapCache;
85
85
  /** 读取当前登录 customerId */
86
86
  private resolveCustomerIdForSmartPricing;
87
+ private resolveAvailableWalletIdsForSmartPricing;
87
88
  /** 读取 schedule 全量列表,供智能定价 schedule_match 使用 */
88
89
  private getScheduleListForSmartPricing;
89
90
  /** 构建智能定价上下文,对齐 OS Server buildProductFormatterContext */
@@ -342,6 +342,9 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
342
342
  this.customerLoginRefreshIdInFlight = params.customerId;
343
343
  const refreshTask = (async () => {
344
344
  var _a;
345
+ await this.store.order.loadDiscountConfig({
346
+ customerId: params.customerId
347
+ });
345
348
  this.clearSlotPriceMapCache();
346
349
  this.recalculateOrderPricesFromSmartPricing();
347
350
  if (this.store.holder) {
@@ -355,9 +358,6 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
355
358
  channel: (_a = this.otherParams) == null ? void 0 : _a.channel
356
359
  });
357
360
  }
358
- await this.store.order.loadDiscountConfig({
359
- customerId: params.customerId
360
- });
361
361
  await this.store.order.recalculateSummary({ createIfMissing: true });
362
362
  this.store.order.persistTempOrder();
363
363
  await this.refreshItemRuleQuantityLimits();
@@ -624,6 +624,16 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
624
624
  return void 0;
625
625
  }
626
626
  }
627
+ resolveAvailableWalletIdsForSmartPricing() {
628
+ var _a, _b, _c, _d, _e, _f, _g, _h;
629
+ const orderWalletIds = (_b = (_a = this.store.order) == null ? void 0 : _a.getAvailableWalletIds) == null ? void 0 : _b.call(_a);
630
+ const fallbackWalletIds = ((_c = this.otherParams) == null ? void 0 : _c.available_wallet_ids) || ((_d = this.otherParams) == null ? void 0 : _d.availableWalletIds) || ((_f = (_e = this.otherParams) == null ? void 0 : _e.strategy_context) == null ? void 0 : _f.available_wallet_ids) || ((_h = (_g = this.otherParams) == null ? void 0 : _g.strategy_context) == null ? void 0 : _h.availableWalletIds);
631
+ const source = Array.isArray(orderWalletIds) && orderWalletIds.length ? orderWalletIds : fallbackWalletIds;
632
+ if (!Array.isArray(source))
633
+ return [];
634
+ const ids = source.map((item) => Number(item)).filter((item) => Number.isFinite(item) && item > 0);
635
+ return Array.from(new Set(ids));
636
+ }
627
637
  /** 读取 schedule 全量列表,供智能定价 schedule_match 使用 */
628
638
  getScheduleListForSmartPricing() {
629
639
  var _a;
@@ -640,6 +650,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
640
650
  scheduleList: this.getScheduleListForSmartPricing(),
641
651
  menuList: ((_c = this.otherParams) == null ? void 0 : _c.menuList) || ((_e = (_d = this.otherParams) == null ? void 0 : _d.openData) == null ? void 0 : _e.menuList) || [],
642
652
  customerId: customerId ?? this.resolveCustomerIdForSmartPricing(),
653
+ availableWalletIds: this.resolveAvailableWalletIdsForSmartPricing(),
643
654
  channel: (_f = this.otherParams) == null ? void 0 : _f.channel,
644
655
  businessCode: (_g = this.otherParams) == null ? void 0 : _g.businessCode,
645
656
  orderType: ((_h = this.otherParams) == null ? void 0 : _h.orderType) || ((_i = this.otherParams) == null ? void 0 : _i.type),
@@ -659,6 +670,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
659
670
  return [
660
671
  date,
661
672
  context.customerId ?? "",
673
+ (context.availableWalletIds || []).join(","),
662
674
  context.channel ?? "",
663
675
  context.businessCode ?? ""
664
676
  ].join("|");
@@ -10,6 +10,7 @@ export interface VenueBookingSmartPricingContext {
10
10
  scheduleList?: ScheduleItem[];
11
11
  menuList?: DataVariantMenu[];
12
12
  customerId?: number | string;
13
+ availableWalletIds?: Array<number | string>;
13
14
  channel?: string;
14
15
  businessCode?: string;
15
16
  orderType?: string;
@@ -57,6 +57,7 @@ function buildDataVariantBusinessData(products, context, scheduleDateTime) {
57
57
  scheduleList: context.scheduleList || [],
58
58
  menuList: context.menuList || [],
59
59
  customerId: context.customerId,
60
+ availableWalletIds: context.availableWalletIds ?? strategyContext.available_wallet_ids ?? strategyContext.availableWalletIds,
60
61
  channel: context.channel ?? strategyContext.channel,
61
62
  orderType: context.orderType ?? strategyContext.orderType ?? strategyContext.order_type,
62
63
  businessCode: context.businessCode ?? strategyContext.business_code ?? strategyContext.businessCode,
@@ -71,7 +72,6 @@ function formatProductsWithDataVariant(products, context, scheduleDateTime) {
71
72
  }
72
73
  const resolvedAt = scheduleDateTime || (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
73
74
  const businessData = buildDataVariantBusinessData(products, context, resolvedAt);
74
- console.log(businessData, "businessData");
75
75
  const result = evaluator.resolveProducts(businessData);
76
76
  return Array.isArray(result == null ? void 0 : result.products) ? result.products : products;
77
77
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.559",
4
+ "version": "0.0.561",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",