@pisell/pisellos 0.0.476 → 0.0.477
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/type.d.ts +2 -2
- package/dist/model/strategy/adapter/walletPass/utils.js +4 -3
- package/dist/modules/Product/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/model/strategy/adapter/walletPass/type.d.ts +2 -2
- package/lib/model/strategy/adapter/walletPass/utils.js +3 -3
- package/lib/modules/Product/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -41,7 +41,7 @@ export interface Voucher {
|
|
|
41
41
|
allowCrossProduct: boolean;
|
|
42
42
|
/** 可用商品数量上限 (仅多商品) 默认为0,表示不限制商品数量。 */
|
|
43
43
|
applicableProductLimit: number;
|
|
44
|
-
/** 单商品可用卡券上限(同一 Wallet Pass
|
|
44
|
+
/** 单商品可用卡券上限(同一 Wallet Pass 商品生成的卡券对同一商品的每个 unit 最多抵扣次数,总上限 = maxPassesPerItem × quantity)。默认为 0,表示不限制。 */
|
|
45
45
|
maxPassesPerItem: number;
|
|
46
46
|
};
|
|
47
47
|
}
|
|
@@ -132,7 +132,7 @@ export interface EvaluatorInput {
|
|
|
132
132
|
allowCrossProduct: boolean;
|
|
133
133
|
/** 可用商品数量上限 (仅多商品) 默认为0,表示不限制商品数量。 */
|
|
134
134
|
applicableProductLimit: number;
|
|
135
|
-
/** 单商品可用卡券上限(同一 Wallet Pass
|
|
135
|
+
/** 单商品可用卡券上限(同一 Wallet Pass 商品生成的卡券对同一商品的每个 unit 最多抵扣次数,总上限 = maxPassesPerItem × quantity)。默认为 0,表示不限制。 */
|
|
136
136
|
maxPassesPerItem: number;
|
|
137
137
|
}>[];
|
|
138
138
|
}
|
|
@@ -135,10 +135,11 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
// 按 maxPassesPerItem 过滤商品:排除已达到单商品可用卡券上限的商品
|
|
138
|
+
// maxPassesPerItem 是 per-unit 的限制,总上限 = maxPassesPerItem × quantity
|
|
138
139
|
var filterByMaxPassesPerItem = function filterByMaxPassesPerItem(products, usageMap, walletPassProductId, maxPassesPerItem) {
|
|
139
140
|
if (maxPassesPerItem <= 0) return products; // 0 = 不限制
|
|
140
141
|
return products.filter(function (p) {
|
|
141
|
-
return getItemPassUsage(usageMap, walletPassProductId, p.product_id) < maxPassesPerItem;
|
|
142
|
+
return getItemPassUsage(usageMap, walletPassProductId, p.product_id) < maxPassesPerItem * getProductQuantity(p);
|
|
142
143
|
});
|
|
143
144
|
};
|
|
144
145
|
// ================================================================
|
|
@@ -287,7 +288,7 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
287
288
|
var availableAfterPassLimit = getApplicableProducts(voucher, productsData).filter(function (p) {
|
|
288
289
|
return p[amountField].greaterThan(0);
|
|
289
290
|
}).filter(function (p) {
|
|
290
|
-
return getItemPassUsage(itemPassUsage, product_id, p.product_id) < maxPassesPerItem;
|
|
291
|
+
return getItemPassUsage(itemPassUsage, product_id, p.product_id) < maxPassesPerItem * getProductQuantity(p);
|
|
291
292
|
});
|
|
292
293
|
if (availableAfterPassLimit.length === 0) {
|
|
293
294
|
return {
|
|
@@ -627,7 +628,7 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
627
628
|
var filterByMaxPassesPerItem = function filterByMaxPassesPerItem(products, walletPassProductId, maxPassesPerItem) {
|
|
628
629
|
if (maxPassesPerItem <= 0) return products; // 0 = 不限制
|
|
629
630
|
return products.filter(function (p) {
|
|
630
|
-
return getItemPassUsage(walletPassProductId, p.product_id) < maxPassesPerItem;
|
|
631
|
+
return getItemPassUsage(walletPassProductId, p.product_id) < maxPassesPerItem * getProductQuantity(p);
|
|
631
632
|
});
|
|
632
633
|
};
|
|
633
634
|
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -41,7 +41,7 @@ export interface Voucher {
|
|
|
41
41
|
allowCrossProduct: boolean;
|
|
42
42
|
/** 可用商品数量上限 (仅多商品) 默认为0,表示不限制商品数量。 */
|
|
43
43
|
applicableProductLimit: number;
|
|
44
|
-
/** 单商品可用卡券上限(同一 Wallet Pass
|
|
44
|
+
/** 单商品可用卡券上限(同一 Wallet Pass 商品生成的卡券对同一商品的每个 unit 最多抵扣次数,总上限 = maxPassesPerItem × quantity)。默认为 0,表示不限制。 */
|
|
45
45
|
maxPassesPerItem: number;
|
|
46
46
|
};
|
|
47
47
|
}
|
|
@@ -132,7 +132,7 @@ export interface EvaluatorInput {
|
|
|
132
132
|
allowCrossProduct: boolean;
|
|
133
133
|
/** 可用商品数量上限 (仅多商品) 默认为0,表示不限制商品数量。 */
|
|
134
134
|
applicableProductLimit: number;
|
|
135
|
-
/** 单商品可用卡券上限(同一 Wallet Pass
|
|
135
|
+
/** 单商品可用卡券上限(同一 Wallet Pass 商品生成的卡券对同一商品的每个 unit 最多抵扣次数,总上限 = maxPassesPerItem × quantity)。默认为 0,表示不限制。 */
|
|
136
136
|
maxPassesPerItem: number;
|
|
137
137
|
}>[];
|
|
138
138
|
}
|
|
@@ -105,7 +105,7 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
|
105
105
|
if (maxPassesPerItem <= 0)
|
|
106
106
|
return products2;
|
|
107
107
|
return products2.filter(
|
|
108
|
-
(p) => getItemPassUsage(usageMap, walletPassProductId, p.product_id) < maxPassesPerItem
|
|
108
|
+
(p) => getItemPassUsage(usageMap, walletPassProductId, p.product_id) < maxPassesPerItem * getProductQuantity(p)
|
|
109
109
|
);
|
|
110
110
|
};
|
|
111
111
|
const calculateAvailableMaxAmount = (voucher, productsData, itemPassUsage) => {
|
|
@@ -184,7 +184,7 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
|
184
184
|
if (maxPassesPerItem > 0 && itemPassUsage) {
|
|
185
185
|
const deductTaxAndFee = (config == null ? void 0 : config.deductTaxAndFee) ?? true;
|
|
186
186
|
const amountField = deductTaxAndFee ? "remainingAmountWithTax" : "remainingAmountPure";
|
|
187
|
-
const availableAfterPassLimit = getApplicableProducts(voucher, productsData).filter((p) => p[amountField].greaterThan(0)).filter((p) => getItemPassUsage(itemPassUsage, product_id, p.product_id) < maxPassesPerItem);
|
|
187
|
+
const availableAfterPassLimit = getApplicableProducts(voucher, productsData).filter((p) => p[amountField].greaterThan(0)).filter((p) => getItemPassUsage(itemPassUsage, product_id, p.product_id) < maxPassesPerItem * getProductQuantity(p));
|
|
188
188
|
if (availableAfterPassLimit.length === 0) {
|
|
189
189
|
return { isAvailable: false, reasonCode: "max_passes_per_item_reached" };
|
|
190
190
|
}
|
|
@@ -404,7 +404,7 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
|
|
|
404
404
|
if (maxPassesPerItem <= 0)
|
|
405
405
|
return products2;
|
|
406
406
|
return products2.filter(
|
|
407
|
-
(p) => getItemPassUsage(walletPassProductId, p.product_id) < maxPassesPerItem
|
|
407
|
+
(p) => getItemPassUsage(walletPassProductId, p.product_id) < maxPassesPerItem * getProductQuantity(p)
|
|
408
408
|
);
|
|
409
409
|
};
|
|
410
410
|
selectedVouchers.forEach((selectedVoucher) => {
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|