@pisell/pisellos 2.2.15 → 2.2.17
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/Customer/index.js +1 -1
- package/dist/modules/Payment/index.js +2 -2
- package/dist/modules/Payment/types.d.ts +1 -0
- package/dist/modules/Payment/walletpass.js +3 -1
- package/dist/modules/ProductList/index.js +8 -9
- package/dist/modules/Rules/index.d.ts +4 -2
- package/dist/modules/Rules/index.js +94 -53
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +29 -8
- package/dist/solution/BookingByStep/utils/products.d.ts +6 -0
- package/dist/solution/BookingByStep/utils/products.js +10 -0
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Checkout/index.js +61 -17
- package/dist/solution/ShopDiscount/index.d.ts +4 -0
- package/dist/solution/ShopDiscount/index.js +13 -4
- package/dist/solution/ShopDiscount/types.d.ts +5 -1
- package/lib/modules/Customer/index.js +1 -1
- package/lib/modules/Payment/index.js +1 -1
- package/lib/modules/Payment/types.d.ts +1 -0
- package/lib/modules/Payment/walletpass.js +10 -1
- package/lib/modules/ProductList/index.js +0 -7
- package/lib/modules/Rules/index.d.ts +4 -2
- package/lib/modules/Rules/index.js +71 -52
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +15 -2
- package/lib/solution/BookingByStep/utils/products.d.ts +6 -0
- package/lib/solution/BookingByStep/utils/products.js +8 -2
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Checkout/index.js +66 -17
- package/lib/solution/ShopDiscount/index.d.ts +4 -0
- package/lib/solution/ShopDiscount/index.js +12 -5
- package/lib/solution/ShopDiscount/types.d.ts +5 -1
- package/package.json +2 -2
|
@@ -154,7 +154,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
154
154
|
skip: skip,
|
|
155
155
|
num: num,
|
|
156
156
|
sort_by: SORT_BY,
|
|
157
|
-
with: ['latestWalletDetail.wallet'],
|
|
157
|
+
with: ['latestWalletDetail.wallet', 'contactsInfo'],
|
|
158
158
|
search_wallet_flag: 1,
|
|
159
159
|
search_wallet_pass_flag: 1
|
|
160
160
|
}, search && {
|
|
@@ -21,7 +21,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
21
21
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
22
22
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
23
23
|
import { BaseModule } from "../BaseModule";
|
|
24
|
-
import { PaymentStatus,
|
|
24
|
+
import { PaymentStatus, PaymentMethodType, RoundingRule } from "./types";
|
|
25
25
|
import { getUniqueId } from "../Cart/utils";
|
|
26
26
|
import { CashPaymentImpl } from "./cash";
|
|
27
27
|
import { EftposPaymentImpl } from "./eftpos";
|
|
@@ -1237,7 +1237,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1237
1237
|
this.logInfo('更新订单支付项完成', {
|
|
1238
1238
|
orderUuid: orderUuid
|
|
1239
1239
|
});
|
|
1240
|
-
this.core.effects.emit(
|
|
1240
|
+
this.core.effects.emit("".concat(this.name, ":onPaymentAdded"), {
|
|
1241
1241
|
orderUuid: orderUuid,
|
|
1242
1242
|
payment: newPaymentItem
|
|
1243
1243
|
});
|
|
@@ -64,12 +64,14 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
64
64
|
amountInfo = businessData.amountInfo,
|
|
65
65
|
products = businessData.products,
|
|
66
66
|
order_wait_pay_amount = businessData.order_wait_pay_amount,
|
|
67
|
-
payment_order_id = businessData.payment_order_id
|
|
67
|
+
payment_order_id = businessData.payment_order_id,
|
|
68
|
+
is_price_include_tax = businessData.is_price_include_tax;
|
|
68
69
|
|
|
69
70
|
// 转换金额为数字类型
|
|
70
71
|
var totalAmount = Number(amountInfo.totalAmount);
|
|
71
72
|
var subTotal = Number(amountInfo.subTotal);
|
|
72
73
|
var walletParams = {
|
|
74
|
+
is_price_include_tax: is_price_include_tax,
|
|
73
75
|
sale_channel: 'pos',
|
|
74
76
|
customer_id: customer_id || 0,
|
|
75
77
|
// 提供默认值,确保类型为 number
|
|
@@ -140,17 +140,16 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
140
140
|
productsData = _context3.sent;
|
|
141
141
|
sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
|
|
142
142
|
return Number(b.sort) - Number(a.sort);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
143
|
+
}); // if (sortedList.length) {
|
|
144
|
+
// sortedList.forEach((n: any) => {
|
|
145
|
+
// if (n.is_eject !== 1 && n['schedule.ids'] && n['schedule.ids'].length) {
|
|
146
|
+
// n.is_eject = 1
|
|
147
|
+
// }
|
|
148
|
+
// })
|
|
149
|
+
// }
|
|
151
150
|
this.addProduct(sortedList);
|
|
152
151
|
return _context3.abrupt("return", sortedList);
|
|
153
|
-
case
|
|
152
|
+
case 10:
|
|
154
153
|
case "end":
|
|
155
154
|
return _context3.stop();
|
|
156
155
|
}
|
|
@@ -13,24 +13,26 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
13
13
|
setRulesList(rulesList: Rules[]): Promise<void>;
|
|
14
14
|
getRulesList(): Rules[];
|
|
15
15
|
private checkHolderMatch;
|
|
16
|
-
isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, holders, }: {
|
|
16
|
+
isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, holders, isFormSubject, }: {
|
|
17
17
|
oldDiscountList: Discount[];
|
|
18
18
|
newDiscountList: Discount[];
|
|
19
19
|
productList: any[];
|
|
20
20
|
holders: {
|
|
21
21
|
form_record_id: number;
|
|
22
22
|
}[];
|
|
23
|
+
isFormSubject: boolean;
|
|
23
24
|
}): {
|
|
24
25
|
isAvailable: boolean;
|
|
25
26
|
discountList: Discount[];
|
|
26
27
|
productList: any[];
|
|
27
28
|
};
|
|
28
|
-
calcDiscount({ discountList, productList, holders, }: {
|
|
29
|
+
calcDiscount({ discountList, productList, holders, isFormSubject, }: {
|
|
29
30
|
discountList: Discount[];
|
|
30
31
|
productList: any[];
|
|
31
32
|
holders: {
|
|
32
33
|
form_record_id: number;
|
|
33
34
|
}[];
|
|
35
|
+
isFormSubject: boolean;
|
|
34
36
|
}, options?: {
|
|
35
37
|
isSelected?: boolean;
|
|
36
38
|
discountId?: number;
|
|
@@ -28,6 +28,8 @@ import { uniqueById, getDiscountAmount, getDiscountListAmountTotal, getDiscountL
|
|
|
28
28
|
import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
|
|
29
29
|
import Decimal from 'decimal.js';
|
|
30
30
|
import dayjs from 'dayjs';
|
|
31
|
+
import { isBoolean } from 'lodash-es';
|
|
32
|
+
|
|
31
33
|
// 临时变量
|
|
32
34
|
var flatItem;
|
|
33
35
|
export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
@@ -92,7 +94,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
92
94
|
return this.store.rulesList;
|
|
93
95
|
}
|
|
94
96
|
|
|
95
|
-
//
|
|
97
|
+
// 商品不需要holder,则不需要判断,直接返回true,商品需要holder但是还没填写,那么暂时不使用带有holder的券,直到填写才去匹配
|
|
96
98
|
}, {
|
|
97
99
|
key: "checkHolderMatch",
|
|
98
100
|
value: function checkHolderMatch(discount, product, holders) {
|
|
@@ -102,8 +104,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
102
104
|
// 主预约holder, 目前(20251124)默认只考虑单个holder的情况
|
|
103
105
|
var orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id : undefined;
|
|
104
106
|
var productHolderId = Array.isArray(product.holder_id) ? product.holder_id[0] : product.holder_id;
|
|
105
|
-
//
|
|
106
|
-
if (!
|
|
107
|
+
// 商品不需要选holder,则不对比holder,直接返回true,
|
|
108
|
+
if (!product.isNeedHolder) return true;
|
|
109
|
+
// 商品需要holder,但父预约及商品都无holder,返回false
|
|
110
|
+
if (!orderHolderId && !productHolderId) return false;
|
|
107
111
|
|
|
108
112
|
// 最终直接匹配 holder 是否相同
|
|
109
113
|
return (productHolderId || orderHolderId) === discount.holder.holder_id;
|
|
@@ -117,7 +121,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
117
121
|
var oldDiscountList = _ref.oldDiscountList,
|
|
118
122
|
newDiscountList = _ref.newDiscountList,
|
|
119
123
|
productList = _ref.productList,
|
|
120
|
-
holders = _ref.holders
|
|
124
|
+
holders = _ref.holders,
|
|
125
|
+
isFormSubject = _ref.isFormSubject;
|
|
121
126
|
// 首先检查是否有新的优惠券可应用
|
|
122
127
|
if (!newDiscountList || newDiscountList.length === 0) {
|
|
123
128
|
return {
|
|
@@ -148,7 +153,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
148
153
|
var result = this.calcDiscount({
|
|
149
154
|
discountList: mergedDiscountList,
|
|
150
155
|
productList: _toConsumableArray(productList),
|
|
151
|
-
holders: holders
|
|
156
|
+
holders: holders,
|
|
157
|
+
isFormSubject: isFormSubject
|
|
152
158
|
}, {
|
|
153
159
|
scan: true
|
|
154
160
|
});
|
|
@@ -191,7 +197,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
191
197
|
var _this3 = this;
|
|
192
198
|
var discountList = _ref2.discountList,
|
|
193
199
|
productList = _ref2.productList,
|
|
194
|
-
holders = _ref2.holders
|
|
200
|
+
holders = _ref2.holders,
|
|
201
|
+
isFormSubject = _ref2.isFormSubject;
|
|
195
202
|
// 识别出来是不是在编辑的界面里又新增了商品
|
|
196
203
|
// 这种情况下,如果有可用的优惠券,也会自动勾选上
|
|
197
204
|
var isEditModeAddNewProduct = productList.find(function (n) {
|
|
@@ -427,11 +434,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
427
434
|
originProduct = flatItem.originProduct;
|
|
428
435
|
}
|
|
429
436
|
addModeDiscount.forEach(function (discount) {
|
|
430
|
-
var
|
|
437
|
+
var _product, _product2, _product3, _product4, _flatItem$bundleItem;
|
|
431
438
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
432
439
|
// 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
|
|
440
|
+
var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
|
|
433
441
|
var isHolderMatch = _this3.checkHolderMatch(discount, {
|
|
434
|
-
|
|
442
|
+
isNeedHolder: isFormSubject && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
|
|
443
|
+
holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
435
444
|
}, holders);
|
|
436
445
|
var timeLimit = true;
|
|
437
446
|
timeLimit = !!filterDiscountListByBookingTime([discount], (((_product = product) === null || _product === void 0 ? void 0 : _product.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
|
|
@@ -488,7 +497,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
488
497
|
// 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
|
|
489
498
|
// 🔥 使用扁平化后的列表进行处理
|
|
490
499
|
sortedFlattenedList.forEach(function (flatItem, index) {
|
|
491
|
-
var _product5, _product$discount_lis2, _product6
|
|
500
|
+
var _product5, _product$discount_lis2, _product6;
|
|
492
501
|
// 获取商品数据
|
|
493
502
|
var product, originProduct;
|
|
494
503
|
if (flatItem.type === 'main') {
|
|
@@ -528,7 +537,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
528
537
|
|
|
529
538
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
530
539
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
531
|
-
var _product$discount_lis3, _product$discount_lis4
|
|
540
|
+
var _product$discount_lis3, _product$discount_lis4;
|
|
532
541
|
// 如果商品价格为 0,其实不需要使用任何优惠券,直接 return true
|
|
533
542
|
// 商品券时主商品价格为0不可用
|
|
534
543
|
if ((Number(product.price) <= 0 || !product.price) && !((_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.find(function (n) {
|
|
@@ -537,7 +546,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
537
546
|
})) && (discount.tag || discount.type) === 'good_pass') return false;
|
|
538
547
|
|
|
539
548
|
// 折扣卡商品价格为0时不可用
|
|
540
|
-
if ((Number(product.price)
|
|
549
|
+
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) {
|
|
541
550
|
var _n$discount2;
|
|
542
551
|
return ((_n$discount2 = n.discount) === null || _n$discount2 === void 0 ? void 0 : _n$discount2.resource_id) === discount.id;
|
|
543
552
|
})) && (discount.tag || discount.type) !== 'good_pass') return false;
|
|
@@ -545,18 +554,20 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
545
554
|
var targetUsedDiscounts = usedDiscounts.get(discount.id);
|
|
546
555
|
if (targetUsedDiscounts && (discount.tag || discount.type) === 'good_pass') return false;
|
|
547
556
|
var limitedData = discount.limited_relation_product_data;
|
|
548
|
-
var timeLimit = true;
|
|
549
|
-
timeLimit = !!filterDiscountListByBookingTime([discount], (product.startDate || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
|
|
550
|
-
if (!timeLimit) {
|
|
551
|
-
return false;
|
|
552
|
-
}
|
|
553
557
|
|
|
554
558
|
// 拿到discount配置的holder信息 product信息 product.holder 不可用return false
|
|
559
|
+
var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
|
|
555
560
|
var isHolderMatch = _this3.checkHolderMatch(discount, {
|
|
556
|
-
|
|
561
|
+
isNeedHolder: isFormSubject && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
|
|
562
|
+
holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
557
563
|
}, holders);
|
|
558
564
|
// 如果 holder 不匹配,则不适用
|
|
559
565
|
if (!isHolderMatch) return false;
|
|
566
|
+
var timeLimit = true;
|
|
567
|
+
timeLimit = !!filterDiscountListByBookingTime([discount], (product.startDate || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
|
|
568
|
+
if (!timeLimit) {
|
|
569
|
+
return false;
|
|
570
|
+
}
|
|
560
571
|
|
|
561
572
|
// 判断优惠券是否适用于该商品
|
|
562
573
|
if (limitedData.type === 'product_all') {
|
|
@@ -620,11 +631,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
620
631
|
}
|
|
621
632
|
// bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
|
|
622
633
|
if (flatItem.type === 'bundle') {
|
|
623
|
-
var _product$discount_lis7, _flatItem$
|
|
634
|
+
var _product$discount_lis7, _flatItem$parentProdu;
|
|
624
635
|
if ((_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.some(function (item) {
|
|
625
636
|
var _item$discount2;
|
|
626
637
|
return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === options.discountId;
|
|
627
|
-
}) || (_flatItem$
|
|
638
|
+
}) || (_flatItem$parentProdu = flatItem.parentProduct) !== null && _flatItem$parentProdu !== void 0 && (_flatItem$parentProdu = _flatItem$parentProdu.discount_list) !== null && _flatItem$parentProdu !== void 0 && _flatItem$parentProdu.some(function (item) {
|
|
628
639
|
var _item$discount3;
|
|
629
640
|
return ((_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.resource_id) === options.discountId;
|
|
630
641
|
})) {
|
|
@@ -646,14 +657,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
646
657
|
}
|
|
647
658
|
// bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
|
|
648
659
|
if (flatItem.type === 'bundle') {
|
|
649
|
-
var _product$discount_lis9, _flatItem$
|
|
660
|
+
var _product$discount_lis9, _flatItem$parentProdu2;
|
|
650
661
|
if ((_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
|
|
651
662
|
var _options$selectedList2;
|
|
652
663
|
return options === null || options === void 0 || (_options$selectedList2 = options.selectedList) === null || _options$selectedList2 === void 0 ? void 0 : _options$selectedList2.some(function (n) {
|
|
653
664
|
var _item$discount5;
|
|
654
665
|
return n.discountId === ((_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.resource_id);
|
|
655
666
|
});
|
|
656
|
-
}) || (_flatItem$
|
|
667
|
+
}) || (_flatItem$parentProdu2 = flatItem.parentProduct) !== null && _flatItem$parentProdu2 !== void 0 && (_flatItem$parentProdu2 = _flatItem$parentProdu2.discount_list) !== null && _flatItem$parentProdu2 !== void 0 && _flatItem$parentProdu2.some(function (item) {
|
|
657
668
|
var _options$selectedList3;
|
|
658
669
|
return options === null || options === void 0 || (_options$selectedList3 = options.selectedList) === null || _options$selectedList3 === void 0 ? void 0 : _options$selectedList3.some(function (n) {
|
|
659
670
|
var _item$discount6;
|
|
@@ -664,18 +675,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
664
675
|
}
|
|
665
676
|
}
|
|
666
677
|
}
|
|
667
|
-
if (options !== null && options !== void 0 && options.selectedList && (_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.some(function (item) {
|
|
668
|
-
var _options$selectedList4;
|
|
669
|
-
return options === null || options === void 0 || (_options$selectedList4 = options.selectedList) === null || _options$selectedList4 === void 0 ? void 0 : _options$selectedList4.some(function (n) {
|
|
670
|
-
var _item$discount7;
|
|
671
|
-
return n.discountId === ((_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.resource_id);
|
|
672
|
-
});
|
|
673
|
-
})) {
|
|
674
|
-
isManualDiscount = false;
|
|
675
|
-
}
|
|
676
678
|
|
|
677
679
|
// 如果没有适用的优惠券,或者手动折扣,则不适用优惠券
|
|
678
|
-
if (applicableDiscounts.length === 0 || isManualDiscount) {
|
|
680
|
+
if (applicableDiscounts.length === 0 || isManualDiscount || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
679
681
|
if (flatItem.type === 'main') {
|
|
680
682
|
// 主商品:保持原有逻辑
|
|
681
683
|
if (product.isClient) {
|
|
@@ -701,7 +703,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
701
703
|
discount_list: []
|
|
702
704
|
}))]);
|
|
703
705
|
} else {
|
|
704
|
-
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
|
|
706
|
+
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
|
|
707
|
+
price: product.price,
|
|
708
|
+
main_product_selling_price: product.price
|
|
709
|
+
} : {
|
|
705
710
|
_id: product._id.split('___')[0] + '___' + index,
|
|
706
711
|
total: product.origin_total || product.total,
|
|
707
712
|
price: product.price,
|
|
@@ -714,7 +719,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
714
719
|
// bundle子商品:保存到扁平化Map
|
|
715
720
|
processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
716
721
|
discount_list: [],
|
|
717
|
-
price: flatItem.bundleItem.original_price,
|
|
722
|
+
price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
|
|
718
723
|
processed: true
|
|
719
724
|
})]);
|
|
720
725
|
}
|
|
@@ -746,7 +751,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
746
751
|
}));
|
|
747
752
|
}
|
|
748
753
|
for (var i = 0; i < splitCount; i++) {
|
|
749
|
-
var _product$
|
|
754
|
+
var _product$discount_lis10, _originProduct, _selectedDiscount$met;
|
|
750
755
|
// 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
|
|
751
756
|
var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
|
|
752
757
|
// 标记优惠券为已使用
|
|
@@ -758,7 +763,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
758
763
|
// 优先从 origin_total拿,可能会拿不到(比如用户端预约在没有配置 original_price 的情况下)
|
|
759
764
|
var productOriginTotal = product.origin_total || product.total || 0;
|
|
760
765
|
// 如果当前 product 有 discount_list,则先从 origin_total 拿
|
|
761
|
-
if ((_product$
|
|
766
|
+
if ((_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.length && product.origin_total) {
|
|
762
767
|
productOriginTotal = product.origin_total;
|
|
763
768
|
}
|
|
764
769
|
// 如果originProduct?._productInit?.original_price为 0,product.origin_total可能为空,此时取 product.total
|
|
@@ -895,7 +900,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
895
900
|
}));
|
|
896
901
|
}
|
|
897
902
|
} else {
|
|
898
|
-
var _selectedDiscount3$me, _flatItem$
|
|
903
|
+
var _selectedDiscount3$me, _flatItem$parentProdu3;
|
|
899
904
|
// 折扣卡:不拆分数量,直接应用
|
|
900
905
|
var _selectedDiscount3 = selectedDiscountCard || applicableDiscounts[0];
|
|
901
906
|
usedDiscounts.set(_selectedDiscount3.id, true);
|
|
@@ -921,7 +926,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
921
926
|
custom_product_bundle_map_id: _uniqueId,
|
|
922
927
|
num: product.num || 1
|
|
923
928
|
},
|
|
924
|
-
_num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$
|
|
929
|
+
_num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$parentProdu3 = flatItem.parentProduct) === null || _flatItem$parentProdu3 === void 0 ? void 0 : _flatItem$parentProdu3.num) || 1)
|
|
925
930
|
};
|
|
926
931
|
|
|
927
932
|
// 记录实际应用的折扣
|
|
@@ -1114,14 +1119,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1114
1119
|
var allDiscountAmount = getDiscountListAmountTotal(mainDiscountList);
|
|
1115
1120
|
newTotalWithDiscount = (_Decimal$minus$toNumb = new Decimal(mainProductData.price || 0).minus(allDiscountAmount).toNumber()) !== null && _Decimal$minus$toNumb !== void 0 ? _Decimal$minus$toNumb : newTotalWithDiscount;
|
|
1116
1121
|
newOriginTotalWithDiscount = (_mainProductData$orig = mainProductData.origin_total) !== null && _mainProductData$orig !== void 0 ? _mainProductData$orig : newOriginTotalWithDiscount;
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
// 累加bundle的价格(只累加一次)
|
|
1125
|
+
if (newBundleWithDiscount.length > 0) {
|
|
1126
|
+
newBundleWithDiscount.forEach(function (item) {
|
|
1127
|
+
newTotalWithDiscount += Number(item.price) * Number(item.num);
|
|
1128
|
+
});
|
|
1129
|
+
newBundleWithDiscount.forEach(function (item) {
|
|
1130
|
+
var _item$discount_list2;
|
|
1131
|
+
var originalPrice = ((_item$discount_list2 = item.discount_list) === null || _item$discount_list2 === void 0 || (_item$discount_list2 = _item$discount_list2[0]) === null || _item$discount_list2 === void 0 || (_item$discount_list2 = _item$discount_list2.discount) === null || _item$discount_list2 === void 0 ? void 0 : _item$discount_list2.original_amount) || item.price;
|
|
1132
|
+
newOriginTotalWithDiscount += Number(originalPrice) * Number(item.num);
|
|
1133
|
+
});
|
|
1125
1134
|
}
|
|
1126
1135
|
|
|
1127
1136
|
// 累加options的价格(options不参与折扣,在最终设置total时处理)
|
|
@@ -1184,12 +1193,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1184
1193
|
var _allDiscountAmount = getDiscountListAmount(mainDiscountListOriginal);
|
|
1185
1194
|
newTotalOriginal = (_Decimal$minus$toNumb2 = new Decimal(mainProductData.price || 0).minus(_allDiscountAmount).toNumber()) !== null && _Decimal$minus$toNumb2 !== void 0 ? _Decimal$minus$toNumb2 : newTotalOriginal;
|
|
1186
1195
|
newOriginTotalOriginal = (_mainProductData$orig2 = mainProductData.origin_total) !== null && _mainProductData$orig2 !== void 0 ? _mainProductData$orig2 : newOriginTotalOriginal;
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
// 累加bundle的价格(只累加一次)
|
|
1199
|
+
if (newBundleOriginal.length > 0) {
|
|
1200
|
+
newBundleOriginal.forEach(function (item) {
|
|
1201
|
+
newTotalOriginal += Number(item.price) * Number(item.num);
|
|
1202
|
+
newOriginTotalOriginal += Number(item.price) * Number(item.num);
|
|
1203
|
+
});
|
|
1193
1204
|
}
|
|
1194
1205
|
|
|
1195
1206
|
// 累加options的价格(options不参与折扣,在最终设置total时处理)
|
|
@@ -1284,8 +1295,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1284
1295
|
// 累加bundle的价格(只累加一次)
|
|
1285
1296
|
if (newBundle.length > 0) {
|
|
1286
1297
|
newBundle.forEach(function (item) {
|
|
1287
|
-
var _item$discount_list3;
|
|
1288
1298
|
newTotal += Number(item.price) * Number(item.num);
|
|
1299
|
+
});
|
|
1300
|
+
|
|
1301
|
+
// 计算原始总价(不考虑折扣)
|
|
1302
|
+
newBundle.forEach(function (item) {
|
|
1303
|
+
var _item$discount_list3;
|
|
1289
1304
|
var originalPrice = ((_item$discount_list3 = item.discount_list) === null || _item$discount_list3 === void 0 || (_item$discount_list3 = _item$discount_list3[0]) === null || _item$discount_list3 === void 0 || (_item$discount_list3 = _item$discount_list3.discount) === null || _item$discount_list3 === void 0 ? void 0 : _item$discount_list3.original_amount) || item.price;
|
|
1290
1305
|
newOriginTotal += Number(originalPrice) * Number(item.num);
|
|
1291
1306
|
});
|
|
@@ -1464,8 +1479,34 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1464
1479
|
// 套餐中购买时,判断是否为原价
|
|
1465
1480
|
var _priceType = (_flatItem$bundleItem7 = flatItem.bundleItem) === null || _flatItem$bundleItem7 === void 0 ? void 0 : _flatItem$bundleItem7.price_type;
|
|
1466
1481
|
var _priceTypeExt = (_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.price_type_ext;
|
|
1482
|
+
|
|
1483
|
+
// original_price 对应:
|
|
1484
|
+
// 1. price_type: "markup" && price_type_ext: "product_price"
|
|
1485
|
+
// markup_price 对应:
|
|
1486
|
+
// price_type: "markup" && price_type_ext: ""
|
|
1487
|
+
/** 原价 */
|
|
1488
|
+
var _isOriginalPrice = _priceType === 'markup' && _priceTypeExt === 'product_price';
|
|
1489
|
+
/** 加价 */
|
|
1490
|
+
var _isMarkupPrice = _priceType === 'markup' && (_priceTypeExt === '' || !_priceTypeExt);
|
|
1491
|
+
|
|
1492
|
+
// 检查 rules
|
|
1493
|
+
if (rules.length > 0) {
|
|
1494
|
+
// 检查原价
|
|
1495
|
+
if (_isOriginalPrice && rules.includes('original_price')) {
|
|
1496
|
+
return true;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
// 检查加价
|
|
1500
|
+
if (_isMarkupPrice && rules.includes('markup_price')) {
|
|
1501
|
+
return true;
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
// 如果都不匹配,则不可用
|
|
1505
|
+
return false;
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1467
1508
|
// 原价包括:price_type: "markup" && price_type_ext: "product_price"
|
|
1468
|
-
return
|
|
1509
|
+
return _isOriginalPrice;
|
|
1469
1510
|
}
|
|
1470
1511
|
return false;
|
|
1471
1512
|
}
|
|
@@ -31,7 +31,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
31
31
|
import { BaseModule } from "../../modules/BaseModule";
|
|
32
32
|
import { createModule } from "./types";
|
|
33
33
|
import { formatProductToCartItem, createCartItemOrigin, getUniqueId, handleVariantProduct, formatDateToCartItem, formatAccountToCartItem } from "../../modules/Cart/utils";
|
|
34
|
-
import { getAvailableProductResources } from "./utils/products";
|
|
34
|
+
import { getAvailableProductResources, isSessionProduct } from "./utils/products";
|
|
35
35
|
import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection, isConflict } from "./utils/resources";
|
|
36
36
|
import dayjs from 'dayjs';
|
|
37
37
|
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
|
@@ -238,19 +238,29 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
238
238
|
key: "loadProducts",
|
|
239
239
|
value: (function () {
|
|
240
240
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
241
|
-
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date;
|
|
241
|
+
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date, res;
|
|
242
242
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
243
243
|
while (1) switch (_context2.prev = _context2.next) {
|
|
244
244
|
case 0:
|
|
245
245
|
_ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, schedule_date = _ref.schedule_date;
|
|
246
|
-
|
|
246
|
+
_context2.next = 3;
|
|
247
|
+
return this.store.products.loadProducts({
|
|
247
248
|
category_ids: category_ids,
|
|
248
249
|
product_ids: product_ids,
|
|
249
250
|
collection: collection,
|
|
250
251
|
schedule_date: schedule_date,
|
|
251
252
|
cacheId: this.cacheId
|
|
252
|
-
})
|
|
253
|
-
case
|
|
253
|
+
});
|
|
254
|
+
case 3:
|
|
255
|
+
res = _context2.sent;
|
|
256
|
+
// 预拉取当天的资源数据
|
|
257
|
+
this.getAvailableDate({
|
|
258
|
+
startDate: schedule_date || dayjs().format('YYYY-MM-DD'),
|
|
259
|
+
endDate: schedule_date || dayjs().format('YYYY-MM-DD'),
|
|
260
|
+
products: _toConsumableArray(res)
|
|
261
|
+
});
|
|
262
|
+
return _context2.abrupt("return", res);
|
|
263
|
+
case 6:
|
|
254
264
|
case "end":
|
|
255
265
|
return _context2.stop();
|
|
256
266
|
}
|
|
@@ -282,7 +292,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
282
292
|
value: (function () {
|
|
283
293
|
var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
|
|
284
294
|
var _schedule$product_ids;
|
|
285
|
-
var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, newProductIds, schedule, otherProductsIds, allProductIds;
|
|
295
|
+
var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, newProductIds, schedule, otherProductsIds, allProductIds, res;
|
|
286
296
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
287
297
|
while (1) switch (_context3.prev = _context3.next) {
|
|
288
298
|
case 0:
|
|
@@ -329,8 +339,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
329
339
|
schedule_date: date
|
|
330
340
|
});
|
|
331
341
|
case 10:
|
|
332
|
-
|
|
333
|
-
|
|
342
|
+
res = _context3.sent;
|
|
343
|
+
return _context3.abrupt("return", res);
|
|
344
|
+
case 12:
|
|
334
345
|
case "end":
|
|
335
346
|
return _context3.stop();
|
|
336
347
|
}
|
|
@@ -1150,6 +1161,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1150
1161
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
1151
1162
|
product_variant_id: product_variant_id
|
|
1152
1163
|
});
|
|
1164
|
+
debugger;
|
|
1165
|
+
// 保护,如果进来的是 session 商品,则必须要有 date 和时间片,否则不允许添加
|
|
1166
|
+
if (isSessionProduct(productData)) {
|
|
1167
|
+
if (!date || !date.startTime || !date.endTime) {
|
|
1168
|
+
return {
|
|
1169
|
+
success: false,
|
|
1170
|
+
errorCode: 'date_or_time_required'
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1153
1174
|
|
|
1154
1175
|
// 库存检测
|
|
1155
1176
|
var currentCartItems = this.store.cart.getItems();
|
|
@@ -9,3 +9,9 @@ export declare const getAvailableProductResources: (products: ProductData[]) =>
|
|
|
9
9
|
rules: any[];
|
|
10
10
|
resourcesMap: Record<number, ProductResourceItem>;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* 判断商品是否是 session 商品
|
|
14
|
+
* @param product 商品数据
|
|
15
|
+
* @returns 是否是 session 商品
|
|
16
|
+
*/
|
|
17
|
+
export declare const isSessionProduct: (product: ProductData) => boolean;
|
|
@@ -47,4 +47,14 @@ export var getAvailableProductResources = function getAvailableProductResources(
|
|
|
47
47
|
rules: rules,
|
|
48
48
|
resourcesMap: resourcesMap
|
|
49
49
|
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 判断商品是否是 session 商品
|
|
54
|
+
* @param product 商品数据
|
|
55
|
+
* @returns 是否是 session 商品
|
|
56
|
+
*/
|
|
57
|
+
export var isSessionProduct = function isSessionProduct(product) {
|
|
58
|
+
var _product$scheduleIds, _product$scheduleIds2;
|
|
59
|
+
return ((_product$scheduleIds = product === null || product === void 0 || (_product$scheduleIds2 = product['schedule.ids']) === null || _product$scheduleIds2 === void 0 ? void 0 : _product$scheduleIds2.length) !== null && _product$scheduleIds !== void 0 ? _product$scheduleIds : 0) > 0;
|
|
50
60
|
};
|
|
@@ -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, "skip" | "num">;
|
|
127
127
|
/**
|
|
128
128
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
129
129
|
* @returns 客户状态
|