@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
|
@@ -396,23 +396,66 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
396
396
|
return pre + (item.amount || 0);
|
|
397
397
|
}, 0);
|
|
398
398
|
};
|
|
399
|
-
var
|
|
400
|
-
return {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
399
|
+
var formatProduct = function formatProduct(items) {
|
|
400
|
+
return items.map(function (item) {
|
|
401
|
+
var _item$is_charge_tax;
|
|
402
|
+
return {
|
|
403
|
+
product_id: item.product_id,
|
|
404
|
+
product_variant_id: item.product_variant_id,
|
|
405
|
+
quantity: item.num,
|
|
406
|
+
// 商品是否含税:1;0
|
|
407
|
+
is_charge_tax: (_item$is_charge_tax = item.is_charge_tax) !== null && _item$is_charge_tax !== void 0 ? _item$is_charge_tax : 0,
|
|
408
|
+
// 若商品不含税,计算得到的税费,单位(元)
|
|
409
|
+
tax_fee: item.tax_fee,
|
|
410
|
+
// 整个商品折扣后的总金额
|
|
411
|
+
selling_price: item.calculated_selling_price,
|
|
412
|
+
// 使用者id
|
|
413
|
+
holder_id: item.holder_id,
|
|
414
|
+
// 整个商品折扣前的总金额
|
|
415
|
+
original_price: item.calculated_original_price,
|
|
416
|
+
// 主商品折扣前金额,不包含套餐子商品
|
|
417
|
+
main_product_original_price: item.price,
|
|
418
|
+
// 主商品折扣后金额,不包含套餐子商品
|
|
419
|
+
main_product_selling_price: item.main_product_selling_price,
|
|
420
|
+
metadata: {
|
|
421
|
+
// 主商品+非原价(加减价)子商品税费
|
|
422
|
+
"main_product_attached_bundle_tax_fee": item.metadata.main_product_attached_bundle_tax_fee,
|
|
423
|
+
// 主商品+非原价(加减价)子商品附加费
|
|
424
|
+
"main_product_attached_bundle_surcharge_fee": item.metadata.main_product_attached_bundle_surcharge_fee,
|
|
425
|
+
// 可选,附加费均摊舍入金额
|
|
426
|
+
"surcharge_rounding_remainder": item.metadata.surcharge_rounding_remainder
|
|
427
|
+
},
|
|
428
|
+
product_bundle: item.product_bundle.map(function (bundle) {
|
|
429
|
+
return {
|
|
430
|
+
bundle_id: bundle.bundle_id,
|
|
431
|
+
bundle_product_id: bundle.bundle_product_id,
|
|
432
|
+
bundle_variant_id: bundle.bundle_variant_id,
|
|
433
|
+
price_type: bundle.price_type,
|
|
434
|
+
price_type_ext: bundle.price_type_ext,
|
|
435
|
+
// 套餐子商品总价,不包含折扣金额
|
|
436
|
+
bundle_sum_price: bundle.bundle_sum_price,
|
|
437
|
+
// 套餐子商品折扣后金额
|
|
438
|
+
bundle_selling_price: bundle.bundle_selling_price,
|
|
439
|
+
num: bundle.num,
|
|
440
|
+
is_charge_tax: bundle.is_charge_tax,
|
|
441
|
+
tax_fee: bundle.tax_fee,
|
|
442
|
+
metadata: {
|
|
443
|
+
// 子商品单数量附加费
|
|
444
|
+
"surcharge_fee": bundle.metadata.surcharge_fee,
|
|
445
|
+
// 可选,附加费均摊舍入金额
|
|
446
|
+
"surcharge_rounding_remainder": bundle.metadata.surcharge_rounding_remainder
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
})
|
|
450
|
+
};
|
|
451
|
+
}) || [];
|
|
452
|
+
};
|
|
453
|
+
var productList = formatProduct(((_this$store$currentOr = this.store.currentOrder.order_info) === null || _this$store$currentOr === void 0 || (_this$store$currentOr = _this$store$currentOr.original_order_data) === null || _this$store$currentOr === void 0 || (_this$store$currentOr = _this$store$currentOr.bookings) === null || _this$store$currentOr === void 0 ? void 0 : _this$store$currentOr.map(function (item) {
|
|
454
|
+
return _objectSpread(_objectSpread({}, item.product), {}, {
|
|
405
455
|
holder_id: _this3.getHolderIdFromBooking(item)
|
|
406
|
-
};
|
|
407
|
-
})) || [];
|
|
408
|
-
var relationProducts = ((_this$store$currentOr2 = this.store.currentOrder.order_info) === null || _this$store$currentOr2 === void 0 || (_this$store$currentOr2 = _this$store$currentOr2.original_order_data) === null || _this$store$currentOr2 === void 0
|
|
409
|
-
return {
|
|
410
|
-
product_id: item.product_id,
|
|
411
|
-
product_variant_id: item.product_variant_id,
|
|
412
|
-
quantity: item.num,
|
|
413
|
-
selling_price: item.source_product_price
|
|
414
|
-
};
|
|
415
|
-
})) || [];
|
|
456
|
+
});
|
|
457
|
+
})) || []);
|
|
458
|
+
var relationProducts = formatProduct(((_this$store$currentOr2 = this.store.currentOrder.order_info) === null || _this$store$currentOr2 === void 0 || (_this$store$currentOr2 = _this$store$currentOr2.original_order_data) === null || _this$store$currentOr2 === void 0 ? void 0 : _this$store$currentOr2.relation_products) || []);
|
|
416
459
|
return [].concat(_toConsumableArray(productList), _toConsumableArray(relationProducts));
|
|
417
460
|
}
|
|
418
461
|
}, {
|
|
@@ -447,7 +490,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
447
490
|
depositAmount: (_this$store$currentOr5 = this.store.currentOrder) === null || _this$store$currentOr5 === void 0 ? void 0 : _this$store$currentOr5.deposit_amount,
|
|
448
491
|
isDeposit: (_this$store$currentOr6 = this.store.currentOrder) === null || _this$store$currentOr6 === void 0 ? void 0 : _this$store$currentOr6.is_deposit
|
|
449
492
|
},
|
|
450
|
-
products: this.getProductListByOrder()
|
|
493
|
+
products: this.getProductListByOrder(),
|
|
494
|
+
is_price_include_tax: this.otherParams.is_price_include_tax
|
|
451
495
|
}, params); // 判断订单是否已经同步,如果是则追加payment_order_id参数
|
|
452
496
|
if (this.store.isOrderSynced) {
|
|
453
497
|
walletBusinessData.payment_order_id = (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.order_id;
|
|
@@ -24,6 +24,10 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
24
24
|
setHolders(holders: {
|
|
25
25
|
form_record_id: number;
|
|
26
26
|
}[]): void;
|
|
27
|
+
setBookingSubject(bookingSubject: {
|
|
28
|
+
type?: 'form' | 'customer';
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}): void;
|
|
27
31
|
calcDiscount(productList: Record<string, any>[], options?: SetDiscountSelectedParams): {
|
|
28
32
|
productList: Record<string, any>[];
|
|
29
33
|
discountList: Discount[];
|
|
@@ -51,10 +51,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
51
51
|
productList: [],
|
|
52
52
|
discount: null,
|
|
53
53
|
rules: null,
|
|
54
|
+
holders: [],
|
|
54
55
|
originalDiscountList: [],
|
|
55
56
|
currentBookingTime: "",
|
|
56
57
|
filteredDiscountList: [],
|
|
57
|
-
|
|
58
|
+
bookingSubject: undefined
|
|
58
59
|
};
|
|
59
60
|
return _this;
|
|
60
61
|
}
|
|
@@ -292,11 +293,17 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
292
293
|
value: function setHolders(holders) {
|
|
293
294
|
this.store.holders = holders;
|
|
294
295
|
}
|
|
296
|
+
}, {
|
|
297
|
+
key: "setBookingSubject",
|
|
298
|
+
value: function setBookingSubject(bookingSubject) {
|
|
299
|
+
this.store.bookingSubject = bookingSubject;
|
|
300
|
+
}
|
|
295
301
|
|
|
296
302
|
// 计算优惠券
|
|
297
303
|
}, {
|
|
298
304
|
key: "calcDiscount",
|
|
299
305
|
value: function calcDiscount(productList, options) {
|
|
306
|
+
var _this$store$bookingSu;
|
|
300
307
|
this.store.productList = productList;
|
|
301
308
|
var rulesModule = this.core.getModule("".concat(this.name, "_rules"));
|
|
302
309
|
if (!rulesModule) {
|
|
@@ -308,7 +315,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
308
315
|
var _ref = rulesModule.calcDiscount({
|
|
309
316
|
productList: productList,
|
|
310
317
|
discountList: this.getDiscountList(),
|
|
311
|
-
holders: this.store.holders || []
|
|
318
|
+
holders: this.store.holders || [],
|
|
319
|
+
isFormSubject: ((_this$store$bookingSu = this.store.bookingSubject) === null || _this$store$bookingSu === void 0 ? void 0 : _this$store$bookingSu.type) === 'form'
|
|
312
320
|
}, options) || {
|
|
313
321
|
productList: productList,
|
|
314
322
|
discountList: this.getDiscountList()
|
|
@@ -381,7 +389,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
381
389
|
key: "scanCode",
|
|
382
390
|
value: function () {
|
|
383
391
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
|
|
384
|
-
var _this$store$discount3, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
|
|
392
|
+
var _this$store$discount3, _this$store$bookingSu2, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
|
|
385
393
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
386
394
|
while (1) switch (_context5.prev = _context5.next) {
|
|
387
395
|
case 0:
|
|
@@ -447,7 +455,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
447
455
|
productList: this.store.productList || [],
|
|
448
456
|
oldDiscountList: this.getDiscountList(),
|
|
449
457
|
newDiscountList: withScanList,
|
|
450
|
-
holders: this.store.holders || []
|
|
458
|
+
holders: this.store.holders || [],
|
|
459
|
+
isFormSubject: ((_this$store$bookingSu2 = this.store.bookingSubject) === null || _this$store$bookingSu2 === void 0 ? void 0 : _this$store$bookingSu2.type) === 'form'
|
|
451
460
|
}) || {
|
|
452
461
|
isAvailable: false,
|
|
453
462
|
productList: this.store.productList || [],
|
|
@@ -23,14 +23,18 @@ export interface ShopDiscountState {
|
|
|
23
23
|
discount: DiscountModule | null;
|
|
24
24
|
rules: RulesModule | null;
|
|
25
25
|
productList: Record<string, any>[];
|
|
26
|
-
originalDiscountList: Discount[];
|
|
27
26
|
holders?: {
|
|
28
27
|
form_record_id: number;
|
|
29
28
|
form_id?: number;
|
|
30
29
|
main_field?: string;
|
|
31
30
|
}[];
|
|
31
|
+
originalDiscountList: Discount[];
|
|
32
32
|
currentBookingTime: string | null;
|
|
33
33
|
filteredDiscountList: Discount[];
|
|
34
|
+
bookingSubject?: {
|
|
35
|
+
type?: 'form' | 'customer';
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
};
|
|
34
38
|
}
|
|
35
39
|
export interface SetDiscountSelectedParams {
|
|
36
40
|
discountId: number;
|
|
@@ -102,7 +102,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
102
102
|
skip,
|
|
103
103
|
num,
|
|
104
104
|
sort_by: import_constants.SORT_BY,
|
|
105
|
-
with: ["latestWalletDetail.wallet"],
|
|
105
|
+
with: ["latestWalletDetail.wallet", "contactsInfo"],
|
|
106
106
|
search_wallet_flag: 1,
|
|
107
107
|
search_wallet_pass_flag: 1,
|
|
108
108
|
...search && { search },
|
|
@@ -639,7 +639,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
639
639
|
this.logInfo("更新订单支付项完成", {
|
|
640
640
|
orderUuid
|
|
641
641
|
});
|
|
642
|
-
this.core.effects.emit(
|
|
642
|
+
this.core.effects.emit(`${this.name}:onPaymentAdded`, {
|
|
643
643
|
orderUuid,
|
|
644
644
|
payment: newPaymentItem
|
|
645
645
|
});
|
|
@@ -51,10 +51,19 @@ var WalletPassPaymentImpl = class {
|
|
|
51
51
|
*/
|
|
52
52
|
generateWalletParams(businessData) {
|
|
53
53
|
var _a, _b;
|
|
54
|
-
const {
|
|
54
|
+
const {
|
|
55
|
+
customer_id,
|
|
56
|
+
holder,
|
|
57
|
+
amountInfo,
|
|
58
|
+
products,
|
|
59
|
+
order_wait_pay_amount,
|
|
60
|
+
payment_order_id,
|
|
61
|
+
is_price_include_tax
|
|
62
|
+
} = businessData;
|
|
55
63
|
const totalAmount = Number(amountInfo.totalAmount);
|
|
56
64
|
const subTotal = Number(amountInfo.subTotal);
|
|
57
65
|
const walletParams = {
|
|
66
|
+
is_price_include_tax,
|
|
58
67
|
sale_channel: "pos",
|
|
59
68
|
customer_id: customer_id || 0,
|
|
60
69
|
// 提供默认值,确保类型为 number
|
|
@@ -103,13 +103,6 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
103
103
|
{ osServer: true }
|
|
104
104
|
);
|
|
105
105
|
const sortedList = (productsData.data.list || []).slice().sort((a, b) => Number(b.sort) - Number(a.sort));
|
|
106
|
-
if (sortedList.length) {
|
|
107
|
-
sortedList.forEach((n) => {
|
|
108
|
-
if (n.is_eject !== 1 && n["schedule.ids"] && n["schedule.ids"].length) {
|
|
109
|
-
n.is_eject = 1;
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
106
|
this.addProduct(sortedList);
|
|
114
107
|
return sortedList;
|
|
115
108
|
}
|
|
@@ -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;
|
|
@@ -37,6 +37,7 @@ var import_utils = require("../../solution/ShopDiscount/utils");
|
|
|
37
37
|
var import_utils2 = require("../Cart/utils");
|
|
38
38
|
var import_decimal = __toESM(require("decimal.js"));
|
|
39
39
|
var import_dayjs = __toESM(require("dayjs"));
|
|
40
|
+
var import_lodash_es = require("lodash-es");
|
|
40
41
|
var RulesModule = class extends import_BaseModule.BaseModule {
|
|
41
42
|
constructor(name, version) {
|
|
42
43
|
super(name, version);
|
|
@@ -56,15 +57,17 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
56
57
|
getRulesList() {
|
|
57
58
|
return this.store.rulesList;
|
|
58
59
|
}
|
|
59
|
-
//
|
|
60
|
+
// 商品不需要holder,则不需要判断,直接返回true,商品需要holder但是还没填写,那么暂时不使用带有holder的券,直到填写才去匹配
|
|
60
61
|
checkHolderMatch(discount, product, holders) {
|
|
61
62
|
var _a;
|
|
62
63
|
if (((_a = discount.holder) == null ? void 0 : _a.holder_type) !== "form")
|
|
63
64
|
return true;
|
|
64
65
|
const orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id : void 0;
|
|
65
66
|
const productHolderId = Array.isArray(product.holder_id) ? product.holder_id[0] : product.holder_id;
|
|
66
|
-
if (!
|
|
67
|
+
if (!product.isNeedHolder)
|
|
67
68
|
return true;
|
|
69
|
+
if (!orderHolderId && !productHolderId)
|
|
70
|
+
return false;
|
|
68
71
|
return (productHolderId || orderHolderId) === discount.holder.holder_id;
|
|
69
72
|
}
|
|
70
73
|
// 判断discountList 是否可以对当前productList生效
|
|
@@ -72,7 +75,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
72
75
|
oldDiscountList,
|
|
73
76
|
newDiscountList,
|
|
74
77
|
productList,
|
|
75
|
-
holders
|
|
78
|
+
holders,
|
|
79
|
+
isFormSubject
|
|
76
80
|
}) {
|
|
77
81
|
if (!newDiscountList || newDiscountList.length === 0) {
|
|
78
82
|
return {
|
|
@@ -100,7 +104,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
100
104
|
const result = this.calcDiscount({
|
|
101
105
|
discountList: mergedDiscountList,
|
|
102
106
|
productList: [...productList],
|
|
103
|
-
holders
|
|
107
|
+
holders,
|
|
108
|
+
isFormSubject
|
|
104
109
|
}, {
|
|
105
110
|
scan: true
|
|
106
111
|
});
|
|
@@ -133,7 +138,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
133
138
|
calcDiscount({
|
|
134
139
|
discountList,
|
|
135
140
|
productList,
|
|
136
|
-
holders
|
|
141
|
+
holders,
|
|
142
|
+
isFormSubject
|
|
137
143
|
}, options) {
|
|
138
144
|
const isEditModeAddNewProduct = productList.find((n) => n.booking_id) && productList.find((n) => !n.booking_id);
|
|
139
145
|
const editModeDiscount = [];
|
|
@@ -282,22 +288,24 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
282
288
|
originProduct = flatItem.originProduct;
|
|
283
289
|
}
|
|
284
290
|
addModeDiscount.forEach((discount) => {
|
|
285
|
-
var _a, _b, _c, _d, _e, _f
|
|
291
|
+
var _a, _b, _c, _d, _e, _f;
|
|
286
292
|
const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
|
|
293
|
+
const _tempVar = (flatItem == null ? void 0 : flatItem.type) === "bundle" ? flatItem == null ? void 0 : flatItem.parentProduct : flatItem == null ? void 0 : flatItem.product;
|
|
287
294
|
const isHolderMatch = this.checkHolderMatch(
|
|
288
295
|
discount,
|
|
289
296
|
{
|
|
290
|
-
|
|
297
|
+
isNeedHolder: isFormSubject && !(_tempVar == null ? void 0 : _tempVar.isNormalProduct),
|
|
298
|
+
holder_id: (_tempVar == null ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
291
299
|
},
|
|
292
300
|
holders
|
|
293
301
|
);
|
|
294
302
|
let timeLimit = true;
|
|
295
303
|
timeLimit = !!(0, import_utils.filterDiscountListByBookingTime)([discount], ((product == null ? void 0 : product.startDate) || (0, import_dayjs.default)()).format("YYYY-MM-DD HH:mm:ss")).length;
|
|
296
304
|
const isLimitedProduct = (limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
|
|
297
|
-
const isAvailableProduct = flatItem.type === "main" ? !((product == null ? void 0 : product.booking_id) && ((
|
|
305
|
+
const isAvailableProduct = flatItem.type === "main" ? !((product == null ? void 0 : product.booking_id) && ((_a = product == null ? void 0 : product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount2) => discount2.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount2.tag || discount2.type)))) : !((flatItem == null ? void 0 : flatItem.booking_id) && ((_d = (_c = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _c.metadata) == null ? void 0 : _d.custom_product_bundle_map_id));
|
|
298
306
|
const isBundleAvailable = this.checkPackageSubItemUsageRules(discount, flatItem);
|
|
299
307
|
if (isAvailableProduct && isLimitedProduct && isBundleAvailable && timeLimit) {
|
|
300
|
-
(
|
|
308
|
+
(_e = discountApplicability.get(discount.id)) == null ? void 0 : _e.push(product.id);
|
|
301
309
|
const applicableProducts = discountApplicableProducts.get(discount.id) || [];
|
|
302
310
|
const discountType = discount.tag || discount.type;
|
|
303
311
|
const isGoodPass = discountType === "good_pass";
|
|
@@ -307,7 +315,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
307
315
|
type: discountType,
|
|
308
316
|
tag: discountType,
|
|
309
317
|
discount: {
|
|
310
|
-
discount_card_type: (
|
|
318
|
+
discount_card_type: (_f = discount == null ? void 0 : discount.metadata) == null ? void 0 : _f.discount_card_type,
|
|
311
319
|
fixed_amount: product.price,
|
|
312
320
|
resource_id: discount.id,
|
|
313
321
|
title: discount.format_title,
|
|
@@ -326,7 +334,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
326
334
|
});
|
|
327
335
|
const processedFlatItemsMap = /* @__PURE__ */ new Map();
|
|
328
336
|
sortedFlattenedList.forEach((flatItem, index) => {
|
|
329
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x
|
|
337
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
330
338
|
let product, originProduct;
|
|
331
339
|
if (flatItem.type === "main") {
|
|
332
340
|
product = flatItem.product;
|
|
@@ -358,13 +366,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
358
366
|
return;
|
|
359
367
|
}
|
|
360
368
|
const applicableDiscounts = sortedDiscountList.filter((discount) => {
|
|
361
|
-
var _a2, _b2
|
|
369
|
+
var _a2, _b2;
|
|
362
370
|
if ((Number(product.price) <= 0 || !product.price) && !((_a2 = product.discount_list) == null ? void 0 : _a2.find((n) => {
|
|
363
371
|
var _a3;
|
|
364
372
|
return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
|
|
365
373
|
})) && (discount.tag || discount.type) === "good_pass")
|
|
366
374
|
return false;
|
|
367
|
-
if ((Number(product.price)
|
|
375
|
+
if ((Number(product.price) <= 0 || !product.price) && !((_b2 = product.discount_list) == null ? void 0 : _b2.find((n) => {
|
|
368
376
|
var _a3;
|
|
369
377
|
return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
|
|
370
378
|
})) && (discount.tag || discount.type) !== "good_pass")
|
|
@@ -373,20 +381,22 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
373
381
|
if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
|
|
374
382
|
return false;
|
|
375
383
|
const limitedData = discount.limited_relation_product_data;
|
|
376
|
-
|
|
377
|
-
timeLimit = !!(0, import_utils.filterDiscountListByBookingTime)([discount], (product.startDate || (0, import_dayjs.default)()).format("YYYY-MM-DD HH:mm:ss")).length;
|
|
378
|
-
if (!timeLimit) {
|
|
379
|
-
return false;
|
|
380
|
-
}
|
|
384
|
+
const _tempVar = (flatItem == null ? void 0 : flatItem.type) === "bundle" ? flatItem == null ? void 0 : flatItem.parentProduct : flatItem == null ? void 0 : flatItem.product;
|
|
381
385
|
const isHolderMatch = this.checkHolderMatch(
|
|
382
386
|
discount,
|
|
383
387
|
{
|
|
384
|
-
|
|
388
|
+
isNeedHolder: isFormSubject && !(_tempVar == null ? void 0 : _tempVar.isNormalProduct),
|
|
389
|
+
holder_id: (_tempVar == null ? void 0 : _tempVar.holder_id) || product.holder_id
|
|
385
390
|
},
|
|
386
391
|
holders
|
|
387
392
|
);
|
|
388
393
|
if (!isHolderMatch)
|
|
389
394
|
return false;
|
|
395
|
+
let timeLimit = true;
|
|
396
|
+
timeLimit = !!(0, import_utils.filterDiscountListByBookingTime)([discount], (product.startDate || (0, import_dayjs.default)()).format("YYYY-MM-DD HH:mm:ss")).length;
|
|
397
|
+
if (!timeLimit) {
|
|
398
|
+
return false;
|
|
399
|
+
}
|
|
390
400
|
if (limitedData.type === "product_all") {
|
|
391
401
|
if (!this.checkPackageSubItemUsageRules(discount, flatItem)) {
|
|
392
402
|
return false;
|
|
@@ -464,16 +474,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
464
474
|
}
|
|
465
475
|
}
|
|
466
476
|
}
|
|
467
|
-
if (
|
|
468
|
-
var _a2;
|
|
469
|
-
return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some((n) => {
|
|
470
|
-
var _a3;
|
|
471
|
-
return n.discountId === ((_a3 = item.discount) == null ? void 0 : _a3.resource_id);
|
|
472
|
-
});
|
|
473
|
-
}))) {
|
|
474
|
-
isManualDiscount = false;
|
|
475
|
-
}
|
|
476
|
-
if (applicableDiscounts.length === 0 || isManualDiscount) {
|
|
477
|
+
if (applicableDiscounts.length === 0 || isManualDiscount || (0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
477
478
|
if (flatItem.type === "main") {
|
|
478
479
|
if (product.isClient) {
|
|
479
480
|
processedProductsMap.set(
|
|
@@ -505,7 +506,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
505
506
|
processedProductsMap.set(
|
|
506
507
|
product._id,
|
|
507
508
|
[this.hooks.setProduct(originProduct, {
|
|
508
|
-
...isManualDiscount ? {
|
|
509
|
+
...isManualDiscount ? {
|
|
510
|
+
price: product.price,
|
|
511
|
+
main_product_selling_price: product.price
|
|
512
|
+
} : {
|
|
509
513
|
_id: product._id.split("___")[0] + "___" + index,
|
|
510
514
|
total: product.origin_total || product.total,
|
|
511
515
|
price: product.price,
|
|
@@ -519,7 +523,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
519
523
|
processedFlatItemsMap.set(flatItem._id, [{
|
|
520
524
|
...flatItem,
|
|
521
525
|
discount_list: [],
|
|
522
|
-
price: flatItem.bundleItem.original_price,
|
|
526
|
+
price: isManualDiscount ? flatItem.bundleItem.price : flatItem.bundleItem.original_price,
|
|
523
527
|
processed: true
|
|
524
528
|
}]);
|
|
525
529
|
}
|
|
@@ -546,10 +550,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
546
550
|
usedDiscounts.set(selectedDiscount2.id, true);
|
|
547
551
|
const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
|
|
548
552
|
let productOriginTotal = product.origin_total || product.total || 0;
|
|
549
|
-
if (((
|
|
553
|
+
if (((_t = product.discount_list) == null ? void 0 : _t.length) && product.origin_total) {
|
|
550
554
|
productOriginTotal = product.origin_total;
|
|
551
555
|
}
|
|
552
|
-
if (Number(((
|
|
556
|
+
if (Number(((_u = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _u.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
|
|
553
557
|
productOriginTotal = product.total;
|
|
554
558
|
}
|
|
555
559
|
const targetProductTotal = (0, import_utils.getDiscountAmount)(selectedDiscount2, product.price, product.price);
|
|
@@ -560,7 +564,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
560
564
|
amount,
|
|
561
565
|
type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : discountType,
|
|
562
566
|
discount: {
|
|
563
|
-
discount_card_type: (
|
|
567
|
+
discount_card_type: (_v = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _v.discount_card_type,
|
|
564
568
|
fixed_amount: amount,
|
|
565
569
|
resource_id: selectedDiscount2.id,
|
|
566
570
|
title: selectedDiscount2.format_title,
|
|
@@ -682,7 +686,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
682
686
|
amount: new import_decimal.default(productOriginTotal).minus(targetProductTotal).toNumber() * (product.num || 1),
|
|
683
687
|
type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag,
|
|
684
688
|
discount: {
|
|
685
|
-
discount_card_type: (
|
|
689
|
+
discount_card_type: (_w = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _w.discount_card_type,
|
|
686
690
|
fixed_amount: new import_decimal.default(productOriginTotal).minus(targetProductTotal).toNumber(),
|
|
687
691
|
resource_id: selectedDiscount2.id,
|
|
688
692
|
title: selectedDiscount2.format_title,
|
|
@@ -695,7 +699,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
695
699
|
custom_product_bundle_map_id: uniqueId,
|
|
696
700
|
num: product.num || 1
|
|
697
701
|
},
|
|
698
|
-
_num: (product.num || 1) * (((
|
|
702
|
+
_num: (product.num || 1) * (((_x = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _x.num) || 1)
|
|
699
703
|
};
|
|
700
704
|
const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
|
|
701
705
|
appliedProducts.push(discountDetail);
|
|
@@ -859,14 +863,16 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
859
863
|
const allDiscountAmount = (0, import_utils.getDiscountListAmountTotal)(mainDiscountList);
|
|
860
864
|
newTotalWithDiscount = new import_decimal.default(mainProductData.price || 0).minus(allDiscountAmount).toNumber() ?? newTotalWithDiscount;
|
|
861
865
|
newOriginTotalWithDiscount = mainProductData.origin_total ?? newOriginTotalWithDiscount;
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
866
|
+
}
|
|
867
|
+
if (newBundleWithDiscount.length > 0) {
|
|
868
|
+
newBundleWithDiscount.forEach((item) => {
|
|
869
|
+
newTotalWithDiscount += Number(item.price) * Number(item.num);
|
|
870
|
+
});
|
|
871
|
+
newBundleWithDiscount.forEach((item) => {
|
|
872
|
+
var _a, _b, _c;
|
|
873
|
+
const originalPrice = ((_c = (_b = (_a = item.discount_list) == null ? void 0 : _a[0]) == null ? void 0 : _b.discount) == null ? void 0 : _c.original_amount) || item.price;
|
|
874
|
+
newOriginTotalWithDiscount += Number(originalPrice) * Number(item.num);
|
|
875
|
+
});
|
|
870
876
|
}
|
|
871
877
|
if (product == null ? void 0 : product.options) {
|
|
872
878
|
newTotalWithDiscount = product.options.reduce((accumulator, currentValue) => {
|
|
@@ -918,12 +924,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
918
924
|
const allDiscountAmount = (0, import_utils.getDiscountListAmount)(mainDiscountListOriginal);
|
|
919
925
|
newTotalOriginal = new import_decimal.default(mainProductData.price || 0).minus(allDiscountAmount).toNumber() ?? newTotalOriginal;
|
|
920
926
|
newOriginTotalOriginal = mainProductData.origin_total ?? newOriginTotalOriginal;
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
}
|
|
927
|
+
}
|
|
928
|
+
if (newBundleOriginal.length > 0) {
|
|
929
|
+
newBundleOriginal.forEach((item) => {
|
|
930
|
+
newTotalOriginal += Number(item.price) * Number(item.num);
|
|
931
|
+
newOriginTotalOriginal += Number(item.price) * Number(item.num);
|
|
932
|
+
});
|
|
927
933
|
}
|
|
928
934
|
if (product == null ? void 0 : product.options) {
|
|
929
935
|
newTotalOriginal = product.options.reduce((accumulator, currentValue) => {
|
|
@@ -998,8 +1004,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
998
1004
|
}
|
|
999
1005
|
if (newBundle.length > 0) {
|
|
1000
1006
|
newBundle.forEach((item) => {
|
|
1001
|
-
var _a2, _b2, _c2;
|
|
1002
1007
|
newTotal += Number(item.price) * Number(item.num);
|
|
1008
|
+
});
|
|
1009
|
+
newBundle.forEach((item) => {
|
|
1010
|
+
var _a2, _b2, _c2;
|
|
1003
1011
|
const originalPrice = ((_c2 = (_b2 = (_a2 = item.discount_list) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.discount) == null ? void 0 : _c2.original_amount) || item.price;
|
|
1004
1012
|
newOriginTotal += Number(originalPrice) * Number(item.num);
|
|
1005
1013
|
});
|
|
@@ -1140,7 +1148,18 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1140
1148
|
if (isBundleItem) {
|
|
1141
1149
|
const priceType = (_c = flatItem.bundleItem) == null ? void 0 : _c.price_type;
|
|
1142
1150
|
const priceTypeExt = (_d = flatItem.bundleItem) == null ? void 0 : _d.price_type_ext;
|
|
1143
|
-
|
|
1151
|
+
const isOriginalPrice = priceType === "markup" && priceTypeExt === "product_price";
|
|
1152
|
+
const isMarkupPrice = priceType === "markup" && (priceTypeExt === "" || !priceTypeExt);
|
|
1153
|
+
if (rules.length > 0) {
|
|
1154
|
+
if (isOriginalPrice && rules.includes("original_price")) {
|
|
1155
|
+
return true;
|
|
1156
|
+
}
|
|
1157
|
+
if (isMarkupPrice && rules.includes("markup_price")) {
|
|
1158
|
+
return true;
|
|
1159
|
+
}
|
|
1160
|
+
return false;
|
|
1161
|
+
}
|
|
1162
|
+
return isOriginalPrice;
|
|
1144
1163
|
}
|
|
1145
1164
|
return false;
|
|
1146
1165
|
}
|
|
@@ -185,13 +185,19 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
185
185
|
collection = [],
|
|
186
186
|
schedule_date
|
|
187
187
|
}) {
|
|
188
|
-
|
|
188
|
+
const res = await this.store.products.loadProducts({
|
|
189
189
|
category_ids,
|
|
190
190
|
product_ids,
|
|
191
191
|
collection,
|
|
192
192
|
schedule_date,
|
|
193
193
|
cacheId: this.cacheId
|
|
194
194
|
});
|
|
195
|
+
this.getAvailableDate({
|
|
196
|
+
startDate: schedule_date || (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
197
|
+
endDate: schedule_date || (0, import_dayjs.default)().format("YYYY-MM-DD"),
|
|
198
|
+
products: [...res]
|
|
199
|
+
});
|
|
200
|
+
return res;
|
|
195
201
|
}
|
|
196
202
|
/**
|
|
197
203
|
* 通过 schedule 来读取商品,适用于 session 类商品
|
|
@@ -228,11 +234,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
228
234
|
const allProductIds = [...newProductIds, ...otherProductsIds].filter(
|
|
229
235
|
(n, index, self) => self.indexOf(n) === index
|
|
230
236
|
);
|
|
231
|
-
|
|
237
|
+
const res = await this.loadProducts({
|
|
232
238
|
product_ids: allProductIds,
|
|
233
239
|
category_ids,
|
|
234
240
|
schedule_date: date
|
|
235
241
|
});
|
|
242
|
+
return res;
|
|
236
243
|
}
|
|
237
244
|
/**
|
|
238
245
|
* 更新完商品数据、切换日期、或者在较后的流程里登录了,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
|
|
@@ -599,6 +606,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
599
606
|
quantity = 1
|
|
600
607
|
} = product || {};
|
|
601
608
|
const productData = { ...origin, product_variant_id };
|
|
609
|
+
debugger;
|
|
610
|
+
if ((0, import_products.isSessionProduct)(productData)) {
|
|
611
|
+
if (!date || !date.startTime || !date.endTime) {
|
|
612
|
+
return { success: false, errorCode: "date_or_time_required" };
|
|
613
|
+
}
|
|
614
|
+
}
|
|
602
615
|
const currentCartItems = this.store.cart.getItems();
|
|
603
616
|
const stockCheckResult = (0, import_stock.checkProductStock)({
|
|
604
617
|
productData,
|