@pisell/pisellos 0.0.390 → 0.0.391
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/modules/Cart/utils/cartProduct.js +21 -4
- package/dist/modules/Discount/index.js +2 -2
- package/dist/modules/Discount/types.d.ts +8 -1
- package/dist/modules/Order/utils.js +1 -1
- package/dist/modules/Rules/index.js +267 -98
- package/dist/modules/Summary/utils.d.ts +5 -0
- package/dist/modules/Summary/utils.js +36 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ShopDiscount/utils.d.ts +23 -0
- package/dist/solution/ShopDiscount/utils.js +80 -1
- package/lib/modules/Cart/utils/cartProduct.js +22 -6
- package/lib/modules/Discount/index.js +2 -2
- package/lib/modules/Discount/types.d.ts +8 -1
- package/lib/modules/Order/utils.js +1 -1
- package/lib/modules/Rules/index.js +213 -93
- package/lib/modules/Summary/utils.d.ts +5 -0
- package/lib/modules/Summary/utils.js +27 -3
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.d.ts +23 -0
- package/lib/solution/ShopDiscount/utils.js +49 -1
- package/package.json +1 -1
|
@@ -140,6 +140,7 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
|
|
|
140
140
|
return cartItem;
|
|
141
141
|
};
|
|
142
142
|
export var formatProductToCartItemOrigin = function formatProductToCartItemOrigin(params) {
|
|
143
|
+
var _origin$product;
|
|
143
144
|
var cartItem = params.cartItem,
|
|
144
145
|
product = params.product,
|
|
145
146
|
bundle = params.bundle,
|
|
@@ -148,14 +149,24 @@ export var formatProductToCartItemOrigin = function formatProductToCartItemOrigi
|
|
|
148
149
|
_params$quantity2 = params.quantity,
|
|
149
150
|
quantity = _params$quantity2 === void 0 ? 1 : _params$quantity2;
|
|
150
151
|
var origin = cartItem._origin;
|
|
152
|
+
var product_discount_difference = (((_origin$product = origin.product) === null || _origin$product === void 0 ? void 0 : _origin$product.discount_list) || []).filter(function (item) {
|
|
153
|
+
var _item$metadata;
|
|
154
|
+
return !(item !== null && item !== void 0 && (_item$metadata = item.metadata) !== null && _item$metadata !== void 0 && _item$metadata.custom_product_bundle_map_id);
|
|
155
|
+
}).reduce(function (pre, cur) {
|
|
156
|
+
var _cur$metadata;
|
|
157
|
+
return pre + ((cur === null || cur === void 0 || (_cur$metadata = cur.metadata) === null || _cur$metadata === void 0 ? void 0 : _cur$metadata.product_discount_difference) || 0);
|
|
158
|
+
}, 0);
|
|
151
159
|
if (product) {
|
|
152
|
-
var _origin$
|
|
160
|
+
var _origin$product2, _origin$product3, _product$duration, _product$duration2;
|
|
153
161
|
origin.product = _objectSpread(_objectSpread({}, origin.product || {}), {}, {
|
|
154
162
|
num: quantity,
|
|
155
163
|
product_id: product.id,
|
|
156
164
|
product_variant_id: product_variant_id || 0,
|
|
157
|
-
product_bundle: ((_origin$
|
|
158
|
-
product_option_item: ((_origin$
|
|
165
|
+
product_bundle: ((_origin$product2 = origin.product) === null || _origin$product2 === void 0 ? void 0 : _origin$product2.product_bundle) || [],
|
|
166
|
+
product_option_item: ((_origin$product3 = origin.product) === null || _origin$product3 === void 0 ? void 0 : _origin$product3.product_option_item) || [],
|
|
167
|
+
metadata: {
|
|
168
|
+
product_discount_difference: product_discount_difference
|
|
169
|
+
}
|
|
159
170
|
});
|
|
160
171
|
// 时长类型
|
|
161
172
|
origin.sub_type = product === null || product === void 0 || (_product$duration = product.duration) === null || _product$duration === void 0 ? void 0 : _product$duration.type;
|
|
@@ -193,6 +204,7 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
|
|
|
193
204
|
// 一个商品折扣卡只能存在于一张
|
|
194
205
|
// if (currentValue.type !== 'good_pass') {
|
|
195
206
|
price = getDiscountAmount({
|
|
207
|
+
amount: currentValue.amount,
|
|
196
208
|
tag: currentValue.type,
|
|
197
209
|
par_value: currentValue.discount.percent,
|
|
198
210
|
config: currentValue.config,
|
|
@@ -314,6 +326,10 @@ export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
|
|
|
314
326
|
var _d$originBundleItem;
|
|
315
327
|
return (d === null || d === void 0 ? void 0 : d[key]) || (d === null || d === void 0 || (_d$originBundleItem = d.originBundleItem) === null || _d$originBundleItem === void 0 ? void 0 : _d$originBundleItem[key]);
|
|
316
328
|
};
|
|
329
|
+
var product_discount_difference = ((d === null || d === void 0 ? void 0 : d.discount_list) || []).reduce(function (pre, cur) {
|
|
330
|
+
var _cur$metadata2;
|
|
331
|
+
return pre + ((cur === null || cur === void 0 || (_cur$metadata2 = cur.metadata) === null || _cur$metadata2 === void 0 ? void 0 : _cur$metadata2.product_discount_difference) || 0);
|
|
332
|
+
}, 0);
|
|
317
333
|
return {
|
|
318
334
|
bundle_group_id: getBundleValueByKey('group_id'),
|
|
319
335
|
bundle_id: d.id,
|
|
@@ -326,7 +342,8 @@ export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
|
|
|
326
342
|
discount_list: d.discount_list,
|
|
327
343
|
"bundle_selling_price": d === null || d === void 0 ? void 0 : d.price,
|
|
328
344
|
metadata: {
|
|
329
|
-
custom_product_bundle_map_id: d._id
|
|
345
|
+
custom_product_bundle_map_id: d._id,
|
|
346
|
+
product_discount_difference: product_discount_difference
|
|
330
347
|
}
|
|
331
348
|
};
|
|
332
349
|
});
|
|
@@ -299,9 +299,9 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
299
299
|
}
|
|
300
300
|
if (discount.appliedProductDetails) {
|
|
301
301
|
return discount.appliedProductDetails.reduce(function (total, product) {
|
|
302
|
-
var _product$discount;
|
|
302
|
+
var _product$discount, _product$metadata;
|
|
303
303
|
var price = new Decimal((product === null || product === void 0 || (_product$discount = product.discount) === null || _product$discount === void 0 ? void 0 : _product$discount.fixed_amount) || 0).mul((product === null || product === void 0 ? void 0 : product._num) || 1);
|
|
304
|
-
return new Decimal(total).plus(price).toNumber();
|
|
304
|
+
return new Decimal(total).plus(price).minus((product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.product_discount_difference) || 0).toNumber();
|
|
305
305
|
}, 0);
|
|
306
306
|
}
|
|
307
307
|
}
|
|
@@ -35,6 +35,9 @@ interface ApplicableProductDetails {
|
|
|
35
35
|
title: string;
|
|
36
36
|
original_amount: string;
|
|
37
37
|
num: number;
|
|
38
|
+
metadata?: {
|
|
39
|
+
product_discount_difference?: number;
|
|
40
|
+
};
|
|
38
41
|
discount?: {
|
|
39
42
|
fixed_amount?: number;
|
|
40
43
|
product_id?: number;
|
|
@@ -81,8 +84,12 @@ export interface Discount {
|
|
|
81
84
|
format_title: Formattitle;
|
|
82
85
|
metadata?: {
|
|
83
86
|
discount_card_type?: 'fixed_amount' | 'percent';
|
|
84
|
-
validity_type?: "custom_schedule_validity" | "fixed_validity";
|
|
85
87
|
custom_product_bundle_map_id?: string;
|
|
88
|
+
validity_type?: "custom_schedule_validity" | "fixed_validity";
|
|
89
|
+
discount_calculation_mode: 'item_level' | 'order_level';
|
|
90
|
+
holder: {
|
|
91
|
+
type: "customer" | "custom";
|
|
92
|
+
};
|
|
86
93
|
};
|
|
87
94
|
product: Product;
|
|
88
95
|
type: "product" | 'good_pass';
|
|
@@ -56,7 +56,7 @@ export var getAllDiscountList = function getAllDiscountList(cartItem) {
|
|
|
56
56
|
var _cartItem$_origin, _cartItem$_origin2;
|
|
57
57
|
var discountList = (cartItem === null || cartItem === void 0 || (_cartItem$_origin = cartItem._origin) === null || _cartItem$_origin === void 0 || (_cartItem$_origin = _cartItem$_origin.product) === null || _cartItem$_origin === void 0 ? void 0 : _cartItem$_origin.discount_list) || [];
|
|
58
58
|
((cartItem === null || cartItem === void 0 || (_cartItem$_origin2 = cartItem._origin) === null || _cartItem$_origin2 === void 0 || (_cartItem$_origin2 = _cartItem$_origin2.product) === null || _cartItem$_origin2 === void 0 ? void 0 : _cartItem$_origin2.product_bundle) || []).forEach(function (item) {
|
|
59
|
-
discountList = [].concat(_toConsumableArray(discountList), _toConsumableArray(item.discount_list || []));
|
|
59
|
+
discountList = [].concat(_toConsumableArray(discountList), _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
|
|
60
60
|
item.discount_list = undefined;
|
|
61
61
|
});
|
|
62
62
|
return discountList;
|