@pisell/pisellos 1.0.122 → 1.0.124
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/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +19 -0
- package/dist/modules/Rules/index.js +14 -14
- package/dist/modules/Summary/utils.d.ts +2 -0
- package/dist/modules/Summary/utils.js +9 -5
- package/dist/solution/BookingByStep/index.js +21 -9
- package/dist/solution/BookingByStep/utils/capacity.js +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +14 -0
- package/lib/modules/Rules/index.js +3 -3
- package/lib/modules/Summary/utils.d.ts +2 -0
- package/lib/modules/Summary/utils.js +12 -4
- package/lib/solution/BookingByStep/index.js +7 -8
- package/lib/solution/BookingByStep/utils/capacity.js +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
13
13
|
import Decimal from 'decimal.js';
|
|
14
14
|
import { isNormalProduct } from "../../Product/utils";
|
|
15
15
|
import { getDiscountAmount } from "../../../solution/ShopDiscount/utils";
|
|
16
|
+
import { calcDiscountListDifference } from "../../Summary/utils";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* @title 处理组合商品
|
|
@@ -70,6 +71,11 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
|
|
|
70
71
|
num: num,
|
|
71
72
|
discounts: discounts
|
|
72
73
|
});
|
|
74
|
+
cartItem.totalDifference = getTotalDifference({
|
|
75
|
+
product: product,
|
|
76
|
+
bundle: bundle,
|
|
77
|
+
discounts: discounts
|
|
78
|
+
});
|
|
73
79
|
cartItem.summaryTotal = cartItem.total * (num || 1);
|
|
74
80
|
cartItem.origin_total = getProductOriginTotalPrice({
|
|
75
81
|
product: product,
|
|
@@ -229,6 +235,19 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
|
|
|
229
235
|
}
|
|
230
236
|
return Math.max(0, price);
|
|
231
237
|
};
|
|
238
|
+
var getTotalDifference = function getTotalDifference(params) {
|
|
239
|
+
var bundle = params.bundle,
|
|
240
|
+
discounts = params.discounts;
|
|
241
|
+
var bundleDiscountList = [];
|
|
242
|
+
if (bundle !== null && bundle !== void 0 && bundle.length) {
|
|
243
|
+
bundle.forEach(function (currentValue) {
|
|
244
|
+
bundleDiscountList.push.apply(bundleDiscountList, _toConsumableArray((currentValue === null || currentValue === void 0 ? void 0 : currentValue.discount_list) || []));
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
var allDiscounts = [].concat(_toConsumableArray(discounts || []), bundleDiscountList);
|
|
248
|
+
var productDiscountProductDiscountDifference = calcDiscountListDifference(allDiscounts);
|
|
249
|
+
return productDiscountProductDiscountDifference || 0;
|
|
250
|
+
};
|
|
232
251
|
|
|
233
252
|
/**
|
|
234
253
|
* 获取商品原始总价
|
|
@@ -758,7 +758,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
758
758
|
// 收集该折扣卡适用的商品(排除被其他专属折扣卡占用的商品)
|
|
759
759
|
var applicableProducts = [];
|
|
760
760
|
sortedFlattenedList.forEach(function (flatItem) {
|
|
761
|
-
var _flatItem$parentProdu2, _product$price, _ref5, _flatItem$original_pr;
|
|
761
|
+
var _flatItem$parentProdu2, _flatItem$parentProdu3, _product$price, _ref5, _flatItem$original_pr;
|
|
762
762
|
// 🔥 检查该商品是否被其他专属折扣卡占用
|
|
763
763
|
var occupyingDiscountId = occupiedItems.get(flatItem._id);
|
|
764
764
|
if (occupyingDiscountId !== undefined && occupyingDiscountId !== discount.id) {
|
|
@@ -782,7 +782,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
782
782
|
}
|
|
783
783
|
|
|
784
784
|
// 对于 bundle 子商品,quantity 需要乘以主商品的购买数量
|
|
785
|
-
var quantity = flatItem.type === 'main' ? product.quantity || 1 : (product.num || 1) * (((_flatItem$parentProdu2 = flatItem.parentProduct) === null || _flatItem$parentProdu2 === void 0 ? void 0 : _flatItem$parentProdu2.quantity) || 1);
|
|
785
|
+
var quantity = flatItem.type === 'main' ? product.num || product.quantity || 1 : (product.num || product.quantity || 1) * (((_flatItem$parentProdu2 = flatItem.parentProduct) === null || _flatItem$parentProdu2 === void 0 ? void 0 : _flatItem$parentProdu2.num) || ((_flatItem$parentProdu3 = flatItem.parentProduct) === null || _flatItem$parentProdu3 === void 0 ? void 0 : _flatItem$parentProdu3.quantity) || 1);
|
|
786
786
|
|
|
787
787
|
// 对于主商品:使用 price
|
|
788
788
|
// 对于子商品:优先使用 flatItem.original_price,否则使用 flatItem.price
|
|
@@ -797,8 +797,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
797
797
|
|
|
798
798
|
// 子商品需要传递主商品数量
|
|
799
799
|
if (flatItem.type === 'bundle') {
|
|
800
|
-
var _flatItem$
|
|
801
|
-
productData.parentQuantity = ((_flatItem$
|
|
800
|
+
var _flatItem$parentProdu4;
|
|
801
|
+
productData.parentQuantity = ((_flatItem$parentProdu4 = flatItem.parentProduct) === null || _flatItem$parentProdu4 === void 0 ? void 0 : _flatItem$parentProdu4.quantity) || 1;
|
|
802
802
|
}
|
|
803
803
|
applicableProducts.push(productData);
|
|
804
804
|
});
|
|
@@ -825,7 +825,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
825
825
|
product = flatItem.product;
|
|
826
826
|
originProduct = flatItem.originProduct;
|
|
827
827
|
} else {
|
|
828
|
-
var _flatItem$
|
|
828
|
+
var _flatItem$parentProdu5;
|
|
829
829
|
// bundle子商品:构造虚拟商品对象
|
|
830
830
|
product = {
|
|
831
831
|
_id: flatItem._id,
|
|
@@ -837,7 +837,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
837
837
|
origin_total: flatItem.origin_total,
|
|
838
838
|
booking_id: flatItem.booking_id,
|
|
839
839
|
discount_list: flatItem.discount_list || [],
|
|
840
|
-
startDate: (_flatItem$
|
|
840
|
+
startDate: (_flatItem$parentProdu5 = flatItem.parentProduct) === null || _flatItem$parentProdu5 === void 0 ? void 0 : _flatItem$parentProdu5.startDate
|
|
841
841
|
};
|
|
842
842
|
originProduct = flatItem.originProduct;
|
|
843
843
|
}
|
|
@@ -915,7 +915,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
915
915
|
product = flatItem.product;
|
|
916
916
|
originProduct = flatItem.originProduct;
|
|
917
917
|
} else {
|
|
918
|
-
var _flatItem$bundleItem5, _flatItem$bundleItem6, _flatItem$bundleItem7, _flatItem$
|
|
918
|
+
var _flatItem$bundleItem5, _flatItem$bundleItem6, _flatItem$bundleItem7, _flatItem$parentProdu6;
|
|
919
919
|
// bundle子商品
|
|
920
920
|
product = {
|
|
921
921
|
_id: flatItem._id,
|
|
@@ -928,7 +928,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
928
928
|
origin_total: flatItem === null || flatItem === void 0 || (_flatItem$bundleItem6 = flatItem.bundleItem) === null || _flatItem$bundleItem6 === void 0 ? void 0 : _flatItem$bundleItem6.original_price,
|
|
929
929
|
booking_id: flatItem.booking_id,
|
|
930
930
|
discount_list: (flatItem === null || flatItem === void 0 || (_flatItem$bundleItem7 = flatItem.bundleItem) === null || _flatItem$bundleItem7 === void 0 ? void 0 : _flatItem$bundleItem7.discount_list) || [],
|
|
931
|
-
startDate: (_flatItem$
|
|
931
|
+
startDate: (_flatItem$parentProdu6 = flatItem.parentProduct) === null || _flatItem$parentProdu6 === void 0 ? void 0 : _flatItem$parentProdu6.startDate
|
|
932
932
|
};
|
|
933
933
|
originProduct = flatItem.originProduct;
|
|
934
934
|
}
|
|
@@ -1065,11 +1065,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1065
1065
|
}
|
|
1066
1066
|
// bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
|
|
1067
1067
|
if (flatItem.type === 'bundle') {
|
|
1068
|
-
var _product$discount_lis7, _flatItem$
|
|
1068
|
+
var _product$discount_lis7, _flatItem$parentProdu7;
|
|
1069
1069
|
if ((_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.some(function (item) {
|
|
1070
1070
|
var _item$discount2;
|
|
1071
1071
|
return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === options.discountId;
|
|
1072
|
-
}) || (_flatItem$
|
|
1072
|
+
}) || (_flatItem$parentProdu7 = flatItem.parentProduct) !== null && _flatItem$parentProdu7 !== void 0 && (_flatItem$parentProdu7 = _flatItem$parentProdu7.discount_list) !== null && _flatItem$parentProdu7 !== void 0 && _flatItem$parentProdu7.some(function (item) {
|
|
1073
1073
|
var _item$discount3;
|
|
1074
1074
|
return ((_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.resource_id) === options.discountId;
|
|
1075
1075
|
})) {
|
|
@@ -1091,14 +1091,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1091
1091
|
}
|
|
1092
1092
|
// bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
|
|
1093
1093
|
if (flatItem.type === 'bundle') {
|
|
1094
|
-
var _product$discount_lis9, _flatItem$
|
|
1094
|
+
var _product$discount_lis9, _flatItem$parentProdu8;
|
|
1095
1095
|
if ((_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
|
|
1096
1096
|
var _options$selectedList2;
|
|
1097
1097
|
return options === null || options === void 0 || (_options$selectedList2 = options.selectedList) === null || _options$selectedList2 === void 0 ? void 0 : _options$selectedList2.some(function (n) {
|
|
1098
1098
|
var _item$discount5;
|
|
1099
1099
|
return n.discountId === ((_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.resource_id);
|
|
1100
1100
|
});
|
|
1101
|
-
}) || (_flatItem$
|
|
1101
|
+
}) || (_flatItem$parentProdu8 = flatItem.parentProduct) !== null && _flatItem$parentProdu8 !== void 0 && (_flatItem$parentProdu8 = _flatItem$parentProdu8.discount_list) !== null && _flatItem$parentProdu8 !== void 0 && _flatItem$parentProdu8.some(function (item) {
|
|
1102
1102
|
var _options$selectedList3;
|
|
1103
1103
|
return options === null || options === void 0 || (_options$selectedList3 = options.selectedList) === null || _options$selectedList3 === void 0 ? void 0 : _options$selectedList3.some(function (n) {
|
|
1104
1104
|
var _item$discount6;
|
|
@@ -1378,7 +1378,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1378
1378
|
}));
|
|
1379
1379
|
}
|
|
1380
1380
|
} else {
|
|
1381
|
-
var _selectedDiscount3$me, _selectedDiscount3$me2, _flatItem$
|
|
1381
|
+
var _selectedDiscount3$me, _selectedDiscount3$me2, _flatItem$parentProdu9;
|
|
1382
1382
|
// 折扣卡:不拆分数量,直接应用
|
|
1383
1383
|
var _selectedDiscount3 = selectedDiscountCard || applicableDiscounts[0];
|
|
1384
1384
|
usedDiscounts.set(_selectedDiscount3.id, true);
|
|
@@ -1431,7 +1431,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1431
1431
|
product_discount_difference: _productDiscountDifference
|
|
1432
1432
|
}),
|
|
1433
1433
|
config: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.config,
|
|
1434
|
-
_num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$
|
|
1434
|
+
_num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$parentProdu9 = flatItem.parentProduct) === null || _flatItem$parentProdu9 === void 0 ? void 0 : _flatItem$parentProdu9.num) || 1)
|
|
1435
1435
|
};
|
|
1436
1436
|
|
|
1437
1437
|
// 记录实际应用的折扣
|
|
@@ -7,6 +7,8 @@ export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[], i
|
|
|
7
7
|
* @param item
|
|
8
8
|
*/
|
|
9
9
|
export declare const getBundleDiscountList: (bundle: any[]) => any[];
|
|
10
|
+
export declare const calcDiscountListDifference: (discountList: any[]) => any;
|
|
11
|
+
export declare const getProductDiscountProductDiscountDifference: (item: CartItem) => any;
|
|
10
12
|
/**
|
|
11
13
|
* 计算订单税费(折扣前/折扣后),并把单品税费信息回写到商品数据上(用于明细展示/后续计算)。
|
|
12
14
|
*
|
|
@@ -94,14 +94,18 @@ export var getBundleDiscountList = function getBundleDiscountList(bundle) {
|
|
|
94
94
|
});
|
|
95
95
|
return discountList;
|
|
96
96
|
};
|
|
97
|
-
var
|
|
97
|
+
export var calcDiscountListDifference = function calcDiscountListDifference(discountList) {
|
|
98
|
+
return discountList.reduce(function (pre, cur) {
|
|
99
|
+
var _cur$metadata;
|
|
100
|
+
return pre + ((cur === null || cur === void 0 || (_cur$metadata = cur.metadata) === null || _cur$metadata === void 0 ? void 0 : _cur$metadata.product_discount_difference) || 0);
|
|
101
|
+
}, 0);
|
|
102
|
+
};
|
|
103
|
+
export var getProductDiscountProductDiscountDifference = function getProductDiscountProductDiscountDifference(item) {
|
|
98
104
|
var _item$_origin, _item$_origin2;
|
|
99
105
|
var mainDiscountList = ((_item$_origin = item._origin) === null || _item$_origin === void 0 || (_item$_origin = _item$_origin.product) === null || _item$_origin === void 0 ? void 0 : _item$_origin.discount_list) || [];
|
|
100
106
|
var bundleDiscountList = getBundleDiscountList(((_item$_origin2 = item._origin) === null || _item$_origin2 === void 0 || (_item$_origin2 = _item$_origin2.product) === null || _item$_origin2 === void 0 ? void 0 : _item$_origin2.product_bundle) || []);
|
|
101
107
|
var discountList = [].concat(_toConsumableArray(mainDiscountList), _toConsumableArray(bundleDiscountList));
|
|
102
|
-
return discountList
|
|
103
|
-
return pre + (cur.metadata.product_discount_difference || 0);
|
|
104
|
-
}, 0);
|
|
108
|
+
return calcDiscountListDifference(discountList);
|
|
105
109
|
};
|
|
106
110
|
|
|
107
111
|
/**
|
|
@@ -345,7 +349,7 @@ var processItemsTax = function processItemsTax(items, _ref2, options) {
|
|
|
345
349
|
// 只处理原价的子商品
|
|
346
350
|
if (getBundleItemIsOriginalPrice(bundleItem)) {
|
|
347
351
|
var _ref3, _bundleItem$bundle_se;
|
|
348
|
-
var bundleQuantity = new Decimal(bundleItem.quantity || 1);
|
|
352
|
+
var bundleQuantity = new Decimal(bundleItem.num || bundleItem.quantity || 1);
|
|
349
353
|
var bundleUnitPrice = new Decimal((_ref3 = (_bundleItem$bundle_se = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se !== void 0 ? _bundleItem$bundle_se : bundleItem.price) !== null && _ref3 !== void 0 ? _ref3 : 0);
|
|
350
354
|
|
|
351
355
|
// 计算原始税费(折扣前)- 单个商品(精确值)
|
|
@@ -2215,12 +2215,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2215
2215
|
var _item$_resourceOrigin;
|
|
2216
2216
|
return ((_item$_resourceOrigin = item._resourceOrigin) === null || _item$_resourceOrigin === void 0 ? void 0 : _item$_resourceOrigin[0].id) === firstResource;
|
|
2217
2217
|
}).length;
|
|
2218
|
-
if (sameResourceLength
|
|
2218
|
+
if (sameResourceLength === items.length) {
|
|
2219
2219
|
return 1;
|
|
2220
2220
|
}
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2221
|
+
// 找出单个购物车里最大的需求 capacity 即可
|
|
2222
|
+
return Math.max.apply(Math, _toConsumableArray(items.map(function (item) {
|
|
2223
|
+
return getCapacityInfoByCartItem(item).currentCapacity || 1;
|
|
2224
|
+
})));
|
|
2225
|
+
// return items.reduce((total, item) => {
|
|
2226
|
+
// return total + (getCapacityInfoByCartItem(item).currentCapacity || 0);
|
|
2227
|
+
// }, 0);
|
|
2224
2228
|
};
|
|
2225
2229
|
|
|
2226
2230
|
// 如果是多个人预约,去要求出几个 holder 下最大的商品需求容量capacity
|
|
@@ -2388,9 +2392,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2388
2392
|
if (sameResourceLength !== items.length) {
|
|
2389
2393
|
return 1;
|
|
2390
2394
|
}
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2395
|
+
// 找出单个购物车里最大的需求 capacity 即可
|
|
2396
|
+
return Math.max.apply(Math, _toConsumableArray(items.map(function (item) {
|
|
2397
|
+
return getCapacityInfoByCartItem(item).currentCapacity || 1;
|
|
2398
|
+
})));
|
|
2394
2399
|
}; // 如果是多个预约,去要求出几个 holder 下最大的需求容量capacity
|
|
2395
2400
|
maxCapacity = 1;
|
|
2396
2401
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
@@ -2768,9 +2773,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2768
2773
|
// n.start_at 是 2025-06-30 15:00 end_at 2025-06-30 17:00
|
|
2769
2774
|
// item.start 是 2025-06-30 16:00 item.end 是 2025-06-30 19:00
|
|
2770
2775
|
// 需要判断 n.start_at 和 n.end_at 是否在 item.start 和 item.end 之间
|
|
2771
|
-
//
|
|
2776
|
+
// 如果是仅用于计算的资源, n.start_at 和 n.end_at 在 item.start 和 item.end 有交集,则此时间需要计算
|
|
2777
|
+
// https://project.feishu.cn/v2qint/bug/detail/6657165010
|
|
2772
2778
|
var mTimes = m.times.filter(function (n) {
|
|
2773
|
-
return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute') || dayjs(n.start_at).isBefore(dayjs(item.end), 'minute') && dayjs(n.end_at).isAfter(dayjs(item.start), 'minute');
|
|
2779
|
+
return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute') || m.onlyComputed && dayjs(n.start_at).isBefore(dayjs(item.end), 'minute') && dayjs(n.end_at).isAfter(dayjs(item.start), 'minute');
|
|
2774
2780
|
});
|
|
2775
2781
|
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
2776
2782
|
if (mTimes.length === 0) {
|
|
@@ -3152,6 +3158,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3152
3158
|
itemsByResourceType[resourceCode] = [];
|
|
3153
3159
|
}
|
|
3154
3160
|
// 避免重复添加同一个商品
|
|
3161
|
+
// 如果之前添加过的依赖相同资源的跟我现在是同一个 holder,也不需要重复添加
|
|
3162
|
+
if (itemsByResourceType[resourceCode].find(function (item) {
|
|
3163
|
+
return item.holder_id === cartItem.holder_id;
|
|
3164
|
+
})) {
|
|
3165
|
+
return;
|
|
3166
|
+
}
|
|
3155
3167
|
if (!itemsByResourceType[resourceCode].find(function (item) {
|
|
3156
3168
|
return item._id === cartItem._id;
|
|
3157
3169
|
})) {
|
|
@@ -320,7 +320,7 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
|
|
|
320
320
|
resourcesInType.forEach(function (resource) {
|
|
321
321
|
// 过滤出在时间段内的资源时间片
|
|
322
322
|
var availableTimes = resource.times.filter(function (time) {
|
|
323
|
-
return !dayjs(time.start_at).isAfter(dayjs(timeSlotStart), 'minute') && !dayjs(time.end_at).isBefore(dayjs(timeSlotEnd), 'minute') || dayjs(time.start_at).isBefore(dayjs(timeSlotEnd), 'minute') && dayjs(time.end_at).isAfter(dayjs(timeSlotStart), 'minute');
|
|
323
|
+
return !dayjs(time.start_at).isAfter(dayjs(timeSlotStart), 'minute') && !dayjs(time.end_at).isBefore(dayjs(timeSlotEnd), 'minute') || resource.onlyComputed && dayjs(time.start_at).isBefore(dayjs(timeSlotEnd), 'minute') && dayjs(time.end_at).isAfter(dayjs(timeSlotStart), 'minute');
|
|
324
324
|
});
|
|
325
325
|
if (availableTimes.length > 0) {
|
|
326
326
|
// 简化逻辑:如果资源在时间段内有可用时间,就计算其容量
|
|
@@ -115,7 +115,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
115
115
|
* 获取当前的客户搜索条件
|
|
116
116
|
* @returns 当前搜索条件
|
|
117
117
|
*/
|
|
118
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
118
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
119
119
|
/**
|
|
120
120
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
121
121
|
* @returns 客户状态
|
|
@@ -45,6 +45,7 @@ module.exports = __toCommonJS(cartProduct_exports);
|
|
|
45
45
|
var import_decimal = __toESM(require("decimal.js"));
|
|
46
46
|
var import_utils = require("../../Product/utils");
|
|
47
47
|
var import_utils2 = require("../../../solution/ShopDiscount/utils");
|
|
48
|
+
var import_utils3 = require("../../Summary/utils");
|
|
48
49
|
var handleVariantProduct = (product) => {
|
|
49
50
|
var _a;
|
|
50
51
|
if (product == null ? void 0 : product.product_variant_id) {
|
|
@@ -80,6 +81,7 @@ var formatProductToCartItem = (params) => {
|
|
|
80
81
|
cartItem.price = product == null ? void 0 : product.price;
|
|
81
82
|
cartItem.num = num;
|
|
82
83
|
cartItem.total = getProductTotalPrice({ product, bundle, options, num, discounts });
|
|
84
|
+
cartItem.totalDifference = getTotalDifference({ product, bundle, discounts });
|
|
83
85
|
cartItem.summaryTotal = cartItem.total * (num || 1);
|
|
84
86
|
cartItem.origin_total = getProductOriginTotalPrice({
|
|
85
87
|
product,
|
|
@@ -216,6 +218,18 @@ var getProductTotalPrice = (params) => {
|
|
|
216
218
|
}
|
|
217
219
|
return Math.max(0, price);
|
|
218
220
|
};
|
|
221
|
+
var getTotalDifference = (params) => {
|
|
222
|
+
const { bundle, discounts } = params;
|
|
223
|
+
const bundleDiscountList = [];
|
|
224
|
+
if (bundle == null ? void 0 : bundle.length) {
|
|
225
|
+
bundle.forEach((currentValue) => {
|
|
226
|
+
bundleDiscountList.push(...(currentValue == null ? void 0 : currentValue.discount_list) || []);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
const allDiscounts = [...discounts || [], ...bundleDiscountList];
|
|
230
|
+
const productDiscountProductDiscountDifference = (0, import_utils3.calcDiscountListDifference)(allDiscounts);
|
|
231
|
+
return productDiscountProductDiscountDifference || 0;
|
|
232
|
+
};
|
|
219
233
|
var getProductOriginTotalPrice = (params) => {
|
|
220
234
|
const { product, bundle, options, discounts } = params;
|
|
221
235
|
const num = (params == null ? void 0 : params.num) || 1;
|
|
@@ -502,7 +502,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
502
502
|
}
|
|
503
503
|
const applicableProducts = [];
|
|
504
504
|
sortedFlattenedList.forEach((flatItem) => {
|
|
505
|
-
var _a, _b;
|
|
505
|
+
var _a, _b, _c;
|
|
506
506
|
const occupyingDiscountId = occupiedItems.get(flatItem._id);
|
|
507
507
|
if (occupyingDiscountId !== void 0 && occupyingDiscountId !== discount.id) {
|
|
508
508
|
return;
|
|
@@ -522,7 +522,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
522
522
|
num: flatItem.num
|
|
523
523
|
};
|
|
524
524
|
}
|
|
525
|
-
const quantity = flatItem.type === "main" ? product.quantity || 1 : (product.num || 1) * (((_a = flatItem.parentProduct) == null ? void 0 : _a.quantity) || 1);
|
|
525
|
+
const quantity = flatItem.type === "main" ? product.num || product.quantity || 1 : (product.num || product.quantity || 1) * (((_a = flatItem.parentProduct) == null ? void 0 : _a.num) || ((_b = flatItem.parentProduct) == null ? void 0 : _b.quantity) || 1);
|
|
526
526
|
const originalAmount = flatItem.type === "main" ? Number(product.price ?? 0) : Number(flatItem.original_price ?? flatItem.price ?? 0);
|
|
527
527
|
const productData = {
|
|
528
528
|
productId: flatItem._id,
|
|
@@ -530,7 +530,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
530
530
|
quantity
|
|
531
531
|
};
|
|
532
532
|
if (flatItem.type === "bundle") {
|
|
533
|
-
productData.parentQuantity = ((
|
|
533
|
+
productData.parentQuantity = ((_c = flatItem.parentProduct) == null ? void 0 : _c.quantity) || 1;
|
|
534
534
|
}
|
|
535
535
|
applicableProducts.push(productData);
|
|
536
536
|
});
|
|
@@ -7,6 +7,8 @@ export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[], i
|
|
|
7
7
|
* @param item
|
|
8
8
|
*/
|
|
9
9
|
export declare const getBundleDiscountList: (bundle: any[]) => any[];
|
|
10
|
+
export declare const calcDiscountListDifference: (discountList: any[]) => any;
|
|
11
|
+
export declare const getProductDiscountProductDiscountDifference: (item: CartItem) => any;
|
|
10
12
|
/**
|
|
11
13
|
* 计算订单税费(折扣前/折扣后),并把单品税费信息回写到商品数据上(用于明细展示/后续计算)。
|
|
12
14
|
*
|
|
@@ -29,12 +29,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// src/modules/Summary/utils.ts
|
|
30
30
|
var utils_exports = {};
|
|
31
31
|
__export(utils_exports, {
|
|
32
|
+
calcDiscountListDifference: () => calcDiscountListDifference,
|
|
32
33
|
calculateDeposit: () => calculateDeposit,
|
|
33
34
|
calculateOriginSubtotal: () => calculateOriginSubtotal,
|
|
34
35
|
calculatePriceDetails: () => calculatePriceDetails,
|
|
35
36
|
calculateSubtotal: () => calculateSubtotal,
|
|
36
37
|
calculateTaxFee: () => calculateTaxFee,
|
|
37
38
|
getBundleDiscountList: () => getBundleDiscountList,
|
|
39
|
+
getProductDiscountProductDiscountDifference: () => getProductDiscountProductDiscountDifference,
|
|
38
40
|
getSurcharge: () => getSurcharge,
|
|
39
41
|
getSurchargeAmount: () => getSurchargeAmount,
|
|
40
42
|
getTax: () => getTax
|
|
@@ -84,14 +86,18 @@ var getBundleDiscountList = (bundle) => {
|
|
|
84
86
|
});
|
|
85
87
|
return discountList;
|
|
86
88
|
};
|
|
89
|
+
var calcDiscountListDifference = (discountList) => {
|
|
90
|
+
return discountList.reduce((pre, cur) => {
|
|
91
|
+
var _a;
|
|
92
|
+
return pre + (((_a = cur == null ? void 0 : cur.metadata) == null ? void 0 : _a.product_discount_difference) || 0);
|
|
93
|
+
}, 0);
|
|
94
|
+
};
|
|
87
95
|
var getProductDiscountProductDiscountDifference = (item) => {
|
|
88
96
|
var _a, _b, _c, _d;
|
|
89
97
|
const mainDiscountList = ((_b = (_a = item._origin) == null ? void 0 : _a.product) == null ? void 0 : _b.discount_list) || [];
|
|
90
98
|
const bundleDiscountList = getBundleDiscountList(((_d = (_c = item._origin) == null ? void 0 : _c.product) == null ? void 0 : _d.product_bundle) || []);
|
|
91
99
|
const discountList = [...mainDiscountList, ...bundleDiscountList];
|
|
92
|
-
return discountList
|
|
93
|
-
return pre + (cur.metadata.product_discount_difference || 0);
|
|
94
|
-
}, 0);
|
|
100
|
+
return calcDiscountListDifference(discountList);
|
|
95
101
|
};
|
|
96
102
|
var getTax = ({ service, addons, bookingDetail, bookingId }, options) => {
|
|
97
103
|
const { isEdit, computed, tax_rate, is_price_include_tax } = options;
|
|
@@ -215,7 +221,7 @@ var processItemsTax = (items, { bookingDetail, bookingId }, options) => {
|
|
|
215
221
|
if (Array.isArray(item == null ? void 0 : item.bundle)) {
|
|
216
222
|
for (let bundleItem of item == null ? void 0 : item.bundle) {
|
|
217
223
|
if (getBundleItemIsOriginalPrice(bundleItem)) {
|
|
218
|
-
const bundleQuantity = new import_decimal.default(bundleItem.quantity || 1);
|
|
224
|
+
const bundleQuantity = new import_decimal.default(bundleItem.num || bundleItem.quantity || 1);
|
|
219
225
|
const bundleUnitPrice = new import_decimal.default(
|
|
220
226
|
bundleItem.bundle_selling_price ?? bundleItem.price ?? 0
|
|
221
227
|
);
|
|
@@ -755,12 +761,14 @@ function resetItemsSurchargeSideEffects({ service, addons }) {
|
|
|
755
761
|
}
|
|
756
762
|
// Annotate the CommonJS export names for ESM import in node:
|
|
757
763
|
0 && (module.exports = {
|
|
764
|
+
calcDiscountListDifference,
|
|
758
765
|
calculateDeposit,
|
|
759
766
|
calculateOriginSubtotal,
|
|
760
767
|
calculatePriceDetails,
|
|
761
768
|
calculateSubtotal,
|
|
762
769
|
calculateTaxFee,
|
|
763
770
|
getBundleDiscountList,
|
|
771
|
+
getProductDiscountProductDiscountDifference,
|
|
764
772
|
getSurcharge,
|
|
765
773
|
getSurchargeAmount,
|
|
766
774
|
getTax
|
|
@@ -1536,12 +1536,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1536
1536
|
var _a3;
|
|
1537
1537
|
return ((_a3 = item._resourceOrigin) == null ? void 0 : _a3[0].id) === firstResource;
|
|
1538
1538
|
}).length;
|
|
1539
|
-
if (sameResourceLength
|
|
1539
|
+
if (sameResourceLength === items.length) {
|
|
1540
1540
|
return 1;
|
|
1541
1541
|
}
|
|
1542
|
-
return items.
|
|
1543
|
-
return total + ((0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 0);
|
|
1544
|
-
}, 0);
|
|
1542
|
+
return Math.max(...items.map((item) => (0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
|
|
1545
1543
|
};
|
|
1546
1544
|
let maxCapacity = 1;
|
|
1547
1545
|
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
@@ -1674,9 +1672,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1674
1672
|
if (sameResourceLength !== items.length) {
|
|
1675
1673
|
return 1;
|
|
1676
1674
|
}
|
|
1677
|
-
return items.
|
|
1678
|
-
return total + ((0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 0);
|
|
1679
|
-
}, 0);
|
|
1675
|
+
return Math.max(...items.map((item) => (0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
|
|
1680
1676
|
};
|
|
1681
1677
|
let maxCapacity = 1;
|
|
1682
1678
|
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
@@ -1950,7 +1946,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1950
1946
|
let currentResourceMaxRemainingCapacity = 0;
|
|
1951
1947
|
let isAllTimeSlicesUsable = true;
|
|
1952
1948
|
const mTimes = m.times.filter((n) => {
|
|
1953
|
-
return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute") || (0, import_dayjs.default)(n.start_at).isBefore((0, import_dayjs.default)(item.end), "minute") && (0, import_dayjs.default)(n.end_at).isAfter((0, import_dayjs.default)(item.start), "minute");
|
|
1949
|
+
return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute") || m.onlyComputed && (0, import_dayjs.default)(n.start_at).isBefore((0, import_dayjs.default)(item.end), "minute") && (0, import_dayjs.default)(n.end_at).isAfter((0, import_dayjs.default)(item.start), "minute");
|
|
1954
1950
|
});
|
|
1955
1951
|
if (mTimes.length === 0) {
|
|
1956
1952
|
return;
|
|
@@ -2265,6 +2261,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2265
2261
|
if (!itemsByResourceType[resourceCode]) {
|
|
2266
2262
|
itemsByResourceType[resourceCode] = [];
|
|
2267
2263
|
}
|
|
2264
|
+
if (itemsByResourceType[resourceCode].find((item) => item.holder_id === cartItem.holder_id)) {
|
|
2265
|
+
return;
|
|
2266
|
+
}
|
|
2268
2267
|
if (!itemsByResourceType[resourceCode].find((item) => item._id === cartItem._id)) {
|
|
2269
2268
|
itemsByResourceType[resourceCode].push(cartItem);
|
|
2270
2269
|
}
|
|
@@ -230,7 +230,7 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
230
230
|
let totalAvailableCapacity = 0;
|
|
231
231
|
resourcesInType.forEach((resource) => {
|
|
232
232
|
const availableTimes = resource.times.filter((time) => {
|
|
233
|
-
return !(0, import_dayjs.default)(time.start_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute") && !(0, import_dayjs.default)(time.end_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") || (0, import_dayjs.default)(time.start_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") && (0, import_dayjs.default)(time.end_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute");
|
|
233
|
+
return !(0, import_dayjs.default)(time.start_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute") && !(0, import_dayjs.default)(time.end_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") || resource.onlyComputed && (0, import_dayjs.default)(time.start_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") && (0, import_dayjs.default)(time.end_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute");
|
|
234
234
|
});
|
|
235
235
|
if (availableTimes.length > 0) {
|
|
236
236
|
totalAvailableCapacity += resource.capacity || 0;
|
|
@@ -115,7 +115,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
115
115
|
* 获取当前的客户搜索条件
|
|
116
116
|
* @returns 当前搜索条件
|
|
117
117
|
*/
|
|
118
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
118
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
119
119
|
/**
|
|
120
120
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
121
121
|
* @returns 客户状态
|