@pisell/pisellos 2.3.28 → 2.3.29

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 (84) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  6. package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
  7. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  8. package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
  9. package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  10. package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
  11. package/dist/model/strategy/adapter/index.d.ts +4 -0
  12. package/dist/model/strategy/adapter/index.js +5 -1
  13. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  14. package/dist/modules/Discount/index.d.ts +5 -2
  15. package/dist/modules/Discount/index.js +30 -7
  16. package/dist/modules/Discount/types.d.ts +4 -0
  17. package/dist/modules/Order/index.d.ts +7 -1
  18. package/dist/modules/Order/index.js +187 -74
  19. package/dist/modules/Order/types.d.ts +2 -0
  20. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  21. package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
  22. package/dist/modules/Order/utils.d.ts +2 -1
  23. package/dist/modules/Order/utils.js +2 -8
  24. package/dist/modules/Product/types.d.ts +22 -0
  25. package/dist/modules/ProductList/index.d.ts +1 -1
  26. package/dist/modules/ProductList/index.js +4 -2
  27. package/dist/modules/ProductList/types.d.ts +2 -0
  28. package/dist/server/index.d.ts +50 -0
  29. package/dist/server/index.js +995 -749
  30. package/dist/server/modules/order/index.d.ts +10 -4
  31. package/dist/server/modules/order/index.js +404 -399
  32. package/dist/server/modules/products/index.d.ts +26 -7
  33. package/dist/server/modules/products/index.js +167 -76
  34. package/dist/server/modules/products/types.d.ts +14 -0
  35. package/dist/solution/BaseSales/index.d.ts +9 -1
  36. package/dist/solution/BaseSales/index.js +998 -756
  37. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  38. package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
  39. package/dist/solution/BookingByStep/index.d.ts +1 -1
  40. package/dist/solution/BookingTicket/index.d.ts +14 -2
  41. package/dist/solution/BookingTicket/types.d.ts +2 -0
  42. package/dist/solution/ShopDiscount/index.js +15 -14
  43. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  44. package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
  45. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  46. package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
  47. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  48. package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
  49. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  50. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  51. package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  52. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  53. package/lib/model/strategy/adapter/index.d.ts +4 -0
  54. package/lib/model/strategy/adapter/index.js +13 -2
  55. package/lib/modules/Discount/index.d.ts +5 -2
  56. package/lib/modules/Discount/index.js +23 -3
  57. package/lib/modules/Discount/types.d.ts +4 -0
  58. package/lib/modules/Order/index.d.ts +7 -1
  59. package/lib/modules/Order/index.js +104 -6
  60. package/lib/modules/Order/types.d.ts +2 -0
  61. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  62. package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
  63. package/lib/modules/Order/utils.d.ts +2 -1
  64. package/lib/modules/Order/utils.js +4 -11
  65. package/lib/modules/Product/types.d.ts +22 -0
  66. package/lib/modules/ProductList/index.d.ts +1 -1
  67. package/lib/modules/ProductList/index.js +4 -2
  68. package/lib/modules/ProductList/types.d.ts +2 -0
  69. package/lib/server/index.d.ts +50 -0
  70. package/lib/server/index.js +206 -29
  71. package/lib/server/modules/order/index.d.ts +10 -4
  72. package/lib/server/modules/order/index.js +198 -139
  73. package/lib/server/modules/products/index.d.ts +26 -7
  74. package/lib/server/modules/products/index.js +114 -35
  75. package/lib/server/modules/products/types.d.ts +14 -0
  76. package/lib/solution/BaseSales/index.d.ts +9 -1
  77. package/lib/solution/BaseSales/index.js +229 -54
  78. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  79. package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
  80. package/lib/solution/BookingByStep/index.d.ts +1 -1
  81. package/lib/solution/BookingTicket/index.d.ts +14 -2
  82. package/lib/solution/BookingTicket/types.d.ts +2 -0
  83. package/lib/solution/ShopDiscount/index.js +2 -1
  84. package/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
  * 把 `/order/sales/{id}` 响应(OrderData)解析为 ISalesDetail。
3
3
  *
4
4
  * - 纯函数:不依赖任何运行时模块/插件,便于单测与 view-model 适配
