@pisell/pisellos 2.1.112 → 2.1.113
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 +0 -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 +152 -664
- 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 +0 -1
- package/dist/solution/BookingByStep/index.js +50 -48
- 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 +0 -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 +284 -779
- 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 +0 -1
- package/lib/solution/BookingByStep/index.js +12 -13
- 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;
|
|
@@ -1789,7 +1789,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1789
1789
|
}
|
|
1790
1790
|
// 计算在时间片内有交集的预约容量总和
|
|
1791
1791
|
var totalCapacity = (countMap[n.id] || []).reduce(function (sum, item) {
|
|
1792
|
-
var hasOverlap =
|
|
1792
|
+
var hasOverlap = dayjs(item.time.start_at).isBefore(dayjs(timeSlots.end_at)) && dayjs(item.time.end_at).isAfter(dayjs(timeSlots.start_at));
|
|
1793
1793
|
return hasOverlap ? sum + item.pax : sum;
|
|
1794
1794
|
}, 0);
|
|
1795
1795
|
|
|
@@ -1896,8 +1896,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1896
1896
|
cartItems.forEach(function (item, index) {
|
|
1897
1897
|
var _getCapacityInfoByCar6 = getCapacityInfoByCartItem(item),
|
|
1898
1898
|
currentCapacity = _getCapacityInfoByCar6.currentCapacity;
|
|
1899
|
+
var hasOriginTimeSlot = Boolean(item._origin.start_time) && Boolean(item._origin.end_time) && !(timeSlots !== null && timeSlots !== void 0 && timeSlots.start_time);
|
|
1899
1900
|
// 如果商品已经有时间数据了,意味着是通过先选日期再选商品流程进来的,相当于时间切片已经选中了
|
|
1900
|
-
if (
|
|
1901
|
+
if (hasOriginTimeSlot) {
|
|
1901
1902
|
recordTimeSlots = {
|
|
1902
1903
|
start_time: item._origin.start_time,
|
|
1903
1904
|
end_time: item._origin.end_time,
|
|
@@ -1913,10 +1914,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1913
1914
|
return n.code === resources_code;
|
|
1914
1915
|
});
|
|
1915
1916
|
// 只有 duration 类商品且不含有灵活时间的商品需要这个操作
|
|
1916
|
-
if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$_productOrigin3 = item._productOrigin) !== null && _item$_productOrigin3 !== void 0 && _item$_productOrigin3.duration && !hasFlexibleProduct) {
|
|
1917
|
-
var _item$_productOrigin4
|
|
1918
|
-
var
|
|
1919
|
-
var
|
|
1917
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$_productOrigin3 = item._productOrigin) !== null && _item$_productOrigin3 !== void 0 && _item$_productOrigin3.duration && !hasFlexibleProduct && !hasOriginTimeSlot) {
|
|
1918
|
+
var _item$_productOrigin4;
|
|
1919
|
+
var recordEndAt = recordTimeSlots.end_at ? dayjs(recordTimeSlots.end_at) : dayjs("".concat(item.start_date, " ").concat(recordTimeSlots.end_time));
|
|
1920
|
+
var start_at = recordEndAt;
|
|
1921
|
+
var end_at = start_at.add(((_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.value) || 10, 'minutes');
|
|
1920
1922
|
recordTimeSlots = {
|
|
1921
1923
|
start_time: start_at.format('HH:mm'),
|
|
1922
1924
|
end_time: end_at.format('HH:mm'),
|
|
@@ -1960,13 +1962,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1960
1962
|
errorList.push(item._id);
|
|
1961
1963
|
}
|
|
1962
1964
|
} else {
|
|
1963
|
-
var _item$
|
|
1965
|
+
var _item$_productOrigin5, _productResources$fin;
|
|
1964
1966
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
1965
1967
|
// 能进到这种逻辑,说明是 duration 类商品或者灵活时长商品,且是第一种资源,还没有确定时间
|
|
1966
1968
|
var allCartItems = cloneDeep(_this11.store.cart.getItems());
|
|
1967
1969
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
1968
1970
|
var selectedResources = [];
|
|
1969
|
-
var _resources = cloneDeep(((_item$
|
|
1971
|
+
var _resources = cloneDeep(((_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.product_resource) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.resources) || []);
|
|
1970
1972
|
var currentResourcesRenderList = [];
|
|
1971
1973
|
_resources.forEach(function (n) {
|
|
1972
1974
|
var _n$renderList;
|
|
@@ -2082,8 +2084,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2082
2084
|
var maxCutOffTime = undefined;
|
|
2083
2085
|
var maxCutOffTimeValue = dayjs();
|
|
2084
2086
|
cartItems.forEach(function (item) {
|
|
2085
|
-
var _item$
|
|
2086
|
-
(_item$
|
|
2087
|
+
var _item$_productOrigin6, _item$_productOrigin7, _item$_productOrigin8, _item$_productOrigin9;
|
|
2088
|
+
(_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.product_resource) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.resources) === null || _item$_productOrigin6 === void 0 || _item$_productOrigin6.forEach(function (n) {
|
|
2087
2089
|
// TODO: 少了个 status 的判断
|
|
2088
2090
|
if (n.code === resources_code) {
|
|
2089
2091
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
@@ -2096,10 +2098,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2096
2098
|
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
2097
2099
|
resourceIds.push(item.resource_id);
|
|
2098
2100
|
}
|
|
2099
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
2101
|
+
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.product_resource) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.resources) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.find(function (n) {
|
|
2100
2102
|
return n.code === resources_code;
|
|
2101
|
-
})) === null || _item$
|
|
2102
|
-
if ((_item$
|
|
2103
|
+
})) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.id;
|
|
2104
|
+
if ((_item$_productOrigin8 = item._productOrigin) !== null && _item$_productOrigin8 !== void 0 && _item$_productOrigin8.cut_off_time && ((_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.cut_off_time.type) === 'advance') {
|
|
2103
2105
|
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2104
2106
|
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2105
2107
|
maxCutOffTimeValue = currentCutOffTime;
|
|
@@ -2149,13 +2151,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2149
2151
|
cartItems.forEach(function (item) {
|
|
2150
2152
|
// 单个预约累加账号 多个预约取最大值
|
|
2151
2153
|
if (isSingleResource) {
|
|
2152
|
-
var _item$
|
|
2153
|
-
accountDuration += ((_item$
|
|
2154
|
+
var _item$_productOrigin10;
|
|
2155
|
+
accountDuration += ((_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.duration) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.value) || 10;
|
|
2154
2156
|
} else {
|
|
2155
|
-
var _item$
|
|
2156
|
-
if (accountDuration < (((_item$
|
|
2157
|
-
var _item$
|
|
2158
|
-
accountDuration = ((_item$
|
|
2157
|
+
var _item$_productOrigin11;
|
|
2158
|
+
if (accountDuration < (((_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.value) || 10)) {
|
|
2159
|
+
var _item$_productOrigin12;
|
|
2160
|
+
accountDuration = ((_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.duration) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.value) || 10;
|
|
2159
2161
|
}
|
|
2160
2162
|
}
|
|
2161
2163
|
});
|
|
@@ -2192,8 +2194,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2192
2194
|
}
|
|
2193
2195
|
var resourcesUseableMap = {};
|
|
2194
2196
|
var hasFlexibleDuration = cartItems.some(function (item) {
|
|
2195
|
-
var _item$
|
|
2196
|
-
return ((_item$
|
|
2197
|
+
var _item$_productOrigin13;
|
|
2198
|
+
return ((_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.type) === 'flexible';
|
|
2197
2199
|
});
|
|
2198
2200
|
var operating_day_boundary = (_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.operating_day_boundary;
|
|
2199
2201
|
|
|
@@ -2201,11 +2203,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2201
2203
|
var maxBlockThreshold = 0;
|
|
2202
2204
|
if (hasFlexibleDuration) {
|
|
2203
2205
|
maxBlockThreshold = cartItems.reduce(function (max, item) {
|
|
2204
|
-
var _item$
|
|
2206
|
+
var _item$_productOrigin14;
|
|
2205
2207
|
// 如果开启了灵活时长商品配置,则取 block_threshold 的值
|
|
2206
|
-
if ((_item$
|
|
2207
|
-
var _item$
|
|
2208
|
-
return Math.max(max, ((_item$
|
|
2208
|
+
if ((_item$_productOrigin14 = item._productOrigin) !== null && _item$_productOrigin14 !== void 0 && (_item$_productOrigin14 = _item$_productOrigin14.duration) !== null && _item$_productOrigin14 !== void 0 && (_item$_productOrigin14 = _item$_productOrigin14.flexible_config) !== null && _item$_productOrigin14 !== void 0 && _item$_productOrigin14.is_enable_minimum_duration) {
|
|
2209
|
+
var _item$_productOrigin15;
|
|
2210
|
+
return Math.max(max, ((_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.flexible_config) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.block_threshold) || 0);
|
|
2209
2211
|
}
|
|
2210
2212
|
return 0;
|
|
2211
2213
|
}, 0);
|
|
@@ -2297,8 +2299,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2297
2299
|
maxCutOffTime = undefined;
|
|
2298
2300
|
maxCutOffTimeValue = dayjs();
|
|
2299
2301
|
cartItems.forEach(function (item) {
|
|
2300
|
-
var _item$
|
|
2301
|
-
(_item$
|
|
2302
|
+
var _item$_productOrigin16, _item$_productOrigin17, _item$_productOrigin18, _item$_productOrigin19;
|
|
2303
|
+
(_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.product_resource) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.resources) === null || _item$_productOrigin16 === void 0 || _item$_productOrigin16.forEach(function (n) {
|
|
2302
2304
|
// TODO: 少了个 status 的判断
|
|
2303
2305
|
if (n.code === resources_code) {
|
|
2304
2306
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
@@ -2311,10 +2313,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2311
2313
|
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
2312
2314
|
resourceIds.push(item.resource_id);
|
|
2313
2315
|
}
|
|
2314
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
2316
|
+
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.product_resource) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.resources) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.find(function (n) {
|
|
2315
2317
|
return n.code === resources_code;
|
|
2316
|
-
})) === null || _item$
|
|
2317
|
-
if ((_item$
|
|
2318
|
+
})) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.id;
|
|
2319
|
+
if ((_item$_productOrigin18 = item._productOrigin) !== null && _item$_productOrigin18 !== void 0 && _item$_productOrigin18.cut_off_time && ((_item$_productOrigin19 = item._productOrigin) === null || _item$_productOrigin19 === void 0 ? void 0 : _item$_productOrigin19.cut_off_time.type) === 'advance') {
|
|
2318
2320
|
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2319
2321
|
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2320
2322
|
maxCutOffTimeValue = currentCutOffTime;
|
|
@@ -2337,13 +2339,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2337
2339
|
cartItems.forEach(function (item) {
|
|
2338
2340
|
// 单个预约累加账号 多个预约取最大值
|
|
2339
2341
|
if (isSingleResource) {
|
|
2340
|
-
var _item$
|
|
2341
|
-
accountDuration += ((_item$
|
|
2342
|
+
var _item$_productOrigin20;
|
|
2343
|
+
accountDuration += ((_item$_productOrigin20 = item._productOrigin) === null || _item$_productOrigin20 === void 0 || (_item$_productOrigin20 = _item$_productOrigin20.duration) === null || _item$_productOrigin20 === void 0 ? void 0 : _item$_productOrigin20.value) || 10;
|
|
2342
2344
|
} else {
|
|
2343
|
-
var _item$
|
|
2344
|
-
if (accountDuration < (((_item$
|
|
2345
|
-
var _item$
|
|
2346
|
-
accountDuration = ((_item$
|
|
2345
|
+
var _item$_productOrigin21;
|
|
2346
|
+
if (accountDuration < (((_item$_productOrigin21 = item._productOrigin) === null || _item$_productOrigin21 === void 0 || (_item$_productOrigin21 = _item$_productOrigin21.duration) === null || _item$_productOrigin21 === void 0 ? void 0 : _item$_productOrigin21.value) || 10)) {
|
|
2347
|
+
var _item$_productOrigin22;
|
|
2348
|
+
accountDuration = ((_item$_productOrigin22 = item._productOrigin) === null || _item$_productOrigin22 === void 0 || (_item$_productOrigin22 = _item$_productOrigin22.duration) === null || _item$_productOrigin22 === void 0 ? void 0 : _item$_productOrigin22.value) || 10;
|
|
2347
2349
|
}
|
|
2348
2350
|
}
|
|
2349
2351
|
});
|
|
@@ -2369,18 +2371,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2369
2371
|
case 20:
|
|
2370
2372
|
resourcesUseableMap = {};
|
|
2371
2373
|
hasFlexibleDuration = cartItems.some(function (item) {
|
|
2372
|
-
var _item$
|
|
2373
|
-
return ((_item$
|
|
2374
|
+
var _item$_productOrigin23;
|
|
2375
|
+
return ((_item$_productOrigin23 = item._productOrigin) === null || _item$_productOrigin23 === void 0 || (_item$_productOrigin23 = _item$_productOrigin23.duration) === null || _item$_productOrigin23 === void 0 ? void 0 : _item$_productOrigin23.type) === 'flexible';
|
|
2374
2376
|
});
|
|
2375
2377
|
operating_day_boundary = (_this$shopStore$get2 = this.shopStore.get('core')) === null || _this$shopStore$get2 === void 0 || (_this$shopStore$get2 = _this$shopStore$get2.core) === null || _this$shopStore$get2 === void 0 ? void 0 : _this$shopStore$get2.operating_day_boundary; // 如果有 hasFlexibleDuration,需要把动态时长商品(可能是多个,取最长的那个最低禁止购买时长)的最低禁止购买时长作为 split 的值
|
|
2376
2378
|
maxBlockThreshold = 0;
|
|
2377
2379
|
if (hasFlexibleDuration) {
|
|
2378
2380
|
maxBlockThreshold = cartItems.reduce(function (max, item) {
|
|
2379
|
-
var _item$
|
|
2381
|
+
var _item$_productOrigin24;
|
|
2380
2382
|
// 如果开启了灵活时长商品配置,则取 block_threshold 的值
|
|
2381
|
-
if ((_item$
|
|
2382
|
-
var _item$
|
|
2383
|
-
return Math.max(max, ((_item$
|
|
2383
|
+
if ((_item$_productOrigin24 = item._productOrigin) !== null && _item$_productOrigin24 !== void 0 && (_item$_productOrigin24 = _item$_productOrigin24.duration) !== null && _item$_productOrigin24 !== void 0 && (_item$_productOrigin24 = _item$_productOrigin24.flexible_config) !== null && _item$_productOrigin24 !== void 0 && _item$_productOrigin24.is_enable_minimum_duration) {
|
|
2384
|
+
var _item$_productOrigin25;
|
|
2385
|
+
return Math.max(max, ((_item$_productOrigin25 = item._productOrigin) === null || _item$_productOrigin25 === void 0 || (_item$_productOrigin25 = _item$_productOrigin25.duration) === null || _item$_productOrigin25 === void 0 || (_item$_productOrigin25 = _item$_productOrigin25.flexible_config) === null || _item$_productOrigin25 === void 0 ? void 0 : _item$_productOrigin25.block_threshold) || 0);
|
|
2384
2386
|
}
|
|
2385
2387
|
return 0;
|
|
2386
2388
|
}, 0);
|
|
@@ -2541,10 +2543,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2541
2543
|
var osWarnTips = [];
|
|
2542
2544
|
var newResources = cloneDeep(item._origin.resources);
|
|
2543
2545
|
newResources.forEach(function (resource) {
|
|
2544
|
-
var _item$
|
|
2546
|
+
var _item$_productOrigin26;
|
|
2545
2547
|
// 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
|
|
2546
|
-
if (((_item$
|
|
2547
|
-
var _allResources$find, _item$
|
|
2548
|
+
if (((_item$_productOrigin26 = item._productOrigin) === null || _item$_productOrigin26 === void 0 || (_item$_productOrigin26 = _item$_productOrigin26.duration) === null || _item$_productOrigin26 === void 0 ? void 0 : _item$_productOrigin26.type) === 'flexible') {
|
|
2549
|
+
var _allResources$find, _item$_productOrigin27, _item$_productOrigin28;
|
|
2548
2550
|
item.duration = {
|
|
2549
2551
|
type: 'minutes',
|
|
2550
2552
|
value: 10
|
|
@@ -2627,15 +2629,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2627
2629
|
resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
|
|
2628
2630
|
// 如果是动态时长商品,并且当前选择的时间的结束时间小于了最低提示时长(warningThreshold),则追加一个提示
|
|
2629
2631
|
// 如果currentStartTime + warningThreshold 大于 currentEndTime,且 osWarnTips 没有pisell2.product.card.closing-soon.warning 这一项,则加入这一项
|
|
2630
|
-
if ((_item$
|
|
2632
|
+
if ((_item$_productOrigin27 = item._productOrigin) !== null && _item$_productOrigin27 !== void 0 && (_item$_productOrigin27 = _item$_productOrigin27.duration) !== null && _item$_productOrigin27 !== void 0 && (_item$_productOrigin27 = _item$_productOrigin27.flexible_config) !== null && _item$_productOrigin27 !== void 0 && _item$_productOrigin27.is_enable_minimum_duration && dayjs(currentStartTime).add(((_item$_productOrigin28 = item._productOrigin) === null || _item$_productOrigin28 === void 0 || (_item$_productOrigin28 = _item$_productOrigin28.duration) === null || _item$_productOrigin28 === void 0 || (_item$_productOrigin28 = _item$_productOrigin28.flexible_config) === null || _item$_productOrigin28 === void 0 ? void 0 : _item$_productOrigin28.warning_threshold) || 0, 'minutes').isAfter(dayjs(formattedEndTime))) {
|
|
2631
2633
|
if (!osWarnTips.includes('pisell2.product.card.closing-soon.warning')) {
|
|
2632
2634
|
osWarnTips.push('pisell2.product.card.closing-soon.warning');
|
|
2633
2635
|
}
|
|
2634
2636
|
}
|
|
2635
2637
|
} else {
|
|
2636
|
-
var _item$
|
|
2638
|
+
var _item$_productOrigin29;
|
|
2637
2639
|
resource.startTime = currentStartTime;
|
|
2638
|
-
resource.endTime = dayjs(currentStartTime).add(((_item$
|
|
2640
|
+
resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin29 = item._productOrigin) === null || _item$_productOrigin29 === void 0 || (_item$_productOrigin29 = _item$_productOrigin29.duration) === null || _item$_productOrigin29 === void 0 ? void 0 : _item$_productOrigin29.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
|
|
2639
2641
|
}
|
|
2640
2642
|
// delete resource.times;
|
|
2641
2643
|
});
|
|
@@ -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
|
});
|