@pisell/pisellos 2.1.161 → 2.1.163

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 (78) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +3 -0
  3. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  4. package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
  5. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  6. package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
  7. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  8. package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
  9. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  10. package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
  11. package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  12. package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
  13. package/dist/model/strategy/adapter/index.d.ts +4 -0
  14. package/dist/model/strategy/adapter/index.js +5 -1
  15. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  16. package/dist/modules/Discount/index.d.ts +5 -2
  17. package/dist/modules/Discount/index.js +21 -1
  18. package/dist/modules/Discount/types.d.ts +6 -0
  19. package/dist/modules/Order/index.d.ts +1 -0
  20. package/dist/modules/Order/index.js +18 -6
  21. package/dist/modules/Order/types.d.ts +2 -0
  22. package/dist/modules/ProductList/index.d.ts +3 -1
  23. package/dist/modules/ProductList/index.js +22 -11
  24. package/dist/modules/Rules/index.js +13 -0
  25. package/dist/modules/Schedule/getDateIsInSchedule.js +5 -0
  26. package/dist/modules/Summary/utils.js +42 -21
  27. package/dist/solution/BookingByStep/index.d.ts +2 -2
  28. package/dist/solution/ScanOrder/index.js +1 -1
  29. package/dist/solution/ShopDiscount/index.js +16 -15
  30. package/dist/solution/VenueBooking/index.d.ts +23 -3
  31. package/dist/solution/VenueBooking/index.js +267 -168
  32. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  33. package/dist/solution/VenueBooking/utils/dateSummary.js +12 -25
  34. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -6
  35. package/dist/solution/VenueBooking/utils/slotMerge.js +3 -9
  36. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +70 -0
  37. package/dist/solution/VenueBooking/utils/smartPricing.js +233 -0
  38. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +2 -0
  39. package/dist/solution/VenueBooking/utils/timeSlot.js +9 -4
  40. package/lib/index.d.ts +1 -0
  41. package/lib/index.js +3 -0
  42. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  43. package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
  44. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  45. package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
  46. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  47. package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
  48. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  49. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  50. package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  51. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  52. package/lib/model/strategy/adapter/index.d.ts +4 -0
  53. package/lib/model/strategy/adapter/index.js +13 -2
  54. package/lib/modules/Discount/index.d.ts +5 -2
  55. package/lib/modules/Discount/index.js +11 -1
  56. package/lib/modules/Discount/types.d.ts +6 -0
  57. package/lib/modules/Order/index.d.ts +1 -0
  58. package/lib/modules/Order/index.js +11 -1
  59. package/lib/modules/Order/types.d.ts +2 -0
  60. package/lib/modules/ProductList/index.d.ts +3 -1
  61. package/lib/modules/ProductList/index.js +45 -39
  62. package/lib/modules/Rules/index.js +8 -0
  63. package/lib/modules/Schedule/getDateIsInSchedule.js +4 -0
  64. package/lib/modules/Summary/utils.js +23 -3
  65. package/lib/solution/BookingByStep/index.d.ts +2 -2
  66. package/lib/solution/ScanOrder/index.js +1 -1
  67. package/lib/solution/ShopDiscount/index.js +3 -2
  68. package/lib/solution/VenueBooking/index.d.ts +23 -3
  69. package/lib/solution/VenueBooking/index.js +164 -69
  70. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  71. package/lib/solution/VenueBooking/utils/dateSummary.js +5 -10
  72. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -6
  73. package/lib/solution/VenueBooking/utils/slotMerge.js +3 -4
  74. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +70 -0
  75. package/lib/solution/VenueBooking/utils/smartPricing.js +180 -0
  76. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +2 -0
  77. package/lib/solution/VenueBooking/utils/timeSlot.js +7 -3
  78. package/package.json +1 -1
@@ -15,6 +15,7 @@ export interface OrderState {
15
15
  discountList: any[];
16
16
  discount: DiscountModule | null;
17
17
  rules: RulesModule | null;
18
+ availableWalletIds?: number[];
18
19
  }