5
- * - products 保留 tempOrder / 后端详情原字段,仅做浅拷贝,避免丢失 product_sku 等协议字段
5
+ * - products 保留 tempOrder / 后端详情原字段,仅规范化集合身份并浅拷贝,避免丢失 product_sku 等协议字段
6
6
  * - bookings 平铺保留服务端原顺序,同时输出 byProductUid 反查表与 rootBooking
7
7
  * - header 收敛"非数组顶层字段",便于 ticketBooking view-model 直接消费
8
8
  *
@@ -130,7 +130,7 @@ export interface ISalesDetail {
130
130
  customer: ISalesDetailCustomer | null;
131
131
  /** 服务端 summary(仅输出) */
132
132
  summary: Record<string, any>;
133
- /** 原始响应快照,方便 UI 兜底使用 */
133
+ /** 规范化后的响应快照,方便 UI 兜底使用 */
134
134
  raw: Record<string, any>;
135
135
  }
136
136
  /**
@@ -138,7 +138,7 @@ export interface ISalesDetail {
138
138
  *
139
139
  * 注意:
140
140
  * - 入参允许是 `{ data: OrderData }` 或直接 `OrderData`,自动识别。
141
- * - products 保留原字段;字段补齐由 OrderModule hydrate 负责。
141
+ * - products/bookings/payments 在此补齐集合身份;其余 runtime 字段由 OrderModule hydrate 负责。
142
142
  * - 不做远程请求;不修改入参;返回新对象。
143
143
  */
144
144
  export declare function parseSalesResponse(input: Record<string, any> | null | undefined): ISalesDetail;
@@ -11,7 +11,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
11
11
  * 把 `/order/sales/{id}` 响应(OrderData)解析为 ISalesDetail。
12
12
  *
13
13
  * - 纯函数:不依赖任何运行时模块/插件,便于单测与 view-model 适配
14
- * - products 保留 tempOrder / 后端详情原字段,仅做浅拷贝,避免丢失 product_sku 等协议字段
14
+ * - products 保留 tempOrder / 后端详情原字段,仅规范化集合身份并浅拷贝,避免丢失 product_sku 等协议字段
15
15
  * - bookings 平铺保留服务端原顺序,同时输出 byProductUid 反查表与 rootBooking
16
16
  * - header 收敛"非数组顶层字段",便于 ticketBooking view-model 直接消费
17
17
  *
@@ -23,6 +23,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
23
23
  * - 不在此处发明等价关系;UI 侧(ticketBooking)若需要别的字段,由 view-model 适配层做转换
24
24
  */
25
25
 
26
+ import { normalizeOrderCollections } from "../../../modules/Order/utils/orderCollectionIdentity";
26
27
  /** OrderData 中除大数组外的"顶层 header 字段"白名单,按需扩展。 */
27
28
  var HEADER_KEYS = ['order_id', 'order_number', 'shop_order_number', 'shop_full_order_number', 'type', 'business_code', 'platform', 'sales_channel', 'order_sales_channel', 'vouchers', 'status', 'payment_status', 'shipping_status', 'customer_id', 'customer_name', 'country_calling_code', 'phone', 'email', 'is_price_include_tax', 'tax_title', 'tax_country_code', 'currency_code', 'currency_symbol', 'currency_format', 'is_deposit', 'deposit_amount', 'shop_discount', 'surcharge_fee', 'note', 'schedule_date', 'created_at', 'updated_at', 'metadata', 'total_amount', 'shop_id', 'create_date', 'holder', 'relation_forms', 'contacts', 'contacts_info'];
