@pisell/pisellos 2.1.114 → 2.1.116
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/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/modules/Cart/types.d.ts +0 -2
- package/dist/modules/Cart/utils/cartProduct.js +24 -56
- package/dist/modules/Discount/types.d.ts +8 -18
- package/dist/modules/Payment/index.d.ts +1 -2
- package/dist/modules/Payment/index.js +7 -10
- package/dist/modules/Payment/utils.js +0 -3
- package/dist/modules/Payment/walletpass.d.ts +0 -23
- package/dist/modules/Payment/walletpass.js +95 -191
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.d.ts +5 -9
- package/dist/modules/Rules/index.js +202 -675
- package/dist/modules/Rules/types.d.ts +0 -2
- package/dist/modules/Summary/types.d.ts +0 -2
- package/dist/modules/Summary/utils.d.ts +0 -6
- package/dist/modules/Summary/utils.js +0 -21
- package/dist/plugins/window.d.ts +0 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +1 -1
- package/dist/solution/Checkout/index.js +0 -2
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +7 -23
- package/dist/solution/ShopDiscount/types.d.ts +0 -1
- package/dist/solution/ShopDiscount/types.js +1 -2
- package/dist/solution/ShopDiscount/utils.js +12 -26
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -3
- package/lib/modules/Cart/types.d.ts +0 -2
- package/lib/modules/Cart/utils/cartProduct.js +11 -39
- package/lib/modules/Discount/types.d.ts +8 -18
- package/lib/modules/Payment/index.d.ts +1 -2
- package/lib/modules/Payment/index.js +0 -1
- package/lib/modules/Payment/utils.js +0 -3
- package/lib/modules/Payment/walletpass.d.ts +0 -23
- package/lib/modules/Payment/walletpass.js +17 -94
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.d.ts +5 -9
- package/lib/modules/Rules/index.js +304 -785
- package/lib/modules/Rules/types.d.ts +0 -2
- package/lib/modules/Summary/types.d.ts +0 -2
- package/lib/modules/Summary/utils.d.ts +0 -6
- package/lib/modules/Summary/utils.js +0 -15
- package/lib/plugins/window.d.ts +0 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -2
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +1 -1
- package/lib/solution/Checkout/index.js +0 -2
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +8 -22
- package/lib/solution/ShopDiscount/types.d.ts +0 -1
- package/lib/solution/ShopDiscount/utils.js +6 -10
- package/package.json +1 -1
- package/dist/model/index.d.ts +0 -1
- package/dist/model/index.js +0 -1
- package/dist/model/strategy/adapter/index.d.ts +0 -3
- package/dist/model/strategy/adapter/index.js +0 -4
- package/dist/model/strategy/adapter/type.d.ts +0 -28
- package/dist/model/strategy/adapter/type.js +0 -1
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -499
- package/dist/model/strategy/adapter/walletPass/example.d.ts +0 -4
- package/dist/model/strategy/adapter/walletPass/example.js +0 -258
- package/dist/model/strategy/adapter/walletPass/index.d.ts +0 -32
- package/dist/model/strategy/adapter/walletPass/index.js +0 -182
- package/dist/model/strategy/adapter/walletPass/locales.d.ts +0 -1
- package/dist/model/strategy/adapter/walletPass/locales.js +0 -26
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -187
- package/dist/model/strategy/adapter/walletPass/type.js +0 -1
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -50
- package/dist/model/strategy/adapter/walletPass/utils.js +0 -1104
- package/dist/model/strategy/index.d.ts +0 -94
- package/dist/model/strategy/index.js +0 -551
- package/dist/model/strategy/strategy-example.d.ts +0 -5
- package/dist/model/strategy/strategy-example.js +0 -331
- package/dist/model/strategy/type.d.ts +0 -228
- package/dist/model/strategy/type.js +0 -94
- package/lib/model/index.d.ts +0 -1
- package/lib/model/index.js +0 -23
- package/lib/model/strategy/adapter/index.d.ts +0 -3
- package/lib/model/strategy/adapter/index.js +0 -45
- package/lib/model/strategy/adapter/type.d.ts +0 -28
- package/lib/model/strategy/adapter/type.js +0 -17
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -423
- package/lib/model/strategy/adapter/walletPass/example.d.ts +0 -4
- package/lib/model/strategy/adapter/walletPass/example.js +0 -207
- package/lib/model/strategy/adapter/walletPass/index.d.ts +0 -32
- package/lib/model/strategy/adapter/walletPass/index.js +0 -142
- package/lib/model/strategy/adapter/walletPass/locales.d.ts +0 -1
- package/lib/model/strategy/adapter/walletPass/locales.js +0 -54
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -187
- package/lib/model/strategy/adapter/walletPass/type.js +0 -17
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -50
- package/lib/model/strategy/adapter/walletPass/utils.js +0 -791
- package/lib/model/strategy/index.d.ts +0 -94
- package/lib/model/strategy/index.js +0 -413
- package/lib/model/strategy/strategy-example.d.ts +0 -5
- package/lib/model/strategy/strategy-example.js +0 -318
- package/lib/model/strategy/type.d.ts +0 -228
- package/lib/model/strategy/type.js +0 -44
|
@@ -28,7 +28,6 @@ export interface RulesModuleAPI {
|
|
|
28
28
|
calcDiscount: (params: {
|
|
29
29
|
discountList: any[];
|
|
30
30
|
productList: any[];
|
|
31
|
-
orderTotalAmount: number;
|
|
32
31
|
holders: {
|
|
33
32
|
form_record_id: number;
|
|
34
33
|
}[];
|
|
@@ -67,7 +66,6 @@ export interface RulesParamsHooks {
|
|
|
67
66
|
quantity?: number;
|
|
68
67
|
bundle?: any[];
|
|
69
68
|
main_product_selling_price?: string | number;
|
|
70
|
-
options?: any[];
|
|
71
69
|
}) => Record<string, any>;
|
|
72
70
|
}
|
|
73
71
|
export {};
|
|
@@ -58,12 +58,6 @@ export declare const getTax: ({ service, addons, bookingDetail, bookingId }: {
|
|
|
58
58
|
* @returns 商品总价字符串,保留2位小数
|
|
59
59
|
*/
|
|
60
60
|
export declare const calculateSubtotal: (items: CartItem[]) => string;
|
|
61
|
-
/**
|
|
62
|
-
* 计算商品小计(不含其他费用 不包含折扣卡商品券抵扣金额)
|
|
63
|
-
* @param items - 购物车商品数组
|
|
64
|
-
* @returns 商品总价字符串,保留2位小数
|
|
65
|
-
*/
|
|
66
|
-
export declare const calculateOriginSubtotal: (items: CartItem[]) => string;
|
|
67
61
|
/**
|
|
68
62
|
* @title: 单个商品的税费
|
|
69
63
|
* @description:
|
|
@@ -20,7 +20,6 @@ import { isNormalProduct } from "../Product/utils";
|
|
|
20
20
|
import dayjs from 'dayjs';
|
|
21
21
|
export var calculatePriceDetails = function calculatePriceDetails(shopInfo, items, isInScheduleByDate, surchargeList, scheduleById) {
|
|
22
22
|
var subtotal = new Decimal(calculateSubtotal(items));
|
|
23
|
-
var subOriginTotal = new Decimal(calculateOriginSubtotal(items));
|
|
24
23
|
var totalTaxFee = new Decimal(calculateTaxFee(shopInfo, items));
|
|
25
24
|
// 订单附加费列表
|
|
26
25
|
var surcharge = getSurcharge({
|
|
@@ -59,15 +58,11 @@ export var calculatePriceDetails = function calculatePriceDetails(shopInfo, item
|
|
|
59
58
|
originTax = _getTax.originTax;
|
|
60
59
|
var total = shopInfo !== null && shopInfo !== void 0 && shopInfo.is_price_include_tax ? subtotal.plus(surchargeAmount) : subtotal.plus(tax).plus(surchargeAmount);
|
|
61
60
|
|
|
62
|
-
// 计算总价 不包含折扣卡商品券折扣信息价格
|
|
63
|
-
var originTotal = shopInfo !== null && shopInfo !== void 0 && shopInfo.is_price_include_tax ? subOriginTotal : subOriginTotal.plus(totalTaxFee);
|
|
64
|
-
|
|
65
61
|
// 计算定金
|
|
66
62
|
var deposit = calculateDeposit(items);
|
|
67
63
|
return {
|
|
68
64
|
subtotal: subtotal.toFixed(2),
|
|
69
65
|
total: total.toFixed(2),
|
|
70
|
-
originTotal: originTotal.toFixed(2),
|
|
71
66
|
taxTitle: shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.tax_title,
|
|
72
67
|
taxRate: shopInfo === null || shopInfo === void 0 ? void 0 : shopInfo.tax_rate,
|
|
73
68
|
totalTaxFee: tax,
|
|
@@ -577,22 +572,6 @@ export var calculateSubtotal = function calculateSubtotal(items) {
|
|
|
577
572
|
return subtotal.toFixed(2);
|
|
578
573
|
};
|
|
579
574
|
|
|
580
|
-
/**
|
|
581
|
-
* 计算商品小计(不含其他费用 不包含折扣卡商品券抵扣金额)
|
|
582
|
-
* @param items - 购物车商品数组
|
|
583
|
-
* @returns 商品总价字符串,保留2位小数
|
|
584
|
-
*/
|
|
585
|
-
export var calculateOriginSubtotal = function calculateOriginSubtotal(items) {
|
|
586
|
-
if (!(items !== null && items !== void 0 && items.length)) {
|
|
587
|
-
return '0.00';
|
|
588
|
-
}
|
|
589
|
-
var subtotal = items.reduce(function (sum, item) {
|
|
590
|
-
var cartItemTotalPrice = new Decimal(item.summaryOriginTotal || 0);
|
|
591
|
-
return sum.plus(cartItemTotalPrice);
|
|
592
|
-
}, new Decimal(0));
|
|
593
|
-
return subtotal.toFixed(2);
|
|
594
|
-
};
|
|
595
|
-
|
|
596
575
|
/**
|
|
597
576
|
* @title: 单个商品的税费
|
|
598
577
|
* @description:
|
package/dist/plugins/window.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { WalletPassEvaluator } from '../model';
|
|
2
1
|
import { Plugin } from '../types';
|
|
3
2
|
/**
|
|
4
3
|
* WindowPlugin 接口定义
|
|
@@ -15,7 +14,6 @@ export interface WindowPlugin extends Plugin {
|
|
|
15
14
|
document: Partial<Document>;
|
|
16
15
|
history: History;
|
|
17
16
|
interaction?: any;
|
|
18
|
-
getWalletPassEvaluator?: () => WalletPassEvaluator;
|
|
19
17
|
}
|
|
20
18
|
/**
|
|
21
19
|
* 简单的 Storage 接口实现
|
|
@@ -144,7 +144,6 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
144
144
|
getSummary(): Promise<{
|
|
145
145
|
subtotal: string | number;
|
|
146
146
|
total: string | number;
|
|
147
|
-
originTotal: string | number;
|
|
148
147
|
taxTitle?: string | undefined;
|
|
149
148
|
totalTaxFee?: string | number | undefined;
|
|
150
149
|
isPriceIncludeTax?: 0 | 1 | undefined;
|
|
@@ -311,7 +310,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
310
|
date: string;
|
|
312
311
|
status: string;
|
|
313
312
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
313
|
+
weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
315
314
|
}[]>;
|
|
316
315
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
316
|
private getScheduleDataByIds;
|
|
@@ -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 客户状态
|
|
@@ -124,7 +124,7 @@ export var searchProduct = /*#__PURE__*/function () {
|
|
|
124
124
|
skip: 1,
|
|
125
125
|
num: 20,
|
|
126
126
|
status: 'published',
|
|
127
|
-
with: ['variantGroup'],
|
|
127
|
+
with: ['variantGroup.variantItem', 'optionGroup.optionItem'],
|
|
128
128
|
with_count: ['bundleGroup', 'optionGroup'],
|
|
129
129
|
exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item']
|
|
130
130
|
};
|
|
@@ -403,7 +403,6 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
403
403
|
product_id: item.product_id,
|
|
404
404
|
product_variant_id: item.product_variant_id,
|
|
405
405
|
quantity: item.num,
|
|
406
|
-
is_price_include_tax: item.is_price_include_tax,
|
|
407
406
|
// 商品是否含税:1;0
|
|
408
407
|
is_charge_tax: (_item$is_charge_tax = item.is_charge_tax) !== null && _item$is_charge_tax !== void 0 ? _item$is_charge_tax : 0,
|
|
409
408
|
// 若商品不含税,计算得到的税费,单位(元)
|
|
@@ -428,7 +427,6 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
428
427
|
},
|
|
429
428
|
product_bundle: (item.product_bundle || []).map(function (bundle) {
|
|
430
429
|
return {
|
|
431
|
-
is_price_include_tax: item.is_price_include_tax,
|
|
432
430
|
bundle_id: bundle.bundle_id,
|
|
433
431
|
bundle_product_id: bundle.bundle_product_id,
|
|
434
432
|
bundle_variant_id: bundle.bundle_variant_id,
|
|
@@ -22,7 +22,6 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
|
|
|
22
22
|
getCurrentBookingTime(): string | null;
|
|
23
23
|
private filterDiscountListByBookingTime;
|
|
24
24
|
setCustomer(customer: Customer): Promise<void>;
|
|
25
|
-
setOriginTotalAmount(amount: number): void;
|
|
26
25
|
setHolders(holders: {
|
|
27
26
|
form_record_id: number;
|
|
28
27
|
}[]): void;
|
|
@@ -56,8 +56,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
56
56
|
originalDiscountList: [],
|
|
57
57
|
currentBookingTime: "",
|
|
58
58
|
filteredDiscountList: [],
|
|
59
|
-
bookingSubject: undefined
|
|
60
|
-
orderTotalAmount: 0
|
|
59
|
+
bookingSubject: undefined
|
|
61
60
|
};
|
|
62
61
|
return _this;
|
|
63
62
|
}
|
|
@@ -289,14 +288,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
289
288
|
return _setCustomer.apply(this, arguments);
|
|
290
289
|
}
|
|
291
290
|
return setCustomer;
|
|
292
|
-
}()
|
|
293
|
-
}, {
|
|
294
|
-
key: "setOriginTotalAmount",
|
|
295
|
-
value: function setOriginTotalAmount(amount) {
|
|
296
|
-
this.store.orderTotalAmount = amount;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// 设置holders
|
|
291
|
+
}() // 设置holders
|
|
300
292
|
}, {
|
|
301
293
|
key: "setHolders",
|
|
302
294
|
value: function setHolders(holders) {
|
|
@@ -324,7 +316,6 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
324
316
|
var _ref = rulesModule.calcDiscount({
|
|
325
317
|
productList: productList,
|
|
326
318
|
discountList: this.getDiscountList(),
|
|
327
|
-
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
328
319
|
holders: this.store.holders || [],
|
|
329
320
|
isFormSubject: ((_this$store$bookingSu = this.store.bookingSubject) === null || _this$store$bookingSu === void 0 ? void 0 : _this$store$bookingSu.type) === 'form'
|
|
330
321
|
}, options) || {
|
|
@@ -504,7 +495,6 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
504
495
|
productList: this.store.productList || [],
|
|
505
496
|
oldDiscountList: this.getDiscountList(),
|
|
506
497
|
newDiscountList: withScanList,
|
|
507
|
-
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
508
498
|
holders: this.store.holders || [],
|
|
509
499
|
isFormSubject: ((_this$store$bookingSu2 = this.store.bookingSubject) === null || _this$store$bookingSu2 === void 0 ? void 0 : _this$store$bookingSu2.type) === 'form'
|
|
510
500
|
}) || {
|
|
@@ -618,27 +608,21 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
618
608
|
return n.id === (((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id);
|
|
619
609
|
});
|
|
620
610
|
if (index !== -1) {
|
|
621
|
-
var
|
|
611
|
+
var _discount$metadata;
|
|
622
612
|
editModeDiscountList[index] = _objectSpread(_objectSpread({}, editModeDiscountList[index]), {}, {
|
|
623
|
-
metadata: _objectSpread(_objectSpread({}, discount.metadata || {}), {}, {
|
|
624
|
-
num: ((editModeDiscountList === null || editModeDiscountList === void 0 || (_editModeDiscountList = editModeDiscountList[index]) === null || _editModeDiscountList === void 0 || (_editModeDiscountList = _editModeDiscountList.metadata) === null || _editModeDiscountList === void 0 ? void 0 : _editModeDiscountList.num) || 1) + (((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.num) || 1)
|
|
625
|
-
}),
|
|
626
613
|
amount: new Decimal(discount.amount || 0).plus(new Decimal(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
627
|
-
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$
|
|
614
|
+
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
628
615
|
});
|
|
629
616
|
} else {
|
|
630
|
-
var _discount$
|
|
617
|
+
var _discount$metadata2, _discount$discount2, _discount$discount3, _discount$discount4;
|
|
631
618
|
if (discount.type && !discount.tag) {
|
|
632
619
|
discount.tag = discount.type;
|
|
633
620
|
}
|
|
634
621
|
editModeDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
|
|
635
|
-
metadata: _objectSpread(_objectSpread({}, discount.metadata || {}), {}, {
|
|
636
|
-
num: ((_discount$metadata3 = discount.metadata) === null || _discount$metadata3 === void 0 ? void 0 : _discount$metadata3.num) || 1
|
|
637
|
-
}),
|
|
638
622
|
name: discount.name || discount.discount.title.auto,
|
|
639
623
|
isEditMode: true,
|
|
640
624
|
limited_relation_product_data: {},
|
|
641
|
-
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$
|
|
625
|
+
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.product_discount_difference) || 0).toNumber(),
|
|
642
626
|
isAvailable: true,
|
|
643
627
|
id: ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) || discount.id,
|
|
644
628
|
format_title: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.title) || discount.format_title,
|
|
@@ -831,7 +815,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
831
815
|
return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
|
|
832
816
|
case 19:
|
|
833
817
|
_context10.next = 21;
|
|
834
|
-
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"),
|
|
818
|
+
return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
|
|
835
819
|
case 21:
|
|
836
820
|
_context10.next = 26;
|
|
837
821
|
break;
|
|
@@ -8,5 +8,4 @@ export var ShopDiscountHooks = /*#__PURE__*/function (ShopDiscountHooks) {
|
|
|
8
8
|
ShopDiscountHooks["onRulesListChange"] = "shopDiscount:onRulesListChange";
|
|
9
9
|
ShopDiscountHooks["onLoadPrepareCalcResult"] = "shopDiscount:onLoadPrepareCalcResult";
|
|
10
10
|
return ShopDiscountHooks;
|
|
11
|
-
}({});
|
|
12
|
-
;
|
|
11
|
+
}({});
|
|
@@ -40,37 +40,23 @@ export var isAllNormalProduct = function isAllNormalProduct(items) {
|
|
|
40
40
|
* @returns
|
|
41
41
|
*/
|
|
42
42
|
export var getDiscountAmount = function getDiscountAmount(discount, total, price) {
|
|
43
|
-
var
|
|
44
|
-
|
|
43
|
+
var _discount$metadata;
|
|
45
44
|
// 商品券
|
|
46
45
|
if (discount.tag === 'good_pass') {
|
|
47
|
-
|
|
48
|
-
} else {
|
|
49
|
-
var _discount$metadata;
|
|
50
|
-
// 判断是否是固定金额
|
|
51
|
-
var isFixedAmount = (discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.discount_card_type) === 'fixed_amount';
|
|
52
|
-
|
|
53
|
-
// 固定金额 小于0时返回0
|
|
54
|
-
if (isFixedAmount) {
|
|
55
|
-
discountedPrice = Math.max(new Decimal(price).minus(new Decimal(discount.par_value || 0)).toNumber(), 0);
|
|
56
|
-
} else {
|
|
57
|
-
// 百分比:根据折扣卡金额计算
|
|
58
|
-
discountedPrice = new Decimal(100).minus(discount.par_value || 0).div(100).mul(new Decimal(price)).toNumber();
|
|
59
|
-
}
|
|
46
|
+
return new Decimal(price).minus(new Decimal(price || 0)).toNumber();
|
|
60
47
|
}
|
|
61
48
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
*/
|
|
49
|
+
// 判断是否是固定金额
|
|
50
|
+
var isFixedAmount = (discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.discount_card_type) === 'fixed_amount';
|
|
51
|
+
|
|
52
|
+
// 固定金额 小于0时返回0
|
|
53
|
+
if (isFixedAmount) {
|
|
54
|
+
var _discount$amount;
|
|
55
|
+
return Math.max(new Decimal(price).minus(new Decimal(((_discount$amount = discount.amount) !== null && _discount$amount !== void 0 ? _discount$amount : discount.par_value) || 0)).toNumber(), 0);
|
|
56
|
+
}
|
|
72
57
|
|
|
73
|
-
|
|
58
|
+
// 百分比:根据折扣卡金额计算
|
|
59
|
+
return new Decimal(100).minus(discount.par_value || 0).div(100).mul(new Decimal(price)).toNumber();
|
|
74
60
|
};
|
|
75
61
|
export var getDiscountListAmountTotal = function getDiscountListAmountTotal(discount) {
|
|
76
62
|
return discount.reduce(function (acc, cur) {
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -38,7 +38,6 @@ __reExport(src_exports, require("./types"), module.exports);
|
|
|
38
38
|
__reExport(src_exports, require("./modules"), module.exports);
|
|
39
39
|
__reExport(src_exports, require("./plugins"), module.exports);
|
|
40
40
|
__reExport(src_exports, require("./solution"), module.exports);
|
|
41
|
-
__reExport(src_exports, require("./model"), module.exports);
|
|
42
41
|
var import_core = require("./core");
|
|
43
42
|
var import_core2 = __toESM(require("./core"));
|
|
44
43
|
var src_default = import_core2.default;
|
|
@@ -48,6 +47,5 @@ var src_default = import_core2.default;
|
|
|
48
47
|
...require("./types"),
|
|
49
48
|
...require("./modules"),
|
|
50
49
|
...require("./plugins"),
|
|
51
|
-
...require("./solution")
|
|
52
|
-
...require("./model")
|
|
50
|
+
...require("./solution")
|
|
53
51
|
});
|
|
@@ -46,18 +46,6 @@ 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
48
|
var import_utils3 = require("../../Summary/utils");
|
|
49
|
-
var toDiscountPayload = (discountItem) => {
|
|
50
|
-
var _a, _b;
|
|
51
|
-
return {
|
|
52
|
-
amount: discountItem.amount,
|
|
53
|
-
tag: discountItem.type,
|
|
54
|
-
par_value: (_a = discountItem.discount) == null ? void 0 : _a.percent,
|
|
55
|
-
config: discountItem.config,
|
|
56
|
-
metadata: {
|
|
57
|
-
discount_card_type: (_b = discountItem == null ? void 0 : discountItem.discount) == null ? void 0 : _b.discount_card_type
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
49
|
var handleVariantProduct = (product) => {
|
|
62
50
|
var _a;
|
|
63
51
|
if (product == null ? void 0 : product.product_variant_id) {
|
|
@@ -102,14 +90,6 @@ var formatProductToCartItem = (params) => {
|
|
|
102
90
|
num,
|
|
103
91
|
discounts
|
|
104
92
|
});
|
|
105
|
-
const origin_total = getProductTotalPrice({
|
|
106
|
-
product: cartItem._productInit || cartItem._productOrigin,
|
|
107
|
-
bundle,
|
|
108
|
-
options,
|
|
109
|
-
num,
|
|
110
|
-
discounts: []
|
|
111
|
-
});
|
|
112
|
-
cartItem.summaryOriginTotal = (origin_total || 0) * (num || 1);
|
|
113
93
|
cartItem.image = product == null ? void 0 : product.cover;
|
|
114
94
|
cartItem.like_status = "common";
|
|
115
95
|
cartItem.duration = product == null ? void 0 : product.duration;
|
|
@@ -204,24 +184,17 @@ var formatProductToCartItemOrigin = (params) => {
|
|
|
204
184
|
var getProductTotalPrice = (params) => {
|
|
205
185
|
const { product, bundle, options, discounts } = params;
|
|
206
186
|
let price = Number(product.price);
|
|
207
|
-
const optionRows = (options == null ? void 0 : options.map((currentValue) => ({
|
|
208
|
-
unit: Number(currentValue.price ?? currentValue.add_price ?? 0),
|
|
209
|
-
num: Number(currentValue.num ?? currentValue.quantity ?? 1)
|
|
210
|
-
}))) ?? [];
|
|
211
187
|
if (discounts == null ? void 0 : discounts.length) {
|
|
212
188
|
discounts.forEach((currentValue) => {
|
|
213
189
|
var _a;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
...row,
|
|
221
|
-
unit: (0, import_utils2.getDiscountAmount)(payload, row.unit, row.unit)
|
|
222
|
-
};
|
|
190
|
+
price = (0, import_utils2.getDiscountAmount)({
|
|
191
|
+
amount: currentValue.amount,
|
|
192
|
+
tag: currentValue.type,
|
|
193
|
+
par_value: currentValue.discount.percent,
|
|
194
|
+
metadata: {
|
|
195
|
+
discount_card_type: (_a = currentValue == null ? void 0 : currentValue.discount) == null ? void 0 : _a.discount_card_type
|
|
223
196
|
}
|
|
224
|
-
}
|
|
197
|
+
}, price, price);
|
|
225
198
|
});
|
|
226
199
|
}
|
|
227
200
|
if (bundle == null ? void 0 : bundle.length) {
|
|
@@ -229,11 +202,10 @@ var getProductTotalPrice = (params) => {
|
|
|
229
202
|
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
230
203
|
}, price);
|
|
231
204
|
}
|
|
232
|
-
if (
|
|
233
|
-
price =
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
);
|
|
205
|
+
if (options == null ? void 0 : options.length) {
|
|
206
|
+
price = options.reduce((accumulator, currentValue) => {
|
|
207
|
+
return accumulator + Number(currentValue.price) * Number(currentValue.num);
|
|
208
|
+
}, price);
|
|
237
209
|
}
|
|
238
210
|
return Math.max(0, price);
|
|
239
211
|
};
|
|
@@ -18,6 +18,14 @@ interface Formattitle {
|
|
|
18
18
|
interface PackageSubItemUsageRules {
|
|
19
19
|
type: 'universal_discount' | 'package_exclusive' | 'single_item_promo' | 'custom_usage_rules';
|
|
20
20
|
rules: ("original_price" | "markup_price")[];
|
|
21
|
+
package_scope?: {
|
|
22
|
+
type: 'all_packages' | 'specific_packages';
|
|
23
|
+
exclude_bundle_product_ids: number[];
|
|
24
|
+
include_bundle_product_ids: number[];
|
|
25
|
+
filter: 0 | 1;
|
|
26
|
+
rule: any[];
|
|
27
|
+
rule_type: 'and' | 'or';
|
|
28
|
+
};
|
|
21
29
|
}
|
|
22
30
|
interface Limitedrelationproductdata {
|
|
23
31
|
id: number;
|
|
@@ -25,8 +33,6 @@ interface Limitedrelationproductdata {
|
|
|
25
33
|
product_ids: number[];
|
|
26
34
|
product_collection_id: number[];
|
|
27
35
|
package_sub_item_usage_rules?: PackageSubItemUsageRules;
|
|
28
|
-
filter: 0 | 1;
|
|
29
|
-
exclude_product_ids: number[];
|
|
30
36
|
}
|
|
31
37
|
interface ApplicableProductDetails {
|
|
32
38
|
amount: string;
|
|
@@ -83,7 +89,6 @@ export interface Discount {
|
|
|
83
89
|
balance: string;
|
|
84
90
|
format_title: Formattitle;
|
|
85
91
|
metadata?: {
|
|
86
|
-
num?: number;
|
|
87
92
|
discount_card_type?: 'fixed_amount' | 'percent';
|
|
88
93
|
custom_product_bundle_map_id?: string;
|
|
89
94
|
validity_type?: "custom_schedule_validity" | "fixed_validity";
|
|
@@ -108,21 +113,6 @@ export interface Discount {
|
|
|
108
113
|
isSelected?: boolean;
|
|
109
114
|
isAvailable?: boolean;
|
|
110
115
|
isUsed?: boolean;
|
|
111
|
-
config?: {
|
|
112
|
-
isAvailable?: boolean;
|
|
113
|
-
/** 最大抵扣金额 */
|
|
114
|
-
maxDeductionAmount?: number;
|
|
115
|
-
/** 每单最多使用张数 */
|
|
116
|
-
maxUsagePerOrder?: number;
|
|
117
|
-
/** 是否抵扣税费与附加费 */
|
|
118
|
-
deductTaxAndFee?: boolean;
|
|
119
|
-
/** 适用粒度(多商品共用) */
|
|
120
|
-
allowCrossProduct?: boolean;
|
|
121
|
-
/** 可用商品数量上限 */
|
|
122
|
-
applicableProductLimit?: number;
|
|
123
|
-
/** 是否抵扣单规格价格 (Option Price) */
|
|
124
|
-
deductOptionPrice?: boolean;
|
|
125
|
-
};
|
|
126
116
|
applicableProductIds?: number[];
|
|
127
117
|
applicableProductDetails: ApplicableProductDetails[];
|
|
128
118
|
appliedProductDetails: ApplicableProductDetails[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
-
import { RequestPlugin
|
|
2
|
+
import { RequestPlugin } from '../../plugins';
|
|
3
3
|
import { BaseModule } from '../BaseModule';
|
|
4
4
|
import { PaymentModuleAPI, PaymentMethod, PaymentOrder, PaymentItem, PaymentItemInput, PaymentUpdateFields, PushOrderParams, CashPayment, EftposPayment, WalletPassPayment, RoundingRule, RoundingInterval, RoundingResult } from './types';
|
|
5
5
|
export * from './types';
|
|
@@ -21,7 +21,6 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
|
|
|
21
21
|
request: RequestPlugin;
|
|
22
22
|
private app;
|
|
23
23
|
private store;
|
|
24
|
-
window: WindowPlugin;
|
|
25
24
|
private dbManager;
|
|
26
25
|
private logger;
|
|
27
26
|
protected otherParams: any;
|
|
@@ -70,7 +70,6 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
70
70
|
this.otherParams = options.otherParams || {};
|
|
71
71
|
this.request = core.getPlugin("request");
|
|
72
72
|
const appPlugin = core.getPlugin("app");
|
|
73
|
-
this.window = core.getPlugin("window");
|
|
74
73
|
if (!this.request) {
|
|
75
74
|
throw new Error("支付模块需要 request 插件支持");
|
|
76
75
|
}
|
|
@@ -25,9 +25,6 @@ __export(utils_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(utils_exports);
|
|
27
27
|
var getAvailableMaxAmount = (data) => {
|
|
28
|
-
if (typeof data._available_max_amount === "number") {
|
|
29
|
-
return data._available_max_amount;
|
|
30
|
-
}
|
|
31
28
|
return data.tag !== "point_card" ? data.available_max_amount : data == null ? void 0 : data.recommended_usage_amount;
|
|
32
29
|
};
|
|
33
30
|
var formatWalletPassList2PreparePayments = (list) => {
|
|
@@ -9,7 +9,6 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
9
9
|
private userIdentificationCodes;
|
|
10
10
|
private searchResults;
|
|
11
11
|
private walletParams;
|
|
12
|
-
private walletInitData;
|
|
13
12
|
constructor(paymentModule: PaymentModule);
|
|
14
13
|
/**
|
|
15
14
|
* 发送事件的辅助方法
|
|
@@ -38,14 +37,7 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
38
37
|
initializeWalletDataFromBusinessAsync(businessData: WalletInitBusinessData): Promise<{
|
|
39
38
|
walletRecommendList: WalletRecommendItem[];
|
|
40
39
|
userIdentificationCodes: UserIdentificationCodeItem[];
|
|
41
|
-
transformList: any[];
|
|
42
|
-
noApplicableVoucher: any[];
|
|
43
|
-
products: any[];
|
|
44
40
|
}>;
|
|
45
|
-
/**
|
|
46
|
-
* 获取订单基础详情
|
|
47
|
-
*/
|
|
48
|
-
getOrderBasicDetailAsync(orderId: string): Promise<any>;
|
|
49
41
|
/**
|
|
50
42
|
* 初始化钱包数据
|
|
51
43
|
* 先获取推荐列表,再获取用户识别码列表(顺序执行)
|
|
@@ -53,9 +45,6 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
53
45
|
initializeWalletDataAsync(baseParams: WalletDeductionRecommendParams): Promise<{
|
|
54
46
|
walletRecommendList: WalletRecommendItem[];
|
|
55
47
|
userIdentificationCodes: UserIdentificationCodeItem[];
|
|
56
|
-
transformList: any[];
|
|
57
|
-
noApplicableVoucher: any[];
|
|
58
|
-
products: any[];
|
|
59
48
|
}>;
|
|
60
49
|
getWalletPassRecommendListAsync(params: WalletDeductionRecommendParams): Promise<WalletRecommendItem[]>;
|
|
61
50
|
formatWalletPassList2PreparePayments(list: WalletRecommendItem[]): {
|
|
@@ -103,18 +92,6 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
103
92
|
* 清除搜索结果缓存
|
|
104
93
|
*/
|
|
105
94
|
clearSearchResults(): void;
|
|
106
|
-
/**
|
|
107
|
-
* 获取存储的钱包初始化数据
|
|
108
|
-
*/
|
|
109
|
-
getStoredWalletInitData(): {
|
|
110
|
-
transformList: any[];
|
|
111
|
-
noApplicableVoucher: any[];
|
|
112
|
-
products: any[];
|
|
113
|
-
} | null;
|
|
114
|
-
/**
|
|
115
|
-
* 清除存储的钱包初始化数据
|
|
116
|
-
*/
|
|
117
|
-
clearStoredWalletInitData(): void;
|
|
118
95
|
/**
|
|
119
96
|
* 清除所有缓存数据
|
|
120
97
|
*/
|