@pisell/pisellos 0.0.461 → 0.0.462

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.
@@ -1,206 +1,4 @@
1
- import type { EvaluationResult, RuntimeContext } from '../../type';
2
- import type { BusinessAdapter } from '../type';
3
- import type { PromotionBusinessData, PromotionTransformResult } from './type';
4
- import { PromotionEvaluator } from './evaluator';
5
- export { PromotionEvaluator };
6
- /**
7
- * Promotion 适配器
8
- *
9
- * 用于将促销活动业务数据转换为策略引擎可识别的格式
10
- * 策略引擎只负责匹配,具体的优惠计算由业务层完成
11
- */
12
- export declare class PromotionAdapter implements BusinessAdapter {
13
- name: string;
14
- version: string;
15
- /**
16
- * 准备运行时上下文
17
- *
18
- * 将业务数据转换为策略引擎可识别的 RuntimeContext
19
- */
20
- prepareContext(businessData: PromotionBusinessData): RuntimeContext;
21
- /**
22
- * 转换执行结果
23
- *
24
- * 将策略引擎的通用结果转换为业务层需要的格式
25
- * 主要是整理 matchedActions,让业务层更容易使用
26
- */
27
- transformResult(result: EvaluationResult, businessData?: PromotionBusinessData): PromotionTransformResult;
28
- /**
29
- * 格式化配置
30
- */
31
- formatConfig(result: EvaluationResult, businessData?: PromotionBusinessData): {
32
- result: EvaluationResult;
33
- businessData?: PromotionBusinessData;
34
- };
35
- /**
36
- * 格式化日期时间
37
- */
38
- private formatDateTime;
39
- /**
40
- * 解析 Action 详情
41
- *
42
- * 将 matchedAction 转换为更易用的结构
43
- */
44
- private parseActionDetail;
45
- /**
46
- * 解析 X件Y元 Action
47
- */
48
- private parseXItemsForYPriceAction;
49
- /**
50
- * 解析 买X送Y Action
51
- */
52
- private parseBuyXGetYFreeAction;
53
- /**
54
- * 获取适用的商品列表
55
- *
56
- * 从购物车商品中筛选出符合策略条件的商品
57
- */
58
- private getApplicableProducts;
59
- /**
60
- * 查找商品匹配规则
61
- */
62
- private findProductMatchRule;
63
- /**
64
- * 检查商品是否匹配
65
- */
66
- private isProductMatch;
67
- }
68
- export default PromotionAdapter;
69
- /**
70
- * X件Y元策略配置示例
71
- *
72
- * 业务规则:
73
- * - 每X件商品固定价格Y元(可累计)
74
- * - 支持跨商品组合(A+B可以凑成一组)
75
- * - 买5件 = 2组优惠 + 1件原价
76
- *
77
- * 商品匹配规则:
78
- * - product_variant_id = 0 表示匹配任意变体
79
- * - product_variant_id != 0 表示精确匹配该变体
80
- */
81
- export declare const X_ITEMS_FOR_Y_PRICE_STRATEGY: {
82
- metadata: {
83
- id: string;
84
- name: {
85
- en: string;
86
- 'zh-CN': string;
87
- 'zh-HK': string;
88
- };
89
- type: string;
90
- custom: {
91
- display: {
92
- product_card: {
93
- text: {
94
- en: string;
95
- 'zh-CN': string;
96
- 'zh-HK': string;
97
- };
98
- type: string;
99
- };
100
- };
101
- };
102
- };
103
- conditions: {
104
- operator: string;
105
- rules: ({
106
- type: string;
107
- field: string;
108
- value: string;
109
- operator: string;
110
- } | {
111
- type: string;
112
- field: string;
113
- value: {
114
- product_id: number;
115
- product_variant_id: number;
116
- }[];
117
- operator: string;
118
- })[];
119
- actionIds: string[];
120
- };
121
- actions: {
122
- id: string;
123
- type: string;
124
- value: {
125
- x: number;
126
- price: number;
127
- };
128
- valueType: string;
129
- target: string;
130
- priority: number;
131
- config: {
132
- allowCrossProduct: boolean;
133
- cumulative: boolean;
134
- };
135
- }[];
136
- };
137
- /**
138
- * 买X送Y策略配置示例
139
- *
140
- * 业务规则:
141
- * - 买X件送Y件(可累计:买2送2、买3送3...)
142
- * - 赠品由用户从列表中选择
143
- *
144
- * 商品匹配规则:
145
- * - product_variant_id = 0 表示匹配任意变体
146
- * - product_variant_id != 0 表示精确匹配该变体
147
- */
148
- export declare const BUY_X_GET_Y_FREE_STRATEGY: {
149
- metadata: {
150
- id: string;
151
- name: {
152
- en: string;
153
- 'zh-CN': string;
154
- 'zh-HK': string;
155
- };
156
- type: string;
157
- custom: {
158
- display: {
159
- product_card: {
160
- text: {
161
- en: string;
162
- 'zh-CN': string;
163
- 'zh-HK': string;
164
- };
165
- type: string;
166
- };
167
- };
168
- };
169
- };
170
- conditions: {
171
- operator: string;
172
- rules: ({
173
- type: string;
174
- field: string;
175
- value: string;
176
- operator: string;
177
- } | {
178
- type: string;
179
- field: string;
180
- value: {
181
- product_id: number;
182
- product_variant_id: number;
183
- }[];
184
- operator: string;
185
- })[];
186
- actionIds: string[];
187
- };
188
- actions: {
189
- id: string;
190
- type: string;
191
- value: {
192
- buyQuantity: number;
193
- freeQuantity: number;
194
- };
195
- valueType: string;
196
- target: string;
197
- priority: number;
198
- config: {
199
- cumulative: boolean;
200
- giftProducts: {
201
- product_id: number;
202
- product_variant_id: number;
203
- }[];
204
- };
205
- }[];
206
- };
1
+ export { PromotionEvaluator } from './evaluator';
2
+ export { PromotionAdapter } from './adapter';
3
+ export { default } from './adapter';
4
+ export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, } from './examples';
@@ -0,0 +1,49 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/model/strategy/adapter/promotion/index.ts
30
+ var promotion_exports = {};
31
+ __export(promotion_exports, {
32
+ BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
+ PromotionAdapter: () => import_adapter.PromotionAdapter,
34
+ PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
+ X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
+ default: () => import_adapter2.default
37
+ });
38
+ module.exports = __toCommonJS(promotion_exports);
39
+ var import_evaluator = require("./evaluator");
40
+ var import_adapter = require("./adapter");
41
+ var import_adapter2 = __toESM(require("./adapter"));
42
+ var import_examples = require("./examples");
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ BUY_X_GET_Y_FREE_STRATEGY,
46
+ PromotionAdapter,
47
+ PromotionEvaluator,
48
+ X_ITEMS_FOR_Y_PRICE_STRATEGY
49
+ });
@@ -1285,6 +1285,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1285
1285
  product_id: bundleItem.product_id,
1286
1286
  price: item.price,
1287
1287
  num: item.num,
1288
+ quantity: item.num,
1288
1289
  discount_list: updatedDiscountList2
1289
1290
  });
1290
1291
  });
@@ -1309,6 +1310,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1309
1310
  product_id: bundleItem.product_id,
1310
1311
  price: item.price,
1311
1312
  num: item.num,
1313
+ quantity: item.num,
1312
1314
  discount_list: updatedDiscountList2
1313
1315
  });
1314
1316
  } else {
@@ -1474,6 +1476,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1474
1476
  product_id: bundleItem.product_id,
1475
1477
  price: item.price,
1476
1478
  num: item.num,
1479
+ quantity: item.num,
1477
1480
  discount_list: updatedDiscountList2
1478
1481
  });
1479
1482
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.461",
4
+ "version": "0.0.462",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",