@pisell/pisellos 2.2.141 → 2.2.143
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/walletPass/evaluator.js +33 -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/server/index.js +2 -1
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/order/types.d.ts +21 -1
- package/dist/server/modules/order/types.js +4 -0
- package/dist/server/modules/order/utils/filterOrders.js +209 -4
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/model/strategy/adapter/walletPass/evaluator.js +22 -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/server/index.js +2 -1
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/order/types.d.ts +21 -1
- package/lib/server/modules/order/utils/filterOrders.js +207 -4
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -24,6 +24,25 @@ var defaultStrategyMetadataCustom = {
|
|
|
24
24
|
deductOptionPrice: false
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* 条件 field → reasonCode 映射
|
|
29
|
+
* 用于将策略引擎返回的 failedField 转换为本地化文案 key
|
|
30
|
+
*/
|
|
31
|
+
var FIELD_REASON_CODE_MAP = {
|
|
32
|
+
orderTotalAmount: 'order_total_amount_not_enough',
|
|
33
|
+
applicableProductTotalAmount: 'applicable_product_total_amount_not_enough',
|
|
34
|
+
applicableProductCount: 'applicable_product_count_not_enough'
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 用阈值替换文案中的占位符(同时兼容 ${value} 和 {value})
|
|
39
|
+
*/
|
|
40
|
+
function formatReason(template, value) {
|
|
41
|
+
if (!template) return template;
|
|
42
|
+
var replacement = value === undefined || value === null ? '' : String(value);
|
|
43
|
+
return template.replace(/\$\{value\}/g, replacement).replace(/\{value\}/g, replacement);
|
|
44
|
+
}
|
|
45
|
+
|
|
27
46
|
/**
|
|
28
47
|
* Wallet Pass 评估器
|
|
29
48
|
* 用于评估哪些 voucher 可以在当前订单中使用
|
|
@@ -191,13 +210,17 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
|
|
|
191
210
|
strategyResult: evaluationResult
|
|
192
211
|
});
|
|
193
212
|
} else {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
213
|
+
var _evaluationResult$mat, _evaluationResult$mat2;
|
|
214
|
+
// 优先根据失败的 field 映射到具体的 reasonCode(更精确的失败原因)
|
|
215
|
+
var reasonCode = 'not_meet_the_required_conditions';
|
|
216
|
+
var thresholdValue = undefined;
|
|
217
|
+
var failedField = (_evaluationResult$mat = evaluationResult.matched) === null || _evaluationResult$mat === void 0 ? void 0 : _evaluationResult$mat.failedField;
|
|
218
|
+
var failedRule = (_evaluationResult$mat2 = evaluationResult.matched) === null || _evaluationResult$mat2 === void 0 || (_evaluationResult$mat2 = _evaluationResult$mat2.failedRules) === null || _evaluationResult$mat2 === void 0 ? void 0 : _evaluationResult$mat2[0];
|
|
219
|
+
if (failedField && FIELD_REASON_CODE_MAP[failedField]) {
|
|
220
|
+
reasonCode = FIELD_REASON_CODE_MAP[failedField];
|
|
221
|
+
thresholdValue = failedRule === null || failedRule === void 0 ? void 0 : failedRule.value;
|
|
222
|
+
} else if (evaluationResult.code) {
|
|
223
|
+
// 兜底:保留原有 code → reasonCode 映射
|
|
201
224
|
var codeMapping = {
|
|
202
225
|
INSUFFICIENT_AMOUNT: 'not_meet_the_required_conditions',
|
|
203
226
|
USAGE_LIMIT_EXCEEDED: 'usage_limit_reached',
|
|
@@ -207,6 +230,8 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
|
|
|
207
230
|
};
|
|
208
231
|
reasonCode = codeMapping[evaluationResult.code] || 'not_meet_the_required_conditions';
|
|
209
232
|
}
|
|
233
|
+
var rawText = this.getText(reasonCode);
|
|
234
|
+
var reason = thresholdValue !== undefined ? formatReason(rawText, thresholdValue) : rawText;
|
|
210
235
|
results.push({
|
|
211
236
|
voucher: voucher,
|
|
212
237
|
isApplicable: false,
|
|
@@ -214,7 +239,7 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
|
|
|
214
239
|
maxDeduction: 0,
|
|
215
240
|
deductTaxAndFee: false,
|
|
216
241
|
applicableProductIds: [],
|
|
217
|
-
reason:
|
|
242
|
+
reason: reason,
|
|
218
243
|
reasonCode: reasonCode,
|
|
219
244
|
strategyResult: evaluationResult
|
|
220
245
|
});
|
|
@@ -5,7 +5,10 @@ export var locales = {
|
|
|
5
5
|
'usage_limit_reached': '已达到使用次数上限',
|
|
6
6
|
'max_passes_per_item_reached': '该商品已达到卡券使用上限',
|
|
7
7
|
'not_available_for_this_channel': '当前渠道不可使用',
|
|
8
|
-
'not_valid_for_this_order_type': '当前订单类型不适用'
|
|
8
|
+
'not_valid_for_this_order_type': '当前订单类型不适用',
|
|
9
|
+
'order_total_amount_not_enough': '订单满 ${value} 才可用',
|
|
10
|
+
'applicable_product_total_amount_not_enough': '适用商品满 ${value} 才可用',
|
|
11
|
+
'applicable_product_count_not_enough': '至少购买 {value} 件适用商品才可用'
|
|
9
12
|
},
|
|
10
13
|
'en': {
|
|
11
14
|
'not_meet_the_required_conditions': 'Not meet the required conditions.',
|
|
@@ -13,7 +16,10 @@ export var locales = {
|
|
|
13
16
|
'usage_limit_reached': 'Usage limit reached.',
|
|
14
17
|
'max_passes_per_item_reached': 'Max passes per item reached.',
|
|
15
18
|
'not_available_for_this_channel': 'Not available for this channel.',
|
|
16
|
-
'not_valid_for_this_order_type': 'Not valid for this order type.'
|
|
19
|
+
'not_valid_for_this_order_type': 'Not valid for this order type.',
|
|
20
|
+
'order_total_amount_not_enough': 'Spend ${value} to use',
|
|
21
|
+
'applicable_product_total_amount_not_enough': '${value} on eligible items',
|
|
22
|
+
'applicable_product_count_not_enough': 'Buy {value} eligible items to use'
|
|
17
23
|
},
|
|
18
24
|
'zh-HK': {
|
|
19
25
|
'not_meet_the_required_conditions': '未達使用條件',
|
|
@@ -21,6 +27,9 @@ export var locales = {
|
|
|
21
27
|
'usage_limit_reached': '已達使用次數上限',
|
|
22
28
|
'max_passes_per_item_reached': '該商品已達卡券使用上限',
|
|
23
29
|
'not_available_for_this_channel': '當前渠道不可使用',
|
|
24
|
-
'not_valid_for_this_order_type': '當前訂單類型不適用'
|
|
30
|
+
'not_valid_for_this_order_type': '當前訂單類型不適用',
|
|
31
|
+
'order_total_amount_not_enough': '訂單滿 ${value} 才可用',
|
|
32
|
+
'applicable_product_total_amount_not_enough': '適用商品滿 ${value} 才可用',
|
|
33
|
+
'applicable_product_count_not_enough': '至少購買 {value} 件適用商品才可用'
|
|
25
34
|
}
|
|
26
35
|
};
|
|
@@ -27,17 +27,30 @@ export declare class StrategyEngine {
|
|
|
27
27
|
*
|
|
28
28
|
* @param group 条件组
|
|
29
29
|
* @param context 运行时上下文
|
|
30
|
-
* @returns
|
|
30
|
+
* @returns 评估结果对象,包含条件是否满足、收集到的 actionIds、以及失败的原子规则信息
|
|
31
31
|
*/
|
|
32
32
|
private evaluateConditionGroup;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* 评估条件组的逻辑运算(带失败规则收集)
|
|
35
|
+
*
|
|
36
|
+
* 失败规则收集策略:
|
|
37
|
+
* - `and`:返回第一个失败的原子规则(嵌套 group 递归取其首个失败原子规则)
|
|
38
|
+
* - `or`:所有分支失败时,聚合每个分支的失败规则
|
|
39
|
+
* - `not`:被取反规则实际通过时,记录该规则
|
|
40
|
+
*/
|
|
41
|
+
private evaluateGroupLogicDetailed;
|
|
42
|
+
/**
|
|
43
|
+
* 评估单个规则(带失败规则收集)
|
|
44
|
+
*/
|
|
45
|
+
private evaluateRuleDetailed;
|
|
46
|
+
/**
|
|
47
|
+
* 评估原子规则(不收集失败信息,仅返回布尔结果)
|
|
35
48
|
*/
|
|
36
|
-
private
|
|
49
|
+
private evaluateAtomicRule;
|
|
37
50
|
/**
|
|
38
|
-
*
|
|
51
|
+
* 构建失败规则信息
|
|
39
52
|
*/
|
|
40
|
-
private
|
|
53
|
+
private buildFailedRuleInfo;
|
|
41
54
|
/**
|
|
42
55
|
* 评估代码模式条件
|
|
43
56
|
*/
|
|
@@ -6,6 +6,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
6
6
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
7
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
8
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
11
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
10
12
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
11
13
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -68,6 +70,7 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
68
70
|
errors: []
|
|
69
71
|
};
|
|
70
72
|
try {
|
|
73
|
+
var _evaluationResult$fai;
|
|
71
74
|
// 验证配置
|
|
72
75
|
this.validateConfig(config);
|
|
73
76
|
if (this.options.enableTrace) {
|
|
@@ -125,11 +128,14 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
125
128
|
applicable: applicable,
|
|
126
129
|
code: applicable ? SUCCESS_CODES.SUCCESS : NOT_APPLICABLE_CODES.CONDITION_NOT_MET,
|
|
127
130
|
message: applicable ? 'Strategy is applicable' : 'Conditions not met',
|
|
128
|
-
matched: {
|
|
131
|
+
matched: _objectSpread({
|
|
129
132
|
conditions: applicable,
|
|
130
133
|
actionIds: evaluationResult.actionIds,
|
|
131
134
|
details: {}
|
|
132
|
-
},
|
|
135
|
+
}, applicable ? {} : {
|
|
136
|
+
failedField: (_evaluationResult$fai = evaluationResult.failedRules[0]) === null || _evaluationResult$fai === void 0 ? void 0 : _evaluationResult$fai.field,
|
|
137
|
+
failedRules: evaluationResult.failedRules
|
|
138
|
+
}),
|
|
133
139
|
matchedActions: sortedActions,
|
|
134
140
|
outputs: {},
|
|
135
141
|
config: config
|
|
@@ -174,19 +180,18 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
174
180
|
*
|
|
175
181
|
* @param group 条件组
|
|
176
182
|
* @param context 运行时上下文
|
|
177
|
-
* @returns
|
|
183
|
+
* @returns 评估结果对象,包含条件是否满足、收集到的 actionIds、以及失败的原子规则信息
|
|
178
184
|
*/
|
|
179
185
|
}, {
|
|
180
186
|
key: "evaluateConditionGroup",
|
|
181
187
|
value: function evaluateConditionGroup(group, context) {
|
|
182
188
|
var collectedActionIds = [];
|
|
183
189
|
|
|
184
|
-
// 评估当前层的 operator 和 rules
|
|
185
|
-
var
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (
|
|
189
|
-
// 收集当前层的 actionIds
|
|
190
|
+
// 评估当前层的 operator 和 rules(同时收集失败信息)
|
|
191
|
+
var _this$evaluateGroupLo = this.evaluateGroupLogicDetailed(group, context),
|
|
192
|
+
satisfied = _this$evaluateGroupLo.satisfied,
|
|
193
|
+
failedRules = _this$evaluateGroupLo.failedRules;
|
|
194
|
+
if (satisfied) {
|
|
190
195
|
collectedActionIds.push.apply(collectedActionIds, _toConsumableArray(group.actionIds));
|
|
191
196
|
|
|
192
197
|
// 递归评估嵌套的 ConditionGroup,收集嵌套层的 actionIds
|
|
@@ -207,54 +212,134 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
207
212
|
}
|
|
208
213
|
}
|
|
209
214
|
return {
|
|
210
|
-
satisfied:
|
|
211
|
-
actionIds: collectedActionIds
|
|
215
|
+
satisfied: satisfied,
|
|
216
|
+
actionIds: collectedActionIds,
|
|
217
|
+
failedRules: failedRules
|
|
212
218
|
};
|
|
213
219
|
}
|
|
214
220
|
|
|
215
221
|
/**
|
|
216
|
-
*
|
|
222
|
+
* 评估条件组的逻辑运算(带失败规则收集)
|
|
223
|
+
*
|
|
224
|
+
* 失败规则收集策略:
|
|
225
|
+
* - `and`:返回第一个失败的原子规则(嵌套 group 递归取其首个失败原子规则)
|
|
226
|
+
* - `or`:所有分支失败时,聚合每个分支的失败规则
|
|
227
|
+
* - `not`:被取反规则实际通过时,记录该规则
|
|
217
228
|
*/
|
|
218
229
|
}, {
|
|
219
|
-
key: "
|
|
220
|
-
value: function
|
|
221
|
-
var _this = this;
|
|
230
|
+
key: "evaluateGroupLogicDetailed",
|
|
231
|
+
value: function evaluateGroupLogicDetailed(group, context) {
|
|
222
232
|
var operator = group.operator,
|
|
223
233
|
rules = group.rules;
|
|
224
234
|
switch (operator) {
|
|
225
235
|
case 'and':
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
236
|
+
{
|
|
237
|
+
var _iterator2 = _createForOfIteratorHelper(rules),
|
|
238
|
+
_step2;
|
|
239
|
+
try {
|
|
240
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
241
|
+
var rule = _step2.value;
|
|
242
|
+
var ruleResult = this.evaluateRuleDetailed(rule, context);
|
|
243
|
+
if (!ruleResult.satisfied) {
|
|
244
|
+
return {
|
|
245
|
+
satisfied: false,
|
|
246
|
+
failedRules: ruleResult.failedRules
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
} catch (err) {
|
|
251
|
+
_iterator2.e(err);
|
|
252
|
+
} finally {
|
|
253
|
+
_iterator2.f();
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
satisfied: true,
|
|
257
|
+
failedRules: []
|
|
258
|
+
};
|
|
259
|
+
}
|
|
230
260
|
case 'or':
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
261
|
+
{
|
|
262
|
+
var aggregated = [];
|
|
263
|
+
var _iterator3 = _createForOfIteratorHelper(rules),
|
|
264
|
+
_step3;
|
|
265
|
+
try {
|
|
266
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
267
|
+
var _rule = _step3.value;
|
|
268
|
+
var _ruleResult = this.evaluateRuleDetailed(_rule, context);
|
|
269
|
+
if (_ruleResult.satisfied) {
|
|
270
|
+
return {
|
|
271
|
+
satisfied: true,
|
|
272
|
+
failedRules: []
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
aggregated.push.apply(aggregated, _toConsumableArray(_ruleResult.failedRules));
|
|
276
|
+
}
|
|
277
|
+
} catch (err) {
|
|
278
|
+
_iterator3.e(err);
|
|
279
|
+
} finally {
|
|
280
|
+
_iterator3.f();
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
satisfied: false,
|
|
284
|
+
failedRules: aggregated
|
|
285
|
+
};
|
|
286
|
+
}
|
|
235
287
|
case 'not':
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
288
|
+
{
|
|
289
|
+
if (rules.length === 0) {
|
|
290
|
+
return {
|
|
291
|
+
satisfied: false,
|
|
292
|
+
failedRules: []
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
var _ruleResult2 = this.evaluateRuleDetailed(rules[0], context);
|
|
296
|
+
if (_ruleResult2.satisfied) {
|
|
297
|
+
// 被取反规则实际通过,导致 not 失败
|
|
298
|
+
var failed = this.isConditionGroup(rules[0]) ? [] : [this.buildFailedRuleInfo(rules[0], context)];
|
|
299
|
+
return {
|
|
300
|
+
satisfied: false,
|
|
301
|
+
failedRules: failed
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
return {
|
|
305
|
+
satisfied: true,
|
|
306
|
+
failedRules: []
|
|
307
|
+
};
|
|
308
|
+
}
|
|
239
309
|
default:
|
|
240
310
|
throw new Error("Unknown operator: ".concat(operator));
|
|
241
311
|
}
|
|
242
312
|
}
|
|
243
313
|
|
|
244
314
|
/**
|
|
245
|
-
*
|
|
315
|
+
* 评估单个规则(带失败规则收集)
|
|
246
316
|
*/
|
|
247
317
|
}, {
|
|
248
|
-
key: "
|
|
249
|
-
value: function
|
|
250
|
-
// 如果是嵌套的条件组,递归评估
|
|
318
|
+
key: "evaluateRuleDetailed",
|
|
319
|
+
value: function evaluateRuleDetailed(rule, context) {
|
|
251
320
|
if (this.isConditionGroup(rule)) {
|
|
252
|
-
return this.
|
|
321
|
+
return this.evaluateGroupLogicDetailed(rule, context);
|
|
253
322
|
}
|
|
254
|
-
|
|
255
|
-
// 原子条件规则
|
|
256
323
|
var conditionRule = rule;
|
|
324
|
+
var satisfied = this.evaluateAtomicRule(conditionRule, context);
|
|
325
|
+
if (satisfied) {
|
|
326
|
+
return {
|
|
327
|
+
satisfied: true,
|
|
328
|
+
failedRules: []
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
return {
|
|
332
|
+
satisfied: false,
|
|
333
|
+
failedRules: [this.buildFailedRuleInfo(conditionRule, context)]
|
|
334
|
+
};
|
|
335
|
+
}
|
|
257
336
|
|
|
337
|
+
/**
|
|
338
|
+
* 评估原子规则(不收集失败信息,仅返回布尔结果)
|
|
339
|
+
*/
|
|
340
|
+
}, {
|
|
341
|
+
key: "evaluateAtomicRule",
|
|
342
|
+
value: function evaluateAtomicRule(conditionRule, context) {
|
|
258
343
|
// Code 模式:使用 eval 执行
|
|
259
344
|
if (conditionRule.type === 'code' && conditionRule.code) {
|
|
260
345
|
return this.evaluateCodeCondition(conditionRule.code, context);
|
|
@@ -264,6 +349,21 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
264
349
|
return this.evaluateOperatorCondition(conditionRule, context);
|
|
265
350
|
}
|
|
266
351
|
|
|
352
|
+
/**
|
|
353
|
+
* 构建失败规则信息
|
|
354
|
+
*/
|
|
355
|
+
}, {
|
|
356
|
+
key: "buildFailedRuleInfo",
|
|
357
|
+
value: function buildFailedRuleInfo(conditionRule, context) {
|
|
358
|
+
var actualValue = conditionRule.field ? this.getFieldValue(conditionRule.field, context) : undefined;
|
|
359
|
+
return {
|
|
360
|
+
field: conditionRule.field,
|
|
361
|
+
operator: conditionRule.operator,
|
|
362
|
+
value: conditionRule.value,
|
|
363
|
+
actualValue: actualValue
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
|
|
267
367
|
/**
|
|
268
368
|
* 评估代码模式条件
|
|
269
369
|
*/
|
|
@@ -323,11 +423,11 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
323
423
|
// 支持点号路径,如 "order.total"
|
|
324
424
|
var path = field.split('.');
|
|
325
425
|
var value = context.attributes;
|
|
326
|
-
var
|
|
327
|
-
|
|
426
|
+
var _iterator4 = _createForOfIteratorHelper(path),
|
|
427
|
+
_step4;
|
|
328
428
|
try {
|
|
329
|
-
for (
|
|
330
|
-
var key =
|
|
429
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
430
|
+
var key = _step4.value;
|
|
331
431
|
if (value && _typeof(value) === 'object' && key in value) {
|
|
332
432
|
value = value[key];
|
|
333
433
|
} else {
|
|
@@ -335,9 +435,9 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
335
435
|
}
|
|
336
436
|
}
|
|
337
437
|
} catch (err) {
|
|
338
|
-
|
|
438
|
+
_iterator4.e(err);
|
|
339
439
|
} finally {
|
|
340
|
-
|
|
440
|
+
_iterator4.f();
|
|
341
441
|
}
|
|
342
442
|
return value;
|
|
343
443
|
}
|
|
@@ -437,11 +537,11 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
437
537
|
var actionMap = new Map(actions.map(function (action) {
|
|
438
538
|
return [action.id, action];
|
|
439
539
|
}));
|
|
440
|
-
var
|
|
441
|
-
|
|
540
|
+
var _iterator5 = _createForOfIteratorHelper(actionIds),
|
|
541
|
+
_step5;
|
|
442
542
|
try {
|
|
443
|
-
for (
|
|
444
|
-
var id =
|
|
543
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
544
|
+
var id = _step5.value;
|
|
445
545
|
var action = actionMap.get(id);
|
|
446
546
|
if (action) {
|
|
447
547
|
matchedActions.push(action);
|
|
@@ -453,9 +553,9 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
453
553
|
}
|
|
454
554
|
}
|
|
455
555
|
} catch (err) {
|
|
456
|
-
|
|
556
|
+
_iterator5.e(err);
|
|
457
557
|
} finally {
|
|
458
|
-
|
|
558
|
+
_iterator5.f();
|
|
459
559
|
}
|
|
460
560
|
return matchedActions;
|
|
461
561
|
}
|
|
@@ -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
|
* 执行轨迹
|
package/dist/server/index.js
CHANGED
|
@@ -2665,7 +2665,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
2665
2665
|
rawCount: rawList.length,
|
|
2666
2666
|
filteredCount: result.count,
|
|
2667
2667
|
size: result.size,
|
|
2668
|
-
skip: result.skip
|
|
2668
|
+
skip: result.skip,
|
|
2669
|
+
rejected: result.rejected
|
|
2669
2670
|
});
|
|
2670
2671
|
return _context23.abrupt("return", {
|
|
2671
2672
|
code: 200,
|
|
@@ -14,7 +14,7 @@ export { QuotationHooks } from './quotation/types';
|
|
|
14
14
|
export { ScheduleModuleEx } from './schedule';
|
|
15
15
|
export type { ScheduleState, ScheduleItem } from './schedule/types';
|
|
16
16
|
export { OrderModule } from './order';
|
|
17
|
-
export type { OrderState, OrderData, OrderId, OrderSummary, OrderBookingItem, OrderProductLineItem, OrderPaymentItem, OrderSurchargeItem, OrderProductDiscountItem, OrderWithoutBookings, BookingData, OrderFilters, BookingFilters, OrderFilterResult, BookingFilterResult, OrderModulePagedResult, } from './order/types';
|
|
17
|
+
export type { OrderState, OrderData, OrderId, OrderSummary, OrderBookingItem, OrderProductLineItem, OrderPaymentItem, OrderSurchargeItem, OrderProductDiscountItem, OrderWithoutBookings, BookingData, OrderFilters, BookingFilters, OrderFilterResult, OrderFilterRejectDetail, OrderFilterRejectedEntry, BookingFilterResult, OrderModulePagedResult, } from './order/types';
|
|
18
18
|
export { OrderHooks } from './order/types';
|
|
19
19
|
export { FloorPlanModule } from './floor-plan';
|
|
20
20
|
export type { FloorPlanItem, FloorPlanState, FloorPlanSyncMessage } from './floor-plan/types';
|
|
@@ -479,7 +479,27 @@ export interface OrderModulePagedResult<T> {
|
|
|
479
479
|
size: number;
|
|
480
480
|
skip: number;
|
|
481
481
|
}
|
|
482
|
-
|
|
482
|
+
/** 单条筛选未命中说明(用于排查过滤原因) */
|
|
483
|
+
export interface OrderFilterRejectDetail {
|
|
484
|
+
/** 对应 OrderFilters 维度的标识 */
|
|
485
|
+
field: string;
|
|
486
|
+
/** 订单上该维度的当前值 */
|
|
487
|
+
actual: unknown;
|
|
488
|
+
/** 本次筛选的期望值/区间(便于对照) */
|
|
489
|
+
expected?: unknown;
|
|
490
|
+
}
|
|
491
|
+
/** 未通过筛选的订单及首个未满足条件(与过滤短路顺序一致) */
|
|
492
|
+
export interface OrderFilterRejectedEntry {
|
|
493
|
+
order_id?: OrderId | null;
|
|
494
|
+
/** 系统订单号等,便于与业务「订单号」对照 */
|
|
495
|
+
order_number?: string;
|
|
496
|
+
/** 按筛选顺序命中的第一条未满足条件 */
|
|
497
|
+
reason: OrderFilterRejectDetail;
|
|
498
|
+
}
|
|
499
|
+
export type OrderFilterResult = OrderModulePagedResult<OrderData> & {
|
|
500
|
+
/** 被过滤掉的订单及首个命中原因(与筛选短路顺序一致;不含仅分页未展示的已通过订单) */
|
|
501
|
+
rejected: OrderFilterRejectedEntry[];
|
|
502
|
+
};
|
|
483
503
|
export type BookingFilterResult = OrderModulePagedResult<BookingData>;
|
|
484
504
|
/**
|
|
485
505
|
* SSE 同步配置
|