28
29
  function pickHeader(raw) {
@@ -108,19 +109,16 @@ function indexBookingsByProductUid(bookings) {
108
109
  *
109
110
  * 注意:
110
111
  * - 入参允许是 `{ data: OrderData }` 或直接 `OrderData`,自动识别。
111
- * - products 保留原字段;字段补齐由 OrderModule hydrate 负责。
112
+ * - products/bookings/payments 在此补齐集合身份;其余 runtime 字段由 OrderModule hydrate 负责。
112
113
  * - 不做远程请求;不修改入参;返回新对象。
113
114
  */
114
115
  export function parseSalesResponse(input) {
115
- var raw = input && _typeof(input) === 'object' && input.data && input.order_id == null ? input.data : input || {};
116
+ var sourceRaw = input && _typeof(input) === 'object' && input.data && input.order_id == null ? input.data : input || {};
117
+ var raw = normalizeOrderCollections(sourceRaw).order;
116
118
  var productsRaw = Array.isArray(raw === null || raw === void 0 ? void 0 : raw.products) ? raw.products : [];
117
- var products = productsRaw.map(function (p, index) {
119
+ var products = productsRaw.map(function (p) {
118
120
  var row = _objectSpread({}, p || {});
119
121
  var metadata = row.metadata && _typeof(row.metadata) === 'object' ? _objectSpread({}, row.metadata) : {};
120
- if (!metadata.unique_identification_number) {
121
- var _row$product_id, _row$product_variant_;
122
- metadata.unique_identification_number = "sales-product-".concat((_row$product_id = row.product_id) !== null && _row$product_id !== void 0 ? _row$product_id : 'unknown', "-").concat((_row$product_variant_ = row.product_variant_id) !== null && _row$product_variant_ !== void 0 ? _row$product_variant_ : 0, "-").concat(index);
123
- }
124
122
  delete metadata.price_schema_version;
125
123
  delete row.identity_key;
126
124
  return _objectSpread(_objectSpread({}, row), {}, {
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 6 | 3 | 4 | 5;
314
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -322,7 +322,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
322
322
  * 获取当前的客户搜索条件
323
323
  * @returns 当前搜索条件
324
324
  */
325
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
325
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
326
326
  /**
327
327
  * 获取客户列表状态(包含滚动加载相关状态)
328
328
  * @returns 客户状态
@@ -441,7 +441,19 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
441
441
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
442
442
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
443
443
  */
444
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
444
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
445
+ action: "reloadCatalog";
446
+ } | {
447
+ action: "add";
448
+ cacheItem: any;
449
+ } | {
450
+ action: "requiresDetail";
451
+ payload: AddProductRequiresDetailPayload;
452
+ } | {
453
+ action: "requiresBookingEdit";
454
+ cacheItem: any;
455
+ payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
456
+ };
445
457
  /** 规格弹窗 callback 后的第二段决策。 */
446
458
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
447
459
  /**
@@ -83,6 +83,8 @@ export interface ILoadProductsParams {
83
83
  extension_type?: string[];
84
84
  /** 商品发布状态 */
85
85
  status?: string;
86
+ /** 智能定价条件上下文,仅影响策略命中,不参与商品集合筛选 */
87
+ strategy_context?: Record<string, any>;
86
88
  }
87
89
  /**
88
90
  * 加载商品详情的参数
@@ -756,7 +756,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
756
756
  key: "loadPrepareConfig",
757
757
  value: function () {
758
758
  var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
759
- var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$discount8, _this$store$productLi2, orderId, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
759
+ var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$discount8, _this$store$productLi2, orderId, customerId, prepareConfigResult, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
760
760
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
761
761
  while (1) switch (_context9.prev = _context9.next) {
762
762
  case 0:
@@ -777,7 +777,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
777
777
  order_id: orderId
778
778
  } : {}));
779
779
  case 5:
780
- goodPassList = _context9.sent;
780
+ prepareConfigResult = _context9.sent;
781
+ goodPassList = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList) || [];
781
782
  scanDiscount = (_this$getDiscountList = this.getDiscountList()) === null || _this$getDiscountList === void 0 ? void 0 : _this$getDiscountList.filter(function (item) {
782
783
  return item.isScan;
783
784
  }); // goodPassList 里可能有 scanDiscount 重合的部分,goodPassList 需要剔除
@@ -789,35 +790,35 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
789
790
  });
790
791
  newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
791
792
  this.store.originalDiscountList = newDiscountList;
792
- _context9.next = 13;
793
+ _context9.next = 14;
793
794
  return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.setOriginalDiscountList(newDiscountList);
794
- case 13:
795
+ case 14:
795
796
  // 根据当前预约时间过滤优惠券列表
796
797
  filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
797
798
  this.store.filteredDiscountList = filteredDiscountList;
798
799
  this.setDiscountList(filteredDiscountList || []);
799
800
  if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
800
- _context9.next = 20;
801
+ _context9.next = 21;
801
802
  break;
802
803
  }
803
804
  _result3 = this.calcDiscount(this.store.productList);
804
- _context9.next = 20;
805
+ _context9.next = 21;
805
806
  return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
806
- case 20:
807
- _context9.next = 22;
807
+ case 21:
808
+ _context9.next = 23;
808
809
  return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
809
- case 22:
810
- _context9.next = 27;
810
+ case 23:
811
+ _context9.next = 28;
811
812
  break;
812
- case 24:
813
- _context9.prev = 24;
813
+ case 25:
814
+ _context9.prev = 25;
814
815
  _context9.t0 = _context9["catch"](0);
815
816
  console.error('[ShopDiscount] 加载准备配置出错:', _context9.t0);
816
- case 27:
817
+ case 28:
817
818
  case "end":
818
819
  return _context9.stop();
819
820
  }
820
- }, _callee9, this, [[0, 24]]);
821
+ }, _callee9, this, [[0, 25]]);
821
822
  }));
822
823
  function loadPrepareConfig(_x9) {
823
824
  return _loadPrepareConfig.apply(this, arguments);
@@ -0,0 +1,50 @@
1
+ import type { EvaluationResult, RuntimeContext } from '../../type';
2
+ import type { BusinessAdapter } from '../type';
3
+ import type { DataVariantBusinessData, DataVariantProduct } from './type';
4
+ /**
5
+ * Data Variant 适配器。
6
+ *
7
+ * 负责把智能定价运行态数据转换为 StrategyEngine 能识别的 attributes。
8
+ */
9
+ export declare class DataVariantAdapter implements BusinessAdapter {
10
+ name: string;
11
+ version: string;
12
+ /**
13
+ * 准备批量全局上下文。
14
+ *
15
+ * 这里只放不依赖单个商品的字段,用于预计算 schedule/channel/orderType 等条件。
16
+ */
17
+ prepareContext(businessData: DataVariantBusinessData): RuntimeContext;
18
+ /**
19
+ * 准备全局预计算上下文。
20
+ */
21
+ prepareGlobalContext(businessData: DataVariantBusinessData): RuntimeContext;
22
+ /**
23
+ * 准备单商品上下文。
24
+ *
25
+ * 商品级条件只在当前商品 data_variants 引用到对应规则后才评估。
26
+ */
27
+ prepareProductContext(businessData: DataVariantBusinessData, product: DataVariantProduct): RuntimeContext;
28
+ transformResult(result: EvaluationResult): EvaluationResult;
29
+ formatConfig(result: EvaluationResult, businessData?: DataVariantBusinessData): {
30
+ result: EvaluationResult;
31
+ businessData?: DataVariantBusinessData;
32
+ };
33
+ /**
34
+ * 构建 menu_match 使用的轻量商品对象。
35
+ *
36
+ * collection_ids 来自商品 collection 字段,避免 operator 读取复杂商品对象。
37
+ */
38
+ buildProductValue(product: DataVariantProduct): {
39
+ id: number;
40
+ product_variant_id: number;
41
+ collection_ids: number[];
42
+ };
43
+ private toNumber;
44
+ /**
45
+ * 归一化客户 id:无效值返回 undefined,有效值统一为 number。
46
+ */
47
+ private normalizeCustomerId;
48
+ private normalizeNumberArray;
49
+ }
50
+ export default DataVariantAdapter;
@@ -0,0 +1,149 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/model/strategy/adapter/dataVariant/adapter.ts
20
+ var adapter_exports = {};
21
+ __export(adapter_exports, {
22
+ DataVariantAdapter: () => DataVariantAdapter,
23
+ default: () => adapter_default
24
+ });
25
+ module.exports = __toCommonJS(adapter_exports);
26
+ var DataVariantAdapter = class {
27
+ constructor() {
28
+ this.name = "DataVariantAdapter";
29
+ this.version = "1.0.0";
30
+ }
31
+ /**
32
+ * 准备批量全局上下文。
33
+ *
34
+ * 这里只放不依赖单个商品的字段,用于预计算 schedule/channel/orderType 等条件。
35
+ */
36
+ prepareContext(businessData) {
37
+ return this.prepareGlobalContext(businessData);
38
+ }
39
+ /**
40
+ * 准备全局预计算上下文。
41
+ */
42
+ prepareGlobalContext(businessData) {
43
+ const {
44
+ products,
45
+ scheduleDateTime,
46
+ channel,
47
+ orderType,
48
+ businessCode,
49
+ customerId,
50
+ availableWalletIds,
51
+ custom
52
+ } = businessData;
53
+ const normalizedCustomerId = this.normalizeCustomerId(customerId);
54
+ const normalizedAvailableWalletIds = this.normalizeNumberArray(availableWalletIds ?? (custom == null ? void 0 : custom.available_wallet_ids));
55
+ const resolvedBusinessCode = businessCode || (custom == null ? void 0 : custom.business_code) || (custom == null ? void 0 : custom.businessCode) || "";
56
+ return {
57
+ entities: {
58
+ products
59
+ },
60
+ attributes: {
61
+ ...custom,
62
+ schedule: scheduleDateTime || "",
63
+ channel: channel || (custom == null ? void 0 : custom.channel) || "",
64
+ orderType: orderType || (custom == null ? void 0 : custom.orderType) || (custom == null ? void 0 : custom.order_type) || "",
65
+ // snake_case 与策略配置 field 对齐;customerId 保留兼容旧配置
66
+ customer_id: normalizedCustomerId,
67
+ customerId: normalizedCustomerId,
68
+ available_wallet_ids: normalizedAvailableWalletIds,
69
+ availableWalletIds: normalizedAvailableWalletIds,
70
+ business_code: resolvedBusinessCode
71
+ },
72
+ metadata: {
73
+ timestamp: Date.now()
74
+ }
75
+ };
76
+ }
77
+ /**
78
+ * 准备单商品上下文。
79
+ *
80
+ * 商品级条件只在当前商品 data_variants 引用到对应规则后才评估。
81
+ */
82
+ prepareProductContext(businessData, product) {
83
+ const base = this.prepareGlobalContext(businessData);
84
+ const productValue = this.buildProductValue(product);
85
+ return {
86
+ ...base,
87
+ entities: {
88
+ ...base.entities,
89
+ currentProduct: product
90
+ },
91
+ attributes: {
92
+ ...base.attributes,
93
+ product: productValue,
94
+ productIdAndVariantId: {
95
+ product_id: productValue.id,
96
+ product_variant_id: productValue.product_variant_id
97
+ }
98
+ }
99
+ };
100
+ }
101
+ transformResult(result) {
102
+ return result;
103
+ }
104
+ formatConfig(result, businessData) {
105
+ return { result, businessData };
106
+ }
107
+ /**
108
+ * 构建 menu_match 使用的轻量商品对象。
109
+ *
110
+ * collection_ids 来自商品 collection 字段,避免 operator 读取复杂商品对象。
111
+ */
112
+ buildProductValue(product) {
113
+ const productId = this.toNumber(product.id ?? product.product_id);
114
+ const variantId = this.toNumber(
115
+ product.product_variant_id ?? product.variant_id
116
+ );
117
+ const collectionIds = Array.isArray(product.collection) ? product.collection.map((item) => this.toNumber(item == null ? void 0 : item.id)).filter((id) => id > 0) : [];
118
+ return {
119
+ id: productId,
120
+ product_variant_id: variantId,
121
+ collection_ids: collectionIds
122
+ };
123
+ }
124
+ toNumber(value) {
125
+ const parsed = Number(value);
126
+ return Number.isFinite(parsed) ? parsed : 0;
127
+ }
128
+ /**
129
+ * 归一化客户 id:无效值返回 undefined,有效值统一为 number。
130
+ */
131
+ normalizeCustomerId(value) {
132
+ if (value === void 0 || value === null || value === "") {
133
+ return void 0;
134
+ }
135
+ const parsed = Number(value);
136
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
137
+ }
138
+ normalizeNumberArray(value) {
139
+ if (!Array.isArray(value))
140
+ return [];
141
+ const ids = value.map((item) => Number(item)).filter((item) => Number.isFinite(item) && item > 0);
142
+ return Array.from(new Set(ids));
143
+ }
144
+ };
145
+ var adapter_default = DataVariantAdapter;
146
+ // Annotate the CommonJS export names for ESM import in node:
147
+ 0 && (module.exports = {
148
+ DataVariantAdapter
149
+ });
@@ -0,0 +1,89 @@
1
+ import type { ConditionRule, StrategyConfig } from '../../type';
2
+ import type { ConditionScope, DataVariantBusinessData, DataVariantMenu, DataVariantRuleMetadata, MenuScope, ResolvedDataVariantResult } from './type';
3
+ /**
4
+ * Data Variant 评估器。
5
+ *
6
+ * 当前阶段只提供策略模型能力和示例验证,不接入 ProductList 业务链路。
7
+ */
8
+ export declare class DataVariantEvaluator {
9
+ private adapter;
10
+ private strategyConfigs;
11
+ constructor();
12
+ /**
13
+ * 设置策略配置列表,仅保留 metadata.type === 'data_variant' 的策略。
14
+ */
15
+ setStrategyConfigs(configs: StrategyConfig[]): void;
16
+ getStrategyConfigs(): StrategyConfig<DataVariantRuleMetadata>[];
17
+ /**
18
+ * 批量解析商品 Data Variant。
19
+ *
20
+ * 先执行全局预计算,再只针对商品自身 data_variants 引用到的规则做商品级判断。
21
+ */
22
+ resolveProducts(businessData: DataVariantBusinessData): ResolvedDataVariantResult;
23
+ /**
24
+ * 根据 operator/field 判断条件是否依赖当前商品。
25
+ */
26
+ getConditionScope(rule: ConditionRule): ConditionScope;
27
+ /**
28
+ * 将餐牌 partyroom_package 预构建为 Map/Set 索引。
29
+ */
30
+ buildMenuScopeMap(menuList: DataVariantMenu[]): Map<number, MenuScope>;
31
+ /**
32
+ * 从当前策略中所有 schedule_match.value 绑定的 schedule_id 提取时间点。
33
+ *
34
+ * 这里不依赖餐牌,只读取策略配置和调用方传入的 scheduleList。
35
+ */
36
+ buildScheduleTimePoints(strategyConfigs: StrategyConfig<DataVariantRuleMetadata>[], scheduleList: NonNullable<DataVariantBusinessData['scheduleList']>): string[];
37
+ private buildGlobalEffectiveRuleMap;
38
+ private resolveProduct;
39
+ /**
40
+ * 解析套餐子商品上的 Data Variant 覆盖。
41
+ *
42
+ * bundle_item 以 bundle_product_id / bundle_variant_id 作为商品身份参与 product_match 等条件判断。
43
+ */
44
+ private resolveProductBundleItems;
45
+ /**
46
+ * 将 bundle_item 转为 DataVariantProduct 并评估 data_variants。
47
+ */
48
+ private resolveBundleItem;
49
+ /**
50
+ * bundle_item 的商品身份映射:bundle_product_id + bundle_variant_id。
51
+ */
52
+ private toBundleItemDataVariantProduct;
53
+ /**
54
+ * 仅回写命中的字段,避免污染 bundle_item 的结构字段。
55
+ */
56
+ private mergeBundleItemResolvedData;
57
+ private evaluateProductRules;
58
+ /**
59
+ * 拆分策略条件。
60
+ *
61
+ * 当前 MVP 支持顶层 and 原子条件拆分;复杂条件保守地放到商品级完整判断。
62
+ */
63
+ private splitStrategyConfig;
64
+ private createEngine;
65
+ private evaluateScheduleMatch;
66
+ private evaluateMenuMatch;
67
+ private evaluateArrayIntersects;
68
+ private collectScheduleIdsFromStrategies;
69
+ private extractTimePointsFromSchedules;
70
+ private addDateTimePoint;
71
+ private addRawTimePoint;
72
+ private extractTimeFromDateTime;
73
+ private normalizeTime;
74
+ private timeToMinutes;
75
+ private isProductInMenuScope;
76
+ private mergeMatchedVariants;
77
+ private getProductDataVariants;
78
+ private normalizeStrategyConfigs;
79
+ private isStrategyActive;
80
+ private getStrategyPriority;
81
+ private createAlwaysTrueConditions;
82
+ private flattenConditionRules;
83
+ private isConditionGroup;
84
+ private normalizeNumberArray;
85
+ private normalizeComparableArray;
86
+ private buildProductKey;
87
+ private toNumber;
88
+ }
89
+ export default DataVariantEvaluator;