19
20
  /** 更新购物车行:仅传 SKU 时命中同 SKU 第一行;多行同 SKU 须传 identity_key / 选项指纹等 */
20
21
  export interface UpdateProductInOrderParams {
@@ -248,5 +249,6 @@ export interface OrderModuleAPI {
248
249
  action?: 'create';
249
250
  }) => Promise<void>;
250
251
  getDiscountList: () => Discount[];
252
+ getAvailableWalletIds: () => number[];
251
253
  applyDiscount: () => void;
252
254
  }
@@ -11,7 +11,7 @@ export declare class ProductList extends BaseModule implements Module {
11
11
  constructor(name?: string, version?: string);
12
12
  initialize(core: PisellCore, options: any): Promise<void>;
13
13
  storeChange(path?: string, value?: any): Promise<void>;
14
- loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, }: {
14
+ loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, with_extra, }: {
15
15
  category_ids?: number[];
16
16
  product_ids?: number[];
17
17
  collection?: number | string[];
@@ -22,6 +22,8 @@ export declare class ProductList extends BaseModule implements Module {
22
22
  menu_list_ids?: number[];
23
23
  with_count?: string[];
24
24
  with_schedule?: number;
25
+ /** 追加到默认 with 字段(如 dataVariants) */
26
+ with_extra?: string[];
25
27
  }): Promise<any>;
26
28
  loadProductsPrice({ ids, customer_id, schedule_date, channel, }: {
27
29
  ids?: number[];
@@ -59,7 +59,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
59
59
  schedule_datetime,
60
60
  schedule_date,
61
61
  cacheId,
62
- with_schedule
62
+ with_schedule,
63
+ with_extra = []
63
64
  }) {
64
65
  var _a;
65
66
  let userPlugin = this.core.getPlugin("user");
@@ -69,44 +70,49 @@ var ProductList = class extends import_BaseModule.BaseModule {
69
70
  } catch (error) {
70
71
  console.error(error);
71
72
  }
72
- const productsData = await this.request.post(
73
- `/product/query`,
74
- {
75
- open_quotation: 1,
76
- open_bundle: 0,
77
- exclude_extension_type: [
78
- "product_party",
79
- "product_event",
80
- "product_series_event",
81
- "product_package_ticket",
82
- "ticket",
83
- "event_item"
84
- ],
85
- with: ["category", "collection", "resourceRelation"],
86
- status: "published",
87
- num: 500,
88
- skip: 1,
89
- customer_id,
90
- category_ids,
91
- ids: product_ids,
92
- collection,
93
- front_end_cache_id: cacheId,
94
- menu_list_ids,
95
- with_count,
96
- // client_schedule_ids: schedule_ids,
97
- schedule_date,
98
- // application_code: this.otherParams?.channel === 'online_store' ? 'online-store' : this.otherParams?.channel,
99
- application_code: "online-store",
100
- with_schedule,
101
- schedule_datetime,
102
- is_eject: 1
103
- },
104
- { useCache: true, customToast: () => {
105
- } }
106
- );
107
- const sortedList = (productsData.data.list || []).slice().sort((a, b) => Number(b.sort) - Number(a.sort));
108
- this.addProduct(sortedList);
109
- return sortedList;
73
+ try {
74
+ const productsData = await this.request.post(
75
+ `/product/query`,
76
+ {
77
+ open_quotation: 1,
78
+ open_bundle: 0,
79
+ exclude_extension_type: [
80
+ "product_party",
81
+ "product_event",
82
+ "product_series_event",
83
+ "product_package_ticket",
84
+ "ticket",
85
+ "event_item"
86
+ ],
87
+ with: ["category", "collection", "resourceRelation", ...with_extra],
88
+ status: "published",
89
+ num: 500,
90
+ skip: 1,
91
+ customer_id,
92
+ category_ids,
93
+ ids: product_ids,
94
+ collection,
95
+ front_end_cache_id: cacheId,
96
+ with_count,
97
+ // client_schedule_ids: schedule_ids,
98
+ schedule_date,
99
+ schedule_datetime,
100
+ // application_code: this.otherParams?.channel === 'online_store' ? 'online-store' : this.otherParams?.channel,
101
+ application_code: "online-store",
102
+ with_schedule,
103
+ is_eject: 1,
104
+ menu_list_ids,
105
+ open_deposit: 1
106
+ },
107
+ { useCache: true, customToast: () => {
108
+ } }
109
+ );
110
+ const sortedList = (productsData.data.list || []).slice().sort((a, b) => Number(b.sort) - Number(a.sort));
111
+ this.addProduct(sortedList);
112
+ return sortedList;
113
+ } catch (error) {
114
+ return error;
115
+ }
110
116
  }
