@pisell/pisellos 2.1.151 → 2.1.152
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/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/model/strategy/adapter/promotion/evaluator.js +26 -99
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +8 -61
- package/dist/model/strategy/adapter/walletPass/locales.js +3 -12
- package/dist/model/strategy/engine.d.ts +5 -18
- package/dist/model/strategy/engine.js +45 -145
- package/dist/model/strategy/type.d.ts +0 -17
- package/dist/model/strategy/type.js +0 -4
- package/dist/modules/Cart/types.d.ts +0 -2
- package/dist/modules/Cart/utils/cartProduct.js +25 -56
- package/dist/modules/Discount/index.d.ts +9 -3
- package/dist/modules/Discount/index.js +103 -11
- package/dist/modules/Discount/types.d.ts +8 -19
- 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 +66 -1
- package/dist/modules/Order/index.js +906 -30
- package/dist/modules/Order/types.d.ts +174 -12
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +118 -0
- package/dist/modules/Order/utils.js +586 -2
- package/dist/modules/Payment/index.d.ts +1 -2
- package/dist/modules/Payment/index.js +7 -10
- package/dist/modules/Payment/utils.js +0 -3
- package/dist/modules/Payment/walletpass.d.ts +0 -23
- package/dist/modules/Payment/walletpass.js +95 -191
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -3
- package/dist/modules/Quotation/index.d.ts +48 -0
- package/dist/modules/Quotation/index.js +248 -0
- package/dist/modules/Quotation/types.d.ts +42 -0
- package/dist/modules/Quotation/types.js +1 -0
- package/dist/modules/Rules/index.d.ts +5 -9
- package/dist/modules/Rules/index.js +168 -677
- package/dist/modules/Rules/types.d.ts +0 -2
- package/dist/modules/SalesSummary/index.d.ts +63 -0
- package/dist/modules/SalesSummary/index.js +174 -0
- package/dist/modules/SalesSummary/types.d.ts +60 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +30 -0
- package/dist/modules/SalesSummary/utils.js +480 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +23 -0
- package/dist/modules/ScanOrderLogger/index.js +174 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +221 -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 +53 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/types.d.ts +0 -2
- package/dist/modules/Summary/utils.d.ts +3 -9
- package/dist/modules/Summary/utils.js +41 -52
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/plugins/window.d.ts +0 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -2
- package/dist/solution/BookingByStep/index.js +46 -43
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/Checkout/index.js +0 -2
- package/dist/solution/ScanOrder/index.d.ts +152 -0
- package/dist/solution/ScanOrder/index.js +3132 -0
- package/dist/solution/ScanOrder/types.d.ts +287 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +167 -0
- package/dist/solution/ScanOrder/utils.js +764 -0
- package/dist/solution/ShopDiscount/index.d.ts +3 -2
- package/dist/solution/ShopDiscount/index.js +60 -59
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/types.js +1 -2
- package/dist/solution/ShopDiscount/utils.js +12 -26
- package/dist/solution/VenueBooking/index.d.ts +200 -0
- package/dist/solution/VenueBooking/index.js +3459 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +154 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +131 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +239 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -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/index.d.ts +0 -1
- package/lib/index.js +1 -3
- package/lib/model/strategy/adapter/promotion/evaluator.js +8 -57
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +3 -34
- package/lib/model/strategy/adapter/walletPass/locales.js +3 -12
- package/lib/model/strategy/engine.d.ts +5 -18
- package/lib/model/strategy/engine.js +21 -85
- package/lib/model/strategy/type.d.ts +0 -17
- package/lib/modules/Cart/types.d.ts +0 -2
- package/lib/modules/Cart/utils/cartProduct.js +12 -39
- package/lib/modules/Discount/index.d.ts +9 -3
- package/lib/modules/Discount/index.js +65 -4
- package/lib/modules/Discount/types.d.ts +8 -19
- 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 +66 -1
- package/lib/modules/Order/index.js +515 -1
- package/lib/modules/Order/types.d.ts +174 -12
- package/lib/modules/Order/utils.d.ts +118 -0
- package/lib/modules/Order/utils.js +483 -2
- package/lib/modules/Payment/index.d.ts +1 -2
- package/lib/modules/Payment/index.js +0 -1
- package/lib/modules/Payment/utils.js +0 -3
- package/lib/modules/Payment/walletpass.d.ts +0 -23
- package/lib/modules/Payment/walletpass.js +17 -94
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +5 -3
- package/lib/modules/Quotation/index.d.ts +48 -0
- package/lib/modules/Quotation/index.js +152 -0
- package/lib/modules/Quotation/types.d.ts +42 -0
- package/lib/modules/Quotation/types.js +17 -0
- package/lib/modules/Rules/index.d.ts +5 -9
- package/lib/modules/Rules/index.js +288 -780
- package/lib/modules/Rules/types.d.ts +0 -2
- package/lib/modules/SalesSummary/index.d.ts +63 -0
- package/lib/modules/SalesSummary/index.js +105 -0
- package/lib/modules/SalesSummary/types.d.ts +60 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +30 -0
- package/lib/modules/SalesSummary/utils.js +420 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +23 -0
- package/lib/modules/ScanOrderLogger/index.js +147 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +157 -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 +53 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/types.d.ts +0 -2
- package/lib/modules/Summary/utils.d.ts +3 -9
- package/lib/modules/Summary/utils.js +22 -31
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/plugins/window.d.ts +0 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -2
- package/lib/solution/BookingByStep/index.js +6 -4
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/Checkout/index.js +0 -2
- package/lib/solution/ScanOrder/index.d.ts +152 -0
- package/lib/solution/ScanOrder/index.js +1901 -0
- package/lib/solution/ScanOrder/types.d.ts +287 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +167 -0
- package/lib/solution/ScanOrder/utils.js +635 -0
- package/lib/solution/ShopDiscount/index.d.ts +3 -2
- package/lib/solution/ShopDiscount/index.js +19 -25
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.js +6 -10
- package/lib/solution/VenueBooking/index.d.ts +200 -0
- package/lib/solution/VenueBooking/index.js +1926 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +154 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +92 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +237 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -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
|
@@ -6,8 +6,6 @@ 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; }
|
|
11
9
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
10
|
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); } }
|
|
13
11
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -70,7 +68,6 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
70
68
|
errors: []
|
|
71
69
|
};
|
|
72
70
|
try {
|
|
73
|
-
var _evaluationResult$fai;
|
|
74
71
|
// 验证配置
|
|
75
72
|
this.validateConfig(config);
|
|
76
73
|
if (this.options.enableTrace) {
|
|
@@ -128,14 +125,11 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
128
125
|
applicable: applicable,
|
|
129
126
|
code: applicable ? SUCCESS_CODES.SUCCESS : NOT_APPLICABLE_CODES.CONDITION_NOT_MET,
|
|
130
127
|
message: applicable ? 'Strategy is applicable' : 'Conditions not met',
|
|
131
|
-
matched:
|
|
128
|
+
matched: {
|
|
132
129
|
conditions: applicable,
|
|
133
130
|
actionIds: evaluationResult.actionIds,
|
|
134
131
|
details: {}
|
|
135
|
-
},
|
|
136
|
-
failedField: (_evaluationResult$fai = evaluationResult.failedRules[0]) === null || _evaluationResult$fai === void 0 ? void 0 : _evaluationResult$fai.field,
|
|
137
|
-
failedRules: evaluationResult.failedRules
|
|
138
|
-
}),
|
|
132
|
+
},
|
|
139
133
|
matchedActions: sortedActions,
|
|
140
134
|
outputs: {},
|
|
141
135
|
config: config
|
|
@@ -180,18 +174,19 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
180
174
|
*
|
|
181
175
|
* @param group 条件组
|
|
182
176
|
* @param context 运行时上下文
|
|
183
|
-
* @returns
|
|
177
|
+
* @returns 评估结果对象,包含条件是否满足和收集到的 actionIds
|
|
184
178
|
*/
|
|
185
179
|
}, {
|
|
186
180
|
key: "evaluateConditionGroup",
|
|
187
181
|
value: function evaluateConditionGroup(group, context) {
|
|
188
182
|
var collectedActionIds = [];
|
|
189
183
|
|
|
190
|
-
// 评估当前层的 operator 和 rules
|
|
191
|
-
var
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (
|
|
184
|
+
// 评估当前层的 operator 和 rules
|
|
185
|
+
var isCurrentLayerSatisfied = this.evaluateGroupLogic(group, context);
|
|
186
|
+
|
|
187
|
+
// 如果当前层条件满足
|
|
188
|
+
if (isCurrentLayerSatisfied) {
|
|
189
|
+
// 收集当前层的 actionIds
|
|
195
190
|
collectedActionIds.push.apply(collectedActionIds, _toConsumableArray(group.actionIds));
|
|
196
191
|
|
|
197
192
|
// 递归评估嵌套的 ConditionGroup,收集嵌套层的 actionIds
|
|
@@ -212,134 +207,54 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
212
207
|
}
|
|
213
208
|
}
|
|
214
209
|
return {
|
|
215
|
-
satisfied:
|
|
216
|
-
actionIds: collectedActionIds
|
|
217
|
-
failedRules: failedRules
|
|
210
|
+
satisfied: isCurrentLayerSatisfied,
|
|
211
|
+
actionIds: collectedActionIds
|
|
218
212
|
};
|
|
219
213
|
}
|
|
220
214
|
|
|
221
215
|
/**
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* 失败规则收集策略:
|
|
225
|
-
* - `and`:返回第一个失败的原子规则(嵌套 group 递归取其首个失败原子规则)
|
|
226
|
-
* - `or`:所有分支失败时,聚合每个分支的失败规则
|
|
227
|
-
* - `not`:被取反规则实际通过时,记录该规则
|
|
216
|
+
* 评估条件组的逻辑运算
|
|
228
217
|
*/
|
|
229
218
|
}, {
|
|
230
|
-
key: "
|
|
231
|
-
value: function
|
|
219
|
+
key: "evaluateGroupLogic",
|
|
220
|
+
value: function evaluateGroupLogic(group, context) {
|
|
221
|
+
var _this = this;
|
|
232
222
|
var operator = group.operator,
|
|
233
223
|
rules = group.rules;
|
|
234
224
|
switch (operator) {
|
|
235
225
|
case 'and':
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
}
|
|
226
|
+
// 所有规则都必须满足
|
|
227
|
+
return rules.every(function (rule) {
|
|
228
|
+
return _this.evaluateRule(rule, context);
|
|
229
|
+
});
|
|
260
230
|
case 'or':
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
-
}
|
|
231
|
+
// 任一规则满足即可
|
|
232
|
+
return rules.some(function (rule) {
|
|
233
|
+
return _this.evaluateRule(rule, context);
|
|
234
|
+
});
|
|
287
235
|
case 'not':
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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
|
-
}
|
|
236
|
+
// 对第一个规则取反
|
|
237
|
+
if (rules.length === 0) return false;
|
|
238
|
+
return !this.evaluateRule(rules[0], context);
|
|
309
239
|
default:
|
|
310
240
|
throw new Error("Unknown operator: ".concat(operator));
|
|
311
241
|
}
|
|
312
242
|
}
|
|
313
243
|
|
|
314
244
|
/**
|
|
315
|
-
*
|
|
245
|
+
* 评估单个规则
|
|
316
246
|
*/
|
|
317
247
|
}, {
|
|
318
|
-
key: "
|
|
319
|
-
value: function
|
|
248
|
+
key: "evaluateRule",
|
|
249
|
+
value: function evaluateRule(rule, context) {
|
|
250
|
+
// 如果是嵌套的条件组,递归评估
|
|
320
251
|
if (this.isConditionGroup(rule)) {
|
|
321
|
-
return this.
|
|
252
|
+
return this.evaluateGroupLogic(rule, context);
|
|
322
253
|
}
|
|
254
|
+
|
|
255
|
+
// 原子条件规则
|
|
323
256
|
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
|
-
}
|
|
336
257
|
|
|
337
|
-
/**
|
|
338
|
-
* 评估原子规则(不收集失败信息,仅返回布尔结果)
|
|
339
|
-
*/
|
|
340
|
-
}, {
|
|
341
|
-
key: "evaluateAtomicRule",
|
|
342
|
-
value: function evaluateAtomicRule(conditionRule, context) {
|
|
343
258
|
// Code 模式:使用 eval 执行
|
|
344
259
|
if (conditionRule.type === 'code' && conditionRule.code) {
|
|
345
260
|
return this.evaluateCodeCondition(conditionRule.code, context);
|
|
@@ -349,21 +264,6 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
349
264
|
return this.evaluateOperatorCondition(conditionRule, context);
|
|
350
265
|
}
|
|
351
266
|
|
|
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
|
-
|
|
367
267
|
/**
|
|
368
268
|
* 评估代码模式条件
|
|
369
269
|
*/
|
|
@@ -423,11 +323,11 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
423
323
|
// 支持点号路径,如 "order.total"
|
|
424
324
|
var path = field.split('.');
|
|
425
325
|
var value = context.attributes;
|
|
426
|
-
var
|
|
427
|
-
|
|
326
|
+
var _iterator2 = _createForOfIteratorHelper(path),
|
|
327
|
+
_step2;
|
|
428
328
|
try {
|
|
429
|
-
for (
|
|
430
|
-
var key =
|
|
329
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
330
|
+
var key = _step2.value;
|
|
431
331
|
if (value && _typeof(value) === 'object' && key in value) {
|
|
432
332
|
value = value[key];
|
|
433
333
|
} else {
|
|
@@ -435,9 +335,9 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
435
335
|
}
|
|
436
336
|
}
|
|
437
337
|
} catch (err) {
|
|
438
|
-
|
|
338
|
+
_iterator2.e(err);
|
|
439
339
|
} finally {
|
|
440
|
-
|
|
340
|
+
_iterator2.f();
|
|
441
341
|
}
|
|
442
342
|
return value;
|
|
443
343
|
}
|
|
@@ -537,11 +437,11 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
537
437
|
var actionMap = new Map(actions.map(function (action) {
|
|
538
438
|
return [action.id, action];
|
|
539
439
|
}));
|
|
540
|
-
var
|
|
541
|
-
|
|
440
|
+
var _iterator3 = _createForOfIteratorHelper(actionIds),
|
|
441
|
+
_step3;
|
|
542
442
|
try {
|
|
543
|
-
for (
|
|
544
|
-
var id =
|
|
443
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
444
|
+
var id = _step3.value;
|
|
545
445
|
var action = actionMap.get(id);
|
|
546
446
|
if (action) {
|
|
547
447
|
matchedActions.push(action);
|
|
@@ -553,9 +453,9 @@ export var StrategyEngine = /*#__PURE__*/function () {
|
|
|
553
453
|
}
|
|
554
454
|
}
|
|
555
455
|
} catch (err) {
|
|
556
|
-
|
|
456
|
+
_iterator3.e(err);
|
|
557
457
|
} finally {
|
|
558
|
-
|
|
458
|
+
_iterator3.f();
|
|
559
459
|
}
|
|
560
460
|
return matchedActions;
|
|
561
461
|
}
|
|
@@ -165,23 +165,6 @@ 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;
|
|
185
168
|
}
|
|
186
169
|
/**
|
|
187
170
|
* 执行轨迹
|
|
@@ -15,20 +15,6 @@ import { isNormalProduct } from "../../Product/utils";
|
|
|
15
15
|
import { getDiscountAmount } from "../../../solution/ShopDiscount/utils";
|
|
16
16
|
import { calcDiscountListDifference } from "../../Summary/utils";
|
|
17
17
|
|
|
18
|
-
/** 与 Rules / ShopDiscount 一致的折扣入参,用于主价与 option 单价 */
|
|
19
|
-
var toDiscountPayload = function toDiscountPayload(discountItem) {
|
|
20
|
-
var _discountItem$discoun, _discountItem$discoun2;
|
|
21
|
-
return {
|
|
22
|
-
amount: discountItem.amount,
|
|
23
|
-
tag: discountItem.type,
|
|
24
|
-
par_value: (_discountItem$discoun = discountItem.discount) === null || _discountItem$discoun === void 0 ? void 0 : _discountItem$discoun.percent,
|
|
25
|
-
config: discountItem.config,
|
|
26
|
-
metadata: {
|
|
27
|
-
discount_card_type: discountItem === null || discountItem === void 0 || (_discountItem$discoun2 = discountItem.discount) === null || _discountItem$discoun2 === void 0 ? void 0 : _discountItem$discoun2.discount_card_type
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
|
|
32
18
|
/**
|
|
33
19
|
* @title 处理组合商品
|
|
34
20
|
* @description 组合商品需要直接修改 product 里的价格和 is_charge_tax
|
|
@@ -72,7 +58,6 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
|
|
|
72
58
|
quantity = _params$quantity === void 0 ? 1 : _params$quantity,
|
|
73
59
|
discounts = params.discounts;
|
|
74
60
|
var num = quantity; // 当前按照单个商品加入购物车
|
|
75
|
-
|
|
76
61
|
if (product) {
|
|
77
62
|
cartItem.id = product === null || product === void 0 ? void 0 : product.id;
|
|
78
63
|
cartItem.name = product === null || product === void 0 ? void 0 : product.title;
|
|
@@ -98,15 +83,6 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
|
|
|
98
83
|
num: num,
|
|
99
84
|
discounts: discounts
|
|
100
85
|
});
|
|
101
|
-
// 不包含折扣卡商品券的总价
|
|
102
|
-
var origin_total = getProductTotalPrice({
|
|
103
|
-
product: cartItem._productInit || cartItem._productOrigin,
|
|
104
|
-
bundle: bundle,
|
|
105
|
-
options: options,
|
|
106
|
-
num: num,
|
|
107
|
-
discounts: []
|
|
108
|
-
});
|
|
109
|
-
cartItem.summaryOriginTotal = (origin_total || 0) * (num || 1);
|
|
110
86
|
cartItem.image = product === null || product === void 0 ? void 0 : product.cover;
|
|
111
87
|
cartItem.like_status = 'common';
|
|
112
88
|
cartItem.duration = product === null || product === void 0 ? void 0 : product.duration;
|
|
@@ -209,7 +185,6 @@ export var formatProductToCartItemOrigin = function formatProductToCartItemOrigi
|
|
|
209
185
|
* @returns 商品总价
|
|
210
186
|
*/
|
|
211
187
|
export var getProductTotalPrice = function getProductTotalPrice(params) {
|
|
212
|
-
var _options$map;
|
|
213
188
|
var product = params.product,
|
|
214
189
|
bundle = params.bundle,
|
|
215
190
|
options = params.options,
|
|
@@ -217,29 +192,22 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
|
|
|
217
192
|
// const num = params.num || 1;
|
|
218
193
|
var price = Number(product.price);
|
|
219
194
|
|
|
220
|
-
// option 行:unit 折后价在循环中与主商品使用同一套 getDiscountAmount(含 deductOptionPrice)
|
|
221
|
-
var optionRows = (_options$map = options === null || options === void 0 ? void 0 : options.map(function (currentValue) {
|
|
222
|
-
var _ref, _currentValue$price, _ref2, _currentValue$num;
|
|
223
|
-
return {
|
|
224
|
-
unit: Number((_ref = (_currentValue$price = currentValue.price) !== null && _currentValue$price !== void 0 ? _currentValue$price : currentValue.add_price) !== null && _ref !== void 0 ? _ref : 0),
|
|
225
|
-
num: Number((_ref2 = (_currentValue$num = currentValue.num) !== null && _currentValue$num !== void 0 ? _currentValue$num : currentValue.quantity) !== null && _ref2 !== void 0 ? _ref2 : 1)
|
|
226
|
-
};
|
|
227
|
-
})) !== null && _options$map !== void 0 ? _options$map : [];
|
|
228
|
-
|
|
229
195
|
// 如果商品有折扣,则计算折扣
|
|
230
196
|
if (discounts !== null && discounts !== void 0 && discounts.length) {
|
|
231
197
|
discounts.forEach(function (currentValue) {
|
|
232
|
-
var _currentValue$
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (currentValue
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
198
|
+
var _currentValue$discoun;
|
|
199
|
+
// 不是商品券则代表折扣卡,计算打折后的价格
|
|
200
|
+
// 一个商品折扣卡只能存在于一张
|
|
201
|
+
// if (currentValue.type !== 'good_pass') {
|
|
202
|
+
price = getDiscountAmount({
|
|
203
|
+
amount: currentValue.amount,
|
|
204
|
+
tag: currentValue.type,
|
|
205
|
+
par_value: currentValue.discount.percent,
|
|
206
|
+
metadata: {
|
|
207
|
+
discount_card_type: currentValue === null || currentValue === void 0 || (_currentValue$discoun = currentValue.discount) === null || _currentValue$discoun === void 0 ? void 0 : _currentValue$discoun.discount_card_type
|
|
241
208
|
}
|
|
242
|
-
}
|
|
209
|
+
}, price, price);
|
|
210
|
+
// }
|
|
243
211
|
});
|
|
244
212
|
}
|
|
245
213
|
if (bundle !== null && bundle !== void 0 && bundle.length) {
|
|
@@ -248,10 +216,10 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
|
|
|
248
216
|
}, price);
|
|
249
217
|
}
|
|
250
218
|
|
|
251
|
-
// 单规格
|
|
252
|
-
if (
|
|
253
|
-
price =
|
|
254
|
-
return accumulator +
|
|
219
|
+
// 单规格
|
|
220
|
+
if (options !== null && options !== void 0 && options.length) {
|
|
221
|
+
price = options.reduce(function (accumulator, currentValue) {
|
|
222
|
+
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
255
223
|
}, price);
|
|
256
224
|
}
|
|
257
225
|
return Math.max(0, price);
|
|
@@ -382,6 +350,7 @@ export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
|
|
|
382
350
|
option: formatOptionsToOrigin(getBundleValueByKey('option')),
|
|
383
351
|
discount_list: d.discount_list,
|
|
384
352
|
"bundle_selling_price": d === null || d === void 0 ? void 0 : d.price,
|
|
353
|
+
// "custom_price": d?.price,
|
|
385
354
|
metadata: {
|
|
386
355
|
custom_product_bundle_map_id: d._id,
|
|
387
356
|
product_discount_difference: product_discount_difference
|
|
@@ -410,11 +379,11 @@ export var getProductDeposit = function getProductDeposit(params) {
|
|
|
410
379
|
// 判定商品是否有定金规则
|
|
411
380
|
if ((product === null || product === void 0 || (_product$custom_depos2 = product.custom_deposit_data) === null || _product$custom_depos2 === void 0 ? void 0 : _product$custom_depos2.has_deposit) == 1) {
|
|
412
381
|
var total = new Decimal(0);
|
|
413
|
-
var
|
|
414
|
-
deposit_fixed =
|
|
415
|
-
deposit_percentage =
|
|
416
|
-
deposit_policy_data =
|
|
417
|
-
self_deposit_policy_ids =
|
|
382
|
+
var _ref = (product === null || product === void 0 ? void 0 : product.custom_deposit_data) || {},
|
|
383
|
+
deposit_fixed = _ref.deposit_fixed,
|
|
384
|
+
deposit_percentage = _ref.deposit_percentage,
|
|
385
|
+
deposit_policy_data = _ref.deposit_policy_data,
|
|
386
|
+
self_deposit_policy_ids = _ref.self_deposit_policy_ids;
|
|
418
387
|
// 所有协议数据
|
|
419
388
|
var allProtocols = deposit_policy_data || [];
|
|
420
389
|
// 是否存在定金,主商品has_deposit为1,但是自身没有定金设置,需要判定子商品是否存在定金,如果不存在最终判定也是不存在定金
|
|
@@ -508,9 +477,9 @@ export var handleProductDeposit = function handleProductDeposit(params) {
|
|
|
508
477
|
depositTotal: new Decimal(0)
|
|
509
478
|
};
|
|
510
479
|
}
|
|
511
|
-
var
|
|
512
|
-
deposit_fixed =
|
|
513
|
-
deposit_percentage =
|
|
480
|
+
var _ref2 = depositData || {},
|
|
481
|
+
deposit_fixed = _ref2.deposit_fixed,
|
|
482
|
+
deposit_percentage = _ref2.deposit_percentage;
|
|
514
483
|
if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
|
|
515
484
|
var depositFixed = Decimal(deposit_fixed || 0);
|
|
516
485
|
var depositPercent = Decimal(deposit_percentage || 0);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { Discount, DiscountModuleAPI } from './types';
|
|
3
|
+
import { Discount, DiscountModuleAPI, DiscountWithReason } from './types';
|
|
4
4
|
export declare class DiscountModule extends BaseModule implements Module, DiscountModuleAPI {
|
|
5
5
|
protected defaultName: string;
|
|
6
6
|
protected defaultVersion: string;
|
|
@@ -17,17 +17,23 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
17
17
|
setOriginalDiscountList(originalDiscountList: Discount[]): Promise<void>;
|
|
18
18
|
getOriginalDiscountList(): Discount[];
|
|
19
19
|
loadPrepareConfig(params: {
|
|
20
|
-
action?: 'create';
|
|
20
|
+
action?: 'create' | 'edit';
|
|
21
21
|
with_good_pass: 0 | 1;
|
|
22
22
|
with_discount_card: 0 | 1;
|
|
23
23
|
customer_id: number;
|
|
24
24
|
with_wallet_pass_holder: 0 | 1;
|
|
25
25
|
request_timezone: string;
|
|
26
|
+
order_id?: number;
|
|
26
27
|
}): Promise<Discount[]>;
|
|
27
|
-
batchSearch(code: string,
|
|
28
|
+
batchSearch(code: string, options?: {
|
|
29
|
+
customerId?: number;
|
|
30
|
+
orderId?: number;
|
|
31
|
+
}): Promise<DiscountWithReason>;
|
|
28
32
|
batchSearchByProductIds(productIds: number[]): Promise<any>;
|
|
29
33
|
filterEnabledDiscountList(discountList: Discount[]): Discount[];
|
|
30
34
|
private checkUsageCreditsLimit;
|
|
35
|
+
filterEnabledDiscountListWithReason(discountList: Discount[]): DiscountWithReason;
|
|
36
|
+
private checkUsageCreditsLimitWithFailKey;
|
|
31
37
|
uniqueByProductId(discountList: Discount[]): Discount[];
|
|
32
38
|
filterDiscountListByProductIds(discountList: Discount[], productIds: number[]): Discount[];
|
|
33
39
|
calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
2
4
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
5
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
6
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -176,28 +178,33 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
176
178
|
}, {
|
|
177
179
|
key: "batchSearch",
|
|
178
180
|
value: function () {
|
|
179
|
-
var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code,
|
|
180
|
-
var result,
|
|
181
|
+
var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, options) {
|
|
182
|
+
var _ref, customerId, orderId, result, resultDiscountWithReason;
|
|
181
183
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
182
184
|
while (1) switch (_context5.prev = _context5.next) {
|
|
183
185
|
case 0:
|
|
184
|
-
|
|
185
|
-
|
|
186
|
+
_ref = options || {}, customerId = _ref.customerId, orderId = _ref.orderId;
|
|
187
|
+
_context5.next = 3;
|
|
188
|
+
return this.request.get("/machinecode/batch-search", _objectSpread(_objectSpread({
|
|
186
189
|
code: code,
|
|
187
190
|
translate_flag: 1,
|
|
188
191
|
tags: ['good_pass', 'product_discount_card'],
|
|
189
|
-
available: 1,
|
|
192
|
+
// available: 1,
|
|
190
193
|
relation_product: 1,
|
|
191
194
|
with: ['extensionData', 'customScheduleSnapshot', 'holder.detail'],
|
|
192
195
|
order_behavior_count: 1,
|
|
193
|
-
order_behavior_count_customer_id: customerId || 1
|
|
196
|
+
order_behavior_count_customer_id: customerId || 1
|
|
197
|
+
}, orderId ? {
|
|
198
|
+
order_behavior_count_order_id: orderId
|
|
199
|
+
} : {}), {}, {
|
|
200
|
+
unified_status_info_flag: 1,
|
|
194
201
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
195
|
-
});
|
|
196
|
-
case
|
|
202
|
+
}));
|
|
203
|
+
case 3:
|
|
197
204
|
result = _context5.sent;
|
|
198
|
-
|
|
199
|
-
return _context5.abrupt("return",
|
|
200
|
-
case
|
|
205
|
+
resultDiscountWithReason = this.filterEnabledDiscountListWithReason((result === null || result === void 0 ? void 0 : result.data) || []) || [];
|
|
206
|
+
return _context5.abrupt("return", resultDiscountWithReason);
|
|
207
|
+
case 6:
|
|
201
208
|
case "end":
|
|
202
209
|
return _context5.stop();
|
|
203
210
|
}
|
|
@@ -305,6 +312,91 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
305
312
|
return true;
|
|
306
313
|
}
|
|
307
314
|
|
|
315
|
+
// 过滤启用且可用的优惠券,并返回校验失败原因
|
|
316
|
+
}, {
|
|
317
|
+
key: "filterEnabledDiscountListWithReason",
|
|
318
|
+
value: function filterEnabledDiscountListWithReason(discountList) {
|
|
319
|
+
var _this3 = this;
|
|
320
|
+
var lists = discountList.filter(function (discount) {
|
|
321
|
+
return discount.limit_status === 'enable';
|
|
322
|
+
}).filter(function (discount) {
|
|
323
|
+
var remaining = new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0);
|
|
324
|
+
return remaining;
|
|
325
|
+
}).map(function (discount) {
|
|
326
|
+
var limitFailKey = _this3.checkUsageCreditsLimitWithFailKey(discount);
|
|
327
|
+
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
328
|
+
usageLimitFailKey: limitFailKey
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
// 可用的列表
|
|
333
|
+
var availableLists = lists.filter(function (item) {
|
|
334
|
+
return !item.usageLimitFailKey && item.unified_available_status !== 0;
|
|
335
|
+
});
|
|
336
|
+
// 不可用数据
|
|
337
|
+
var currentFailDiscount = lists.find(function (item) {
|
|
338
|
+
return item.usageLimitFailKey;
|
|
339
|
+
});
|
|
340
|
+
return {
|
|
341
|
+
discountList: availableLists,
|
|
342
|
+
unavailableReasonKey: currentFailDiscount === null || currentFailDiscount === void 0 ? void 0 : currentFailDiscount.usageLimitFailKey
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// 检查使用次数限制,并返回校验失败原因
|
|
347
|
+
}, {
|
|
348
|
+
key: "checkUsageCreditsLimitWithFailKey",
|
|
349
|
+
value: function checkUsageCreditsLimitWithFailKey(discount) {
|
|
350
|
+
if (!discount.extension_data || discount.extension_data.length === 0) {
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
var usageCreditsData = discount.extension_data.find(function (data) {
|
|
354
|
+
return data.field_key === 'usage_credits';
|
|
355
|
+
});
|
|
356
|
+
if (!usageCreditsData) {
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
var value = usageCreditsData.value;
|
|
360
|
+
|
|
361
|
+
// 总次数限制
|
|
362
|
+
if (value.total_credits && value.total_credits > 0) {
|
|
363
|
+
if ((discount.total_order_behavior_count || 0) >= value.total_credits) {
|
|
364
|
+
return 'total_credits';
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// 单用户限制
|
|
369
|
+
if (value.per_user_limit && value.per_user_limit > 0) {
|
|
370
|
+
if ((discount.customer_order_behavior_count || 0) >= value.per_user_limit) {
|
|
371
|
+
return 'per_user_limit';
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// 单日限制
|
|
376
|
+
if (value.max_per_day && value.max_per_day > 0) {
|
|
377
|
+
if ((discount.today_order_behavior_count || 0) >= value.max_per_day) {
|
|
378
|
+
return 'max_per_day';
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// 单周限制
|
|
383
|
+
if (value.max_per_week && value.max_per_week > 0) {
|
|
384
|
+
if ((discount.week_order_behavior_count || 0) >= value.max_per_week) {
|
|
385
|
+
return 'max_per_week';
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// 单月限制
|
|
390
|
+
if (value.max_per_month && value.max_per_month > 0) {
|
|
391
|
+
if ((discount.month_order_behavior_count || 0) >= value.max_per_month) {
|
|
392
|
+
return 'max_per_month';
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// 全部通过
|
|
397
|
+
return null;
|
|
398
|
+
}
|
|
399
|
+
|
|
308
400
|
// 根据productIds去重
|
|
309
401
|
}, {
|
|
310
402
|
key: "uniqueByProductId",
|