@pisell/pisellos 0.0.391 → 0.0.393
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/Discount/index.js +1 -1
- package/dist/modules/Rules/index.js +5 -8
- package/dist/modules/Summary/utils.js +1 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/ShopDiscount/index.js +4 -3
- package/lib/modules/Discount/index.js +1 -1
- package/lib/modules/Rules/index.js +5 -8
- package/lib/modules/Summary/utils.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/ShopDiscount/index.js +6 -6
- package/package.json +1 -1
|
@@ -301,7 +301,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
301
301
|
return discount.appliedProductDetails.reduce(function (total, product) {
|
|
302
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).
|
|
304
|
+
return new Decimal(total).plus(price).add((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
|
}
|
|
@@ -746,15 +746,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
746
746
|
|
|
747
747
|
// 如果商品价格为 0,其实不需要使用任何优惠券,直接 return true
|
|
748
748
|
// 商品券时主商品价格为0不可用
|
|
749
|
-
if ((Number(product.price) <= 0 || !product.price) && !((_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.
|
|
750
|
-
var _n$discount;
|
|
751
|
-
return ((_n$discount = n.discount) === null || _n$discount === void 0 ? void 0 : _n$discount.resource_id) === discount.id;
|
|
752
|
-
})) && (discount.tag || discount.type) === 'good_pass') return false;
|
|
749
|
+
if ((Number(product.price) <= 0 || !product.price) && !((_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.length) && (discount.tag || discount.type) === 'good_pass') return false;
|
|
753
750
|
|
|
754
751
|
// 折扣卡商品价格为0时不可用
|
|
755
752
|
if ((Number(product.price) <= 0 || !product.price) && !((_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.find(function (n) {
|
|
756
|
-
var _n$
|
|
757
|
-
return ((_n$
|
|
753
|
+
var _n$discount;
|
|
754
|
+
return ((_n$discount = n.discount) === null || _n$discount === void 0 ? void 0 : _n$discount.resource_id) === discount.id;
|
|
758
755
|
})) && (discount.tag || discount.type) !== 'good_pass') return false;
|
|
759
756
|
// 如果优惠券已被使用,则跳过
|
|
760
757
|
var targetUsedDiscounts = usedDiscounts.get(discount.id);
|
|
@@ -1045,7 +1042,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1045
1042
|
metadata: _objectSpread({
|
|
1046
1043
|
num: 1
|
|
1047
1044
|
}, productDiscountDifference !== undefined && {
|
|
1048
|
-
product_discount_difference:
|
|
1045
|
+
product_discount_difference: productDiscountDifference
|
|
1049
1046
|
})
|
|
1050
1047
|
};
|
|
1051
1048
|
appliedProducts.push(discountDetail);
|
|
@@ -1214,7 +1211,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1214
1211
|
custom_product_bundle_map_id: _uniqueId,
|
|
1215
1212
|
num: product.num || 1
|
|
1216
1213
|
}, _productDiscountDifference !== undefined && {
|
|
1217
|
-
product_discount_difference:
|
|
1214
|
+
product_discount_difference: _productDiscountDifference
|
|
1218
1215
|
}),
|
|
1219
1216
|
config: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.config,
|
|
1220
1217
|
_num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$parentProdu7 = flatItem.parentProduct) === null || _flatItem$parentProdu7 === void 0 ? void 0 : _flatItem$parentProdu7.num) || 1)
|
|
@@ -69,7 +69,7 @@ export var calculateSubtotal = function calculateSubtotal(items) {
|
|
|
69
69
|
var subtotal = items.reduce(function (sum, item) {
|
|
70
70
|
var cartItemTotalPrice = new Decimal(item.summaryTotal || 0);
|
|
71
71
|
var productDiscountProductDiscountDifference = getProductDiscountProductDiscountDifference(item);
|
|
72
|
-
return sum.plus(cartItemTotalPrice).
|
|
72
|
+
return sum.plus(cartItemTotalPrice).sub(productDiscountProductDiscountDifference);
|
|
73
73
|
}, new Decimal(0));
|
|
74
74
|
return subtotal.toFixed(2);
|
|
75
75
|
};
|
|
@@ -308,7 +308,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
308
308
|
date: string;
|
|
309
309
|
status: string;
|
|
310
310
|
week: string;
|
|
311
|
-
weekNum: 0 |
|
|
311
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
312
312
|
}[]>;
|
|
313
313
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
314
314
|
private getScheduleDataByIds;
|
|
@@ -576,12 +576,13 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
576
576
|
return n.id === (((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id);
|
|
577
577
|
});
|
|
578
578
|
if (index !== -1) {
|
|
579
|
+
var _discount$metadata;
|
|
579
580
|
editModeDiscountList[index] = _objectSpread(_objectSpread({}, editModeDiscountList[index]), {}, {
|
|
580
581
|
amount: new Decimal(discount.amount || 0).plus(new Decimal(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
581
|
-
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
582
|
+
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
582
583
|
});
|
|
583
584
|
} else {
|
|
584
|
-
var _discount$discount2, _discount$discount3, _discount$discount4;
|
|
585
|
+
var _discount$metadata2, _discount$discount2, _discount$discount3, _discount$discount4;
|
|
585
586
|
if (discount.type && !discount.tag) {
|
|
586
587
|
discount.tag = discount.type;
|
|
587
588
|
}
|
|
@@ -589,7 +590,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
589
590
|
name: discount.name || discount.discount.title.auto,
|
|
590
591
|
isEditMode: true,
|
|
591
592
|
limited_relation_product_data: {},
|
|
592
|
-
savedAmount: discount.amount
|
|
593
|
+
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.product_discount_difference) || 0).toNumber(),
|
|
593
594
|
isAvailable: true,
|
|
594
595
|
id: ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) || discount.id,
|
|
595
596
|
format_title: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.title) || discount.format_title,
|
|
@@ -178,7 +178,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
178
178
|
return discount.appliedProductDetails.reduce((total, product) => {
|
|
179
179
|
var _a, _b;
|
|
180
180
|
const price = new import_decimal.default(((_a = product == null ? void 0 : product.discount) == null ? void 0 : _a.fixed_amount) || 0).mul((product == null ? void 0 : product._num) || 1);
|
|
181
|
-
return new import_decimal.default(total).plus(price).
|
|
181
|
+
return new import_decimal.default(total).plus(price).add(((_b = product == null ? void 0 : product.metadata) == null ? void 0 : _b.product_discount_difference) || 0).toNumber();
|
|
182
182
|
}, 0);
|
|
183
183
|
}
|
|
184
184
|
}
|
|
@@ -538,10 +538,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
538
538
|
return false;
|
|
539
539
|
}
|
|
540
540
|
}
|
|
541
|
-
if ((Number(product.price) <= 0 || !product.price) && !((_b2 = product.discount_list) == null ? void 0 : _b2.
|
|
542
|
-
var _a3;
|
|
543
|
-
return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
|
|
544
|
-
})) && (discount.tag || discount.type) === "good_pass")
|
|
541
|
+
if ((Number(product.price) <= 0 || !product.price) && !((_b2 = product.discount_list) == null ? void 0 : _b2.length) && (discount.tag || discount.type) === "good_pass")
|
|
545
542
|
return false;
|
|
546
543
|
if ((Number(product.price) <= 0 || !product.price) && !((_c2 = product.discount_list) == null ? void 0 : _c2.find((n) => {
|
|
547
544
|
var _a3;
|
|
@@ -818,8 +815,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
818
815
|
config: selectedDiscount2 == null ? void 0 : selectedDiscount2.config,
|
|
819
816
|
metadata: {
|
|
820
817
|
num: 1,
|
|
821
|
-
// 🔥 order_level 分摊差值
|
|
822
|
-
...productDiscountDifference !== void 0 && { product_discount_difference:
|
|
818
|
+
// 🔥 order_level 分摊差值
|
|
819
|
+
...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference }
|
|
823
820
|
}
|
|
824
821
|
};
|
|
825
822
|
appliedProducts.push(discountDetail);
|
|
@@ -972,8 +969,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
972
969
|
// 🔥 使用唯一的 _id
|
|
973
970
|
custom_product_bundle_map_id: uniqueId,
|
|
974
971
|
num: product.num || 1,
|
|
975
|
-
// 🔥 order_level 分摊差值
|
|
976
|
-
...productDiscountDifference !== void 0 && { product_discount_difference:
|
|
972
|
+
// 🔥 order_level 分摊差值
|
|
973
|
+
...productDiscountDifference !== void 0 && { product_discount_difference: productDiscountDifference }
|
|
977
974
|
},
|
|
978
975
|
config: selectedDiscount2 == null ? void 0 : selectedDiscount2.config,
|
|
979
976
|
_num: (product.num || 1) * (((_y = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _y.num) || 1)
|
|
@@ -83,7 +83,7 @@ var calculateSubtotal = (items) => {
|
|
|
83
83
|
const subtotal = items.reduce((sum, item) => {
|
|
84
84
|
const cartItemTotalPrice = new import_decimal.default(item.summaryTotal || 0);
|
|
85
85
|
const productDiscountProductDiscountDifference = getProductDiscountProductDiscountDifference(item);
|
|
86
|
-
return sum.plus(cartItemTotalPrice).
|
|
86
|
+
return sum.plus(cartItemTotalPrice).sub(productDiscountProductDiscountDifference);
|
|
87
87
|
}, new import_decimal.default(0));
|
|
88
88
|
return subtotal.toFixed(2);
|
|
89
89
|
};
|
|
@@ -308,7 +308,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
308
308
|
date: string;
|
|
309
309
|
status: string;
|
|
310
310
|
week: string;
|
|
311
|
-
weekNum: 0 |
|
|
311
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
312
312
|
}[]>;
|
|
313
313
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
314
314
|
private getScheduleDataByIds;
|
|
@@ -375,7 +375,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
375
375
|
if (item.booking_id) {
|
|
376
376
|
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(item);
|
|
377
377
|
(item.discount_list || []).forEach((discount) => {
|
|
378
|
-
var _a3, _b, _c;
|
|
378
|
+
var _a3, _b, _c, _d, _e;
|
|
379
379
|
if (discount.id && ["good_pass", "discount_card"].includes(discount.type)) {
|
|
380
380
|
const index = editModeDiscountList.findIndex((n) => {
|
|
381
381
|
var _a4;
|
|
@@ -385,7 +385,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
385
385
|
editModeDiscountList[index] = {
|
|
386
386
|
...editModeDiscountList[index],
|
|
387
387
|
amount: new import_decimal.default(discount.amount || 0).plus(new import_decimal.default(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
388
|
-
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(new import_decimal.default(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
388
|
+
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((_a3 = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a3.product_discount_difference) || 0).plus(new import_decimal.default(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
389
389
|
};
|
|
390
390
|
} else {
|
|
391
391
|
if (discount.type && !discount.tag) {
|
|
@@ -396,13 +396,13 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
396
396
|
name: discount.name || discount.discount.title.auto,
|
|
397
397
|
isEditMode: true,
|
|
398
398
|
limited_relation_product_data: {},
|
|
399
|
-
savedAmount: discount.amount
|
|
399
|
+
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.product_discount_difference) || 0).toNumber(),
|
|
400
400
|
isAvailable: true,
|
|
401
|
-
id: ((
|
|
402
|
-
format_title: ((
|
|
401
|
+
id: ((_c = discount.discount) == null ? void 0 : _c.resource_id) || discount.id,
|
|
402
|
+
format_title: ((_d = discount.discount) == null ? void 0 : _d.title) || discount.format_title,
|
|
403
403
|
isDisabled: true,
|
|
404
404
|
isSelected: true,
|
|
405
|
-
product_id: ((
|
|
405
|
+
product_id: ((_e = discount.discount) == null ? void 0 : _e.product_id) || discount.product_id
|
|
406
406
|
});
|
|
407
407
|
}
|
|
408
408
|
}
|