111
117
  async loadProductsPrice({
112
118
  ids = [],
@@ -362,6 +362,11 @@ var RulesModule = class extends import_BaseModule.BaseModule {
362
362
  }
363
363
  return priceB.minus(priceA).toNumber();
364
364
  });
365
+ const isProductIncludedByLimitedData = (limitedData, productId) => {
366
+ const excludedIds = (limitedData == null ? void 0 : limitedData.exclude_product_ids) || [];
367
+ const isExcluded = (limitedData == null ? void 0 : limitedData.filter) === 1 && excludedIds.some((id) => String(id) === String(productId));
368
+ return !isExcluded;
369
+ };
365
370
  const usedDiscounts = /* @__PURE__ */ new Map();
366
371
  const discountApplicability = /* @__PURE__ */ new Map();
367
372
  const discountApplicableProducts = /* @__PURE__ */ new Map();
@@ -632,6 +637,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
632
637
  return false;
633
638
  }
634
639
  if (limitedData.type === "product_all") {
640
+ if (!isProductIncludedByLimitedData(limitedData, product.id)) {
641
+ return false;
642
+ }
635
643
  if (!this.checkPackageSubItemUsageRules(discount, flatItem)) {
636
644
  return false;
637
645
  }
@@ -34,6 +34,10 @@ __export(getDateIsInSchedule_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(getDateIsInSchedule_exports);
36
36
  var import_dayjs = __toESM(require("dayjs"));
37
+ var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter"));
38
+ var import_isSameOrBefore = __toESM(require("dayjs/plugin/isSameOrBefore"));
39
+ import_dayjs.default.extend(import_isSameOrAfter.default);
40
+ import_dayjs.default.extend(import_isSameOrBefore.default);
37
41
  var getDateIsInSchedule = (dateTime, scheduleList) => {
38
42
  if (!dateTime || !scheduleList || scheduleList.length === 0) {
39
43
  return false;
@@ -373,6 +373,26 @@ var calculateTaxFee = (shopInfo, items) => {
373
373
  }, new import_decimal.default(0));
374
374
  return totalTaxFee;
375
375
  };
376
+ var getCartItemDepositData = (item) => {
377
+ var _a, _b, _c, _d;
378
+ const target = item;
379
+ return ((_a = target == null ? void 0 : target._productOrigin) == null ? void 0 : _a.custom_deposit_data) || ((_b = target == null ? void 0 : target._origin) == null ? void 0 : _b.custom_deposit_data) || ((_d = (_c = target == null ? void 0 : target._origin) == null ? void 0 : _c.product) == null ? void 0 : _d.custom_deposit_data);
380
+ };
381
+ var getCartItemQuantity = (item) => {
382
+ return new import_decimal.default((item == null ? void 0 : item.num) || 1);
383
+ };
384
+ var calculateCartItemDepositTotal = (item) => {
385
+ var _a;
386
+ const depositData = getCartItemDepositData(item);
387
+ if ((depositData == null ? void 0 : depositData.has_deposit) == 1 && typeof (depositData == null ? void 0 : depositData.deposit_fixed) === "string" && typeof (depositData == null ? void 0 : depositData.deposit_percentage) === "string") {
388
+ const lineTotal = new import_decimal.default(item.summaryTotal ?? item.total ?? 0);
389
+ const quantity = getCartItemQuantity(item);
390
+ const fixedTotal = new import_decimal.default(depositData.deposit_fixed || 0).times(quantity);
391
+ const percentageTotal = new import_decimal.default(depositData.deposit_percentage || 0).times(lineTotal);
392
+ return fixedTotal.plus(percentageTotal);
393
+ }
394
+ return new import_decimal.default(((_a = item == null ? void 0 : item.deposit) == null ? void 0 : _a.total) || 0);
395
+ };
376
396
  var calculateDeposit = (items) => {
377
397
  if (!(items == null ? void 0 : items.length)) {
378
398
  return void 0;
@@ -380,11 +400,11 @@ var calculateDeposit = (items) => {
380
400
  const protocols = [];
381
401
  let hasDeposit = false;
382
402
  const total = items.reduce((sum, item) => {
383
- var _a, _b, _c;
403
+ var _a, _b;
384
404
  if (item == null ? void 0 : item.deposit) {
385
405
  hasDeposit = true;
386
- const cartItemTotalPrice = new import_decimal.default(((_a = item == null ? void 0 : item.deposit) == null ? void 0 : _a.total) || 0);
387
- (_c = (_b = item == null ? void 0 : item.deposit) == null ? void 0 : _b.protocols) == null ? void 0 : _c.forEach((protocol) => {
406
+ const cartItemTotalPrice = calculateCartItemDepositTotal(item);
407
+ (_b = (_a = item == null ? void 0 : item.deposit) == null ? void 0 : _a.protocols) == null ? void 0 : _b.forEach((protocol) => {
388
408
  if (protocols.findIndex((p) => p.id === protocol.id) === -1) {
389
409
  protocols.push(protocol);
390
410
  }
@@ -310,7 +310,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
310
310
  date: string;
311
311
  status: string;
312
312
  week: string;
313
- weekNum: 0 | 2 | 1 | 5 | 4 | 3 | 6;
313
+ weekNum: 0 | 1 | 5 | 4 | 2 | 3 | 6;
314
314
  }[]>;
315
315
  submitTimeSlot(timeSlots: TimeSliceItem): void;
316
316
  private getScheduleDataByIds;
@@ -329,7 +329,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
329
329
  count: number;
330
330
  left: number;
331
331
  summaryCount: number;
332
- status: "lots_of_space" | "filling_up_fast" | "sold_out";
332
+ status: "sold_out" | "lots_of_space" | "filling_up_fast";
333
333
  }[];
334
334
  /**
335
335
  * 找到多个资源的公共可用时间段
@@ -563,7 +563,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
563
563
  ...tempOrder.metadata || {},
564
564
  shop_service_data: {
565
565
  ...(tempOrder.metadata || {}).shop_service_data || {},
566
- service_type: ((_a = this.otherParams) == null ? void 0 : _a.businessCode) === "dine_in" ? "dine_in" : "take_away",
566
+ service_type: ((_a = this.otherParams) == null ? void 0 : _a.businessCode) === "dine_in" ? "dine_in" : "",
567
567
  pickup_reference_mode: mode
568
568
  }
569
569
  };
@@ -511,7 +511,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
511
511
  try {
512
512
  const orderId = this.store.orderId;
513
513
  const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
514
- const goodPassList = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
514
+ const prepareConfig = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
515
515
  customer_id: customerId,
516
516
  action: orderId ? "edit" : "create",
517
517
  with_good_pass: 1,
@@ -520,11 +520,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
520
520
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
521
521
  ...orderId ? { order_id: orderId } : {}
522
522
  }));
523
+ const goodPassList = (prepareConfig == null ? void 0 : prepareConfig.discountList) || [];
523
524
  const scanDiscount = (_c = this.getDiscountList()) == null ? void 0 : _c.filter(
524
525
  (item) => item.isScan
525
526
  );
526
527
  const scanDiscountIds = scanDiscount.map((n) => n.id);
527
- const newGoodPassList = goodPassList == null ? void 0 : goodPassList.filter((n) => !scanDiscountIds.includes(n.id));
528
+ const newGoodPassList = goodPassList.filter((n) => !scanDiscountIds.includes(n.id));
528
529
  const newDiscountList = [...scanDiscount, ...newGoodPassList || []];
529
530
  this.store.originalDiscountList = newDiscountList;
530
531
  await ((_d = this.store.discount) == null ? void 0 : _d.setOriginalDiscountList(newDiscountList));
@@ -3,6 +3,7 @@ import { BaseModule } from '../../modules/BaseModule';
3
3
  import { VenueBookingAddLogParams, VenueBookingSlotConfig, VenueDateSummaryItem, VenueSlotSelection, VenueTimeSlotGrid } from './types';
4
4
  import type { ScanOrderOrderProduct, ScanOrderOrderProductIdentity } from '../ScanOrder/types';
5
5
  import type { UpdateProductInOrderParams } from '../../modules/Order/types';
6
+ import type { ScheduleItem } from '../../modules/Schedule/types';
6
7
  import type { OpenDataAvailabilityResult } from '../../modules/OpenData';
7
8
  import type { ProductData } from '../../modules/Product/types';
8
9
  import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
@@ -40,6 +41,10 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
40
41
  private productsLoaded;
41
42
  private loadOpenDataConfigInFlight;
42
43
  private static readonly OPEN_DATA_CACHE_TTL;
44
+ /** 按日期缓存 slot 智能定价 Map,避免同周重复 resolveProducts */
45
+ private slotPriceMapCache;
46
+ /** loadProducts 后缓存的全量商品(venue + addon),供分段算价复用 */
47
+ private smartPricingProductCatalog;
43
48
  private getLoggerContext;
44
49
  private safeStringify;
45
50
  private pickErrorMessage;
@@ -68,6 +73,22 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
68
73
  passed: boolean | null;
69
74
  failures: QuantityCheckResult[];
70
75
  };
76
+ /** 清除 slot 价格分段缓存(商品重载 / 登录后 customerId 变化时调用) */
77
+ private clearSlotPriceMapCache;
78
+ /** 读取当前登录 customerId */
79
+ private resolveCustomerIdForSmartPricing;
80
+ private resolveAvailableWalletIdsForSmartPricing;
81
+ /** 读取 schedule 全量列表,供智能定价 schedule_match 使用 */
82
+ private getScheduleListForSmartPricing;
83
+ /** 构建智能定价上下文,对齐 OS Server buildProductFormatterContext */
84
+ private buildSmartPricingContext;
85
+ /** venue + addon 全量商品,供智能定价评估 */
86
+ private getAllProductsForSmartPricing;
87
+ private getSlotPriceMapCacheKey;
88
+ /**
89
+ * 按 schedule 分段构建 slot 价格 Map,带实例级缓存。
90
+ */
91
+ private buildSlotPriceMapForDate;
71
92
  loadAllProducts(): Promise<{
72
93
  venueProducts: ProductData[];
73
94
  addonProducts: ProductData[];
@@ -140,8 +161,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
140
161
  setSlotConfig(config: Partial<VenueBookingSlotConfig>): void;
141
162
  getSlotConfig(): VenueBookingSlotConfig;
142
163
  loadSchedules(): Promise<void>;
143
- private injectScheduleResolverToQuotation;
144
- getScheduleListByIds(ids: number[]): import("../../modules/Schedule/types").ScheduleItem[];
164
+ getScheduleListByIds(ids: number[]): ScheduleItem[];
145
165
  getTempOrder(): import("./types").ScanOrderTempOrder | null;
146
166
  updateTempOrderNote(note: string): string;
147
167
  updateTempOrderContactsInfo(contactsInfo: any[]): any[];
@@ -149,7 +169,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
149
169
  onCustomerLogin(params: {
150
170
  customerId: number;
151
171
  }): Promise<void>;
152
- private recalculateOrderPricesFromQuotation;
172
+ private recalculateOrderPricesFromSmartPricing;
153
173
  scanCode(code: string, customerId?: number): Promise<{
154
174
  isAvailable: boolean;
155
175
  discountList: import("../../modules/Discount").Discount[];