@pisell/pisellos 2.1.168 → 2.1.170

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 (75) 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 +867 -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 +149 -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/modules/Discount/index.d.ts +5 -2
  16. package/dist/modules/Discount/index.js +21 -1
  17. package/dist/modules/Discount/types.d.ts +4 -0
  18. package/dist/modules/Order/index.d.ts +1 -0
  19. package/dist/modules/Order/index.js +18 -6
  20. package/dist/modules/Order/types.d.ts +2 -0
  21. package/dist/modules/ProductList/index.d.ts +3 -1
  22. package/dist/modules/ProductList/index.js +22 -11
  23. package/dist/modules/Schedule/getDateIsInSchedule.js +5 -0
  24. package/dist/solution/ScanOrder/index.js +1 -1
  25. package/dist/solution/ShopDiscount/index.js +16 -15
  26. package/dist/solution/VenueBooking/index.d.ts +49 -3
  27. package/dist/solution/VenueBooking/index.js +537 -287
  28. package/dist/solution/VenueBooking/types.d.ts +3 -1
  29. package/dist/solution/VenueBooking/types.js +1 -0
  30. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  31. package/dist/solution/VenueBooking/utils/dateSummary.js +12 -25
  32. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -6
  33. package/dist/solution/VenueBooking/utils/slotMerge.js +3 -9
  34. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  35. package/dist/solution/VenueBooking/utils/smartPricing.js +302 -0
  36. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +2 -0
  37. package/dist/solution/VenueBooking/utils/timeSlot.js +9 -4
  38. package/lib/index.d.ts +1 -0
  39. package/lib/index.js +3 -0
  40. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  41. package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
  42. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  43. package/lib/model/strategy/adapter/dataVariant/evaluator.js +666 -0
  44. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  45. package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
  46. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  47. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  48. package/lib/model/strategy/adapter/dataVariant/type.d.ts +149 -0
  49. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  50. package/lib/model/strategy/adapter/index.d.ts +4 -0
  51. package/lib/model/strategy/adapter/index.js +13 -2
  52. package/lib/modules/Discount/index.d.ts +5 -2
  53. package/lib/modules/Discount/index.js +11 -1
  54. package/lib/modules/Discount/types.d.ts +4 -0
  55. package/lib/modules/Order/index.d.ts +1 -0
  56. package/lib/modules/Order/index.js +11 -1
  57. package/lib/modules/Order/types.d.ts +2 -0
  58. package/lib/modules/ProductList/index.d.ts +3 -1
  59. package/lib/modules/ProductList/index.js +45 -39
  60. package/lib/modules/Schedule/getDateIsInSchedule.js +4 -0
  61. package/lib/solution/ScanOrder/index.js +1 -1
  62. package/lib/solution/ShopDiscount/index.js +3 -2
  63. package/lib/solution/VenueBooking/index.d.ts +49 -3
  64. package/lib/solution/VenueBooking/index.js +362 -113
  65. package/lib/solution/VenueBooking/types.d.ts +3 -1
  66. package/lib/solution/VenueBooking/types.js +1 -0
  67. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  68. package/lib/solution/VenueBooking/utils/dateSummary.js +5 -10
  69. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -6
  70. package/lib/solution/VenueBooking/utils/slotMerge.js +3 -4
  71. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  72. package/lib/solution/VenueBooking/utils/smartPricing.js +225 -0
  73. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +2 -0
  74. package/lib/solution/VenueBooking/utils/timeSlot.js +7 -3
  75. package/package.json +1 -1
@@ -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 = [],
@@ -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;
@@ -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';
@@ -17,6 +18,7 @@ interface VenueBookingItemRuleRuntimeConfig {
17
18
  custom?: Record<string, any>;
18
19
  }
