@pisell/pisellos 2.1.108 → 2.1.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/walletPass/evaluator.js +2 -1
- package/dist/model/strategy/adapter/walletPass/type.d.ts +11 -0
- package/dist/modules/Cart/utils/cartProduct.js +46 -25
- package/dist/modules/Discount/types.d.ts +2 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.js +171 -74
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -1
- package/lib/model/strategy/adapter/walletPass/type.d.ts +11 -0
- package/lib/modules/Cart/utils/cartProduct.js +31 -12
- package/lib/modules/Discount/types.d.ts +2 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.js +228 -141
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -43,6 +43,8 @@ export interface Voucher {
|
|
|
43
43
|
applicableProductLimit: number;
|
|
44
44
|
/** 单订单行每单位可用同一 Wallet Pass 券次数;该行总券次上限 = maxPassesPerItem × 该行 quantity(按行唯一键区分)。0 表示不限制。 */
|
|
45
45
|
maxPassesPerItem: number;
|
|
46
|
+
/** 是否抵扣单规格价格 (Option Price),默认 false。开启后折扣范围包含 option 的 add_price */
|
|
47
|
+
deductOptionPrice: boolean;
|
|
46
48
|
};
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
@@ -62,6 +64,13 @@ export interface Product {
|
|
|
62
64
|
main_product_original_price?: number;
|
|
63
65
|
/** 主商品折扣后金额,不包含套餐子商品 */
|
|
64
66
|
main_product_selling_price?: number;
|
|
67
|
+
/** 单规格(Option)列表 */
|
|
68
|
+
product_options?: {
|
|
69
|
+
id: number;
|
|
70
|
+
add_price: number | string;
|
|
71
|
+
num: number;
|
|
72
|
+
[key: string]: any;
|
|
73
|
+
}[];
|
|
65
74
|
/** 主商品税费 */
|
|
66
75
|
tax_fee: number;
|
|
67
76
|
metadata: {
|
|
@@ -138,6 +147,8 @@ export interface EvaluatorInput {
|
|
|
138
147
|
applicableProductLimit: number;
|
|
139
148
|
/** 单订单行每单位可用同一 Wallet Pass 券次数;行总上限 = maxPassesPerItem × 该行 quantity(按行唯一键计)。0 表示不限制。 */
|
|
140
149
|
maxPassesPerItem: number;
|
|
150
|
+
/** 是否抵扣单规格价格 (Option Price),默认 false */
|
|
151
|
+
deductOptionPrice: boolean;
|
|
141
152
|
}>[];
|
|
142
153
|
}
|
|
143
154
|
/**
|
|
@@ -15,6 +15,20 @@ 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
|
+
|
|
18
32
|
/**
|
|
19
33
|
* @title 处理组合商品
|
|
20
34
|
* @description 组合商品需要直接修改 product 里的价格和 is_charge_tax
|
|
@@ -195,6 +209,7 @@ export var formatProductToCartItemOrigin = function formatProductToCartItemOrigi
|
|
|
195
209
|
* @returns 商品总价
|
|
196
210
|
*/
|
|
197
211
|
export var getProductTotalPrice = function getProductTotalPrice(params) {
|
|
212
|
+
var _options$map;
|
|
198
213
|
var product = params.product,
|
|
199
214
|
bundle = params.bundle,
|
|
200
215
|
options = params.options,
|
|
@@ -202,23 +217,29 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
|
|
|
202
217
|
// const num = params.num || 1;
|
|
203
218
|
var price = Number(product.price);
|
|
204
219
|
|
|
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
|
+
|
|
205
229
|
// 如果商品有折扣,则计算折扣
|
|
206
230
|
if (discounts !== null && discounts !== void 0 && discounts.length) {
|
|
207
231
|
discounts.forEach(function (currentValue) {
|
|
208
|
-
var _currentValue$
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
metadata: {
|
|
218
|
-
discount_card_type: currentValue === null || currentValue === void 0 || (_currentValue$discoun = currentValue.discount) === null || _currentValue$discoun === void 0 ? void 0 : _currentValue$discoun.discount_card_type
|
|
232
|
+
var _currentValue$config;
|
|
233
|
+
var payload = toDiscountPayload(currentValue);
|
|
234
|
+
price = getDiscountAmount(payload, price, price);
|
|
235
|
+
if (currentValue !== null && currentValue !== void 0 && (_currentValue$config = currentValue.config) !== null && _currentValue$config !== void 0 && _currentValue$config.deductOptionPrice && optionRows.length) {
|
|
236
|
+
for (var i = 0; i < optionRows.length; i++) {
|
|
237
|
+
var row = optionRows[i];
|
|
238
|
+
optionRows[i] = _objectSpread(_objectSpread({}, row), {}, {
|
|
239
|
+
unit: getDiscountAmount(payload, row.unit, row.unit)
|
|
240
|
+
});
|
|
219
241
|
}
|
|
220
|
-
}
|
|
221
|
-
// }
|
|
242
|
+
}
|
|
222
243
|
});
|
|
223
244
|
}
|
|
224
245
|
if (bundle !== null && bundle !== void 0 && bundle.length) {
|
|
@@ -227,10 +248,10 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
|
|
|
227
248
|
}, price);
|
|
228
249
|
}
|
|
229
250
|
|
|
230
|
-
// 单规格
|
|
231
|
-
if (
|
|
232
|
-
price =
|
|
233
|
-
return accumulator +
|
|
251
|
+
// 单规格 / 加购 option
|
|
252
|
+
if (optionRows.length) {
|
|
253
|
+
price = optionRows.reduce(function (accumulator, row) {
|
|
254
|
+
return accumulator + row.unit * row.num;
|
|
234
255
|
}, price);
|
|
235
256
|
}
|
|
236
257
|
return Math.max(0, price);
|
|
@@ -389,11 +410,11 @@ export var getProductDeposit = function getProductDeposit(params) {
|
|
|
389
410
|
// 判定商品是否有定金规则
|
|
390
411
|
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) {
|
|
391
412
|
var total = new Decimal(0);
|
|
392
|
-
var
|
|
393
|
-
deposit_fixed =
|
|
394
|
-
deposit_percentage =
|
|
395
|
-
deposit_policy_data =
|
|
396
|
-
self_deposit_policy_ids =
|
|
413
|
+
var _ref3 = (product === null || product === void 0 ? void 0 : product.custom_deposit_data) || {},
|
|
414
|
+
deposit_fixed = _ref3.deposit_fixed,
|
|
415
|
+
deposit_percentage = _ref3.deposit_percentage,
|
|
416
|
+
deposit_policy_data = _ref3.deposit_policy_data,
|
|
417
|
+
self_deposit_policy_ids = _ref3.self_deposit_policy_ids;
|
|
397
418
|
// 所有协议数据
|
|
398
419
|
var allProtocols = deposit_policy_data || [];
|
|
399
420
|
// 是否存在定金,主商品has_deposit为1,但是自身没有定金设置,需要判定子商品是否存在定金,如果不存在最终判定也是不存在定金
|
|
@@ -487,9 +508,9 @@ export var handleProductDeposit = function handleProductDeposit(params) {
|
|
|
487
508
|
depositTotal: new Decimal(0)
|
|
488
509
|
};
|
|
489
510
|
}
|
|
490
|
-
var
|
|
491
|
-
deposit_fixed =
|
|
492
|
-
deposit_percentage =
|
|
511
|
+
var _ref4 = depositData || {},
|
|
512
|
+
deposit_fixed = _ref4.deposit_fixed,
|
|
513
|
+
deposit_percentage = _ref4.deposit_percentage;
|
|
493
514
|
if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
|
|
494
515
|
var depositFixed = Decimal(deposit_fixed || 0);
|
|
495
516
|
var depositPercent = Decimal(deposit_percentage || 0);
|
|
@@ -120,6 +120,8 @@ export interface Discount {
|
|
|
120
120
|
allowCrossProduct?: boolean;
|
|
121
121
|
/** 可用商品数量上限 */
|
|
122
122
|
applicableProductLimit?: number;
|
|
123
|
+
/** 是否抵扣单规格价格 (Option Price) */
|
|
124
|
+
deductOptionPrice?: boolean;
|
|
123
125
|
};
|
|
124
126
|
applicableProductIds?: number[];
|
|
125
127
|
applicableProductDetails: ApplicableProductDetails[];
|
|
@@ -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
|
}
|