@pisell/pisellos 2.1.172 → 2.1.174
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/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +12 -63
- 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/Cart/utils/changePrice.js +16 -9
- package/dist/modules/Discount/availability.d.ts +7 -0
- package/dist/modules/Discount/availability.js +52 -0
- package/dist/modules/Discount/entitlementPass.d.ts +34 -0
- package/dist/modules/Discount/entitlementPass.js +147 -0
- package/dist/modules/Discount/entitlementState.d.ts +8 -0
- package/dist/modules/Discount/entitlementState.js +205 -0
- package/dist/modules/Discount/index.d.ts +12 -3
- package/dist/modules/Discount/index.js +211 -17
- package/dist/modules/Discount/types.d.ts +42 -22
- package/dist/modules/Holder/index.d.ts +48 -0
- package/dist/modules/Holder/index.js +640 -0
- package/dist/modules/Holder/types.d.ts +123 -0
- package/dist/modules/Holder/types.js +1 -0
- package/dist/modules/Holder/utils.d.ts +13 -0
- package/dist/modules/Holder/utils.js +34 -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 +67 -1
- package/dist/modules/Order/index.js +923 -30
- package/dist/modules/Order/types.d.ts +176 -12
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +128 -0
- package/dist/modules/Order/utils.js +621 -5
- 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/types.d.ts +7 -0
- 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/entitlementLines.d.ts +8 -0
- package/dist/modules/Rules/entitlementLines.js +157 -0
- package/dist/modules/Rules/index.d.ts +17 -11
- package/dist/modules/Rules/index.js +495 -726
- package/dist/modules/Rules/types.d.ts +2 -4
- 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 +67 -57
- package/dist/modules/index.d.ts +5 -0
- package/dist/modules/index.js +6 -1
- package/dist/plugins/window.d.ts +3 -2
- package/dist/solution/BookingByStep/index.d.ts +17 -3
- package/dist/solution/BookingByStep/index.js +322 -247
- package/dist/solution/BookingByStep/types.d.ts +4 -1
- package/dist/solution/BookingByStep/types.js +7 -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 +158 -0
- package/dist/solution/ScanOrder/index.js +3474 -0
- package/dist/solution/ScanOrder/types.d.ts +307 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +172 -0
- package/dist/solution/ScanOrder/utils.js +796 -0
- package/dist/solution/ShopDiscount/index.d.ts +6 -2
- package/dist/solution/ShopDiscount/index.js +194 -110
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/types.js +1 -2
- package/dist/solution/ShopDiscount/utils.d.ts +1 -0
- package/dist/solution/ShopDiscount/utils.js +52 -27
- package/dist/solution/VenueBooking/index.d.ts +225 -0
- package/dist/solution/VenueBooking/index.js +3749 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +156 -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/dist/types/index.d.ts +1 -0
- 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 +49 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +7 -36
- 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/Cart/utils/changePrice.js +13 -9
- package/lib/modules/Discount/availability.d.ts +7 -0
- package/lib/modules/Discount/availability.js +91 -0
- package/lib/modules/Discount/entitlementPass.d.ts +34 -0
- package/lib/modules/Discount/entitlementPass.js +184 -0
- package/lib/modules/Discount/entitlementState.d.ts +8 -0
- package/lib/modules/Discount/entitlementState.js +206 -0
- package/lib/modules/Discount/index.d.ts +12 -3
- package/lib/modules/Discount/index.js +123 -12
- package/lib/modules/Discount/types.d.ts +42 -22
- package/lib/modules/Holder/index.d.ts +48 -0
- package/lib/modules/Holder/index.js +402 -0
- package/lib/modules/Holder/types.d.ts +123 -0
- package/lib/modules/Holder/types.js +17 -0
- package/lib/modules/Holder/utils.d.ts +13 -0
- package/lib/modules/Holder/utils.js +71 -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 +67 -1
- package/lib/modules/Order/index.js +529 -1
- package/lib/modules/Order/types.d.ts +176 -12
- package/lib/modules/Order/utils.d.ts +128 -0
- package/lib/modules/Order/utils.js +514 -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/types.d.ts +7 -0
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +5 -4
- 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/entitlementLines.d.ts +8 -0
- package/lib/modules/Rules/entitlementLines.js +158 -0
- package/lib/modules/Rules/index.d.ts +17 -11
- package/lib/modules/Rules/index.js +548 -798
- package/lib/modules/Rules/types.d.ts +2 -4
- 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 +45 -34
- package/lib/modules/index.d.ts +5 -0
- package/lib/modules/index.js +11 -1
- package/lib/plugins/window.d.ts +3 -2
- package/lib/solution/BookingByStep/index.d.ts +17 -3
- package/lib/solution/BookingByStep/index.js +45 -4
- package/lib/solution/BookingByStep/types.d.ts +4 -1
- package/lib/solution/BookingByStep/types.js +15 -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 +158 -0
- package/lib/solution/ScanOrder/index.js +2135 -0
- package/lib/solution/ScanOrder/types.d.ts +307 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +172 -0
- package/lib/solution/ScanOrder/utils.js +658 -0
- package/lib/solution/ShopDiscount/index.d.ts +6 -2
- package/lib/solution/ShopDiscount/index.js +94 -50
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.d.ts +1 -0
- package/lib/solution/ShopDiscount/utils.js +48 -11
- package/lib/solution/VenueBooking/index.d.ts +225 -0
- package/lib/solution/VenueBooking/index.js +2073 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +156 -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/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
+
var promotion_exports = {};
|
|
31
|
+
__export(promotion_exports, {
|
|
32
|
+
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
+
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
+
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
+
default: () => import_adapter2.default
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
+
var import_evaluator = require("./evaluator");
|
|
40
|
+
var import_adapter = require("./adapter");
|
|
41
|
+
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
+
var import_examples = require("./examples");
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
+
PromotionAdapter,
|
|
47
|
+
PromotionEvaluator,
|
|
48
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
+
});
|
|
@@ -8,12 +8,10 @@ export declare class WalletPassEvaluator {
|
|
|
8
8
|
private engine;
|
|
9
9
|
private strategyConfigs;
|
|
10
10
|
private locale;
|
|
11
|
-
private otherParams;
|
|
12
11
|
constructor();
|
|
13
12
|
setStrategyConfigs(strategyConfigs: StrategyConfig[]): void;
|
|
14
13
|
getStrategyConfigs(): StrategyConfig[];
|
|
15
14
|
setLocale(locale: string): void;
|
|
16
|
-
setOtherParams(otherParams: any): void;
|
|
17
15
|
getText(key: string): string;
|
|
18
16
|
/**
|
|
19
17
|
* 搜索券的格式
|
|
@@ -28,6 +26,8 @@ export declare class WalletPassEvaluator {
|
|
|
28
26
|
/** 检查代金券/折扣卡是否可用 并返回config */
|
|
29
27
|
checkVoucherAvailability(input: EvaluatorInput): {
|
|
30
28
|
isAvailable: boolean;
|
|
29
|
+
reason: string | undefined;
|
|
30
|
+
reasonCode: string | undefined;
|
|
31
31
|
config: {
|
|
32
32
|
[x: string]: any;
|
|
33
33
|
};
|
|
@@ -45,27 +45,10 @@ var defaultStrategyMetadataCustom = {
|
|
|
45
45
|
maxPassesPerItem: 0,
|
|
46
46
|
deductOptionPrice: false
|
|
47
47
|
};
|
|
48
|
-
var FIELD_REASON_CODE_MAP = {
|
|
49
|
-
orderTotalAmount: "order_total_amount_not_enough",
|
|
50
|
-
applicableProductTotalAmount: "applicable_product_total_amount_not_enough",
|
|
51
|
-
applicableProductCount: "applicable_product_count_not_enough"
|
|
52
|
-
};
|
|
53
|
-
var AMOUNT_FIELDS = /* @__PURE__ */ new Set([
|
|
54
|
-
"orderTotalAmount",
|
|
55
|
-
"applicableProductTotalAmount"
|
|
56
|
-
]);
|
|
57
|
-
function formatReason(template, value, currency = "") {
|
|
58
|
-
if (!template)
|
|
59
|
-
return template;
|
|
60
|
-
const v = value === void 0 || value === null ? "" : String(value);
|
|
61
|
-
const c = currency === void 0 || currency === null ? "" : String(currency);
|
|
62
|
-
return template.replace(/\$\{value\}/g, () => v).replace(/\{value\}/g, () => v).replace(/\{currency\}/g, () => c);
|
|
63
|
-
}
|
|
64
48
|
var WalletPassEvaluator = class {
|
|
65
49
|
constructor() {
|
|
66
50
|
this.strategyConfigs = [];
|
|
67
51
|
this.locale = "en";
|
|
68
|
-
this.otherParams = {};
|
|
69
52
|
this.engine = new import__.StrategyEngine({
|
|
70
53
|
debug: false,
|
|
71
54
|
enableTrace: false
|
|
@@ -81,9 +64,6 @@ var WalletPassEvaluator = class {
|
|
|
81
64
|
setLocale(locale) {
|
|
82
65
|
this.locale = locale;
|
|
83
66
|
}
|
|
84
|
-
setOtherParams(otherParams) {
|
|
85
|
-
this.otherParams = otherParams;
|
|
86
|
-
}
|
|
87
67
|
getText(key) {
|
|
88
68
|
var _a, _b;
|
|
89
69
|
return (_b = (_a = import_locales.locales) == null ? void 0 : _a[this.locale]) == null ? void 0 : _b[key];
|
|
@@ -121,7 +101,7 @@ var WalletPassEvaluator = class {
|
|
|
121
101
|
* 评估可用的 vouchers
|
|
122
102
|
*/
|
|
123
103
|
evaluate(input) {
|
|
124
|
-
var _a, _b
|
|
104
|
+
var _a, _b;
|
|
125
105
|
const { orderTotalAmount, products, vouchers, strategyConfigs } = input;
|
|
126
106
|
const productIds = products.map((p) => p.product_id);
|
|
127
107
|
const results = [];
|
|
@@ -196,13 +176,7 @@ var WalletPassEvaluator = class {
|
|
|
196
176
|
});
|
|
197
177
|
} else {
|
|
198
178
|
let reasonCode = "not_meet_the_required_conditions";
|
|
199
|
-
|
|
200
|
-
const failedField = (_c = evaluationResult.matched) == null ? void 0 : _c.failedField;
|
|
201
|
-
const failedRule = (_e = (_d = evaluationResult.matched) == null ? void 0 : _d.failedRules) == null ? void 0 : _e[0];
|
|
202
|
-
if (failedField && FIELD_REASON_CODE_MAP[failedField]) {
|
|
203
|
-
reasonCode = FIELD_REASON_CODE_MAP[failedField];
|
|
204
|
-
thresholdValue = failedRule == null ? void 0 : failedRule.value;
|
|
205
|
-
} else if (evaluationResult.code) {
|
|
179
|
+
if (evaluationResult.code) {
|
|
206
180
|
const codeMapping = {
|
|
207
181
|
INSUFFICIENT_AMOUNT: "not_meet_the_required_conditions",
|
|
208
182
|
USAGE_LIMIT_EXCEEDED: "usage_limit_reached",
|
|
@@ -212,10 +186,6 @@ var WalletPassEvaluator = class {
|
|
|
212
186
|
};
|
|
213
187
|
reasonCode = codeMapping[evaluationResult.code] || "not_meet_the_required_conditions";
|
|
214
188
|
}
|
|
215
|
-
const rawText = this.getText(reasonCode);
|
|
216
|
-
const currency = failedField && AMOUNT_FIELDS.has(failedField) ? ((_g = (_f = this.otherParams) == null ? void 0 : _f.getData) == null ? void 0 : _g.call(_f, "shop_symbol")) || "" : "";
|
|
217
|
-
console.log(currency, "currency12345");
|
|
218
|
-
const reason = thresholdValue !== void 0 ? formatReason(rawText, thresholdValue, currency) : rawText;
|
|
219
189
|
results.push({
|
|
220
190
|
voucher,
|
|
221
191
|
isApplicable: false,
|
|
@@ -223,7 +193,7 @@ var WalletPassEvaluator = class {
|
|
|
223
193
|
maxDeduction: 0,
|
|
224
194
|
deductTaxAndFee: false,
|
|
225
195
|
applicableProductIds: [],
|
|
226
|
-
reason,
|
|
196
|
+
reason: this.getText(reasonCode),
|
|
227
197
|
reasonCode,
|
|
228
198
|
strategyResult: evaluationResult
|
|
229
199
|
});
|
|
@@ -233,14 +203,16 @@ var WalletPassEvaluator = class {
|
|
|
233
203
|
}
|
|
234
204
|
/** 检查代金券/折扣卡是否可用 并返回config */
|
|
235
205
|
checkVoucherAvailability(input) {
|
|
236
|
-
var _a, _b, _c, _d, _e;
|
|
206
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
237
207
|
const { orderTotalAmount, products, vouchers } = input;
|
|
238
208
|
const results = this.evaluate(input);
|
|
239
209
|
const isAvailable = ((_a = results[0]) == null ? void 0 : _a.isApplicable) || false;
|
|
240
210
|
return {
|
|
241
211
|
isAvailable,
|
|
212
|
+
reason: (_b = results[0]) == null ? void 0 : _b.reason,
|
|
213
|
+
reasonCode: (_c = results[0]) == null ? void 0 : _c.reasonCode,
|
|
242
214
|
config: {
|
|
243
|
-
...(
|
|
215
|
+
...(_g = (_f = (_e = (_d = results[0]) == null ? void 0 : _d.strategyResult) == null ? void 0 : _e.config) == null ? void 0 : _f.metadata) == null ? void 0 : _g.custom
|
|
244
216
|
}
|
|
245
217
|
};
|
|
246
218
|
}
|
|
@@ -416,7 +388,6 @@ var WalletPassEvaluator = class {
|
|
|
416
388
|
* 计算适用商品的总金额和数量
|
|
417
389
|
*/
|
|
418
390
|
calculateApplicableProducts(products, applicableProductIds, deductTaxAndFee) {
|
|
419
|
-
console.log(products, "products1234");
|
|
420
391
|
let total = 0;
|
|
421
392
|
let count = 0;
|
|
422
393
|
if (applicableProductIds !== null && applicableProductIds.length === 0) {
|
|
@@ -29,10 +29,7 @@ var locales = {
|
|
|
29
29
|
"usage_limit_reached": "已达到使用次数上限",
|
|
30
30
|
"max_passes_per_item_reached": "该商品已达到卡券使用上限",
|
|
31
31
|
"not_available_for_this_channel": "当前渠道不可使用",
|
|
32
|
-
"not_valid_for_this_order_type": "当前订单类型不适用"
|
|
33
|
-
"order_total_amount_not_enough": "满 {currency}{value} 可用",
|
|
34
|
-
"applicable_product_total_amount_not_enough": "满 {currency}{value} 可用",
|
|
35
|
-
"applicable_product_count_not_enough": "至少 {value} 件"
|
|
32
|
+
"not_valid_for_this_order_type": "当前订单类型不适用"
|
|
36
33
|
},
|
|
37
34
|
"en": {
|
|
38
35
|
"not_meet_the_required_conditions": "Not meet the required conditions.",
|
|
@@ -40,10 +37,7 @@ var locales = {
|
|
|
40
37
|
"usage_limit_reached": "Usage limit reached.",
|
|
41
38
|
"max_passes_per_item_reached": "Max passes per item reached.",
|
|
42
39
|
"not_available_for_this_channel": "Not available for this channel.",
|
|
43
|
-
"not_valid_for_this_order_type": "Not valid for this order type."
|
|
44
|
-
"order_total_amount_not_enough": "Spend {currency}{value} to use",
|
|
45
|
-
"applicable_product_total_amount_not_enough": "Spend {currency}{value} to use",
|
|
46
|
-
"applicable_product_count_not_enough": "Min. Qty {value}"
|
|
40
|
+
"not_valid_for_this_order_type": "Not valid for this order type."
|
|
47
41
|
},
|
|
48
42
|
"zh-HK": {
|
|
49
43
|
"not_meet_the_required_conditions": "未達使用條件",
|
|
@@ -51,10 +45,7 @@ var locales = {
|
|
|
51
45
|
"usage_limit_reached": "已達使用次數上限",
|
|
52
46
|
"max_passes_per_item_reached": "該商品已達卡券使用上限",
|
|
53
47
|
"not_available_for_this_channel": "當前渠道不可使用",
|
|
54
|
-
"not_valid_for_this_order_type": "當前訂單類型不適用"
|
|
55
|
-
"order_total_amount_not_enough": "滿 {currency}{value} 可用",
|
|
56
|
-
"applicable_product_total_amount_not_enough": "滿 {currency}{value} 可用",
|
|
57
|
-
"applicable_product_count_not_enough": "至少 {value} 件"
|
|
48
|
+
"not_valid_for_this_order_type": "當前訂單類型不適用"
|
|
58
49
|
}
|
|
59
50
|
};
|
|
60
51
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -27,30 +27,17 @@ 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
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* 失败规则收集策略:
|
|
37
|
-
* - `and`:返回第一个失败的原子规则(嵌套 group 递归取其首个失败原子规则)
|
|
38
|
-
* - `or`:所有分支失败时,聚合每个分支的失败规则
|
|
39
|
-
* - `not`:被取反规则实际通过时,记录该规则
|
|
40
|
-
*/
|
|
41
|
-
private evaluateGroupLogicDetailed;
|
|
42
|
-
/**
|
|
43
|
-
* 评估单个规则(带失败规则收集)
|
|
44
|
-
*/
|
|
45
|
-
private evaluateRuleDetailed;
|
|
46
|
-
/**
|
|
47
|
-
* 评估原子规则(不收集失败信息,仅返回布尔结果)
|
|
34
|
+
* 评估条件组的逻辑运算
|
|
48
35
|
*/
|
|
49
|
-
private
|
|
36
|
+
private evaluateGroupLogic;
|
|
50
37
|
/**
|
|
51
|
-
*
|
|
38
|
+
* 评估单个规则
|
|
52
39
|
*/
|
|
53
|
-
private
|
|
40
|
+
private evaluateRule;
|
|
54
41
|
/**
|
|
55
42
|
* 评估代码模式条件
|
|
56
43
|
*/
|
|
@@ -42,7 +42,7 @@ var StrategyEngine = class {
|
|
|
42
42
|
* 评估策略
|
|
43
43
|
*/
|
|
44
44
|
evaluate(config, context) {
|
|
45
|
-
var _a
|
|
45
|
+
var _a;
|
|
46
46
|
const startTime = Date.now();
|
|
47
47
|
const trace = {
|
|
48
48
|
steps: [],
|
|
@@ -105,11 +105,7 @@ var StrategyEngine = class {
|
|
|
105
105
|
matched: {
|
|
106
106
|
conditions: applicable,
|
|
107
107
|
actionIds: evaluationResult.actionIds,
|
|
108
|
-
details: {}
|
|
109
|
-
...applicable ? {} : {
|
|
110
|
-
failedField: (_a = evaluationResult.failedRules[0]) == null ? void 0 : _a.field,
|
|
111
|
-
failedRules: evaluationResult.failedRules
|
|
112
|
-
}
|
|
108
|
+
details: {}
|
|
113
109
|
},
|
|
114
110
|
matchedActions: sortedActions,
|
|
115
111
|
outputs: {},
|
|
@@ -123,7 +119,7 @@ var StrategyEngine = class {
|
|
|
123
119
|
} catch (error) {
|
|
124
120
|
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
125
121
|
if (this.options.enableTrace) {
|
|
126
|
-
(
|
|
122
|
+
(_a = trace.errors) == null ? void 0 : _a.push({
|
|
127
123
|
step: "evaluation",
|
|
128
124
|
error: errorMessage,
|
|
129
125
|
timestamp: Date.now()
|
|
@@ -153,15 +149,12 @@ var StrategyEngine = class {
|
|
|
153
149
|
*
|
|
154
150
|
* @param group 条件组
|
|
155
151
|
* @param context 运行时上下文
|
|
156
|
-
* @returns
|
|
152
|
+
* @returns 评估结果对象,包含条件是否满足和收集到的 actionIds
|
|
157
153
|
*/
|
|
158
154
|
evaluateConditionGroup(group, context) {
|
|
159
155
|
const collectedActionIds = [];
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
context
|
|
163
|
-
);
|
|
164
|
-
if (satisfied) {
|
|
156
|
+
const isCurrentLayerSatisfied = this.evaluateGroupLogic(group, context);
|
|
157
|
+
if (isCurrentLayerSatisfied) {
|
|
165
158
|
collectedActionIds.push(...group.actionIds);
|
|
166
159
|
for (const rule of group.rules) {
|
|
167
160
|
if (this.isConditionGroup(rule)) {
|
|
@@ -171,98 +164,41 @@ var StrategyEngine = class {
|
|
|
171
164
|
}
|
|
172
165
|
}
|
|
173
166
|
return {
|
|
174
|
-
satisfied,
|
|
175
|
-
actionIds: collectedActionIds
|
|
176
|
-
failedRules
|
|
167
|
+
satisfied: isCurrentLayerSatisfied,
|
|
168
|
+
actionIds: collectedActionIds
|
|
177
169
|
};
|
|
178
170
|
}
|
|
179
171
|
/**
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* 失败规则收集策略:
|
|
183
|
-
* - `and`:返回第一个失败的原子规则(嵌套 group 递归取其首个失败原子规则)
|
|
184
|
-
* - `or`:所有分支失败时,聚合每个分支的失败规则
|
|
185
|
-
* - `not`:被取反规则实际通过时,记录该规则
|
|
172
|
+
* 评估条件组的逻辑运算
|
|
186
173
|
*/
|
|
187
|
-
|
|
174
|
+
evaluateGroupLogic(group, context) {
|
|
188
175
|
const { operator, rules } = group;
|
|
189
176
|
switch (operator) {
|
|
190
|
-
case "and":
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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
|
-
}
|
|
177
|
+
case "and":
|
|
178
|
+
return rules.every((rule) => this.evaluateRule(rule, context));
|
|
179
|
+
case "or":
|
|
180
|
+
return rules.some((rule) => this.evaluateRule(rule, context));
|
|
181
|
+
case "not":
|
|
182
|
+
if (rules.length === 0)
|
|
183
|
+
return false;
|
|
184
|
+
return !this.evaluateRule(rules[0], context);
|
|
224
185
|
default:
|
|
225
186
|
throw new Error(`Unknown operator: ${operator}`);
|
|
226
187
|
}
|
|
227
188
|
}
|
|
228
189
|
/**
|
|
229
|
-
*
|
|
190
|
+
* 评估单个规则
|
|
230
191
|
*/
|
|
231
|
-
|
|
192
|
+
evaluateRule(rule, context) {
|
|
232
193
|
if (this.isConditionGroup(rule)) {
|
|
233
|
-
return this.
|
|
194
|
+
return this.evaluateGroupLogic(rule, context);
|
|
234
195
|
}
|
|
235
196
|
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) {
|
|
249
197
|
if (conditionRule.type === "code" && conditionRule.code) {
|
|
250
198
|
return this.evaluateCodeCondition(conditionRule.code, context);
|
|
251
199
|
}
|
|
252
200
|
return this.evaluateOperatorCondition(conditionRule, context);
|
|
253
201
|
}
|
|
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
|
-
}
|
|
266
202
|
/**
|
|
267
203
|
* 评估代码模式条件
|
|
268
204
|
*/
|
|
@@ -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
|
* 执行轨迹
|
|
@@ -46,18 +46,6 @@ 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
|
-
};
|
|
61
49
|
var handleVariantProduct = (product) => {
|
|
62
50
|
var _a;
|
|
63
51
|
if (product == null ? void 0 : product.product_variant_id) {
|
|
@@ -102,14 +90,6 @@ var formatProductToCartItem = (params) => {
|
|
|
102
90
|
num,
|
|
103
91
|
discounts
|
|
104
92
|
});
|
|
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);
|
|
113
93
|
cartItem.image = product == null ? void 0 : product.cover;
|
|
114
94
|
cartItem.like_status = "common";
|
|
115
95
|
cartItem.duration = product == null ? void 0 : product.duration;
|
|
@@ -204,24 +184,17 @@ var formatProductToCartItemOrigin = (params) => {
|
|
|
204
184
|
var getProductTotalPrice = (params) => {
|
|
205
185
|
const { product, bundle, options, discounts } = params;
|
|
206
186
|
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
|
-
}))) ?? [];
|
|
211
187
|
if (discounts == null ? void 0 : discounts.length) {
|
|
212
188
|
discounts.forEach((currentValue) => {
|
|
213
189
|
var _a;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
...row,
|
|
221
|
-
unit: (0, import_utils2.getDiscountAmount)(payload, row.unit, row.unit)
|
|
222
|
-
};
|
|
190
|
+
price = (0, import_utils2.getDiscountAmount)({
|
|
191
|
+
amount: currentValue.amount,
|
|
192
|
+
tag: currentValue.type,
|
|
193
|
+
par_value: currentValue.discount.percent,
|
|
194
|
+
metadata: {
|
|
195
|
+
discount_card_type: (_a = currentValue == null ? void 0 : currentValue.discount) == null ? void 0 : _a.discount_card_type
|
|
223
196
|
}
|
|
224
|
-
}
|
|
197
|
+
}, price, price);
|
|
225
198
|
});
|
|
226
199
|
}
|
|
227
200
|
if (bundle == null ? void 0 : bundle.length) {
|
|
@@ -229,11 +202,10 @@ var getProductTotalPrice = (params) => {
|
|
|
229
202
|
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
230
203
|
}, price);
|
|
231
204
|
}
|
|
232
|
-
if (
|
|
233
|
-
price =
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
);
|
|
205
|
+
if (options == null ? void 0 : options.length) {
|
|
206
|
+
price = options.reduce((accumulator, currentValue) => {
|
|
207
|
+
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
208
|
+
}, price);
|
|
237
209
|
}
|
|
238
210
|
return Math.max(0, price);
|
|
239
211
|
};
|
|
@@ -341,6 +313,7 @@ var formatBundleToOrigin = (bundle) => {
|
|
|
341
313
|
option: formatOptionsToOrigin(getBundleValueByKey("option")),
|
|
342
314
|
discount_list: d.discount_list,
|
|
343
315
|
"bundle_selling_price": d == null ? void 0 : d.price,
|
|
316
|
+
// "custom_price": d?.price,
|
|
344
317
|
metadata: {
|
|
345
318
|
custom_product_bundle_map_id: d._id,
|
|
346
319
|
product_discount_difference
|
|
@@ -34,7 +34,7 @@ __export(changePrice_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(changePrice_exports);
|
|
35
35
|
var import_decimal = __toESM(require("decimal.js"));
|
|
36
36
|
async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCart, updateItemInitInfo) {
|
|
37
|
-
var _a, _b;
|
|
37
|
+
var _a, _b, _c, _d, _e, _f;
|
|
38
38
|
for (const item of cartItems) {
|
|
39
39
|
const targetProduct = priceData.find((n) => n.id === item.id);
|
|
40
40
|
const cartProduct = await getProduct(
|
|
@@ -44,10 +44,14 @@ async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCa
|
|
|
44
44
|
if (!productInfo) {
|
|
45
45
|
productInfo = item._productOrigin;
|
|
46
46
|
}
|
|
47
|
+
const variantId = ((_a = item == null ? void 0 : item._productOrigin) == null ? void 0 : _a.product_variant_id) ?? ((_c = (_b = item == null ? void 0 : item._origin) == null ? void 0 : _b.product) == null ? void 0 : _c.product_variant_id);
|
|
48
|
+
const targetVariant = (_d = targetProduct == null ? void 0 : targetProduct.variant) == null ? void 0 : _d.find(
|
|
49
|
+
(variant) => Number(variant.id) === Number(variantId)
|
|
50
|
+
);
|
|
47
51
|
let bundle = item._bundleOrigin;
|
|
48
|
-
productInfo.price = targetProduct == null ? void 0 : targetProduct.price;
|
|
49
|
-
productInfo.base_price = targetProduct == null ? void 0 : targetProduct.base_price;
|
|
50
|
-
productInfo.product_variant_id = (
|
|
52
|
+
productInfo.price = (targetVariant == null ? void 0 : targetVariant.price) ?? (targetProduct == null ? void 0 : targetProduct.price) ?? productInfo.price;
|
|
53
|
+
productInfo.base_price = (targetVariant == null ? void 0 : targetVariant.base_price) ?? (targetProduct == null ? void 0 : targetProduct.base_price) ?? productInfo.base_price;
|
|
54
|
+
productInfo.product_variant_id = (_e = item._productOrigin) == null ? void 0 : _e.product_variant_id;
|
|
51
55
|
bundle = bundle == null ? void 0 : bundle.map((n) => {
|
|
52
56
|
var _a2;
|
|
53
57
|
const targetBundle = (_a2 = targetProduct == null ? void 0 : targetProduct.bundle_group) == null ? void 0 : _a2.find(
|
|
@@ -76,14 +80,14 @@ async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCa
|
|
|
76
80
|
return n;
|
|
77
81
|
});
|
|
78
82
|
if (targetProduct == null ? void 0 : targetProduct.variant) {
|
|
79
|
-
productInfo.variant = (
|
|
83
|
+
productInfo.variant = (_f = productInfo.variant) == null ? void 0 : _f.map((n) => {
|
|
80
84
|
var _a2;
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
85
|
+
const targetVariant2 = (_a2 = targetProduct.variant) == null ? void 0 : _a2.find((m) => m.id === n.id);
|
|
86
|
+
if (targetVariant2) {
|
|
83
87
|
return {
|
|
84
88
|
...n,
|
|
85
|
-
price:
|
|
86
|
-
base_price:
|
|
89
|
+
price: targetVariant2.price,
|
|
90
|
+
base_price: targetVariant2.base_price
|
|
87
91
|
};
|
|
88
92
|
}
|
|
89
93
|
return n;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Discount, DiscountFilterRejectKey } from './types';
|
|
2
|
+
/** 周期限制只影响当前使用;total_credits 才代表整张卡的次数耗尽。 */
|
|
3
|
+
export declare function getDiscountUsageLimitFailKey(discount: Discount): DiscountFilterRejectKey | null;
|
|
4
|
+
export declare function hasAvailableDiscountBalance(discount: Discount): boolean;
|
|
5
|
+
/** 按卡本身当前生命周期判断;预约时间或一次日程不匹配不代表已失效。 */
|
|
6
|
+
export declare function getDiscountLifecycleReason(discount: Discount): 'disabled' | 'exhausted' | 'expired' | 'not_shared_at_store' | undefined;
|
|
7
|
+
export declare function getDiscountUsageBlockReason(discount: Discount): string | undefined;
|