@pisell/pisellos 2.3.222 → 2.3.224

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.
@@ -0,0 +1,9 @@
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";
@@ -642,7 +642,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
642
642
  generateIdempotencyToken(): string;
643
643
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
644
644
  createOrder(params: CommitOrderParams['query']): {
645
- type: "appointment_booking" | "virtual";
645
+ type: "virtual" | "appointment_booking";
646
646
  platform: string;
647
647
  sales_channel: string;
648
648
  order_sales_channel: string;
@@ -1633,6 +1633,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1633
1633
  _context11.prev = 61;
1634
1634
  _context11.next = 64;
1635
1635
  return this.giftSelectResolver({
1636
+ inventoryReserved: tempOrder.products.map(function (line) {
1637
+ return {
1638
+ product_id: Number(line.product_id),
1639
+ product_variant_id: Number(line.product_variant_id || 0),
1640
+ quantity: Number(line.num) || 0
1641
+ };
1642
+ }),
1636
1643
  strategyId: addAction.strategyId,
1637
1644
  strategyName: addAction.strategyName,
1638
1645
  giftCount: addAction.giftCount,
@@ -46,6 +46,12 @@ export interface OrderPromotionEvaluator {
46
46
  }
47
47
  /** 赠品解析回调 context(OS → SDK 的请求体) */
48
48
  export interface OrderGiftSelectContext {
49
+ /** Inventory already consumed by the pending order, including its triggering product. */
50
+ inventoryReserved?: Array<{
51
+ product_id: number;
52
+ product_variant_id: number;
53
+ quantity: number;
54
+ }>;
49
55
  strategyId: string;
50
56
  strategyName: string | Record<string, string>;
51
57
  giftCount: number;
@@ -21,6 +21,23 @@ var DEFAULT_BUSINESS_HOURS = {
21
21
  startTime: '00:00',
22
22
  endTime: '00:00'
23
23
  };
24
+ // Only factory-owned snapshots are immutable. A caller may provide a mutable
25
+ // projection, or freeze its outer object without freezing its products/cells.
26
+ var immutableProjections = new WeakSet();
27
+ var projectionStaticIndices = new WeakMap();
28
+ function getProjectionStaticIndex(projection, key, build) {
29
+ if (!immutableProjections.has(projection)) return build(projection);
30
+ var indices = projectionStaticIndices.get(projection);
31
+ if (!indices) {
32
+ indices = {};
33
+ projectionStaticIndices.set(projection, indices);
34
+ }
35
+ var existing = indices[key];
36
+ if (existing) return existing;
37
+ var index = build(projection);
38
+ indices[key] = index;
39
+ return index;
40
+ }
24
41
  function availabilityError(code, message, details) {
25
42
  return new AvailabilityError(code, message, details);
26
43
  }
@@ -879,9 +896,11 @@ export function createAvailabilityProjection(input) {
879
896
  resources: resources,
880
897
  resourceOccupancies: resourceOccupancies
881
898
  };
882
- return deepFreeze(_objectSpread(_objectSpread({}, projectionBase), {}, {
899
+ var projection = deepFreeze(_objectSpread(_objectSpread({}, projectionBase), {}, {
883
900
  cells: buildCells(projectionBase)
884
901
  }));
902
+ immutableProjections.add(projection);
903
+ return projection;
885
904
  }
886
905
  function uniqByOccupancy(occupancies) {
887
906
  var map = new Map();
@@ -2252,8 +2271,8 @@ export function queryAvailabilityProjection(projection, request) {
2252
2271
  assertRangesWithinProjection(projection, request.selectedRanges);
2253
2272
  }
2254
2273
  var productIdSet = (_request$productIds2 = request.productIds) !== null && _request$productIds2 !== void 0 && _request$productIds2.length ? new Set(request.productIds.map(String)) : null;
2255
- var productIndex = buildProductIndex(projection);
2256
- var cellIndex = buildAvailabilityCellIndex(projection);
2274
+ var productIndex = getProjectionStaticIndex(projection, 'productIndex', buildProductIndex);
2275
+ var cellIndex = getProjectionStaticIndex(projection, 'cellIndex', buildAvailabilityCellIndex);
2257
2276
  var groupResourceIndex = buildGroupResourceIndex({
2258
2277
  projection: projection,
2259
2278
  resourceIds: request.resourceIds,
@@ -2574,14 +2593,14 @@ export function validateAvailabilitySelection(projection, params) {
2574
2593
  var normalizedPartySize = normalizePartySize(params.partySize);
2575
2594
  var normalizedBookingCount = normalizeBookingCount(params.bookingCount);
2576
2595
  assertRangesWithinProjection(projection, [params.candidate]);
2577
- var productIndex = buildProductIndex(projection);
2596
+ var productIndex = getProjectionStaticIndex(projection, 'productIndex', buildProductIndex);
2578
2597
  var evaluatedAt = formatDateTime(localDateToScalar(new Date()), projection.meta.timezone, (_extractFixedOffsetMi7 = extractFixedOffsetMinutes(projection.meta.now)) !== null && _extractFixedOffsetMi7 !== void 0 ? _extractFixedOffsetMi7 : captureRuntimeOffsetMinutes());
2579
2598
  var evaluated = evaluateCandidate(projection, params.candidate, {
2580
2599
  partySize: normalizedPartySize,
2581
2600
  evaluatedAt: evaluatedAt,
2582
2601
  requirementSelections: params.requirementSelections,
2583
2602
  allowImplicitSelection: false,
2584
- cellIndex: buildAvailabilityCellIndex(projection),
2603
+ cellIndex: getProjectionStaticIndex(projection, 'cellIndex', buildAvailabilityCellIndex),
2585
2604
  productIndex: productIndex,
2586
2605
  groupResourceIndex: buildGroupResourceIndex({
2587
2606
  projection: projection,
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  date: string;
343
343
  status: string;
344
344
  week: string;
345
- weekNum: 0 | 5 | 1 | 2 | 4 | 3 | 6;
345
+ weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
346
346
  }[]>;
347
347
  submitTimeSlot(timeSlots: TimeSliceItem): void;
348
348
  private getScheduleDataByIds;
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
389
389
  };
390
390
  setOtherData(key: string, value: any): void;
391
391
  getOtherData(key: string): any;
392
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
392
+ getProductTypeById(id: number): Promise<"normal" | "session" | "duration">;
393
393
  /**
394
394
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
395
395
  *
@@ -373,7 +373,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
373
373
  * 获取当前的客户搜索条件
374
374
  * @returns 当前搜索条件
375
375
  */
376
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
376
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
377
377
  /**
378
378
  * 获取客户列表状态(包含滚动加载相关状态)
379
379
  * @returns 客户状态
@@ -25,18 +25,26 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
25
25
  notes?: import("../../../modules/Order/types").SalesNote[] | undefined;
26
26
  summary?: import("../../../modules/Order/types").OrderSummary | undefined;
27
27
  small_ticket_data_flag?: number | undefined;
28
- bookings: any[];
28
+ metadata: Record<string, any>;
29
+ type: string;
30
+ note: string;
31
+ holder: Record<string, any> | null;
32
+ relation_forms: any[];
33
+ holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
34
+ order_id: number | null;
29
35
  external_sale_number: string;
30
- payments: any[];
31
36
  customer_id: number | null;
32
- order_id: number | null;
37
+ bookings: any[];
38
+ payments: any[];
33
39
  order_number: string | null;
40
+ order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
34
41
  shop_order_number: string | null;
35
- type: string;
36
42
  business_code?: string | undefined;
43
+ status: string;
44
+ schedule_date: string;
45
+ shop_full_order_number: string | null;
37
46
  sales_channel: string;
38
47
  order_sales_channel: string;
39
- status: string;
40
48
  shipping_status: string;
41
49
  customer_name: string;
42
50
  country_calling_code: string;
@@ -52,21 +60,13 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
52
60
  deposit_amount: string;
53
61
  shop_discount: string;
54
62
  surcharge_fee: string;
55
- note: string;
56
- schedule_date: string;
63
+ buzzer?: string | undefined;
64
+ delivery_type?: string | undefined;
65
+ table_number?: Record<string, any> | undefined;
57
66
  refunds?: any[] | undefined;
58
67
  surcharges: any[];
59
- relation_forms: any[];
60
68
  contacts: any[];
61
69
  contacts_info: Record<string, any> | null;
62
- holder: Record<string, any> | null;
63
- holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
64
- order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
65
- metadata: Record<string, any>;
66
- buzzer?: string | undefined;
67
- shop_full_order_number: string | null;
68
- delivery_type?: string | undefined;
69
- table_number?: Record<string, any> | undefined;
70
70
  };
71
71
  export declare function describeChangedBookings(before: OrderTempOrder['bookings'], after: OrderTempOrder['bookings']): {
72
72
  schedule_event_id: any;
@@ -642,7 +642,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
642
642
  generateIdempotencyToken(): string;
643
643
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
644
644
  createOrder(params: CommitOrderParams['query']): {
645
- type: "appointment_booking" | "virtual";
645
+ type: "virtual" | "appointment_booking";
646
646
  platform: string;
647
647
  sales_channel: string;
648
648
  order_sales_channel: string;
@@ -1091,6 +1091,11 @@ class OrderModule extends _BaseModule.BaseModule {
1091
1091
  }) : null;
1092
1092
  try {
1093
1093
  const giftResult = await this.giftSelectResolver({
1094
+ inventoryReserved: tempOrder.products.map(line => ({
1095
+ product_id: Number(line.product_id),
1096
+ product_variant_id: Number(line.product_variant_id || 0),
1097
+ quantity: Number(line.num) || 0
1098
+ })),
1094
1099
  strategyId: addAction.strategyId,
1095
1100
  strategyName: addAction.strategyName,
1096
1101
  giftCount: addAction.giftCount,
@@ -46,6 +46,12 @@ export interface OrderPromotionEvaluator {
46
46
  }
47
47
  /** 赠品解析回调 context(OS → SDK 的请求体) */
48
48
  export interface OrderGiftSelectContext {
49
+ /** Inventory already consumed by the pending order, including its triggering product. */
50
+ inventoryReserved?: Array<{
51
+ product_id: number;
52
+ product_variant_id: number;
53
+ quantity: number;
54
+ }>;
49
55
  strategyId: string;
50
56
  strategyName: string | Record<string, string>;
51
57
  giftCount: number;
@@ -15,6 +15,23 @@ const DEFAULT_BUSINESS_HOURS = {
15
15
  startTime: '00:00',
16
16
  endTime: '00:00'
17
17
  };
18
+ // Only factory-owned snapshots are immutable. A caller may provide a mutable
19
+ // projection, or freeze its outer object without freezing its products/cells.
20
+ const immutableProjections = new WeakSet();
21
+ const projectionStaticIndices = new WeakMap();
22
+ function getProjectionStaticIndex(projection, key, build) {
23
+ if (!immutableProjections.has(projection)) return build(projection);
24
+ let indices = projectionStaticIndices.get(projection);
25
+ if (!indices) {
26
+ indices = {};
27
+ projectionStaticIndices.set(projection, indices);
28
+ }
29
+ const existing = indices[key];
30
+ if (existing) return existing;
31
+ const index = build(projection);
32
+ indices[key] = index;
33
+ return index;
34
+ }
18
35
  function availabilityError(code, message, details) {
19
36
  return new _types.AvailabilityError(code, message, details);
20
37
  }
@@ -796,10 +813,12 @@ function createAvailabilityProjection(input) {
796
813
  resources,
797
814
  resourceOccupancies
798
815
  };
799
- return deepFreeze({
816
+ const projection = deepFreeze({
800
817
  ...projectionBase,
801
818
  cells: buildCells(projectionBase)
802
819
  });
820
+ immutableProjections.add(projection);
821
+ return projection;
803
822
  }
804
823
  function uniqByOccupancy(occupancies) {
805
824
  const map = new Map();
@@ -1916,8 +1935,8 @@ function queryAvailabilityProjection(projection, request, runtimeOptions = {}) {
1916
1935
  assertRangesWithinProjection(projection, request.selectedRanges);
1917
1936
  }
1918
1937
  const productIdSet = request.productIds?.length ? new Set(request.productIds.map(String)) : null;
1919
- const productIndex = buildProductIndex(projection);
1920
- const cellIndex = buildAvailabilityCellIndex(projection);
1938
+ const productIndex = getProjectionStaticIndex(projection, 'productIndex', buildProductIndex);
1939
+ const cellIndex = getProjectionStaticIndex(projection, 'cellIndex', buildAvailabilityCellIndex);
1921
1940
  const groupResourceIndex = buildGroupResourceIndex({
1922
1941
  projection,
1923
1942
  resourceIds: request.resourceIds,
@@ -2192,14 +2211,14 @@ function validateAvailabilitySelection(projection, params, runtimeOptions = {})
2192
2211
  const normalizedPartySize = normalizePartySize(params.partySize);
2193
2212
  const normalizedBookingCount = normalizeBookingCount(params.bookingCount);
2194
2213
  assertRangesWithinProjection(projection, [params.candidate]);
2195
- const productIndex = buildProductIndex(projection);
2214
+ const productIndex = getProjectionStaticIndex(projection, 'productIndex', buildProductIndex);
2196
2215
  const evaluatedAt = formatDateTime((0, _localClock.localDateToScalar)(new Date()), projection.meta.timezone, (0, _localClock.extractFixedOffsetMinutes)(projection.meta.now) ?? (0, _localClock.captureRuntimeOffsetMinutes)());
2197
2216
  const evaluated = evaluateCandidate(projection, params.candidate, {
2198
2217
  partySize: normalizedPartySize,
2199
2218
  evaluatedAt,
2200
2219
  requirementSelections: params.requirementSelections,
2201
2220
  allowImplicitSelection: false,
2202
- cellIndex: buildAvailabilityCellIndex(projection),
2221
+ cellIndex: getProjectionStaticIndex(projection, 'cellIndex', buildAvailabilityCellIndex),
2203
2222
  productIndex,
2204
2223
  groupResourceIndex: buildGroupResourceIndex({
2205
2224
  projection,
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  date: string;
343
343
  status: string;
344
344
  week: string;
345
- weekNum: 0 | 5 | 1 | 2 | 4 | 3 | 6;
345
+ weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
346
346
  }[]>;
347
347
  submitTimeSlot(timeSlots: TimeSliceItem): void;
348
348
  private getScheduleDataByIds;
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
389
389
  };
390
390
  setOtherData(key: string, value: any): void;
391
391
  getOtherData(key: string): any;
392
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
392
+ getProductTypeById(id: number): Promise<"normal" | "session" | "duration">;
393
393
  /**
394
394
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
395
395
  *
@@ -373,7 +373,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
373
373
  * 获取当前的客户搜索条件
374
374
  * @returns 当前搜索条件
375
375
  */
376
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
376
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
377
377
  /**
378
378
  * 获取客户列表状态(包含滚动加载相关状态)
379
379
  * @returns 客户状态
@@ -25,18 +25,26 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
25
25
  notes?: import("../../../modules/Order/types").SalesNote[] | undefined;
26
26
  summary?: import("../../../modules/Order/types").OrderSummary | undefined;
27
27
  small_ticket_data_flag?: number | undefined;
28
- bookings: any[];
28
+ metadata: Record<string, any>;
29
+ type: string;
30
+ note: string;
31
+ holder: Record<string, any> | null;
32
+ relation_forms: any[];
33
+ holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
34
+ order_id: number | null;
29
35
  external_sale_number: string;
30
- payments: any[];
31
36
  customer_id: number | null;
32
- order_id: number | null;
37
+ bookings: any[];
38
+ payments: any[];
33
39
  order_number: string | null;
40
+ order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
34
41
  shop_order_number: string | null;
35
- type: string;
36
42
  business_code?: string | undefined;
43
+ status: string;
44
+ schedule_date: string;
45
+ shop_full_order_number: string | null;
37
46
  sales_channel: string;
38
47
  order_sales_channel: string;
39
- status: string;
40
48
  shipping_status: string;
41
49
  customer_name: string;
42
50
  country_calling_code: string;
@@ -52,21 +60,13 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
52
60
  deposit_amount: string;
53
61
  shop_discount: string;
54
62
  surcharge_fee: string;
55
- note: string;
56
- schedule_date: string;
63
+ buzzer?: string | undefined;
64
+ delivery_type?: string | undefined;
65
+ table_number?: Record<string, any> | undefined;
57
66
  refunds?: any[] | undefined;
58
67
  surcharges: any[];
59
- relation_forms: any[];
60
68
  contacts: any[];
61
69
  contacts_info: Record<string, any> | null;
62
- holder: Record<string, any> | null;
63
- holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
64
- order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
65
- metadata: Record<string, any>;
66
- buzzer?: string | undefined;
67
- shop_full_order_number: string | null;
68
- delivery_type?: string | undefined;
69
- table_number?: Record<string, any> | undefined;
70
70
  };
71
71
  export declare function describeChangedBookings(before: OrderTempOrder['bookings'], after: OrderTempOrder['bookings']): {
72
72
  schedule_event_id: any;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.222",
4
+ "version": "2.3.224",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",