@pisell/pisellos 2.1.149 → 2.1.151
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +61 -8
- package/dist/model/strategy/adapter/walletPass/locales.js +12 -3
- package/dist/model/strategy/engine.d.ts +18 -5
- package/dist/model/strategy/engine.js +145 -45
- package/dist/model/strategy/type.d.ts +17 -0
- package/dist/model/strategy/type.js +4 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +56 -25
- package/dist/modules/Discount/types.d.ts +19 -1
- package/dist/modules/Order/index.d.ts +1 -65
- package/dist/modules/Order/index.js +30 -899
- package/dist/modules/Order/types.d.ts +12 -174
- package/dist/modules/Order/types.js +0 -2
- package/dist/modules/Order/utils.d.ts +0 -118
- package/dist/modules/Order/utils.js +2 -586
- package/dist/modules/Payment/index.d.ts +2 -1
- package/dist/modules/Payment/index.js +10 -7
- package/dist/modules/Payment/utils.js +3 -0
- package/dist/modules/Payment/walletpass.d.ts +23 -0
- package/dist/modules/Payment/walletpass.js +191 -95
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +3 -4
- package/dist/modules/Rules/index.d.ts +9 -5
- package/dist/modules/Rules/index.js +677 -168
- package/dist/modules/Rules/types.d.ts +2 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +18 -11
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/types.d.ts +2 -0
- package/dist/modules/Summary/utils.d.ts +9 -3
- package/dist/modules/Summary/utils.js +52 -41
- package/dist/modules/index.d.ts +0 -4
- package/dist/modules/index.js +1 -5
- package/dist/plugins/window.d.ts +2 -0
- package/dist/solution/BookingByStep/index.d.ts +3 -2
- package/dist/solution/BookingByStep/index.js +43 -46
- package/dist/solution/BookingByStep/types.d.ts +1 -3
- package/dist/solution/BookingByStep/types.js +1 -5
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
- package/dist/solution/Checkout/index.js +2 -0
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +23 -7
- package/dist/solution/ShopDiscount/types.d.ts +1 -0
- package/dist/solution/ShopDiscount/types.js +2 -1
- package/dist/solution/ShopDiscount/utils.js +26 -12
- package/dist/solution/index.d.ts +0 -2
- package/dist/solution/index.js +1 -3
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +34 -3
- package/lib/model/strategy/adapter/walletPass/locales.js +12 -3
- package/lib/model/strategy/engine.d.ts +18 -5
- package/lib/model/strategy/engine.js +85 -21
- package/lib/model/strategy/type.d.ts +17 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +39 -12
- package/lib/modules/Discount/types.d.ts +19 -1
- package/lib/modules/Order/index.d.ts +1 -65
- package/lib/modules/Order/index.js +1 -513
- package/lib/modules/Order/types.d.ts +12 -174
- package/lib/modules/Order/utils.d.ts +0 -118
- package/lib/modules/Order/utils.js +2 -483
- package/lib/modules/Payment/index.d.ts +2 -1
- package/lib/modules/Payment/index.js +1 -0
- package/lib/modules/Payment/utils.js +3 -0
- package/lib/modules/Payment/walletpass.d.ts +23 -0
- package/lib/modules/Payment/walletpass.js +94 -17
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +3 -5
- package/lib/modules/Rules/index.d.ts +9 -5
- package/lib/modules/Rules/index.js +780 -288
- package/lib/modules/Rules/types.d.ts +2 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +11 -9
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/types.d.ts +2 -0
- package/lib/modules/Summary/utils.d.ts +9 -3
- package/lib/modules/Summary/utils.js +31 -22
- package/lib/modules/index.d.ts +0 -4
- package/lib/modules/index.js +1 -9
- package/lib/plugins/window.d.ts +2 -0
- package/lib/solution/BookingByStep/index.d.ts +3 -2
- package/lib/solution/BookingByStep/index.js +4 -6
- package/lib/solution/BookingByStep/types.d.ts +1 -3
- package/lib/solution/BookingByStep/types.js +0 -10
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
- package/lib/solution/Checkout/index.js +2 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +22 -8
- package/lib/solution/ShopDiscount/types.d.ts +1 -0
- package/lib/solution/ShopDiscount/utils.js +10 -6
- package/lib/solution/index.d.ts +0 -2
- package/lib/solution/index.js +1 -5
- package/package.json +1 -1
- package/dist/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +0 -1
- package/dist/modules/OpenData/index.d.ts +0 -24
- package/dist/modules/OpenData/index.js +0 -173
- package/dist/modules/OpenData/types.d.ts +0 -73
- package/dist/modules/OpenData/types.js +0 -1
- package/dist/modules/OpenData/utils.d.ts +0 -2
- package/dist/modules/OpenData/utils.js +0 -75
- package/dist/modules/Quotation/index.d.ts +0 -48
- package/dist/modules/Quotation/index.js +0 -248
- package/dist/modules/Quotation/types.d.ts +0 -42
- package/dist/modules/Quotation/types.js +0 -1
- package/dist/modules/SalesSummary/index.d.ts +0 -63
- package/dist/modules/SalesSummary/index.js +0 -174
- package/dist/modules/SalesSummary/types.d.ts +0 -60
- package/dist/modules/SalesSummary/types.js +0 -1
- package/dist/modules/SalesSummary/utils.d.ts +0 -30
- package/dist/modules/SalesSummary/utils.js +0 -480
- package/dist/modules/ScanOrderLogger/index.d.ts +0 -23
- package/dist/modules/ScanOrderLogger/index.js +0 -174
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/providers/feishu.js +0 -221
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
- package/dist/modules/ScanOrderLogger/providers/grafana.js +0 -50
- package/dist/modules/ScanOrderLogger/types.d.ts +0 -53
- package/dist/modules/ScanOrderLogger/types.js +0 -1
- package/dist/solution/ScanOrder/index.d.ts +0 -152
- package/dist/solution/ScanOrder/index.js +0 -3132
- package/dist/solution/ScanOrder/types.d.ts +0 -287
- package/dist/solution/ScanOrder/types.js +0 -35
- package/dist/solution/ScanOrder/utils.d.ts +0 -167
- package/dist/solution/ScanOrder/utils.js +0 -764
- package/dist/solution/VenueBooking/index.d.ts +0 -199
- package/dist/solution/VenueBooking/index.js +0 -3459
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -343
- package/dist/solution/VenueBooking/types.d.ts +0 -154
- package/dist/solution/VenueBooking/types.js +0 -21
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
- package/dist/solution/VenueBooking/utils/dateSummary.js +0 -104
- package/dist/solution/VenueBooking/utils/resource.d.ts +0 -14
- package/dist/solution/VenueBooking/utils/resource.js +0 -131
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -38
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -239
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -32
- package/dist/solution/VenueBooking/utils/timeSlot.js +0 -453
- package/dist/solution/VenueBooking/utils.d.ts +0 -1
- package/dist/solution/VenueBooking/utils.js +0 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/modules/OpenData/index.d.ts +0 -24
- package/lib/modules/OpenData/index.js +0 -119
- package/lib/modules/OpenData/types.d.ts +0 -73
- package/lib/modules/OpenData/types.js +0 -17
- package/lib/modules/OpenData/utils.d.ts +0 -2
- package/lib/modules/OpenData/utils.js +0 -111
- package/lib/modules/Quotation/index.d.ts +0 -48
- package/lib/modules/Quotation/index.js +0 -152
- package/lib/modules/Quotation/types.d.ts +0 -42
- package/lib/modules/Quotation/types.js +0 -17
- package/lib/modules/SalesSummary/index.d.ts +0 -63
- package/lib/modules/SalesSummary/index.js +0 -105
- package/lib/modules/SalesSummary/types.d.ts +0 -60
- package/lib/modules/SalesSummary/types.js +0 -17
- package/lib/modules/SalesSummary/utils.d.ts +0 -30
- package/lib/modules/SalesSummary/utils.js +0 -420
- package/lib/modules/ScanOrderLogger/index.d.ts +0 -23
- package/lib/modules/ScanOrderLogger/index.js +0 -147
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/providers/feishu.js +0 -157
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
- package/lib/modules/ScanOrderLogger/providers/grafana.js +0 -52
- package/lib/modules/ScanOrderLogger/types.d.ts +0 -53
- package/lib/modules/ScanOrderLogger/types.js +0 -17
- package/lib/solution/ScanOrder/index.d.ts +0 -152
- package/lib/solution/ScanOrder/index.js +0 -1901
- package/lib/solution/ScanOrder/types.d.ts +0 -287
- package/lib/solution/ScanOrder/types.js +0 -36
- package/lib/solution/ScanOrder/utils.d.ts +0 -167
- package/lib/solution/ScanOrder/utils.js +0 -635
- package/lib/solution/VenueBooking/index.d.ts +0 -199
- package/lib/solution/VenueBooking/index.js +0 -1926
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -343
- package/lib/solution/VenueBooking/types.d.ts +0 -154
- package/lib/solution/VenueBooking/types.js +0 -44
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
- package/lib/solution/VenueBooking/utils/dateSummary.js +0 -110
- package/lib/solution/VenueBooking/utils/resource.d.ts +0 -14
- package/lib/solution/VenueBooking/utils/resource.js +0 -92
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -38
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -237
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -32
- package/lib/solution/VenueBooking/utils/timeSlot.js +0 -339
- package/lib/solution/VenueBooking/utils.d.ts +0 -1
- package/lib/solution/VenueBooking/utils.js +0 -69
|
@@ -42,7 +42,7 @@ var StrategyEngine = class {
|
|
|
42
42
|
* 评估策略
|
|
43
43
|
*/
|
|
44
44
|
evaluate(config, context) {
|
|
45
|
-
var _a;
|
|
45
|
+
var _a, _b;
|
|
46
46
|
const startTime = Date.now();
|
|
47
47
|
const trace = {
|
|
48
48
|
steps: [],
|
|
@@ -105,7 +105,11 @@ var StrategyEngine = class {
|
|
|
105
105
|
matched: {
|
|
106
106
|
conditions: applicable,
|
|
107
107
|
actionIds: evaluationResult.actionIds,
|
|
108
|
-
details: {}
|
|
108
|
+
details: {},
|
|
109
|
+
...applicable ? {} : {
|
|
110
|
+
failedField: (_a = evaluationResult.failedRules[0]) == null ? void 0 : _a.field,
|
|
111
|
+
failedRules: evaluationResult.failedRules
|
|
112
|
+
}
|
|
109
113
|
},
|
|
110
114
|
matchedActions: sortedActions,
|
|
111
115
|
outputs: {},
|
|
@@ -119,7 +123,7 @@ var StrategyEngine = class {
|
|
|
119
123
|
} catch (error) {
|
|
120
124
|
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
121
125
|
if (this.options.enableTrace) {
|
|
122
|
-
(
|
|
126
|
+
(_b = trace.errors) == null ? void 0 : _b.push({
|
|
123
127
|
step: "evaluation",
|
|
124
128
|
error: errorMessage,
|
|
125
129
|
timestamp: Date.now()
|
|
@@ -149,12 +153,15 @@ var StrategyEngine = class {
|
|
|
149
153
|
*
|
|
150
154
|
* @param group 条件组
|
|
151
155
|
* @param context 运行时上下文
|
|
152
|
-
* @returns
|
|
156
|
+
* @returns 评估结果对象,包含条件是否满足、收集到的 actionIds、以及失败的原子规则信息
|
|
153
157
|
*/
|
|
154
158
|
evaluateConditionGroup(group, context) {
|
|
155
159
|
const collectedActionIds = [];
|
|
156
|
-
const
|
|
157
|
-
|
|
160
|
+
const { satisfied, failedRules } = this.evaluateGroupLogicDetailed(
|
|
161
|
+
group,
|
|
162
|
+
context
|
|
163
|
+
);
|
|
164
|
+
if (satisfied) {
|
|
158
165
|
collectedActionIds.push(...group.actionIds);
|
|
159
166
|
for (const rule of group.rules) {
|
|
160
167
|
if (this.isConditionGroup(rule)) {
|
|
@@ -164,41 +171,98 @@ var StrategyEngine = class {
|
|
|
164
171
|
}
|
|
165
172
|
}
|
|
166
173
|
return {
|
|
167
|
-
satisfied
|
|
168
|
-
actionIds: collectedActionIds
|
|
174
|
+
satisfied,
|
|
175
|
+
actionIds: collectedActionIds,
|
|
176
|
+
failedRules
|
|
169
177
|
};
|
|
170
178
|
}
|
|
171
179
|
/**
|
|
172
|
-
*
|
|
180
|
+
* 评估条件组的逻辑运算(带失败规则收集)
|
|
181
|
+
*
|
|
182
|
+
* 失败规则收集策略:
|
|
183
|
+
* - `and`:返回第一个失败的原子规则(嵌套 group 递归取其首个失败原子规则)
|
|
184
|
+
* - `or`:所有分支失败时,聚合每个分支的失败规则
|
|
185
|
+
* - `not`:被取反规则实际通过时,记录该规则
|
|
173
186
|
*/
|
|
174
|
-
|
|
187
|
+
evaluateGroupLogicDetailed(group, context) {
|
|
175
188
|
const { operator, rules } = group;
|
|
176
189
|
switch (operator) {
|
|
177
|
-
case "and":
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
190
|
+
case "and": {
|
|
191
|
+
for (const rule of rules) {
|
|
192
|
+
const ruleResult = this.evaluateRuleDetailed(rule, context);
|
|
193
|
+
if (!ruleResult.satisfied) {
|
|
194
|
+
return {
|
|
195
|
+
satisfied: false,
|
|
196
|
+
failedRules: ruleResult.failedRules
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return { satisfied: true, failedRules: [] };
|
|
201
|
+
}
|
|
202
|
+
case "or": {
|
|
203
|
+
const aggregated = [];
|
|
204
|
+
for (const rule of rules) {
|
|
205
|
+
const ruleResult = this.evaluateRuleDetailed(rule, context);
|
|
206
|
+
if (ruleResult.satisfied) {
|
|
207
|
+
return { satisfied: true, failedRules: [] };
|
|
208
|
+
}
|
|
209
|
+
aggregated.push(...ruleResult.failedRules);
|
|
210
|
+
}
|
|
211
|
+
return { satisfied: false, failedRules: aggregated };
|
|
212
|
+
}
|
|
213
|
+
case "not": {
|
|
214
|
+
if (rules.length === 0) {
|
|
215
|
+
return { satisfied: false, failedRules: [] };
|
|
216
|
+
}
|
|
217
|
+
const ruleResult = this.evaluateRuleDetailed(rules[0], context);
|
|
218
|
+
if (ruleResult.satisfied) {
|
|
219
|
+
const failed = this.isConditionGroup(rules[0]) ? [] : [this.buildFailedRuleInfo(rules[0], context)];
|
|
220
|
+
return { satisfied: false, failedRules: failed };
|
|
221
|
+
}
|
|
222
|
+
return { satisfied: true, failedRules: [] };
|
|
223
|
+
}
|
|
185
224
|
default:
|
|
186
225
|
throw new Error(`Unknown operator: ${operator}`);
|
|
187
226
|
}
|
|
188
227
|
}
|
|
189
228
|
/**
|
|
190
|
-
*
|
|
229
|
+
* 评估单个规则(带失败规则收集)
|
|
191
230
|
*/
|
|
192
|
-
|
|
231
|
+
evaluateRuleDetailed(rule, context) {
|
|
193
232
|
if (this.isConditionGroup(rule)) {
|
|
194
|
-
return this.
|
|
233
|
+
return this.evaluateGroupLogicDetailed(rule, context);
|
|
195
234
|
}
|
|
196
235
|
const conditionRule = rule;
|
|
236
|
+
const satisfied = this.evaluateAtomicRule(conditionRule, context);
|
|
237
|
+
if (satisfied) {
|
|
238
|
+
return { satisfied: true, failedRules: [] };
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
satisfied: false,
|
|
242
|
+
failedRules: [this.buildFailedRuleInfo(conditionRule, context)]
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* 评估原子规则(不收集失败信息,仅返回布尔结果)
|
|
247
|
+
*/
|
|
248
|
+
evaluateAtomicRule(conditionRule, context) {
|
|
197
249
|
if (conditionRule.type === "code" && conditionRule.code) {
|
|
198
250
|
return this.evaluateCodeCondition(conditionRule.code, context);
|
|
199
251
|
}
|
|
200
252
|
return this.evaluateOperatorCondition(conditionRule, context);
|
|
201
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* 构建失败规则信息
|
|
256
|
+
*/
|
|
257
|
+
buildFailedRuleInfo(conditionRule, context) {
|
|
258
|
+
const actualValue = conditionRule.field ? this.getFieldValue(conditionRule.field, context) : void 0;
|
|
259
|
+
return {
|
|
260
|
+
field: conditionRule.field,
|
|
261
|
+
operator: conditionRule.operator,
|
|
262
|
+
value: conditionRule.value,
|
|
263
|
+
actualValue
|
|
264
|
+
};
|
|
265
|
+
}
|
|
202
266
|
/**
|
|
203
267
|
* 评估代码模式条件
|
|
204
268
|
*/
|
|
@@ -165,6 +165,23 @@ export interface MatchedInfo {
|
|
|
165
165
|
actionIds: string[];
|
|
166
166
|
/** 详细匹配信息 */
|
|
167
167
|
details: Record<string, any>;
|
|
168
|
+
/** 顶层第一个失败的 field(仅在 conditions=false 时存在,便于直接消费) */
|
|
169
|
+
failedField?: string;
|
|
170
|
+
/** 失败的原子规则列表(仅在 conditions=false 时存在;or 全失败时可能有多条) */
|
|
171
|
+
failedRules?: FailedRuleInfo[];
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* 失败规则信息
|
|
175
|
+
*/
|
|
176
|
+
export interface FailedRuleInfo {
|
|
177
|
+
/** 字段名 */
|
|
178
|
+
field?: string;
|
|
179
|
+
/** 运算符 */
|
|
180
|
+
operator?: string;
|
|
181
|
+
/** 配置的比较值(阈值) */
|
|
182
|
+
value?: any;
|
|
183
|
+
/** 实际取到的字段值 */
|
|
184
|
+
actualValue?: any;
|
|
168
185
|
}
|
|
169
186
|
/**
|
|
170
187
|
* 执行轨迹
|
|
@@ -46,6 +46,18 @@ var import_decimal = __toESM(require("decimal.js"));
|
|
|
46
46
|
var import_utils = require("../../Product/utils");
|
|
47
47
|
var import_utils2 = require("../../../solution/ShopDiscount/utils");
|
|
48
48
|
var import_utils3 = require("../../Summary/utils");
|
|
49
|
+
var toDiscountPayload = (discountItem) => {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
return {
|
|
52
|
+
amount: discountItem.amount,
|
|
53
|
+
tag: discountItem.type,
|
|
54
|
+
par_value: (_a = discountItem.discount) == null ? void 0 : _a.percent,
|
|
55
|
+
config: discountItem.config,
|
|
56
|
+
metadata: {
|
|
57
|
+
discount_card_type: (_b = discountItem == null ? void 0 : discountItem.discount) == null ? void 0 : _b.discount_card_type
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
};
|
|
49
61
|
var handleVariantProduct = (product) => {
|
|
50
62
|
var _a;
|
|
51
63
|
if (product == null ? void 0 : product.product_variant_id) {
|
|
@@ -90,6 +102,14 @@ var formatProductToCartItem = (params) => {
|
|
|
90
102
|
num,
|
|
91
103
|
discounts
|
|
92
104
|
});
|
|
105
|
+
const origin_total = getProductTotalPrice({
|
|
106
|
+
product: cartItem._productInit || cartItem._productOrigin,
|
|
107
|
+
bundle,
|
|
108
|
+
options,
|
|
109
|
+
num,
|
|
110
|
+
discounts: []
|
|
111
|
+
});
|
|
112
|
+
cartItem.summaryOriginTotal = (origin_total || 0) * (num || 1);
|
|
93
113
|
cartItem.image = product == null ? void 0 : product.cover;
|
|
94
114
|
cartItem.like_status = "common";
|
|
95
115
|
cartItem.duration = product == null ? void 0 : product.duration;
|
|
@@ -184,17 +204,24 @@ var formatProductToCartItemOrigin = (params) => {
|
|
|
184
204
|
var getProductTotalPrice = (params) => {
|
|
185
205
|
const { product, bundle, options, discounts } = params;
|
|
186
206
|
let price = Number(product.price);
|
|
207
|
+
const optionRows = (options == null ? void 0 : options.map((currentValue) => ({
|
|
208
|
+
unit: Number(currentValue.price ?? currentValue.add_price ?? 0),
|
|
209
|
+
num: Number(currentValue.num ?? currentValue.quantity ?? 1)
|
|
210
|
+
}))) ?? [];
|
|
187
211
|
if (discounts == null ? void 0 : discounts.length) {
|
|
188
212
|
discounts.forEach((currentValue) => {
|
|
189
213
|
var _a;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
214
|
+
const payload = toDiscountPayload(currentValue);
|
|
215
|
+
price = (0, import_utils2.getDiscountAmount)(payload, price, price);
|
|
216
|
+
if (((_a = currentValue == null ? void 0 : currentValue.config) == null ? void 0 : _a.deductOptionPrice) && optionRows.length) {
|
|
217
|
+
for (let i = 0; i < optionRows.length; i++) {
|
|
218
|
+
const row = optionRows[i];
|
|
219
|
+
optionRows[i] = {
|
|
220
|
+
...row,
|
|
221
|
+
unit: (0, import_utils2.getDiscountAmount)(payload, row.unit, row.unit)
|
|
222
|
+
};
|
|
196
223
|
}
|
|
197
|
-
}
|
|
224
|
+
}
|
|
198
225
|
});
|
|
199
226
|
}
|
|
200
227
|
if (bundle == null ? void 0 : bundle.length) {
|
|
@@ -202,10 +229,11 @@ var getProductTotalPrice = (params) => {
|
|
|
202
229
|
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
203
230
|
}, price);
|
|
204
231
|
}
|
|
205
|
-
if (
|
|
206
|
-
price =
|
|
207
|
-
|
|
208
|
-
|
|
232
|
+
if (optionRows.length) {
|
|
233
|
+
price = optionRows.reduce(
|
|
234
|
+
(accumulator, row) => accumulator + row.unit * row.num,
|
|
235
|
+
price
|
|
236
|
+
);
|
|
209
237
|
}
|
|
210
238
|
return Math.max(0, price);
|
|
211
239
|
};
|
|
@@ -313,7 +341,6 @@ var formatBundleToOrigin = (bundle) => {
|
|
|
313
341
|
option: formatOptionsToOrigin(getBundleValueByKey("option")),
|
|
314
342
|
discount_list: d.discount_list,
|
|
315
343
|
"bundle_selling_price": d == null ? void 0 : d.price,
|
|
316
|
-
// "custom_price": d?.price,
|
|
317
344
|
metadata: {
|
|
318
345
|
custom_product_bundle_map_id: d._id,
|
|
319
346
|
product_discount_difference
|
|
@@ -19,7 +19,7 @@ interface PackageSubItemUsageRules {
|
|
|
19
19
|
type: 'universal_discount' | 'package_exclusive' | 'single_item_promo' | 'custom_usage_rules';
|
|
20
20
|
rules: ("original_price" | "markup_price")[];
|
|
21
21
|
package_scope?: {
|
|
22
|
-
type: 'all_packages' | 'specific_packages'
|
|
22
|
+
type: 'all_packages' | 'specific_packages';
|
|
23
23
|
exclude_bundle_product_ids: number[];
|
|
24
24
|
include_bundle_product_ids: number[];
|
|
25
25
|
filter: 0 | 1;
|
|
@@ -33,6 +33,8 @@ interface Limitedrelationproductdata {
|
|
|
33
33
|
product_ids: number[];
|
|
34
34
|
product_collection_id: number[];
|
|
35
35
|
package_sub_item_usage_rules?: PackageSubItemUsageRules;
|
|
36
|
+
filter: 0 | 1;
|
|
37
|
+
exclude_product_ids: number[];
|
|
36
38
|
}
|
|
37
39
|
interface ApplicableProductDetails {
|
|
38
40
|
amount: string;
|
|
@@ -89,6 +91,7 @@ export interface Discount {
|
|
|
89
91
|
balance: string;
|
|
90
92
|
format_title: Formattitle;
|
|
91
93
|
metadata?: {
|
|
94
|
+
num?: number;
|
|
92
95
|
discount_card_type?: 'fixed_amount' | 'percent';
|
|
93
96
|
custom_product_bundle_map_id?: string;
|
|
94
97
|
validity_type?: "custom_schedule_validity" | "fixed_validity";
|
|
@@ -113,6 +116,21 @@ export interface Discount {
|
|
|
113
116
|
isSelected?: boolean;
|
|
114
117
|
isAvailable?: boolean;
|
|
115
118
|
isUsed?: boolean;
|
|
119
|
+
config?: {
|
|
120
|
+
isAvailable?: boolean;
|
|
121
|
+
/** 最大抵扣金额 */
|
|
122
|
+
maxDeductionAmount?: number;
|
|
123
|
+
/** 每单最多使用张数 */
|
|
124
|
+
maxUsagePerOrder?: number;
|
|
125
|
+
/** 是否抵扣税费与附加费 */
|
|
126
|
+
deductTaxAndFee?: boolean;
|
|
127
|
+
/** 适用粒度(多商品共用) */
|
|
128
|
+
allowCrossProduct?: boolean;
|
|
129
|
+
/** 可用商品数量上限 */
|
|
130
|
+
applicableProductLimit?: number;
|
|
131
|
+
/** 是否抵扣单规格价格 (Option Price) */
|
|
132
|
+
deductOptionPrice?: boolean;
|
|
133
|
+
};
|
|
116
134
|
applicableProductIds?: number[];
|
|
117
135
|
applicableProductDetails: ApplicableProductDetails[];
|
|
118
136
|
appliedProductDetails: ApplicableProductDetails[];
|
|
@@ -1,26 +1,13 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { OrderModuleAPI, CommitOrderParams,
|
|
3
|
+
import { OrderModuleAPI, CommitOrderParams, CheckoutOrderParams } from './types';
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
|
-
import { type SubmitPayloadEnhancer } from './utils';
|
|
6
|
-
import type { ScanOrderOrderProduct, ScanOrderOrderProductIdentity, ScanOrderSummary, ScanOrderTempOrder } from '../../solution/ScanOrder/types';
|
|
7
|
-
import type { Discount } from '../Discount/types';
|
|
8
|
-
import { UnavailableReason } from '../Rules/types';
|
|
9
5
|
export declare class OrderModule extends BaseModule implements Module, OrderModuleAPI {
|
|
10
6
|
protected defaultName: string;
|
|
11
7
|
protected defaultVersion: string;
|
|
12
8
|
private store;
|
|
13
9
|
private request;
|
|
14
10
|
private logger;
|
|
15
|
-
private window;
|
|
16
|
-
private cacheId;
|
|
17
|
-
private salesSummaryModuleName;
|
|
18
|
-
private rulesHooksOverride?;
|
|
19
|
-
/**
|
|
20
|
-
* Populate `savedAmount` on each discount based on product-level discount details.
|
|
21
|
-
* Only selected discounts get a non-zero value.
|
|
22
|
-
*/
|
|
23
|
-
static populateSavedAmounts(productList: Array<Record<string, any>>, discountList: Array<Record<string, any>>): void;
|
|
24
11
|
constructor(name?: string, version?: string);
|
|
25
12
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
26
13
|
/**
|
|
@@ -35,52 +22,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
35
22
|
* 记录错误日志
|
|
36
23
|
*/
|
|
37
24
|
private logError;
|
|
38
|
-
private registerDiscountModules;
|
|
39
|
-
private createDefaultRulesHooks;
|
|
40
|
-
loadDiscountConfig(params: {
|
|
41
|
-
customerId: number;
|
|
42
|
-
action?: 'create';
|
|
43
|
-
}): Promise<void>;
|
|
44
|
-
getDiscountList(): Discount[];
|
|
45
|
-
scanCode(code: string, customerId?: number): Promise<{
|
|
46
|
-
isAvailable: boolean;
|
|
47
|
-
discountList: Discount[];
|
|
48
|
-
type: 'server' | 'clientCalc';
|
|
49
|
-
unavailableReason?: UnavailableReason;
|
|
50
|
-
}>;
|
|
51
|
-
applyDiscount(): void;
|
|
52
|
-
initTempOrder(params: {
|
|
53
|
-
cacheId?: string;
|
|
54
|
-
salesSummaryModuleName?: string;
|
|
55
|
-
}): void;
|
|
56
|
-
private getTempOrderStorageKey;
|
|
57
|
-
private restoreTempOrderFromStorage;
|
|
58
|
-
persistTempOrder(): void;
|
|
59
|
-
private createDefaultTempOrderInstance;
|
|
60
|
-
ensureTempOrder(): ScanOrderTempOrder;
|
|
61
|
-
restoreOrder(): ScanOrderTempOrder;
|
|
62
|
-
getTempOrder(): ScanOrderTempOrder | null;
|
|
63
|
-
addNewOrder(): Promise<ScanOrderTempOrder>;
|
|
64
|
-
getOrderProducts(): ScanOrderOrderProduct[];
|
|
65
|
-
private getSalesSummary;
|
|
66
|
-
recalculateSummary(options?: {
|
|
67
|
-
createIfMissing?: boolean;
|
|
68
|
-
}): Promise<ScanOrderSummary | null>;
|
|
69
|
-
getScanOrderSummary(): Promise<ScanOrderSummary>;
|
|
70
|
-
updateTempOrderNote(note: string): string;
|
|
71
|
-
updateTempOrderBuzzer(buzzer: string): string;
|
|
72
|
-
updateTempOrderContactsInfo(contactsInfo: any[]): any[];
|
|
73
|
-
addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
|
|
74
|
-
updateProductInOrder(params: UpdateProductInOrderParams): Promise<ScanOrderOrderProduct[]>;
|
|
75
|
-
removeProductFromOrder(identity: ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
|
|
76
|
-
submitTempOrder<T = any>(params?: {
|
|
77
|
-
cacheId?: string;
|
|
78
|
-
platform?: string;
|
|
79
|
-
businessCode?: string;
|
|
80
|
-
channel?: string;
|
|
81
|
-
type?: string;
|
|
82
|
-
enhancePayload?: SubmitPayloadEnhancer;
|
|
83
|
-
}): Promise<T>;
|
|
84
25
|
createOrder(params: CommitOrderParams['query']): {
|
|
85
26
|
type: "virtual" | "appointment_booking";
|
|
86
27
|
platform: string;
|
|
@@ -110,9 +51,4 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
110
51
|
* @returns 后端返回的订单数据(包含订单ID等)
|
|
111
52
|
*/
|
|
112
53
|
createOrderByCheckout(params: CheckoutOrderParams): Promise<any>;
|
|
113
|
-
submitScanOrder<T = any>(params: SubmitScanOrderParams): Promise<T>;
|
|
114
|
-
scanOrderMore<T = any>(params: ScanOrderMoreParams): Promise<T>;
|
|
115
|
-
getOrderInfoByRemote(order_id: number): Promise<any>;
|
|
116
|
-
getLastOrderInfo(): Record<string, any> | undefined;
|
|
117
54
|
}
|
|
118
|
-
export type { UpdateProductInOrderParams } from './types';
|