@pisell/pisellos 2.3.224 → 2.3.225

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.
@@ -44,7 +44,7 @@ export declare class DataVariantEvaluator {
44
44
  * 返回 null 表示接口没有提供该字段;空 Map 表示已计算但没有任何命中。
45
45
  */
46
46
  private getAuthoritativeVariantPriorities;
47
- private normalizeDataVariantId;
47
+ private normalizeId;
48
48
  private buildGlobalEffectiveRuleMap;
49
49
  private resolveProduct;
50
50
  /**
@@ -90,6 +90,7 @@ export declare class DataVariantEvaluator {
90
90
  private timeToMinutes;
91
91
  private isProductInMenuScope;
92
92
  private mergeMatchedVariants;
93
+ private mergeSkuVariants;
93
94
  private getProductDataVariants;
94
95
  private normalizeStrategyConfigs;
95
96
  private isStrategyActive;
@@ -230,7 +230,7 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
230
230
  try {
231
231
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
232
232
  var rawId = _step4.value;
233
- var id = this.normalizeDataVariantId(rawId);
233
+ var id = this.normalizeId(rawId);
234
234
  if (id === null || seen.has(id)) continue;
235
235
  seen.add(id);
236
236
  orderedIds.push(id);
@@ -245,8 +245,8 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
245
245
  }));
246
246
  }
247
247
  }, {
248
- key: "normalizeDataVariantId",
249
- value: function normalizeDataVariantId(value) {
248
+ key: "normalizeId",
249
+ value: function normalizeId(value) {
250
250
  if (value === undefined || value === null) return null;
251
251
  var normalized = String(value).trim();
252
252
  return normalized || null;
@@ -305,7 +305,7 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
305
305
  var variant = _step6.value;
306
306
  if (variant.business_type === 'multi_currency_settlement') continue;
307
307
  if (authoritativeVariantPriorities !== null) {
308
- var variantId = this.normalizeDataVariantId(variant.id);
308
+ var variantId = this.normalizeId(variant.id);
309
309
  var priority = variantId === null ? undefined : authoritativeVariantPriorities.get(variantId);
310
310
  if (priority === undefined) continue;
311
311
  matchedVariants.push({
@@ -357,7 +357,7 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
357
357
  var ruleId = String(variant.data_variant_rule_id);
358
358
  var isDefault = Number(variant.data_variant_rule_id) === 0;
359
359
  var rule = isDefault ? undefined : globalEffectiveRuleMap.get(ruleId);
360
- var variantId = _this3.normalizeDataVariantId(variant.id);
360
+ var variantId = _this3.normalizeId(variant.id);
361
361
  var authoritativePriority = variantId === null ? undefined : authoritativeVariantPriorities === null || authoritativeVariantPriorities === void 0 ? void 0 : authoritativeVariantPriorities.get(variantId);
362
362
  var available;
363
363
  var priority;
@@ -849,10 +849,15 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
849
849
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
850
850
  key = _Object$entries$_i[0],
851
851
  value = _Object$entries$_i[1];
852
- if (value === undefined) continue;
852
+ if (value === undefined || key === 'variant_overrides') continue;
853
853
  result[key] = value;
854
854
  appliedFields.add(key);
855
855
  }
856
+ var mergedVariants = this.mergeSkuVariants(result.variant, matched.data.variant_overrides);
857
+ if (mergedVariants) {
858
+ result.variant = mergedVariants;
859
+ appliedFields.add('variant');
860
+ }
856
861
  appliedRuleIds.push(matched.ruleId);
857
862
  }
858
863
  } catch (err) {
@@ -863,7 +868,7 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
863
868
  result._dataVariant = {
864
869
  appliedRuleIds: appliedRuleIds,
865
870
  appliedVariantIds: Array.from(new Set(_toConsumableArray(sortedVariants).reverse().map(function (matched) {
866
- return _this8.normalizeDataVariantId(matched.variant.id);
871
+ return _this8.normalizeId(matched.variant.id);
867
872
  }).filter(function (id) {
868
873
  return id !== null;
869
874
  }))),
@@ -872,6 +877,46 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
872
877
  };
873
878
  return result;
874
879
  }
880
+ }, {
881
+ key: "mergeSkuVariants",
882
+ value: function mergeSkuVariants(variants, overrides) {
883
+ var _this9 = this;
884
+ if (!Array.isArray(variants) || !Array.isArray(overrides)) return;
885
+ var overridesById = new Map();
886
+ var _iterator18 = _createForOfIteratorHelper(overrides),
887
+ _step18;
888
+ try {
889
+ for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
890
+ var override = _step18.value;
891
+ var rawId = override === null || override === void 0 ? void 0 : override.id;
892
+ if (typeof rawId !== 'number' && typeof rawId !== 'string') continue;
893
+ var id = this.normalizeId(rawId);
894
+ if (id === null) continue;
895
+ var fields = Object.entries(override).filter(function (_ref5) {
896
+ var _ref6 = _slicedToArray(_ref5, 2),
897
+ key = _ref6[0],
898
+ value = _ref6[1];
899
+ return key !== 'id' && value !== undefined;
900
+ });
901
+ if (fields.length === 0) continue;
902
+ overridesById.set(id, _objectSpread(_objectSpread({}, overridesById.get(id)), Object.fromEntries(fields)));
903
+ }
904
+ } catch (err) {
905
+ _iterator18.e(err);
906
+ } finally {
907
+ _iterator18.f();
908
+ }
909
+ if (overridesById.size === 0) return;
910
+ var hasUpdates = false;
911
+ var merged = variants.map(function (variant) {
912
+ var id = _this9.normalizeId(variant === null || variant === void 0 ? void 0 : variant.id);
913
+ var fields = id === null ? undefined : overridesById.get(id);
914
+ if (!fields) return variant;
915
+ hasUpdates = true;
916
+ return _objectSpread(_objectSpread({}, variant), fields);
917
+ });
918
+ return hasUpdates ? merged : undefined;
919
+ }
875
920
  }, {
876
921
  key: "getProductDataVariants",
877
922
  value: function getProductDataVariants(product) {
@@ -915,11 +960,11 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
915
960
  key: "flattenConditionRules",
916
961
  value: function flattenConditionRules(group) {
917
962
  var rules = [];
918
- var _iterator18 = _createForOfIteratorHelper(group.rules),
919
- _step18;
963
+ var _iterator19 = _createForOfIteratorHelper(group.rules),
964
+ _step19;
920
965
  try {
921
- for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
922
- var rule = _step18.value;
966
+ for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
967
+ var rule = _step19.value;
923
968
  if (this.isConditionGroup(rule)) {
924
969
  rules.push.apply(rules, _toConsumableArray(this.flattenConditionRules(rule)));
925
970
  } else {
@@ -927,9 +972,9 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
927
972
  }
928
973
  }
929
974
  } catch (err) {
930
- _iterator18.e(err);
975
+ _iterator19.e(err);
931
976
  } finally {
932
- _iterator18.f();
977
+ _iterator19.f();
933
978
  }
934
979
  return rules;
935
980
  }
@@ -941,10 +986,10 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
941
986
  }, {
942
987
  key: "normalizeNumberArray",
943
988
  value: function normalizeNumberArray(value) {
944
- var _this9 = this;
989
+ var _this10 = this;
945
990
  if (!Array.isArray(value)) return [];
946
991
  return value.map(function (item) {
947
- return _this9.toNumber(item);
992
+ return _this10.toNumber(item);
948
993
  }).filter(function (item) {
949
994
  return item > 0;
950
995
  });
@@ -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";
@@ -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: "virtual" | "appointment_booking";
645
+ type: "appointment_booking" | "virtual";
646
646
  platform: string;
647
647
  sales_channel: string;
648
648
  order_sales_channel: string;
@@ -72,7 +72,7 @@ export declare const calculateOriginSubtotal: (items: CartItem[]) => string;
72
72
  * @return {*}
73
73
  * @Author: xiangfeng.xue
74
74
  */
75
- export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => Decimal | "0.00";
75
+ export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => "0.00" | Decimal;
76
76
  /**
77
77
  * @title: 计算定金
78
78
  * @param items - 购物车商品数组
@@ -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 | 1 | 2 | 5 | 4 | 3 | 6;
345
+ weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
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" | "session" | "duration">;
392
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
393
393
  /**
394
394
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
395
395
  *
@@ -33,19 +33,15 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
33
33
  holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
34
34
  order_id: number | null;
35
35
  external_sale_number: string;
36
- customer_id: number | null;
37
- bookings: any[];
38
- payments: any[];
39
36
  order_number: string | null;
40
- order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
41
37
  shop_order_number: string | null;
42
- business_code?: string | undefined;
43
- status: string;
44
- schedule_date: string;
45
38
  shop_full_order_number: string | null;
39
+ business_code?: string | undefined;
46
40
  sales_channel: string;
47
41
  order_sales_channel: string;
42
+ status: string;
48
43
  shipping_status: string;
44
+ customer_id: number | null;
49
45
  customer_name: string;
50
46
  country_calling_code: string;
51
47
  phone: string;
@@ -63,10 +59,14 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
63
59
  buzzer?: string | undefined;
64
60
  delivery_type?: string | undefined;
65
61
  table_number?: Record<string, any> | undefined;
62
+ schedule_date: string;
63
+ bookings: any[];
64
+ payments: any[];
65
+ contacts_info: Record<string, any> | null;
66
+ order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
66
67
  refunds?: any[] | undefined;
67
68
  surcharges: any[];
68
69
  contacts: any[];
69
- contacts_info: Record<string, any> | null;
70
70
  };
71
71
  export declare function describeChangedBookings(before: OrderTempOrder['bookings'], after: OrderTempOrder['bookings']): {
72
72
  schedule_event_id: any;
@@ -44,7 +44,7 @@ export declare class DataVariantEvaluator {
44
44
  * 返回 null 表示接口没有提供该字段;空 Map 表示已计算但没有任何命中。
45
45
  */
46
46
  private getAuthoritativeVariantPriorities;
47
- private normalizeDataVariantId;
47
+ private normalizeId;
48
48
  private buildGlobalEffectiveRuleMap;
49
49
  private resolveProduct;
50
50
  /**
@@ -90,6 +90,7 @@ export declare class DataVariantEvaluator {
90
90
  private timeToMinutes;
91
91
  private isProductInMenuScope;
92
92
  private mergeMatchedVariants;
93
+ private mergeSkuVariants;
93
94
  private getProductDataVariants;
94
95
  private normalizeStrategyConfigs;
95
96
  private isStrategyActive;
@@ -158,14 +158,14 @@ class DataVariantEvaluator {
158
158
  const orderedIds = [];
159
159
  const seen = new Set();
160
160
  for (const rawId of rawIds) {
161
- const id = this.normalizeDataVariantId(rawId);
161
+ const id = this.normalizeId(rawId);
162
162
  if (id === null || seen.has(id)) continue;
163
163
  seen.add(id);
164
164
  orderedIds.push(id);
165
165
  }
166
166
  return new Map(orderedIds.map((id, index) => [id, orderedIds.length - index]));
167
167
  }
168
- normalizeDataVariantId(value) {
168
+ normalizeId(value) {
169
169
  if (value === undefined || value === null) return null;
170
170
  const normalized = String(value).trim();
171
171
  return normalized || null;
@@ -206,7 +206,7 @@ class DataVariantEvaluator {
206
206
  for (const variant of dataVariants) {
207
207
  if (variant.business_type === 'multi_currency_settlement') continue;
208
208
  if (authoritativeVariantPriorities !== null) {
209
- const variantId = this.normalizeDataVariantId(variant.id);
209
+ const variantId = this.normalizeId(variant.id);
210
210
  const priority = variantId === null ? undefined : authoritativeVariantPriorities.get(variantId);
211
211
  if (priority === undefined) continue;
212
212
  matchedVariants.push({
@@ -250,7 +250,7 @@ class DataVariantEvaluator {
250
250
  const ruleId = String(variant.data_variant_rule_id);
251
251
  const isDefault = Number(variant.data_variant_rule_id) === 0;
252
252
  const rule = isDefault ? undefined : globalEffectiveRuleMap.get(ruleId);
253
- const variantId = this.normalizeDataVariantId(variant.id);
253
+ const variantId = this.normalizeId(variant.id);
254
254
  const authoritativePriority = variantId === null ? undefined : authoritativeVariantPriorities?.get(variantId);
255
255
  let available;
256
256
  let priority;
@@ -575,20 +575,54 @@ class DataVariantEvaluator {
575
575
  const appliedFields = new Set();
576
576
  for (const matched of sortedVariants) {
577
577
  for (const [key, value] of Object.entries(matched.data)) {
578
- if (value === undefined) continue;
578
+ if (value === undefined || key === 'variant_overrides') continue;
579
579
  result[key] = value;
580
580
  appliedFields.add(key);
581
581
  }
582
+ const mergedVariants = this.mergeSkuVariants(result.variant, matched.data.variant_overrides);
583
+ if (mergedVariants) {
584
+ result.variant = mergedVariants;
585
+ appliedFields.add('variant');
586
+ }
582
587
  appliedRuleIds.push(matched.ruleId);
583
588
  }
584
589
  result._dataVariant = {
585
590
  appliedRuleIds,
586
- appliedVariantIds: Array.from(new Set([...sortedVariants].reverse().map(matched => this.normalizeDataVariantId(matched.variant.id)).filter(id => id !== null))),
591
+ appliedVariantIds: Array.from(new Set([...sortedVariants].reverse().map(matched => this.normalizeId(matched.variant.id)).filter(id => id !== null))),
587
592
  appliedFields: Array.from(appliedFields),
588
593
  original
589
594
  };
590
595
  return result;
591
596
  }
597
+ mergeSkuVariants(variants, overrides) {
598
+ if (!Array.isArray(variants) || !Array.isArray(overrides)) return;
599
+ const overridesById = new Map();
600
+ for (const override of overrides) {
601
+ const rawId = override?.id;
602
+ if (typeof rawId !== 'number' && typeof rawId !== 'string') continue;
603
+ const id = this.normalizeId(rawId);
604
+ if (id === null) continue;
605
+ const fields = Object.entries(override).filter(([key, value]) => key !== 'id' && value !== undefined);
606
+ if (fields.length === 0) continue;
607
+ overridesById.set(id, {
608
+ ...overridesById.get(id),
609
+ ...Object.fromEntries(fields)
610
+ });
611
+ }
612
+ if (overridesById.size === 0) return;
613
+ let hasUpdates = false;
614
+ const merged = variants.map(variant => {
615
+ const id = this.normalizeId(variant?.id);
616
+ const fields = id === null ? undefined : overridesById.get(id);
617
+ if (!fields) return variant;
618
+ hasUpdates = true;
619
+ return {
620
+ ...variant,
621
+ ...fields
622
+ };
623
+ });
624
+ return hasUpdates ? merged : undefined;
625
+ }
592
626
  getProductDataVariants(product) {
593
627
  return Array.isArray(product.data_variants) ? product.data_variants : [];
594
628
  }
@@ -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: "virtual" | "appointment_booking";
645
+ type: "appointment_booking" | "virtual";
646
646
  platform: string;
647
647
  sales_channel: string;
648
648
  order_sales_channel: string;
@@ -72,7 +72,7 @@ export declare const calculateOriginSubtotal: (items: CartItem[]) => string;
72
72
  * @return {*}
73
73
  * @Author: xiangfeng.xue
74
74
  */
75
- export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => Decimal | "0.00";
75
+ export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => "0.00" | Decimal;
76
76
  /**
77
77
  * @title: 计算定金
78
78
  * @param items - 购物车商品数组
@@ -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 | 1 | 2 | 5 | 4 | 3 | 6;
345
+ weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
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" | "session" | "duration">;
392
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
393
393
  /**
394
394
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
395
395
  *
@@ -33,19 +33,15 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
33
33
  holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
34
34
  order_id: number | null;
35
35
  external_sale_number: string;
36
- customer_id: number | null;
37
- bookings: any[];
38
- payments: any[];
39
36
  order_number: string | null;
40
- order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
41
37
  shop_order_number: string | null;
42
- business_code?: string | undefined;
43
- status: string;
44
- schedule_date: string;
45
38
  shop_full_order_number: string | null;
39
+ business_code?: string | undefined;
46
40
  sales_channel: string;
47
41
  order_sales_channel: string;
42
+ status: string;
48
43
  shipping_status: string;
44
+ customer_id: number | null;
49
45
  customer_name: string;
50
46
  country_calling_code: string;
51
47
  phone: string;
@@ -63,10 +59,14 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
63
59
  buzzer?: string | undefined;
64
60
  delivery_type?: string | undefined;
65
61
  table_number?: Record<string, any> | undefined;
62
+ schedule_date: string;
63
+ bookings: any[];
64
+ payments: any[];
65
+ contacts_info: Record<string, any> | null;
66
+ order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
66
67
  refunds?: any[] | undefined;
67
68
  surcharges: any[];
68
69
  contacts: any[];
69
- contacts_info: Record<string, any> | null;
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.224",
4
+ "version": "2.3.225",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",