@pisell/pisellos 2.3.29 → 2.3.30

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 (98) hide show
  1. package/dist/model/strategy/adapter/index.d.ts +0 -4
  2. package/dist/model/strategy/adapter/index.js +1 -5
  3. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  4. package/dist/modules/Discount/index.d.ts +2 -5
  5. package/dist/modules/Discount/index.js +7 -30
  6. package/dist/modules/Discount/types.d.ts +0 -4
  7. package/dist/modules/Order/index.d.ts +28 -10
  8. package/dist/modules/Order/index.js +747 -498
  9. package/dist/modules/Order/payment-utils.d.ts +23 -0
  10. package/dist/modules/Order/payment-utils.js +203 -0
  11. package/dist/modules/Order/types.d.ts +33 -3
  12. package/dist/modules/Order/utils.js +4 -4
  13. package/dist/modules/Payment/index.d.ts +2 -0
  14. package/dist/modules/Payment/index.js +78 -49
  15. package/dist/modules/Payment/types.d.ts +26 -24
  16. package/dist/modules/Payment/types.js +2 -0
  17. package/dist/modules/Product/index.d.ts +1 -1
  18. package/dist/modules/Product/types.d.ts +0 -22
  19. package/dist/modules/ProductList/index.d.ts +1 -1
  20. package/dist/modules/ProductList/index.js +2 -4
  21. package/dist/modules/ProductList/types.d.ts +0 -2
  22. package/dist/server/index.d.ts +14 -50
  23. package/dist/server/index.js +1975 -1395
  24. package/dist/server/modules/order/index.d.ts +40 -3
  25. package/dist/server/modules/order/index.js +1200 -501
  26. package/dist/server/modules/order/types.d.ts +11 -3
  27. package/dist/server/modules/order/types.js +1 -1
  28. package/dist/server/modules/products/index.d.ts +7 -26
  29. package/dist/server/modules/products/index.js +76 -167
  30. package/dist/server/modules/products/types.d.ts +0 -14
  31. package/dist/solution/BaseSales/index.d.ts +33 -5
  32. package/dist/solution/BaseSales/index.js +622 -345
  33. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  34. package/dist/solution/BookingByStep/index.d.ts +1 -1
  35. package/dist/solution/BookingTicket/index.d.ts +1 -1
  36. package/dist/solution/BookingTicket/index.js +2 -1
  37. package/dist/solution/BookingTicket/types.d.ts +0 -2
  38. package/dist/solution/ShopDiscount/index.js +14 -15
  39. package/dist/utils/payment-number.d.ts +9 -0
  40. package/dist/utils/payment-number.js +69 -0
  41. package/lib/model/strategy/adapter/index.d.ts +0 -4
  42. package/lib/model/strategy/adapter/index.js +2 -13
  43. package/lib/modules/Discount/index.d.ts +2 -5
  44. package/lib/modules/Discount/index.js +3 -23
  45. package/lib/modules/Discount/types.d.ts +0 -4
  46. package/lib/modules/Order/index.d.ts +28 -10
  47. package/lib/modules/Order/index.js +181 -73
  48. package/lib/modules/Order/payment-utils.d.ts +23 -0
  49. package/lib/modules/Order/payment-utils.js +193 -0
  50. package/lib/modules/Order/types.d.ts +33 -3
  51. package/lib/modules/Order/utils.js +2 -3
  52. package/lib/modules/Payment/index.d.ts +2 -0
  53. package/lib/modules/Payment/index.js +33 -12
  54. package/lib/modules/Payment/types.d.ts +26 -24
  55. package/lib/modules/Product/index.d.ts +1 -1
  56. package/lib/modules/Product/types.d.ts +0 -22
  57. package/lib/modules/ProductList/index.d.ts +1 -1
  58. package/lib/modules/ProductList/index.js +2 -4
  59. package/lib/modules/ProductList/types.d.ts +0 -2
  60. package/lib/server/index.d.ts +14 -50
  61. package/lib/server/index.js +633 -214
  62. package/lib/server/modules/order/index.d.ts +40 -3
  63. package/lib/server/modules/order/index.js +434 -31
  64. package/lib/server/modules/order/types.d.ts +11 -3
  65. package/lib/server/modules/products/index.d.ts +7 -26
  66. package/lib/server/modules/products/index.js +35 -114
  67. package/lib/server/modules/products/types.d.ts +0 -14
  68. package/lib/solution/BaseSales/index.d.ts +33 -5
  69. package/lib/solution/BaseSales/index.js +170 -19
  70. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  71. package/lib/solution/BookingByStep/index.d.ts +1 -1
  72. package/lib/solution/BookingTicket/index.d.ts +1 -1
  73. package/lib/solution/BookingTicket/index.js +2 -1
  74. package/lib/solution/BookingTicket/types.d.ts +0 -2
  75. package/lib/solution/ShopDiscount/index.js +1 -2
  76. package/lib/utils/payment-number.d.ts +9 -0
  77. package/lib/utils/payment-number.js +64 -0
  78. package/package.json +1 -1
  79. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  80. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  81. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  82. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
  83. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  84. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  85. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  86. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  87. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  88. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  89. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  90. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  91. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  92. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
  93. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  94. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  95. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  96. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  97. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  98. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
@@ -1,149 +0,0 @@
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
- });
@@ -1,89 +0,0 @@
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;