@pisell/pisellos 0.0.476 → 0.0.478
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 +22 -45
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/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 +8 -39
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/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
|
// ================================================================
|
|
@@ -221,12 +222,8 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
221
222
|
var maxProduct = applicableProducts.reduce(function (max, p) {
|
|
222
223
|
return p[amountField].greaterThan(max[amountField]) ? p : max;
|
|
223
224
|
});
|
|
224
|
-
//
|
|
225
|
-
|
|
226
|
-
// 非跨商品券也受 applicableProductLimit 限制
|
|
227
|
-
var _deductQty = applicableProductLimit > 0 ? Math.min(_currentAvailableQty, applicableProductLimit) : _currentAvailableQty;
|
|
228
|
-
// 实际可抵扣金额 = min(数量 * 单价, 剩余金额)
|
|
229
|
-
finalApplicableAmount = Decimal.min(maxProduct[unitPriceField].times(_deductQty), maxProduct[amountField]);
|
|
225
|
+
// allowCrossProduct=false 时,applicableProductLimit 不生效,直接使用全部可抵扣数量
|
|
226
|
+
finalApplicableAmount = maxProduct[amountField];
|
|
230
227
|
}
|
|
231
228
|
|
|
232
229
|
// 返回最小值
|
|
@@ -287,7 +284,7 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
287
284
|
var availableAfterPassLimit = getApplicableProducts(voucher, productsData).filter(function (p) {
|
|
288
285
|
return p[amountField].greaterThan(0);
|
|
289
286
|
}).filter(function (p) {
|
|
290
|
-
return getItemPassUsage(itemPassUsage, product_id, p.product_id) < maxPassesPerItem;
|
|
287
|
+
return getItemPassUsage(itemPassUsage, product_id, p.product_id) < maxPassesPerItem * getProductQuantity(p);
|
|
291
288
|
});
|
|
292
289
|
if (availableAfterPassLimit.length === 0) {
|
|
293
290
|
return {
|
|
@@ -426,15 +423,12 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
426
423
|
}, new Decimal(0));
|
|
427
424
|
}
|
|
428
425
|
} else {
|
|
429
|
-
//
|
|
426
|
+
// 非跨商品券:单个剩余金额最高的商品
|
|
430
427
|
var maxProduct = applicableProducts.reduce(function (max, p) {
|
|
431
428
|
return p[amountField].greaterThan(max[amountField]) ? p : max;
|
|
432
429
|
});
|
|
433
|
-
//
|
|
434
|
-
|
|
435
|
-
var _deductQty2 = applicableProductLimit > 0 ? Math.min(_currentAvailableQty2, applicableProductLimit) : _currentAvailableQty2;
|
|
436
|
-
// 实际可抵扣金额 = min(数量 * 单价, 剩余金额)
|
|
437
|
-
calculatedAvailableMaxAmount = Decimal.min(maxProduct[unitPriceField].times(_deductQty2), maxProduct[amountField]);
|
|
430
|
+
// allowCrossProduct=false 时,applicableProductLimit 不生效,直接使用全部剩余金额
|
|
431
|
+
calculatedAvailableMaxAmount = maxProduct[amountField];
|
|
438
432
|
}
|
|
439
433
|
|
|
440
434
|
// 取最小值:min(recommended_usage_amount, maxDeductionAmount, 适用商品金额, 订单剩余金额)
|
|
@@ -459,8 +453,8 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
459
453
|
if (deductionLeft.lessThanOrEqualTo(0) || _remainingLimit <= 0) break;
|
|
460
454
|
|
|
461
455
|
// 动态计算当前可抵扣数量 = ceil(剩余金额 / 单价)
|
|
462
|
-
var
|
|
463
|
-
var availableQty = Math.min(
|
|
456
|
+
var _currentAvailableQty = Math.ceil(_product[amountField].dividedBy(_product[unitPriceField]).toNumber());
|
|
457
|
+
var availableQty = Math.min(_currentAvailableQty, _remainingLimit);
|
|
464
458
|
|
|
465
459
|
// 计算本商品最大可抵扣金额 = min(数量 * 单价, 剩余金额)
|
|
466
460
|
var maxDeductForProduct = Decimal.min(_product[unitPriceField].times(availableQty), _product[amountField]);
|
|
@@ -488,18 +482,12 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
488
482
|
_iterator3.f();
|
|
489
483
|
}
|
|
490
484
|
} else {
|
|
491
|
-
//
|
|
485
|
+
// 非跨商品券:只抵扣一个商品(剩余金额最高的)
|
|
486
|
+
// allowCrossProduct=false 时,applicableProductLimit 不生效
|
|
492
487
|
var targetProduct = applicableProducts.reduce(function (max, p) {
|
|
493
488
|
return p[amountField].greaterThan(max[amountField]) ? p : max;
|
|
494
489
|
});
|
|
495
|
-
|
|
496
|
-
// 动态计算当前可抵扣数量
|
|
497
|
-
var _currentAvailableQty4 = Math.ceil(targetProduct[amountField].dividedBy(targetProduct[unitPriceField]).toNumber());
|
|
498
|
-
var _availableQty = applicableProductLimit > 0 ? Math.min(_currentAvailableQty4, applicableProductLimit) : _currentAvailableQty4;
|
|
499
|
-
|
|
500
|
-
// 计算本商品最大可抵扣金额 = min(数量 * 单价, 剩余金额)
|
|
501
|
-
var _maxDeductForProduct = Decimal.min(targetProduct[unitPriceField].times(_availableQty), targetProduct[amountField]);
|
|
502
|
-
var _actualDeductAmount = Decimal.min(deductionLeft, _maxDeductForProduct);
|
|
490
|
+
var _actualDeductAmount = Decimal.min(deductionLeft, targetProduct[amountField]);
|
|
503
491
|
|
|
504
492
|
// 计算实际抵扣的数量
|
|
505
493
|
var _actualDeductQty = Math.ceil(_actualDeductAmount.dividedBy(targetProduct[unitPriceField]).toNumber());
|
|
@@ -512,8 +500,7 @@ export function processVouchers(applicableVouchers, orderTotalAmount, products)
|
|
|
512
500
|
parent_product_id: targetProduct.parent_product_id || null,
|
|
513
501
|
is_bundle_item: targetProduct.is_bundle_item || false,
|
|
514
502
|
deductAmount: _actualDeductAmount.toNumber(),
|
|
515
|
-
|
|
516
|
-
deductQuantity: _actualDeductQty // 抵扣涉及的数量(用于记录)
|
|
503
|
+
deductQuantity: _actualDeductQty
|
|
517
504
|
});
|
|
518
505
|
}
|
|
519
506
|
var totalDeducted = maxDeduction.minus(deductionLeft);
|
|
@@ -627,7 +614,7 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
627
614
|
var filterByMaxPassesPerItem = function filterByMaxPassesPerItem(products, walletPassProductId, maxPassesPerItem) {
|
|
628
615
|
if (maxPassesPerItem <= 0) return products; // 0 = 不限制
|
|
629
616
|
return products.filter(function (p) {
|
|
630
|
-
return getItemPassUsage(walletPassProductId, p.product_id) < maxPassesPerItem;
|
|
617
|
+
return getItemPassUsage(walletPassProductId, p.product_id) < maxPassesPerItem * getProductQuantity(p);
|
|
631
618
|
});
|
|
632
619
|
};
|
|
633
620
|
|
|
@@ -715,18 +702,12 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
715
702
|
_iterator4.f();
|
|
716
703
|
}
|
|
717
704
|
} else {
|
|
718
|
-
//
|
|
705
|
+
// 非跨商品券:只抵扣一个商品(剩余金额最高的)
|
|
706
|
+
// allowCrossProduct=false 时,applicableProductLimit 不生效
|
|
719
707
|
var targetProduct = applicableProducts.reduce(function (max, p) {
|
|
720
708
|
return p[amountField].greaterThan(max[amountField]) ? p : max;
|
|
721
709
|
});
|
|
722
|
-
|
|
723
|
-
// 动态计算当前可抵扣数量
|
|
724
|
-
var _currentAvailableQty5 = Math.ceil(targetProduct[amountField].dividedBy(targetProduct[unitPriceField]).toNumber());
|
|
725
|
-
var _availableQty2 = applicableProductLimit > 0 ? Math.min(_currentAvailableQty5, applicableProductLimit) : _currentAvailableQty5;
|
|
726
|
-
|
|
727
|
-
// 计算本商品最大可抵扣金额 = min(数量 * 单价, 剩余金额)
|
|
728
|
-
var _maxDeductForProduct2 = Decimal.min(targetProduct[unitPriceField].times(_availableQty2), targetProduct[amountField]);
|
|
729
|
-
var _actualDeductAmount2 = Decimal.min(deductionLeft, _maxDeductForProduct2);
|
|
710
|
+
var _actualDeductAmount2 = Decimal.min(deductionLeft, targetProduct[amountField]);
|
|
730
711
|
|
|
731
712
|
// 计算实际抵扣的数量
|
|
732
713
|
var _actualDeductQty2 = Math.ceil(_actualDeductAmount2.dividedBy(targetProduct[unitPriceField]).toNumber());
|
|
@@ -739,8 +720,7 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
739
720
|
parent_product_id: targetProduct.parent_product_id || null,
|
|
740
721
|
is_bundle_item: targetProduct.is_bundle_item || false,
|
|
741
722
|
deductAmount: _actualDeductAmount2.toNumber(),
|
|
742
|
-
|
|
743
|
-
deductQuantity: _actualDeductQty2 // 抵扣涉及的数量(用于记录)
|
|
723
|
+
deductQuantity: _actualDeductQty2
|
|
744
724
|
});
|
|
745
725
|
}
|
|
746
726
|
var totalDeducted = maxDeduction.minus(deductionLeft);
|
|
@@ -864,15 +844,12 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
|
|
|
864
844
|
}, new Decimal(0));
|
|
865
845
|
}
|
|
866
846
|
} else {
|
|
867
|
-
//
|
|
847
|
+
// 非跨商品券:单个剩余金额最高的商品
|
|
848
|
+
// allowCrossProduct=false 时,applicableProductLimit 不生效
|
|
868
849
|
var maxProduct = applicableProducts.reduce(function (max, p) {
|
|
869
850
|
return p[amountField].greaterThan(max[amountField]) ? p : max;
|
|
870
851
|
});
|
|
871
|
-
|
|
872
|
-
var _currentAvailableQty6 = Math.ceil(maxProduct[amountField].dividedBy(maxProduct[unitPriceField]).toNumber());
|
|
873
|
-
var _deductQty3 = applicableProductLimit > 0 ? Math.min(_currentAvailableQty6, applicableProductLimit) : _currentAvailableQty6;
|
|
874
|
-
// 实际可抵扣金额 = min(数量 * 单价, 剩余金额)
|
|
875
|
-
calculatedMaxAmount = Decimal.min(maxProduct[unitPriceField].times(_deductQty3), maxProduct[amountField]);
|
|
852
|
+
calculatedMaxAmount = maxProduct[amountField];
|
|
876
853
|
}
|
|
877
854
|
calculatedMaxAmount = Decimal.min(baseAmount, calculatedMaxAmount, remainingOrderAmount);
|
|
878
855
|
if (calculatedMaxAmount.lessThanOrEqualTo(0)) {
|
|
@@ -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
|
}
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 2 | 1 | 3 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
123
123
|
* 获取当前的客户搜索条件
|
|
124
124
|
* @returns 当前搜索条件
|
|
125
125
|
*/
|
|
126
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
126
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
127
127
|
/**
|
|
128
128
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
129
129
|
* @returns 客户状态
|
|
@@ -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) => {
|
|
@@ -152,12 +152,7 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
|
152
152
|
const maxProduct = applicableProducts.reduce(
|
|
153
153
|
(max, p) => p[amountField].greaterThan(max[amountField]) ? p : max
|
|
154
154
|
);
|
|
155
|
-
|
|
156
|
-
const deductQty = applicableProductLimit > 0 ? Math.min(currentAvailableQty, applicableProductLimit) : currentAvailableQty;
|
|
157
|
-
finalApplicableAmount = import_decimal.default.min(
|
|
158
|
-
maxProduct[unitPriceField].times(deductQty),
|
|
159
|
-
maxProduct[amountField]
|
|
160
|
-
);
|
|
155
|
+
finalApplicableAmount = maxProduct[amountField];
|
|
161
156
|
}
|
|
162
157
|
return import_decimal.default.min(baseAmount, finalApplicableAmount, remainingOrderAmount);
|
|
163
158
|
};
|
|
@@ -184,7 +179,7 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
|
184
179
|
if (maxPassesPerItem > 0 && itemPassUsage) {
|
|
185
180
|
const deductTaxAndFee = (config == null ? void 0 : config.deductTaxAndFee) ?? true;
|
|
186
181
|
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);
|
|
182
|
+
const availableAfterPassLimit = getApplicableProducts(voucher, productsData).filter((p) => p[amountField].greaterThan(0)).filter((p) => getItemPassUsage(itemPassUsage, product_id, p.product_id) < maxPassesPerItem * getProductQuantity(p));
|
|
188
183
|
if (availableAfterPassLimit.length === 0) {
|
|
189
184
|
return { isAvailable: false, reasonCode: "max_passes_per_item_reached" };
|
|
190
185
|
}
|
|
@@ -269,12 +264,7 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
|
269
264
|
const maxProduct = applicableProducts.reduce(
|
|
270
265
|
(max, p) => p[amountField].greaterThan(max[amountField]) ? p : max
|
|
271
266
|
);
|
|
272
|
-
|
|
273
|
-
const deductQty = applicableProductLimit > 0 ? Math.min(currentAvailableQty, applicableProductLimit) : currentAvailableQty;
|
|
274
|
-
calculatedAvailableMaxAmount = import_decimal.default.min(
|
|
275
|
-
maxProduct[unitPriceField].times(deductQty),
|
|
276
|
-
maxProduct[amountField]
|
|
277
|
-
);
|
|
267
|
+
calculatedAvailableMaxAmount = maxProduct[amountField];
|
|
278
268
|
}
|
|
279
269
|
const availableMaxAmount = import_decimal.default.min(
|
|
280
270
|
baseAmount,
|
|
@@ -320,13 +310,7 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
|
320
310
|
const targetProduct = applicableProducts.reduce(
|
|
321
311
|
(max, p) => p[amountField].greaterThan(max[amountField]) ? p : max
|
|
322
312
|
);
|
|
323
|
-
const
|
|
324
|
-
const availableQty = applicableProductLimit > 0 ? Math.min(currentAvailableQty, applicableProductLimit) : currentAvailableQty;
|
|
325
|
-
const maxDeductForProduct = import_decimal.default.min(
|
|
326
|
-
targetProduct[unitPriceField].times(availableQty),
|
|
327
|
-
targetProduct[amountField]
|
|
328
|
-
);
|
|
329
|
-
const actualDeductAmount = import_decimal.default.min(deductionLeft, maxDeductForProduct);
|
|
313
|
+
const actualDeductAmount = import_decimal.default.min(deductionLeft, targetProduct[amountField]);
|
|
330
314
|
const actualDeductQty = Math.ceil(actualDeductAmount.dividedBy(targetProduct[unitPriceField]).toNumber());
|
|
331
315
|
targetProduct[amountField] = targetProduct[amountField].minus(actualDeductAmount);
|
|
332
316
|
deductionLeft = deductionLeft.minus(actualDeductAmount);
|
|
@@ -335,9 +319,7 @@ function processVouchers(applicableVouchers, orderTotalAmount, products) {
|
|
|
335
319
|
parent_product_id: targetProduct.parent_product_id || null,
|
|
336
320
|
is_bundle_item: targetProduct.is_bundle_item || false,
|
|
337
321
|
deductAmount: actualDeductAmount.toNumber(),
|
|
338
|
-
// 转换为数字
|
|
339
322
|
deductQuantity: actualDeductQty
|
|
340
|
-
// 抵扣涉及的数量(用于记录)
|
|
341
323
|
});
|
|
342
324
|
}
|
|
343
325
|
const totalDeducted = maxDeduction.minus(deductionLeft);
|
|
@@ -404,7 +386,7 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
|
|
|
404
386
|
if (maxPassesPerItem <= 0)
|
|
405
387
|
return products2;
|
|
406
388
|
return products2.filter(
|
|
407
|
-
(p) => getItemPassUsage(walletPassProductId, p.product_id) < maxPassesPerItem
|
|
389
|
+
(p) => getItemPassUsage(walletPassProductId, p.product_id) < maxPassesPerItem * getProductQuantity(p)
|
|
408
390
|
);
|
|
409
391
|
};
|
|
410
392
|
selectedVouchers.forEach((selectedVoucher) => {
|
|
@@ -469,13 +451,7 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
|
|
|
469
451
|
const targetProduct = applicableProducts.reduce(
|
|
470
452
|
(max, p) => p[amountField].greaterThan(max[amountField]) ? p : max
|
|
471
453
|
);
|
|
472
|
-
const
|
|
473
|
-
const availableQty = applicableProductLimit > 0 ? Math.min(currentAvailableQty, applicableProductLimit) : currentAvailableQty;
|
|
474
|
-
const maxDeductForProduct = import_decimal.default.min(
|
|
475
|
-
targetProduct[unitPriceField].times(availableQty),
|
|
476
|
-
targetProduct[amountField]
|
|
477
|
-
);
|
|
478
|
-
const actualDeductAmount = import_decimal.default.min(deductionLeft, maxDeductForProduct);
|
|
454
|
+
const actualDeductAmount = import_decimal.default.min(deductionLeft, targetProduct[amountField]);
|
|
479
455
|
const actualDeductQty = Math.ceil(actualDeductAmount.dividedBy(targetProduct[unitPriceField]).toNumber());
|
|
480
456
|
targetProduct[amountField] = targetProduct[amountField].minus(actualDeductAmount);
|
|
481
457
|
deductionLeft = deductionLeft.minus(actualDeductAmount);
|
|
@@ -484,9 +460,7 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
|
|
|
484
460
|
parent_product_id: targetProduct.parent_product_id || null,
|
|
485
461
|
is_bundle_item: targetProduct.is_bundle_item || false,
|
|
486
462
|
deductAmount: actualDeductAmount.toNumber(),
|
|
487
|
-
// 转换为数字
|
|
488
463
|
deductQuantity: actualDeductQty
|
|
489
|
-
// 抵扣涉及的数量(用于记录)
|
|
490
464
|
});
|
|
491
465
|
}
|
|
492
466
|
const totalDeducted = maxDeduction.minus(deductionLeft);
|
|
@@ -578,12 +552,7 @@ function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmount, pr
|
|
|
578
552
|
const maxProduct = applicableProducts.reduce(
|
|
579
553
|
(max, p) => p[amountField].greaterThan(max[amountField]) ? p : max
|
|
580
554
|
);
|
|
581
|
-
|
|
582
|
-
const deductQty = applicableProductLimit > 0 ? Math.min(currentAvailableQty, applicableProductLimit) : currentAvailableQty;
|
|
583
|
-
calculatedMaxAmount = import_decimal.default.min(
|
|
584
|
-
maxProduct[unitPriceField].times(deductQty),
|
|
585
|
-
maxProduct[amountField]
|
|
586
|
-
);
|
|
555
|
+
calculatedMaxAmount = maxProduct[amountField];
|
|
587
556
|
}
|
|
588
557
|
calculatedMaxAmount = import_decimal.default.min(
|
|
589
558
|
baseAmount,
|
|
@@ -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
|
}
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 | 2 | 1 | 3 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
123
123
|
* 获取当前的客户搜索条件
|
|
124
124
|
* @returns 当前搜索条件
|
|
125
125
|
*/
|
|
126
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
126
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
127
127
|
/**
|
|
128
128
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
129
129
|
* @returns 客户状态
|