@pisell/pisellos 2.2.61 → 2.2.62
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.
- package/dist/model/strategy/adapter/index.d.ts +2 -2
- package/dist/model/strategy/adapter/index.js +2 -2
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +66 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +271 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +1 -1
- package/dist/model/strategy/adapter/promotion/examples.d.ts +138 -0
- package/dist/model/strategy/adapter/promotion/examples.js +166 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +4 -206
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/model/strategy/adapter/index.d.ts +2 -2
- package/lib/model/strategy/adapter/index.js +4 -3
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +66 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +217 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +2 -2
- package/lib/model/strategy/adapter/promotion/examples.d.ts +138 -0
- package/lib/model/strategy/adapter/promotion/examples.js +192 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +4 -206
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,192 @@
|
|
|
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/promotion/examples.ts
|
|
20
|
+
var examples_exports = {};
|
|
21
|
+
__export(examples_exports, {
|
|
22
|
+
BUY_X_GET_Y_FREE_STRATEGY: () => BUY_X_GET_Y_FREE_STRATEGY,
|
|
23
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(examples_exports);
|
|
26
|
+
var X_ITEMS_FOR_Y_PRICE_STRATEGY = {
|
|
27
|
+
metadata: {
|
|
28
|
+
id: "STRATEGY_001",
|
|
29
|
+
name: {
|
|
30
|
+
en: "2 items for $10",
|
|
31
|
+
"zh-CN": "2杯10元",
|
|
32
|
+
"zh-HK": "2杯10元"
|
|
33
|
+
},
|
|
34
|
+
type: "promotion",
|
|
35
|
+
custom: {
|
|
36
|
+
display: {
|
|
37
|
+
product_card: {
|
|
38
|
+
text: {
|
|
39
|
+
en: "2 for $10",
|
|
40
|
+
"zh-CN": "2杯10元",
|
|
41
|
+
"zh-HK": "2杯10元"
|
|
42
|
+
},
|
|
43
|
+
type: "tag"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
conditions: {
|
|
49
|
+
operator: "and",
|
|
50
|
+
rules: [
|
|
51
|
+
{
|
|
52
|
+
type: "operator",
|
|
53
|
+
field: "currentDateTime",
|
|
54
|
+
value: "2023-01-01 00:00:00",
|
|
55
|
+
operator: ">="
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: "operator",
|
|
59
|
+
field: "currentDateTime",
|
|
60
|
+
value: "2027-01-01 00:00:00",
|
|
61
|
+
operator: "<="
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
type: "operator",
|
|
65
|
+
field: "productIdAndVariantId",
|
|
66
|
+
value: [
|
|
67
|
+
{
|
|
68
|
+
product_id: 60736,
|
|
69
|
+
product_variant_id: 0
|
|
70
|
+
// 0 = 匹配任意变体
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
product_id: 60737,
|
|
74
|
+
product_variant_id: 0
|
|
75
|
+
// 0 = 匹配任意变体
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
operator: "product_match"
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
actionIds: ["1"]
|
|
82
|
+
},
|
|
83
|
+
actions: [
|
|
84
|
+
{
|
|
85
|
+
id: "1",
|
|
86
|
+
type: "X_ITEMS_FOR_Y_PRICE",
|
|
87
|
+
value: {
|
|
88
|
+
x: 2,
|
|
89
|
+
// 每X件
|
|
90
|
+
price: 10
|
|
91
|
+
// 固定价格Y元
|
|
92
|
+
},
|
|
93
|
+
valueType: "object",
|
|
94
|
+
target: "product",
|
|
95
|
+
priority: 1,
|
|
96
|
+
config: {
|
|
97
|
+
allowCrossProduct: true,
|
|
98
|
+
// 允许跨商品组合(A+B可以凑成一组)
|
|
99
|
+
cumulative: true
|
|
100
|
+
// 可累计(买5件 = 2组优惠 + 1件原价)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
};
|
|
105
|
+
var BUY_X_GET_Y_FREE_STRATEGY = {
|
|
106
|
+
metadata: {
|
|
107
|
+
id: "STRATEGY_002",
|
|
108
|
+
name: {
|
|
109
|
+
en: "Buy 1 Get 1 Free",
|
|
110
|
+
"zh-CN": "买1送1",
|
|
111
|
+
"zh-HK": "買1送1"
|
|
112
|
+
},
|
|
113
|
+
type: "promotion",
|
|
114
|
+
custom: {
|
|
115
|
+
display: {
|
|
116
|
+
product_card: {
|
|
117
|
+
text: {
|
|
118
|
+
en: "Buy 1 Get 1",
|
|
119
|
+
"zh-CN": "买1送1",
|
|
120
|
+
"zh-HK": "買1送1"
|
|
121
|
+
},
|
|
122
|
+
type: "tag"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
conditions: {
|
|
128
|
+
operator: "and",
|
|
129
|
+
rules: [
|
|
130
|
+
{
|
|
131
|
+
type: "operator",
|
|
132
|
+
field: "currentDateTime",
|
|
133
|
+
value: "2023-01-01 00:00:00",
|
|
134
|
+
operator: ">="
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
type: "operator",
|
|
138
|
+
field: "currentDateTime",
|
|
139
|
+
value: "2027-01-01 00:00:00",
|
|
140
|
+
operator: "<="
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
type: "operator",
|
|
144
|
+
field: "productIdAndVariantId",
|
|
145
|
+
value: [
|
|
146
|
+
{
|
|
147
|
+
product_id: 60736,
|
|
148
|
+
product_variant_id: 0
|
|
149
|
+
// 0 = 匹配任意变体
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
product_id: 60737,
|
|
153
|
+
product_variant_id: 0
|
|
154
|
+
// 0 = 匹配任意变体
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
operator: "product_match"
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
actionIds: ["1"]
|
|
161
|
+
},
|
|
162
|
+
actions: [
|
|
163
|
+
{
|
|
164
|
+
id: "1",
|
|
165
|
+
type: "BUY_X_GET_Y_FREE",
|
|
166
|
+
value: {
|
|
167
|
+
buyQuantity: 1,
|
|
168
|
+
// 买X件
|
|
169
|
+
freeQuantity: 1
|
|
170
|
+
// 送Y件
|
|
171
|
+
},
|
|
172
|
+
valueType: "object",
|
|
173
|
+
target: "product",
|
|
174
|
+
priority: 1,
|
|
175
|
+
config: {
|
|
176
|
+
// 可累计(买2送2、买3送3...)
|
|
177
|
+
cumulative: true,
|
|
178
|
+
// 可选的赠品列表
|
|
179
|
+
giftProducts: [
|
|
180
|
+
{ product_id: 60757, product_variant_id: 0 },
|
|
181
|
+
{ product_id: 38782, product_variant_id: 0 },
|
|
182
|
+
{ product_id: 60749, product_variant_id: 27267 }
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
};
|
|
188
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
189
|
+
0 && (module.exports = {
|
|
190
|
+
BUY_X_GET_Y_FREE_STRATEGY,
|
|
191
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
192
|
+
});
|
|
@@ -1,206 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
+
});
|
|
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
123
123
|
* 获取当前的客户搜索条件
|
|
124
124
|
* @returns 当前搜索条件
|
|
125
125
|
*/
|
|
126
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
126
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
127
127
|
/**
|
|
128
128
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
129
129
|
* @returns 客户状态
|