@pisell/pisellos 2.1.119 → 2.1.121
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +7 -0
- package/dist/model/strategy/adapter/index.js +7 -0
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +439 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +64 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +315 -0
- package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/dist/model/strategy/adapter/itemRule/index.js +5 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +206 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- 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.d.ts +213 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +1206 -0
- 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 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +447 -0
- package/dist/model/strategy/adapter/promotion/type.js +209 -0
- package/dist/model/strategy/adapter/type.d.ts +28 -0
- package/dist/model/strategy/adapter/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +502 -0
- package/dist/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/dist/model/strategy/adapter/walletPass/example.js +258 -0
- package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/dist/model/strategy/adapter/walletPass/index.js +182 -0
- package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/dist/model/strategy/adapter/walletPass/locales.js +26 -0
- package/dist/model/strategy/adapter/walletPass/type.d.ts +187 -0
- package/dist/model/strategy/adapter/walletPass/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +1104 -0
- package/dist/model/strategy/engine.d.ts +106 -0
- package/dist/model/strategy/engine.js +611 -0
- package/dist/model/strategy/index.d.ts +3 -0
- package/dist/model/strategy/index.js +8 -0
- package/dist/model/strategy/strategy-example.d.ts +5 -0
- package/dist/model/strategy/strategy-example.js +331 -0
- package/dist/model/strategy/type.d.ts +228 -0
- package/dist/model/strategy/type.js +94 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -0
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +58 -1
- package/dist/modules/Order/index.js +796 -29
- package/dist/modules/Order/types.d.ts +144 -12
- package/dist/modules/Order/utils.d.ts +28 -0
- package/dist/modules/Order/utils.js +250 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +48 -0
- package/dist/modules/Quotation/index.js +245 -0
- package/dist/modules/Quotation/types.d.ts +42 -0
- package/dist/modules/Quotation/types.js +1 -0
- package/dist/modules/Rules/index.js +4 -1
- package/dist/modules/SalesSummary/index.d.ts +63 -0
- package/dist/modules/SalesSummary/index.js +174 -0
- package/dist/modules/SalesSummary/types.d.ts +59 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +30 -0
- package/dist/modules/SalesSummary/utils.js +513 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
- package/dist/modules/ScanOrderLogger/index.js +161 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +95 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +46 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
- package/dist/modules/Summary/utils.d.ts +3 -3
- package/dist/modules/Summary/utils.js +4 -4
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.d.ts +90 -0
- package/dist/solution/ScanOrder/index.js +1853 -0
- package/dist/solution/ScanOrder/types.d.ts +210 -0
- package/dist/solution/ScanOrder/types.js +16 -0
- package/dist/solution/ScanOrder/utils.d.ts +93 -0
- package/dist/solution/ScanOrder/utils.js +397 -0
- package/dist/solution/VenueBooking/index.d.ts +163 -0
- package/dist/solution/VenueBooking/index.js +2931 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +130 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +102 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/resource.js +94 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +29 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +203 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +256 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/index.d.ts +1 -0
- package/lib/model/index.js +23 -0
- package/lib/model/strategy/adapter/index.d.ts +7 -0
- package/lib/model/strategy/adapter/index.js +57 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +338 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +64 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +269 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +58 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +206 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- 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.d.ts +213 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +844 -0
- 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 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +447 -0
- package/lib/model/strategy/adapter/promotion/type.js +51 -0
- package/lib/model/strategy/adapter/type.d.ts +28 -0
- package/lib/model/strategy/adapter/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +424 -0
- package/lib/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/lib/model/strategy/adapter/walletPass/example.js +207 -0
- package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/lib/model/strategy/adapter/walletPass/index.js +142 -0
- package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/lib/model/strategy/adapter/walletPass/locales.js +54 -0
- package/lib/model/strategy/adapter/walletPass/type.d.ts +187 -0
- package/lib/model/strategy/adapter/walletPass/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +791 -0
- package/lib/model/strategy/engine.d.ts +106 -0
- package/lib/model/strategy/engine.js +450 -0
- package/lib/model/strategy/index.d.ts +3 -0
- package/lib/model/strategy/index.js +38 -0
- package/lib/model/strategy/strategy-example.d.ts +5 -0
- package/lib/model/strategy/strategy-example.js +318 -0
- package/lib/model/strategy/type.d.ts +228 -0
- package/lib/model/strategy/type.js +44 -0
- package/lib/modules/Cart/utils/cartProduct.js +1 -0
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +58 -1
- package/lib/modules/Order/index.js +437 -1
- package/lib/modules/Order/types.d.ts +144 -12
- package/lib/modules/Order/utils.d.ts +28 -0
- package/lib/modules/Order/utils.js +250 -2
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +48 -0
- package/lib/modules/Quotation/index.js +149 -0
- package/lib/modules/Quotation/types.d.ts +42 -0
- package/lib/modules/Quotation/types.js +17 -0
- package/lib/modules/Rules/index.js +4 -1
- package/lib/modules/SalesSummary/index.d.ts +63 -0
- package/lib/modules/SalesSummary/index.js +105 -0
- package/lib/modules/SalesSummary/types.d.ts +59 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +30 -0
- package/lib/modules/SalesSummary/utils.js +452 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
- package/lib/modules/ScanOrderLogger/index.js +135 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +82 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +46 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
- package/lib/modules/Summary/utils.d.ts +3 -3
- package/lib/modules/Summary/utils.js +4 -4
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.d.ts +90 -0
- package/lib/solution/ScanOrder/index.js +1071 -0
- package/lib/solution/ScanOrder/types.d.ts +210 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +93 -0
- package/lib/solution/ScanOrder/utils.js +359 -0
- package/lib/solution/VenueBooking/index.d.ts +163 -0
- package/lib/solution/VenueBooking/index.js +1578 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +130 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +101 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/resource.js +80 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +29 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +208 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +200 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +5 -1
- package/package.json +1 -1
|
@@ -0,0 +1,318 @@
|
|
|
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/strategy-example.ts
|
|
20
|
+
var strategy_example_exports = {};
|
|
21
|
+
__export(strategy_example_exports, {
|
|
22
|
+
runExamples: () => runExamples
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(strategy_example_exports);
|
|
25
|
+
var import_index = require("./index");
|
|
26
|
+
var voucherConfig = {
|
|
27
|
+
metadata: {
|
|
28
|
+
id: "VOUCHER_10",
|
|
29
|
+
name: "10元代金券",
|
|
30
|
+
type: "wallet_pass",
|
|
31
|
+
calculationType: "single"
|
|
32
|
+
},
|
|
33
|
+
conditions: {
|
|
34
|
+
operator: "and",
|
|
35
|
+
rules: [
|
|
36
|
+
{
|
|
37
|
+
type: "operator",
|
|
38
|
+
dimension: "scope_product",
|
|
39
|
+
field: "productId",
|
|
40
|
+
operator: "in",
|
|
41
|
+
value: [60734, 60735]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: "operator",
|
|
45
|
+
dimension: "scope_channel",
|
|
46
|
+
field: "channel",
|
|
47
|
+
operator: "in",
|
|
48
|
+
value: ["pos", "mini_program"]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: "operator",
|
|
52
|
+
dimension: "transaction",
|
|
53
|
+
field: "applicableProductTotal",
|
|
54
|
+
operator: ">=",
|
|
55
|
+
value: 100
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: "operator",
|
|
59
|
+
dimension: "limit_usage",
|
|
60
|
+
field: "perUserUsedCount",
|
|
61
|
+
operator: "<",
|
|
62
|
+
value: 1
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
actionIds: ["deduct_10"]
|
|
66
|
+
},
|
|
67
|
+
actions: [
|
|
68
|
+
{
|
|
69
|
+
id: "deduct_10",
|
|
70
|
+
type: "DEDUCT_AMOUNT",
|
|
71
|
+
value: 10,
|
|
72
|
+
valueType: "number",
|
|
73
|
+
valueUnit: "元",
|
|
74
|
+
target: "applicable_products",
|
|
75
|
+
priority: 1,
|
|
76
|
+
config: {
|
|
77
|
+
allowCrossProduct: true,
|
|
78
|
+
deductTaxAndFee: true
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
};
|
|
83
|
+
var voucherContext = {
|
|
84
|
+
entities: {
|
|
85
|
+
order: {
|
|
86
|
+
id: "ORDER_001",
|
|
87
|
+
total: 150,
|
|
88
|
+
items: [
|
|
89
|
+
{ productId: 60734, quantity: 2, price: 75 }
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
customer: {
|
|
93
|
+
id: "USER_001",
|
|
94
|
+
level: "vip"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
attributes: {
|
|
98
|
+
productId: 60734,
|
|
99
|
+
channel: "pos",
|
|
100
|
+
applicableProductTotal: 150,
|
|
101
|
+
perUserUsedCount: 0
|
|
102
|
+
},
|
|
103
|
+
metadata: {
|
|
104
|
+
timestamp: Date.now(),
|
|
105
|
+
locale: "zh-CN"
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
var tieredDiscountConfig = {
|
|
109
|
+
metadata: {
|
|
110
|
+
id: "TIERED_DISCOUNT",
|
|
111
|
+
name: "阶梯满减",
|
|
112
|
+
type: "promotion",
|
|
113
|
+
calculationType: "single"
|
|
114
|
+
},
|
|
115
|
+
conditions: {
|
|
116
|
+
operator: "or",
|
|
117
|
+
rules: [
|
|
118
|
+
// 档位1:100-199 减10
|
|
119
|
+
{
|
|
120
|
+
operator: "and",
|
|
121
|
+
rules: [
|
|
122
|
+
{
|
|
123
|
+
type: "operator",
|
|
124
|
+
dimension: "transaction",
|
|
125
|
+
field: "orderTotal",
|
|
126
|
+
operator: ">=",
|
|
127
|
+
value: 100
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
type: "operator",
|
|
131
|
+
dimension: "transaction",
|
|
132
|
+
field: "orderTotal",
|
|
133
|
+
operator: "<",
|
|
134
|
+
value: 200
|
|
135
|
+
}
|
|
136
|
+
],
|
|
137
|
+
actionIds: ["deduct_10"]
|
|
138
|
+
},
|
|
139
|
+
// 档位2:200-299 减25
|
|
140
|
+
{
|
|
141
|
+
operator: "and",
|
|
142
|
+
rules: [
|
|
143
|
+
{
|
|
144
|
+
type: "operator",
|
|
145
|
+
dimension: "transaction",
|
|
146
|
+
field: "orderTotal",
|
|
147
|
+
operator: ">=",
|
|
148
|
+
value: 200
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
type: "operator",
|
|
152
|
+
dimension: "transaction",
|
|
153
|
+
field: "orderTotal",
|
|
154
|
+
operator: "<",
|
|
155
|
+
value: 300
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
actionIds: ["deduct_25"]
|
|
159
|
+
},
|
|
160
|
+
// 档位3:>= 300 减40
|
|
161
|
+
{
|
|
162
|
+
operator: "and",
|
|
163
|
+
rules: [
|
|
164
|
+
{
|
|
165
|
+
type: "operator",
|
|
166
|
+
dimension: "transaction",
|
|
167
|
+
field: "orderTotal",
|
|
168
|
+
operator: ">=",
|
|
169
|
+
value: 300
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
actionIds: ["deduct_40"]
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
actionIds: []
|
|
176
|
+
},
|
|
177
|
+
actions: [
|
|
178
|
+
{
|
|
179
|
+
id: "deduct_10",
|
|
180
|
+
type: "DEDUCT_AMOUNT",
|
|
181
|
+
value: 10,
|
|
182
|
+
target: "order",
|
|
183
|
+
priority: 1
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
id: "deduct_25",
|
|
187
|
+
type: "DEDUCT_AMOUNT",
|
|
188
|
+
value: 25,
|
|
189
|
+
target: "order",
|
|
190
|
+
priority: 2
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
id: "deduct_40",
|
|
194
|
+
type: "DEDUCT_AMOUNT",
|
|
195
|
+
value: 40,
|
|
196
|
+
target: "order",
|
|
197
|
+
priority: 3
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
};
|
|
201
|
+
var tieredContext = {
|
|
202
|
+
entities: {
|
|
203
|
+
order: { id: "ORDER_002", total: 250 }
|
|
204
|
+
},
|
|
205
|
+
attributes: {
|
|
206
|
+
orderTotal: 250
|
|
207
|
+
},
|
|
208
|
+
metadata: {
|
|
209
|
+
timestamp: Date.now()
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
var codeConditionConfig = {
|
|
213
|
+
metadata: {
|
|
214
|
+
id: "CODE_CONDITION_EXAMPLE",
|
|
215
|
+
name: "代码条件示例",
|
|
216
|
+
type: "custom"
|
|
217
|
+
},
|
|
218
|
+
conditions: {
|
|
219
|
+
operator: "and",
|
|
220
|
+
rules: [
|
|
221
|
+
// 使用 code 模式
|
|
222
|
+
{
|
|
223
|
+
type: "code",
|
|
224
|
+
code: 'attributes.orderTotal >= 100 && entities.customer.level === "vip"'
|
|
225
|
+
},
|
|
226
|
+
// 混合使用 operator 模式
|
|
227
|
+
{
|
|
228
|
+
type: "operator",
|
|
229
|
+
field: "productCount",
|
|
230
|
+
operator: ">=",
|
|
231
|
+
value: 2
|
|
232
|
+
}
|
|
233
|
+
],
|
|
234
|
+
actionIds: ["vip_discount"]
|
|
235
|
+
},
|
|
236
|
+
actions: [
|
|
237
|
+
{
|
|
238
|
+
id: "vip_discount",
|
|
239
|
+
type: "DISCOUNT_RATE",
|
|
240
|
+
value: 0.85,
|
|
241
|
+
target: "order",
|
|
242
|
+
priority: 1
|
|
243
|
+
}
|
|
244
|
+
]
|
|
245
|
+
};
|
|
246
|
+
var codeContext = {
|
|
247
|
+
entities: {
|
|
248
|
+
customer: { id: "USER_002", level: "vip" },
|
|
249
|
+
order: { id: "ORDER_003", total: 150 }
|
|
250
|
+
},
|
|
251
|
+
attributes: {
|
|
252
|
+
orderTotal: 150,
|
|
253
|
+
productCount: 3
|
|
254
|
+
},
|
|
255
|
+
metadata: {
|
|
256
|
+
timestamp: Date.now()
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
function runExamples() {
|
|
260
|
+
console.log("====== 策略模型使用示例 ======\n");
|
|
261
|
+
const engine = (0, import_index.createStrategyEngine)({
|
|
262
|
+
debug: true,
|
|
263
|
+
enableTrace: true
|
|
264
|
+
});
|
|
265
|
+
console.log("示例1: 10元代金券");
|
|
266
|
+
const result1 = engine.evaluate(voucherConfig, voucherContext);
|
|
267
|
+
console.log("结果:", JSON.stringify(result1, null, 2));
|
|
268
|
+
console.log("\n");
|
|
269
|
+
console.log("示例2: 阶梯满减(订单金额250)");
|
|
270
|
+
const result2 = engine.evaluate(tieredDiscountConfig, tieredContext);
|
|
271
|
+
console.log("结果:", JSON.stringify(result2, null, 2));
|
|
272
|
+
console.log("\n");
|
|
273
|
+
console.log("示例3: Code 模式条件");
|
|
274
|
+
const result3 = engine.evaluate(codeConditionConfig, codeContext);
|
|
275
|
+
console.log("结果:", JSON.stringify(result3, null, 2));
|
|
276
|
+
console.log("\n");
|
|
277
|
+
console.log("示例4: 快速评估");
|
|
278
|
+
const result4 = (0, import_index.evaluate)(voucherConfig, voucherContext);
|
|
279
|
+
console.log("适用:", result4.applicable);
|
|
280
|
+
console.log("匹配动作数:", result4.matchedActions.length);
|
|
281
|
+
console.log("\n");
|
|
282
|
+
console.log("示例5: 自定义运算符");
|
|
283
|
+
engine.registerOperator("divisible_by", (fieldValue, compareValue) => {
|
|
284
|
+
return Number(fieldValue) % Number(compareValue) === 0;
|
|
285
|
+
});
|
|
286
|
+
const customOperatorConfig = {
|
|
287
|
+
metadata: { id: "CUSTOM_OP", name: "自定义运算符", type: "test" },
|
|
288
|
+
conditions: {
|
|
289
|
+
operator: "and",
|
|
290
|
+
rules: [
|
|
291
|
+
{
|
|
292
|
+
type: "operator",
|
|
293
|
+
field: "amount",
|
|
294
|
+
operator: "divisible_by",
|
|
295
|
+
value: 10
|
|
296
|
+
}
|
|
297
|
+
],
|
|
298
|
+
actionIds: ["bonus"]
|
|
299
|
+
},
|
|
300
|
+
actions: [{ id: "bonus", type: "ADD_POINTS", value: 100, target: "customer" }]
|
|
301
|
+
};
|
|
302
|
+
const customContext = {
|
|
303
|
+
entities: {},
|
|
304
|
+
attributes: { amount: 50 },
|
|
305
|
+
metadata: { timestamp: Date.now() }
|
|
306
|
+
};
|
|
307
|
+
const result5 = engine.evaluate(customOperatorConfig, customContext);
|
|
308
|
+
console.log("结果:", result5.applicable ? "适用" : "不适用");
|
|
309
|
+
console.log("匹配动作:", result5.matchedActions);
|
|
310
|
+
console.log("\n引擎调试信息:", engine.getDebugInfo());
|
|
311
|
+
}
|
|
312
|
+
if (require.main === module) {
|
|
313
|
+
runExamples();
|
|
314
|
+
}
|
|
315
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
316
|
+
0 && (module.exports = {
|
|
317
|
+
runExamples
|
|
318
|
+
});
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 策略配置主结构
|
|
3
|
+
*/
|
|
4
|
+
export interface StrategyConfig<T = Record<string, any>> {
|
|
5
|
+
/** 元信息 */
|
|
6
|
+
metadata: StrategyMetadata<T>;
|
|
7
|
+
/** 条件组(可嵌套,每层可绑定动作) */
|
|
8
|
+
conditions: ConditionGroup;
|
|
9
|
+
/** 动作列表(带唯一ID) */
|
|
10
|
+
actions: ActionEffect[];
|
|
11
|
+
/** 展示配置(可选) */
|
|
12
|
+
display?: DisplayConfig;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 策略元信息
|
|
16
|
+
*/
|
|
17
|
+
export interface StrategyMetadata<T = Record<string, any>> {
|
|
18
|
+
/** 策略ID */
|
|
19
|
+
id: string;
|
|
20
|
+
/** 策略名称 */
|
|
21
|
+
name: string | Record<string, string>;
|
|
22
|
+
/** 策略类型(完全可扩展) */
|
|
23
|
+
type: string;
|
|
24
|
+
/** 计算类型 */
|
|
25
|
+
calculationType?: 'single' | 'cumulative';
|
|
26
|
+
/** 版本 */
|
|
27
|
+
version?: string;
|
|
28
|
+
/** 描述 */
|
|
29
|
+
description?: string | Record<string, string>;
|
|
30
|
+
/** 自定义元数据 */
|
|
31
|
+
custom?: T;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 条件组(支持嵌套)
|
|
35
|
+
*/
|
|
36
|
+
export interface ConditionGroup {
|
|
37
|
+
/** 逻辑运算符 */
|
|
38
|
+
operator: 'and' | 'or' | 'not';
|
|
39
|
+
/** 条件规则列表(可以是单条件或嵌套的条件组) */
|
|
40
|
+
rules: Array<ConditionRule | ConditionGroup>;
|
|
41
|
+
/** 关联的动作ID列表(必填,可以为空数组) */
|
|
42
|
+
actionIds: string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 条件规则(原子条件)
|
|
46
|
+
* 支持 code 模式使用 eval 执行
|
|
47
|
+
*/
|
|
48
|
+
export interface ConditionRule {
|
|
49
|
+
/** 类型 */
|
|
50
|
+
type: 'code' | 'operator';
|
|
51
|
+
/** 代码(code模式使用,使用eval执行) */
|
|
52
|
+
code?: string;
|
|
53
|
+
/** 维度(完全可扩展) */
|
|
54
|
+
dimension?: string;
|
|
55
|
+
/** 字段名 */
|
|
56
|
+
field?: string;
|
|
57
|
+
/** 运算符 */
|
|
58
|
+
operator?: string;
|
|
59
|
+
/** 比较值 */
|
|
60
|
+
value?: any;
|
|
61
|
+
/** 值类型 */
|
|
62
|
+
valueType?: 'number' | 'string' | 'boolean' | 'array' | 'object' | 'date';
|
|
63
|
+
/** 值单位 */
|
|
64
|
+
valueUnit?: string;
|
|
65
|
+
/** 额外配置 */
|
|
66
|
+
config?: Record<string, any>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 动作效果
|
|
70
|
+
*/
|
|
71
|
+
export interface ActionEffect {
|
|
72
|
+
/** 动作的唯一标识 */
|
|
73
|
+
id: string;
|
|
74
|
+
/** 效果类型(完全可扩展) */
|
|
75
|
+
type: string;
|
|
76
|
+
/** 运算符(可选) */
|
|
77
|
+
operator?: string;
|
|
78
|
+
/** 值 */
|
|
79
|
+
value: any;
|
|
80
|
+
/** 值类型 */
|
|
81
|
+
valueType?: 'number' | 'string' | 'boolean' | 'array' | 'object';
|
|
82
|
+
/** 值单位 */
|
|
83
|
+
valueUnit?: string;
|
|
84
|
+
/** 作用目标 */
|
|
85
|
+
target: string;
|
|
86
|
+
/** 优先级(数字越大优先级越高) */
|
|
87
|
+
priority?: number;
|
|
88
|
+
/** 配置(完全可扩展) */
|
|
89
|
+
config?: Record<string, any>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 展示配置
|
|
93
|
+
*/
|
|
94
|
+
export interface DisplayConfig {
|
|
95
|
+
/** 商品卡片展示 */
|
|
96
|
+
productCard?: {
|
|
97
|
+
text: string | Record<string, string>;
|
|
98
|
+
type: 'tag' | 'badge' | 'label';
|
|
99
|
+
image?: string;
|
|
100
|
+
style?: Record<string, any>;
|
|
101
|
+
};
|
|
102
|
+
/** 详情页展示 */
|
|
103
|
+
detail?: {
|
|
104
|
+
title: string | Record<string, string>;
|
|
105
|
+
description: string | Record<string, string>;
|
|
106
|
+
image?: string;
|
|
107
|
+
};
|
|
108
|
+
/** 自定义展示配置 */
|
|
109
|
+
custom?: Record<string, any>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 运行时上下文结构
|
|
113
|
+
*/
|
|
114
|
+
export interface RuntimeContext {
|
|
115
|
+
/** 实体数据(完全开放,由业务层定义) */
|
|
116
|
+
entities: Record<string, any>;
|
|
117
|
+
/** 属性数据(扁平化的计算值,用于条件判断) */
|
|
118
|
+
attributes: Record<string, any>;
|
|
119
|
+
/** 上下文元数据 */
|
|
120
|
+
metadata: ContextMetadata;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* 上下文元数据
|
|
124
|
+
*/
|
|
125
|
+
export interface ContextMetadata {
|
|
126
|
+
/** 请求ID(用于追踪) */
|
|
127
|
+
requestId?: string;
|
|
128
|
+
/** 时间戳 */
|
|
129
|
+
timestamp: number;
|
|
130
|
+
/** 语言 */
|
|
131
|
+
locale?: string;
|
|
132
|
+
/** 自定义元数据 */
|
|
133
|
+
custom?: Record<string, any>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* 评估结果结构
|
|
137
|
+
*/
|
|
138
|
+
export interface EvaluationResult {
|
|
139
|
+
/** 是否成功执行(引擎层面) */
|
|
140
|
+
success: boolean;
|
|
141
|
+
/** 策略是否适用(业务层面) */
|
|
142
|
+
applicable: boolean;
|
|
143
|
+
/** 结果码 */
|
|
144
|
+
code: string;
|
|
145
|
+
/** 消息(多语言key或直接文本) */
|
|
146
|
+
message?: string;
|
|
147
|
+
/** 匹配信息 */
|
|
148
|
+
matched: MatchedInfo;
|
|
149
|
+
/** 匹配的动作列表(按priority排序) */
|
|
150
|
+
matchedActions: ActionEffect[];
|
|
151
|
+
/** 输出结果(完全开放,由适配器定义) */
|
|
152
|
+
outputs: Record<string, any>;
|
|
153
|
+
/** 执行轨迹(可选,用于调试) */
|
|
154
|
+
trace?: ExecutionTrace;
|
|
155
|
+
/** 策略配置 */
|
|
156
|
+
config: StrategyConfig;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* 匹配信息
|
|
160
|
+
*/
|
|
161
|
+
export interface MatchedInfo {
|
|
162
|
+
/** 条件是否满足 */
|
|
163
|
+
conditions: boolean;
|
|
164
|
+
/** 收集到的 actionIds */
|
|
165
|
+
actionIds: string[];
|
|
166
|
+
/** 详细匹配信息 */
|
|
167
|
+
details: Record<string, any>;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 执行轨迹
|
|
171
|
+
*/
|
|
172
|
+
export interface ExecutionTrace {
|
|
173
|
+
/** 执行步骤 */
|
|
174
|
+
steps: TraceStep[];
|
|
175
|
+
/** 总耗时(毫秒) */
|
|
176
|
+
duration: number;
|
|
177
|
+
/** 错误信息 */
|
|
178
|
+
errors?: Array<{
|
|
179
|
+
step: string;
|
|
180
|
+
error: string;
|
|
181
|
+
timestamp: number;
|
|
182
|
+
}>;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* 追踪步骤
|
|
186
|
+
*/
|
|
187
|
+
export interface TraceStep {
|
|
188
|
+
/** 步骤名称 */
|
|
189
|
+
step: string;
|
|
190
|
+
/** 步骤状态 */
|
|
191
|
+
status: 'success' | 'failed' | 'skipped';
|
|
192
|
+
/** 耗时(毫秒) */
|
|
193
|
+
duration: number;
|
|
194
|
+
/** 详细信息 */
|
|
195
|
+
details?: Record<string, any>;
|
|
196
|
+
}
|
|
197
|
+
/** 成功码 */
|
|
198
|
+
export declare const SUCCESS_CODES: {
|
|
199
|
+
readonly SUCCESS: "SUCCESS";
|
|
200
|
+
};
|
|
201
|
+
/** 不适用码 */
|
|
202
|
+
export declare const NOT_APPLICABLE_CODES: {
|
|
203
|
+
readonly CONDITION_NOT_MET: "CONDITION_NOT_MET";
|
|
204
|
+
};
|
|
205
|
+
/** 错误码 */
|
|
206
|
+
export declare const ERROR_CODES: {
|
|
207
|
+
readonly INVALID_CONFIG: "INVALID_CONFIG";
|
|
208
|
+
readonly INVALID_CONTEXT: "INVALID_CONTEXT";
|
|
209
|
+
readonly EVALUATION_ERROR: "EVALUATION_ERROR";
|
|
210
|
+
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* 引擎配置选项
|
|
214
|
+
*/
|
|
215
|
+
export interface EngineOptions {
|
|
216
|
+
/** 是否启用调试模式 */
|
|
217
|
+
debug?: boolean;
|
|
218
|
+
/** 是否启用追踪 */
|
|
219
|
+
enableTrace?: boolean;
|
|
220
|
+
/** 运算符处理器映射 */
|
|
221
|
+
operatorHandlers?: Record<string, OperatorHandler>;
|
|
222
|
+
/** 自定义错误处理器 */
|
|
223
|
+
errorHandler?: (error: Error, context: RuntimeContext) => void;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* 运算符处理器
|
|
227
|
+
*/
|
|
228
|
+
export type OperatorHandler = (fieldValue: any, compareValue: any, rule: ConditionRule) => boolean;
|
|
@@ -0,0 +1,44 @@
|
|
|
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/type.ts
|
|
20
|
+
var type_exports = {};
|
|
21
|
+
__export(type_exports, {
|
|
22
|
+
ERROR_CODES: () => ERROR_CODES,
|
|
23
|
+
NOT_APPLICABLE_CODES: () => NOT_APPLICABLE_CODES,
|
|
24
|
+
SUCCESS_CODES: () => SUCCESS_CODES
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(type_exports);
|
|
27
|
+
var SUCCESS_CODES = {
|
|
28
|
+
SUCCESS: "SUCCESS"
|
|
29
|
+
};
|
|
30
|
+
var NOT_APPLICABLE_CODES = {
|
|
31
|
+
CONDITION_NOT_MET: "CONDITION_NOT_MET"
|
|
32
|
+
};
|
|
33
|
+
var ERROR_CODES = {
|
|
34
|
+
INVALID_CONFIG: "INVALID_CONFIG",
|
|
35
|
+
INVALID_CONTEXT: "INVALID_CONTEXT",
|
|
36
|
+
EVALUATION_ERROR: "EVALUATION_ERROR",
|
|
37
|
+
UNKNOWN_ERROR: "UNKNOWN_ERROR"
|
|
38
|
+
};
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
ERROR_CODES,
|
|
42
|
+
NOT_APPLICABLE_CODES,
|
|
43
|
+
SUCCESS_CODES
|
|
44
|
+
});
|
|
@@ -313,6 +313,7 @@ var formatBundleToOrigin = (bundle) => {
|
|
|
313
313
|
option: formatOptionsToOrigin(getBundleValueByKey("option")),
|
|
314
314
|
discount_list: d.discount_list,
|
|
315
315
|
"bundle_selling_price": d == null ? void 0 : d.price,
|
|
316
|
+
"custom_price": d == null ? void 0 : d.price,
|
|
316
317
|
metadata: {
|
|
317
318
|
custom_product_bundle_map_id: d._id,
|
|
318
319
|
product_discount_difference
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import type { ScheduleModule } from '../Schedule';
|
|
4
|
+
import type { OpenDataConfig, OpenDataFetchParams, OpenDataAvailabilityResult } from './types';
|
|
5
|
+
export * from './types';
|
|
6
|
+
export { computeAvailability } from './utils';
|
|
7
|
+
export declare class OpenDataModule extends BaseModule implements Module {
|
|
8
|
+
protected defaultName: string;
|
|
9
|
+
protected defaultVersion: string;
|
|
10
|
+
private request;
|
|
11
|
+
private window;
|
|
12
|
+
private store;
|
|
13
|
+
private cacheId;
|
|
14
|
+
private openCache;
|
|
15
|
+
private fatherModule;
|
|
16
|
+
private otherParams;
|
|
17
|
+
constructor(name?: string, version?: string);
|
|
18
|
+
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
19
|
+
fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
|
|
20
|
+
getOpenData(): OpenDataConfig | null;
|
|
21
|
+
getLastFetchedAt(): number | null;
|
|
22
|
+
checkAvailability(scheduleModule?: ScheduleModule): OpenDataAvailabilityResult;
|
|
23
|
+
storeChange(): void;
|
|
24
|
+
}
|