19
20
  export declare class VenueBookingImpl extends BaseModule implements Module {
21
+ private static readonly PRICING_DEBUG_CACHE_ID;
20
22
  protected defaultName: string;
21
23
  protected defaultVersion: string;
22
24
  isSolution: boolean;
@@ -36,15 +38,30 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
36
38
  private loginEffectDisposers;
37
39
  private customerLoginRefreshInFlight;
38
40
  private customerLoginRefreshIdInFlight;
41
+ /** 最近一次确认登录的客户;登录事件与 user 插件更新之间可能存在时序差。 */
42
+ private smartPricingCustomerId;
39
43
  private loadAllProductsInFlight;
40
44
  private productsLoaded;
41
45
  private loadOpenDataConfigInFlight;
42
46
  private static readonly OPEN_DATA_CACHE_TTL;
47
+ /** 按日期缓存 slot 智能定价 Map,避免同周重复 resolveProducts */
48
+ private slotPriceMapCache;
49
+ /** loadProducts 后缓存的全量商品(venue + addon),供分段算价复用 */
50
+ private smartPricingProductCatalog;
51
+ private static readonly PISELL1_LOGIN_SUCCESS;
43
52
  private getLoggerContext;
44
53
  private safeStringify;
45
54
  private pickErrorMessage;
46
55
  private serializeError;
47
56
  private addVenueBookingLog;
57
+ /**
58
+ * 临时线上排查日志:
59
+ * - 仅对指定页面 cacheId 开启,避免影响其他页面
60
+ * - 不 await,且吞掉日志上报异常,保证日志系统不会阻断登录/商品加载主流程
61
+ */
62
+ private logPricingDiagnostics;
63
+ private isPricingDiagnosticsEnabled;
64
+ private getAvailableWalletIdsForDiagnostics;
48
65
  private logMethodStart;
49
66
  private logMethodSuccess;
50
67
  private logMethodError;
@@ -68,6 +85,22 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
68
85
  passed: boolean | null;
69
86
  failures: QuantityCheckResult[];
70
87
  };
88
+ /** 清除 slot 价格分段缓存(商品重载 / 登录后 customerId 变化时调用) */
89
+ private clearSlotPriceMapCache;
90
+ /** 读取当前登录 customerId */
91
+ private resolveCustomerIdForSmartPricing;
92
+ private resolveAvailableWalletIdsForSmartPricing;
93
+ /** 读取 schedule 全量列表,供智能定价 schedule_match 使用 */
94
+ private getScheduleListForSmartPricing;
95
+ /** 构建智能定价上下文,对齐 OS Server buildProductFormatterContext */
96
+ private buildSmartPricingContext;
97
+ /** venue + addon 全量商品,供智能定价评估 */
98
+ private getAllProductsForSmartPricing;
99
+ private getSlotPriceMapCacheKey;
100
+ /**
101
+ * 按 schedule 分段构建 slot 价格 Map,带实例级缓存。
102
+ */
103
+ private buildSlotPriceMapForDate;
71
104
  loadAllProducts(): Promise<{
72
105
  venueProducts: ProductData[];
73
106
  addonProducts: ProductData[];
@@ -140,8 +173,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
140
173
  setSlotConfig(config: Partial<VenueBookingSlotConfig>): void;
141
174
  getSlotConfig(): VenueBookingSlotConfig;
142
175
  loadSchedules(): Promise<void>;
143
- private injectScheduleResolverToQuotation;
144
- getScheduleListByIds(ids: number[]): import("../../modules/Schedule/types").ScheduleItem[];
176
+ getScheduleListByIds(ids: number[]): ScheduleItem[];
145
177
  getTempOrder(): import("./types").ScanOrderTempOrder | null;
146
178
  updateTempOrderNote(note: string): string;
147
179
  updateTempOrderContactsInfo(contactsInfo: any[]): any[];
@@ -149,7 +181,12 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
149
181
  onCustomerLogin(params: {
150
182
  customerId: number;
151
183
  }): Promise<void>;
152
- private recalculateOrderPricesFromQuotation;
184
+ private recalculateOrderPricesFromSmartPricing;
185
+ /**
186
+ * DataVariant 重算价格后,同步刷新订单展示、Rules 与 Summary 共用的价格口径。
187
+ * Rules 会在本轮结束后根据当前客户的 discountList 重新写入实际折扣。
188
+ */
189
+ private resetProductPriceForSmartPricing;
153
190
  scanCode(code: string, customerId?: number): Promise<{
154
191
  isAvailable: boolean;
155
192
  discountList: import("../../modules/Discount").Discount[];
@@ -164,6 +201,15 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
164
201
  discountId: number;
165
202
  isSelected: boolean;
166
203
  }): Promise<import("../../modules/Discount").Discount[]>;
204
+ /**
205
+ * 统一 VenueBooking 折扣后的订单行价。
206
+ *
207
+ * Rules 的 `discount_list.amount` 是已经按适用规则计算出的每件优惠额;它是这里唯一
208
+ * 的折扣金额来源。使用智能定价写入的 source_product_price 减去该金额,再同步
209
+ * selling_price 与 Summary 使用的 main_product_selling_price,避免 UI 的购物车行价、
210
+ * 小计和提交订单各自读取到不同的价格字段。
211
+ */
212
+ private normalizeDiscountedOrderPrices;
167
213
  addNewOrder(): Promise<import("./types").ScanOrderTempOrder>;
168
214
  getOrderProducts(): ScanOrderOrderProduct[];
169
215
  getSummary(): Promise<import("./types").ScanOrderSummary>;