@pisell/pisellos 3.0.78 → 3.0.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +21 -1
- package/dist/modules/Cart/utils/changePrice.js +6 -0
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +16 -8
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +2 -1
- package/dist/modules/Rules/index.js +14 -14
- package/dist/modules/Schedule/index.d.ts +9 -0
- package/dist/modules/Schedule/index.js +76 -0
- package/dist/modules/Summary/index.d.ts +3 -0
- package/dist/modules/Summary/index.js +134 -15
- package/dist/modules/Summary/types.d.ts +7 -0
- package/dist/modules/Summary/utils.d.ts +104 -1
- package/dist/modules/Summary/utils.js +1131 -13
- package/dist/solution/BookingByStep/index.d.ts +4 -7
- package/dist/solution/BookingByStep/index.js +232 -119
- package/dist/solution/ShopDiscount/index.js +2 -1
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +16 -1
- package/lib/modules/Cart/utils/changePrice.js +5 -0
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +7 -1
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +2 -1
- package/lib/modules/Rules/index.js +3 -3
- package/lib/modules/Schedule/index.d.ts +9 -0
- package/lib/modules/Schedule/index.js +60 -0
- package/lib/modules/Summary/index.d.ts +3 -0
- package/lib/modules/Summary/index.js +61 -2
- package/lib/modules/Summary/types.d.ts +7 -0
- package/lib/modules/Summary/utils.d.ts +104 -1
- package/lib/modules/Summary/utils.js +673 -8
- package/lib/solution/BookingByStep/index.d.ts +4 -7
- package/lib/solution/BookingByStep/index.js +189 -90
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
13
13
|
import Decimal from 'decimal.js';
|
|
14
14
|
import { isNormalProduct } from "../../Product/utils";
|
|
15
15
|
import { getDiscountAmount } from "../../../solution/ShopDiscount/utils";
|
|
16
|
+
import { calcDiscountListDifference } from "../../Summary/utils";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* @title 处理组合商品
|
|
@@ -69,6 +70,11 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
|
|
|
69
70
|
num: num,
|
|
70
71
|
discounts: discounts
|
|
71
72
|
});
|
|
73
|
+
cartItem.totalDifference = getTotalDifference({
|
|
74
|
+
product: product,
|
|
75
|
+
bundle: bundle,
|
|
76
|
+
discounts: discounts
|
|
77
|
+
});
|
|
72
78
|
cartItem.summaryTotal = cartItem.total * (num || 1);
|
|
73
79
|
cartItem.origin_total = getProductOriginTotalPrice({
|
|
74
80
|
product: product,
|
|
@@ -218,6 +224,19 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
|
|
|
218
224
|
}
|
|
219
225
|
return Math.max(0, price);
|
|
220
226
|
};
|
|
227
|
+
var getTotalDifference = function getTotalDifference(params) {
|
|
228
|
+
var bundle = params.bundle,
|
|
229
|
+
discounts = params.discounts;
|
|
230
|
+
var bundleDiscountList = [];
|
|
231
|
+
if (bundle !== null && bundle !== void 0 && bundle.length) {
|
|
232
|
+
bundle.forEach(function (currentValue) {
|
|
233
|
+
bundleDiscountList.push.apply(bundleDiscountList, _toConsumableArray((currentValue === null || currentValue === void 0 ? void 0 : currentValue.discount_list) || []));
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
var allDiscounts = [].concat(_toConsumableArray(discounts || []), bundleDiscountList);
|
|
237
|
+
var productDiscountProductDiscountDifference = calcDiscountListDifference(allDiscounts);
|
|
238
|
+
return productDiscountProductDiscountDifference || 0;
|
|
239
|
+
};
|
|
221
240
|
|
|
222
241
|
/**
|
|
223
242
|
* 获取商品原始总价
|
|
@@ -304,7 +323,8 @@ export var formatBundle = function formatBundle(bundle) {
|
|
|
304
323
|
options: formatOptions(item === null || item === void 0 ? void 0 : item.option),
|
|
305
324
|
_bundle_product_id: item._bundle_product_id,
|
|
306
325
|
discount_list: item.discount_list,
|
|
307
|
-
originBundleItem: item.originBundleItem || item
|
|
326
|
+
originBundleItem: item.originBundleItem || item,
|
|
327
|
+
is_charge_tax: item === null || item === void 0 ? void 0 : item.is_charge_tax
|
|
308
328
|
};
|
|
309
329
|
});
|
|
310
330
|
};
|
|
@@ -57,6 +57,12 @@ function _updateAllCartItemPrice() {
|
|
|
57
57
|
if (targetBundleItem.price_type === 'markdown') {
|
|
58
58
|
targetBundleItem.price = new Decimal(targetBundleItem.price || 0).mul(-1).toNumber();
|
|
59
59
|
}
|
|
60
|
+
// 如果有选择 option,还需要加上 option 的价格
|
|
61
|
+
if (n.option) {
|
|
62
|
+
targetBundleItem.price = new Decimal(targetBundleItem.price || 0).add(n.option.reduce(function (pre, cur) {
|
|
63
|
+
return pre + new Decimal(cur.price || 0).mul(cur.num || 1).toNumber();
|
|
64
|
+
}, 0)).toNumber();
|
|
65
|
+
}
|
|
60
66
|
if (targetBundleItem) {
|
|
61
67
|
return _objectSpread(_objectSpread({}, n), {}, {
|
|
62
68
|
price: targetBundleItem.price,
|
|
@@ -37,5 +37,5 @@ export declare class DateModule extends BaseModule implements Module, DateModule
|
|
|
37
37
|
getResourceAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
|
|
38
38
|
clearDateRange(): void;
|
|
39
39
|
storeChange(): void;
|
|
40
|
-
getResourcesListByDate(date: string): any[]
|
|
40
|
+
getResourcesListByDate(date: string): any[];
|
|
41
41
|
}
|
|
@@ -85,6 +85,14 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
85
85
|
}, {
|
|
86
86
|
key: "setDateRange",
|
|
87
87
|
value: function setDateRange(dateRange) {
|
|
88
|
+
var _this2 = this;
|
|
89
|
+
// 如果 dateRange 传入的日期里没有 resource,但是本地有的,要尝试补充下
|
|
90
|
+
dateRange.forEach(function (item) {
|
|
91
|
+
var _item$resource;
|
|
92
|
+
if (!((_item$resource = item.resource) !== null && _item$resource !== void 0 && _item$resource.length)) {
|
|
93
|
+
item.resource = _this2.getResourcesListByDate(item.date);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
88
96
|
this.store.dateRange = dateRange;
|
|
89
97
|
}
|
|
90
98
|
}, {
|
|
@@ -157,10 +165,10 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
157
165
|
return n.date === item.date;
|
|
158
166
|
});
|
|
159
167
|
if (currentItemIndex !== -1) {
|
|
160
|
-
var _item$
|
|
168
|
+
var _item$resource2, _currentItem$resource3;
|
|
161
169
|
var currentItem = currentDateList[currentItemIndex];
|
|
162
170
|
// 看那一天的数据有没有相同的,把不同的资源合并进去即可
|
|
163
|
-
var newResource = (_item$
|
|
171
|
+
var newResource = (_item$resource2 = item.resource) === null || _item$resource2 === void 0 ? void 0 : _item$resource2.filter(function (n) {
|
|
164
172
|
var _currentItem$resource2;
|
|
165
173
|
return !((_currentItem$resource2 = currentItem.resource) !== null && _currentItem$resource2 !== void 0 && _currentItem$resource2.some(function (m) {
|
|
166
174
|
return m.id === n.id;
|
|
@@ -168,8 +176,8 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
168
176
|
});
|
|
169
177
|
// 如果有相同的资源,则使用 item 中的新的resource.times,而不是 currentItem 中的
|
|
170
178
|
(_currentItem$resource3 = currentItem.resource) === null || _currentItem$resource3 === void 0 || _currentItem$resource3.forEach(function (n) {
|
|
171
|
-
var _item$
|
|
172
|
-
var newResource = (_item$
|
|
179
|
+
var _item$resource3;
|
|
180
|
+
var newResource = (_item$resource3 = item.resource) === null || _item$resource3 === void 0 ? void 0 : _item$resource3.find(function (m) {
|
|
173
181
|
return m.id === n.id;
|
|
174
182
|
});
|
|
175
183
|
if (newResource) {
|
|
@@ -261,7 +269,7 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
261
269
|
}, {
|
|
262
270
|
key: "correctResourceTimeSlots",
|
|
263
271
|
value: function correctResourceTimeSlots(resourcesData) {
|
|
264
|
-
var
|
|
272
|
+
var _this3 = this;
|
|
265
273
|
return resourcesData.map(function (resource) {
|
|
266
274
|
// 检查资源是否有 times 数组和 start_time
|
|
267
275
|
if (!resource.times || !Array.isArray(resource.times) || !resource.start_time) {
|
|
@@ -284,7 +292,7 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
284
292
|
// 如果 start_at 早于资源的 start_time,需要修正
|
|
285
293
|
if (startAt.isBefore(resourceStartTime)) {
|
|
286
294
|
// 将 start_time 向上取整到下一个10分钟整数
|
|
287
|
-
var roundedStartTime =
|
|
295
|
+
var roundedStartTime = _this3.roundUpToNext10Minutes(resourceStartTime);
|
|
288
296
|
var roundedStartTimeDayjs = dayjs(roundedStartTime);
|
|
289
297
|
console.log("[DateModule] \u4FEE\u6B63\u65F6\u95F4\u6BB5\u5F00\u59CB\u65F6\u95F4: ".concat(timeSlot.start_at, " -> ").concat(roundedStartTime, " (\u8D44\u6E90ID: ").concat(resource.id, ", \u539F\u59CBstart_time: ").concat(resource.start_time, ")"));
|
|
290
298
|
|
|
@@ -393,9 +401,9 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
393
401
|
value: function getResourcesListByDate(date) {
|
|
394
402
|
var _dateList$find;
|
|
395
403
|
var dateList = this.store.dateList;
|
|
396
|
-
var resourcesList = (_dateList$find = dateList.find(function (item) {
|
|
404
|
+
var resourcesList = (dateList === null || dateList === void 0 || (_dateList$find = dateList.find(function (item) {
|
|
397
405
|
return item.date === date;
|
|
398
|
-
})) === null || _dateList$find === void 0 ? void 0 : _dateList$find.resource;
|
|
406
|
+
})) === null || _dateList$find === void 0 ? void 0 : _dateList$find.resource) || [];
|
|
399
407
|
return resourcesList;
|
|
400
408
|
}
|
|
401
409
|
}]);
|
|
@@ -22,6 +22,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
22
22
|
with_discount_card: 0 | 1;
|
|
23
23
|
customer_id: number;
|
|
24
24
|
with_wallet_pass_holder: 0 | 1;
|
|
25
|
+
request_timezone: string;
|
|
25
26
|
}): Promise<Discount[]>;
|
|
26
27
|
batchSearch(code: string, customerId?: number): Promise<Discount[]>;
|
|
27
28
|
filterEnabledDiscountList(discountList: Discount[]): Discount[];
|
|
@@ -190,7 +190,8 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
190
190
|
relation_product: 1,
|
|
191
191
|
with: ['extensionData', 'customScheduleSnapshot', 'holder.detail'],
|
|
192
192
|
order_behavior_count: 1,
|
|
193
|
-
order_behavior_count_customer_id: customerId || 1
|
|
193
|
+
order_behavior_count_customer_id: customerId || 1,
|
|
194
|
+
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
194
195
|
});
|
|
195
196
|
case 2:
|
|
196
197
|
result = _context5.sent;
|
|
@@ -691,7 +691,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
691
691
|
// 收集该折扣卡适用的商品(排除被其他专属折扣卡占用的商品)
|
|
692
692
|
var applicableProducts = [];
|
|
693
693
|
sortedFlattenedList.forEach(function (flatItem) {
|
|
694
|
-
var _flatItem$parentProdu2, _product$price, _ref5, _flatItem$original_pr;
|
|
694
|
+
var _flatItem$parentProdu2, _flatItem$parentProdu3, _product$price, _ref5, _flatItem$original_pr;
|
|
695
695
|
// 🔥 检查该商品是否被其他专属折扣卡占用
|
|
696
696
|
var occupyingDiscountId = occupiedItems.get(flatItem._id);
|
|
697
697
|
if (occupyingDiscountId !== undefined && occupyingDiscountId !== discount.id) {
|
|
@@ -715,7 +715,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
715
715
|
}
|
|
716
716
|
|
|
717
717
|
// 对于 bundle 子商品,quantity 需要乘以主商品的购买数量
|
|
718
|
-
var quantity = flatItem.type === 'main' ? product.quantity || 1 : (product.num || 1) * (((_flatItem$parentProdu2 = flatItem.parentProduct) === null || _flatItem$parentProdu2 === void 0 ? void 0 : _flatItem$parentProdu2.quantity) || 1);
|
|
718
|
+
var quantity = flatItem.type === 'main' ? product.num || product.quantity || 1 : (product.num || product.quantity || 1) * (((_flatItem$parentProdu2 = flatItem.parentProduct) === null || _flatItem$parentProdu2 === void 0 ? void 0 : _flatItem$parentProdu2.num) || ((_flatItem$parentProdu3 = flatItem.parentProduct) === null || _flatItem$parentProdu3 === void 0 ? void 0 : _flatItem$parentProdu3.quantity) || 1);
|
|
719
719
|
|
|
720
720
|
// 对于主商品:使用 price
|
|
721
721
|
// 对于子商品:优先使用 flatItem.original_price,否则使用 flatItem.price
|
|
@@ -730,8 +730,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
730
730
|
|
|
731
731
|
// 子商品需要传递主商品数量
|
|
732
732
|
if (flatItem.type === 'bundle') {
|
|
733
|
-
var _flatItem$
|
|
734
|
-
productData.parentQuantity = ((_flatItem$
|
|
733
|
+
var _flatItem$parentProdu4;
|
|
734
|
+
productData.parentQuantity = ((_flatItem$parentProdu4 = flatItem.parentProduct) === null || _flatItem$parentProdu4 === void 0 ? void 0 : _flatItem$parentProdu4.quantity) || 1;
|
|
735
735
|
}
|
|
736
736
|
applicableProducts.push(productData);
|
|
737
737
|
});
|
|
@@ -758,7 +758,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
758
758
|
product = flatItem.product;
|
|
759
759
|
originProduct = flatItem.originProduct;
|
|
760
760
|
} else {
|
|
761
|
-
var _flatItem$
|
|
761
|
+
var _flatItem$parentProdu5;
|
|
762
762
|
// bundle子商品:构造虚拟商品对象
|
|
763
763
|
product = {
|
|
764
764
|
_id: flatItem._id,
|
|
@@ -770,7 +770,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
770
770
|
origin_total: flatItem.origin_total,
|
|
771
771
|
booking_id: flatItem.booking_id,
|
|
772
772
|
discount_list: flatItem.discount_list || [],
|
|
773
|
-
startDate: (_flatItem$
|
|
773
|
+
startDate: (_flatItem$parentProdu5 = flatItem.parentProduct) === null || _flatItem$parentProdu5 === void 0 ? void 0 : _flatItem$parentProdu5.startDate
|
|
774
774
|
};
|
|
775
775
|
originProduct = flatItem.originProduct;
|
|
776
776
|
}
|
|
@@ -849,7 +849,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
849
849
|
product = flatItem.product;
|
|
850
850
|
originProduct = flatItem.originProduct;
|
|
851
851
|
} else {
|
|
852
|
-
var _flatItem$bundleItem5, _flatItem$bundleItem6, _flatItem$bundleItem7, _flatItem$
|
|
852
|
+
var _flatItem$bundleItem5, _flatItem$bundleItem6, _flatItem$bundleItem7, _flatItem$parentProdu6;
|
|
853
853
|
// bundle子商品
|
|
854
854
|
product = {
|
|
855
855
|
_id: flatItem._id,
|
|
@@ -862,7 +862,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
862
862
|
origin_total: flatItem === null || flatItem === void 0 || (_flatItem$bundleItem6 = flatItem.bundleItem) === null || _flatItem$bundleItem6 === void 0 ? void 0 : _flatItem$bundleItem6.original_price,
|
|
863
863
|
booking_id: flatItem.booking_id,
|
|
864
864
|
discount_list: (flatItem === null || flatItem === void 0 || (_flatItem$bundleItem7 = flatItem.bundleItem) === null || _flatItem$bundleItem7 === void 0 ? void 0 : _flatItem$bundleItem7.discount_list) || [],
|
|
865
|
-
startDate: (_flatItem$
|
|
865
|
+
startDate: (_flatItem$parentProdu6 = flatItem.parentProduct) === null || _flatItem$parentProdu6 === void 0 ? void 0 : _flatItem$parentProdu6.startDate
|
|
866
866
|
};
|
|
867
867
|
originProduct = flatItem.originProduct;
|
|
868
868
|
}
|
|
@@ -974,11 +974,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
974
974
|
}
|
|
975
975
|
// bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
|
|
976
976
|
if (flatItem.type === 'bundle') {
|
|
977
|
-
var _product$discount_lis7, _flatItem$
|
|
977
|
+
var _product$discount_lis7, _flatItem$parentProdu7;
|
|
978
978
|
if ((_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.some(function (item) {
|
|
979
979
|
var _item$discount2;
|
|
980
980
|
return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === options.discountId;
|
|
981
|
-
}) || (_flatItem$
|
|
981
|
+
}) || (_flatItem$parentProdu7 = flatItem.parentProduct) !== null && _flatItem$parentProdu7 !== void 0 && (_flatItem$parentProdu7 = _flatItem$parentProdu7.discount_list) !== null && _flatItem$parentProdu7 !== void 0 && _flatItem$parentProdu7.some(function (item) {
|
|
982
982
|
var _item$discount3;
|
|
983
983
|
return ((_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.resource_id) === options.discountId;
|
|
984
984
|
})) {
|
|
@@ -1000,14 +1000,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1000
1000
|
}
|
|
1001
1001
|
// bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
|
|
1002
1002
|
if (flatItem.type === 'bundle') {
|
|
1003
|
-
var _product$discount_lis9, _flatItem$
|
|
1003
|
+
var _product$discount_lis9, _flatItem$parentProdu8;
|
|
1004
1004
|
if ((_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
|
|
1005
1005
|
var _options$selectedList2;
|
|
1006
1006
|
return options === null || options === void 0 || (_options$selectedList2 = options.selectedList) === null || _options$selectedList2 === void 0 ? void 0 : _options$selectedList2.some(function (n) {
|
|
1007
1007
|
var _item$discount5;
|
|
1008
1008
|
return n.discountId === ((_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.resource_id);
|
|
1009
1009
|
});
|
|
1010
|
-
}) || (_flatItem$
|
|
1010
|
+
}) || (_flatItem$parentProdu8 = flatItem.parentProduct) !== null && _flatItem$parentProdu8 !== void 0 && (_flatItem$parentProdu8 = _flatItem$parentProdu8.discount_list) !== null && _flatItem$parentProdu8 !== void 0 && _flatItem$parentProdu8.some(function (item) {
|
|
1011
1011
|
var _options$selectedList3;
|
|
1012
1012
|
return options === null || options === void 0 || (_options$selectedList3 = options.selectedList) === null || _options$selectedList3 === void 0 ? void 0 : _options$selectedList3.some(function (n) {
|
|
1013
1013
|
var _item$discount6;
|
|
@@ -1260,7 +1260,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1260
1260
|
}));
|
|
1261
1261
|
}
|
|
1262
1262
|
} else {
|
|
1263
|
-
var _selectedDiscount3$me, _selectedDiscount3$me2, _flatItem$
|
|
1263
|
+
var _selectedDiscount3$me, _selectedDiscount3$me2, _flatItem$parentProdu9;
|
|
1264
1264
|
// 折扣卡:不拆分数量,直接应用
|
|
1265
1265
|
var _selectedDiscount3 = selectedDiscountCard || applicableDiscounts[0];
|
|
1266
1266
|
usedDiscounts.set(_selectedDiscount3.id, true);
|
|
@@ -1306,7 +1306,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1306
1306
|
}, _productDiscountDifference !== undefined && {
|
|
1307
1307
|
product_discount_difference: _productDiscountDifference
|
|
1308
1308
|
}),
|
|
1309
|
-
_num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$
|
|
1309
|
+
_num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$parentProdu9 = flatItem.parentProduct) === null || _flatItem$parentProdu9 === void 0 ? void 0 : _flatItem$parentProdu9.num) || 1)
|
|
1310
1310
|
};
|
|
1311
1311
|
|
|
1312
1312
|
// 记录实际应用的折扣
|
|
@@ -25,4 +25,13 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
25
25
|
setOtherProductsIds(ids: number[]): void;
|
|
26
26
|
getOtherProductsIds(): number[];
|
|
27
27
|
storeChange(): void;
|
|
28
|
+
/**
|
|
29
|
+
* 传入一个时间, 判断改时间是否在schedule 内
|
|
30
|
+
* @param param0 { date: string, schedule: any } date: 日期, schedule: schedule
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
static isInScheduleByDate({ date, schedule, }: {
|
|
34
|
+
date: string;
|
|
35
|
+
schedule: any;
|
|
36
|
+
}): boolean | undefined;
|
|
28
37
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2
7
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
8
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
9
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -21,6 +26,7 @@ import dayjs from 'dayjs';
|
|
|
21
26
|
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
|
22
27
|
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
|
23
28
|
import { generateMonthDates, disableAllDates, disableDatesBeforeOneDay } from "../Date/utils";
|
|
29
|
+
import { calcScheduleDateRange } from "./utils";
|
|
24
30
|
dayjs.extend(isSameOrBefore);
|
|
25
31
|
dayjs.extend(isSameOrAfter);
|
|
26
32
|
export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
@@ -236,6 +242,76 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
236
242
|
});
|
|
237
243
|
}
|
|
238
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* 传入一个时间, 判断改时间是否在schedule 内
|
|
247
|
+
* @param param0 { date: string, schedule: any } date: 日期, schedule: schedule
|
|
248
|
+
* @returns
|
|
249
|
+
*/
|
|
250
|
+
}], [{
|
|
251
|
+
key: "isInScheduleByDate",
|
|
252
|
+
value: function isInScheduleByDate(_ref2) {
|
|
253
|
+
var _schedule$repeat_rule, _schedule$repeat_rule2;
|
|
254
|
+
var date = _ref2.date,
|
|
255
|
+
schedule = _ref2.schedule;
|
|
256
|
+
if (schedule.start_time && schedule.end_time) {
|
|
257
|
+
var isBeforeStartTime = dayjs(date).isBefore(dayjs(schedule.start_time));
|
|
258
|
+
var isAfterEndTime = dayjs(date).isAfter(dayjs(schedule.end_time));
|
|
259
|
+
// 如果不在 schedule 日期区间内直接返回false
|
|
260
|
+
if (isBeforeStartTime || isAfterEndTime) {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// 节约性能, 强制将schedule的时间范围改为前后一天,避免大量计算.
|
|
266
|
+
var _schedule = _objectSpread(_objectSpread({}, schedule), {}, {
|
|
267
|
+
// 开始时间向前推一天
|
|
268
|
+
start_time: dayjs(date).subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'),
|
|
269
|
+
end_time: dayjs(date).add(1, 'day').format('YYYY-MM-DD HH:mm:ss')
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
// 不限制的 改为后一天
|
|
273
|
+
if (((_schedule$repeat_rule = _schedule.repeat_rule) === null || _schedule$repeat_rule === void 0 || (_schedule$repeat_rule = _schedule$repeat_rule.end) === null || _schedule$repeat_rule === void 0 ? void 0 : _schedule$repeat_rule.type) === 'never') {
|
|
274
|
+
_schedule = _objectSpread(_objectSpread({}, _schedule), {}, {
|
|
275
|
+
repeat_rule: _objectSpread(_objectSpread({}, _schedule.repeat_rule), {}, {
|
|
276
|
+
end: {
|
|
277
|
+
type: 'date',
|
|
278
|
+
end_date: _schedule.end_time,
|
|
279
|
+
occurrence: null
|
|
280
|
+
}
|
|
281
|
+
})
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// 限制结束日期的也改为后一天
|
|
286
|
+
if (((_schedule$repeat_rule2 = _schedule.repeat_rule) === null || _schedule$repeat_rule2 === void 0 || (_schedule$repeat_rule2 = _schedule$repeat_rule2.end) === null || _schedule$repeat_rule2 === void 0 ? void 0 : _schedule$repeat_rule2.type) === 'date') {
|
|
287
|
+
_schedule = _objectSpread(_objectSpread({}, _schedule), {}, {
|
|
288
|
+
repeat_rule: _objectSpread(_objectSpread({}, _schedule.repeat_rule), {}, {
|
|
289
|
+
end: _objectSpread(_objectSpread({}, _schedule.repeat_rule.end), {}, {
|
|
290
|
+
end_date: _schedule.end_time
|
|
291
|
+
})
|
|
292
|
+
})
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
var dateRanges = calcScheduleDateRange(_objectSpread({}, _schedule));
|
|
296
|
+
var _iterator = _createForOfIteratorHelper(dateRanges),
|
|
297
|
+
_step;
|
|
298
|
+
try {
|
|
299
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
300
|
+
var range = _step.value;
|
|
301
|
+
var startTime = dayjs(range.start);
|
|
302
|
+
var endTime = dayjs(range.end);
|
|
303
|
+
|
|
304
|
+
// 如果输入时间在这个范围内(包含边界)
|
|
305
|
+
if (dayjs(date).isSameOrAfter(startTime) && dayjs(date).isSameOrBefore(endTime)) {
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
} catch (err) {
|
|
310
|
+
_iterator.e(err);
|
|
311
|
+
} finally {
|
|
312
|
+
_iterator.f();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
239
315
|
}]);
|
|
240
316
|
return ScheduleModule;
|
|
241
317
|
}(BaseModule);
|
|
@@ -13,6 +13,7 @@ export declare class SummaryModule extends BaseModule implements Module, ISummar
|
|
|
13
13
|
private fatherModule;
|
|
14
14
|
constructor(name?: string, version?: string);
|
|
15
15
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
16
|
+
getSurchargeList(): Promise<void>;
|
|
16
17
|
getSummary(cartItems: CartItem[]): Promise<ISummaryState['summary']>;
|
|
17
18
|
/**
|
|
18
19
|
* 获取协议
|
|
@@ -21,4 +22,6 @@ export declare class SummaryModule extends BaseModule implements Module, ISummar
|
|
|
21
22
|
*/
|
|
22
23
|
getProtocol(protocolId: string): Promise<any>;
|
|
23
24
|
storeChange(): void;
|
|
25
|
+
private getTaxforUtils;
|
|
26
|
+
private getSurchargeforUtils;
|
|
24
27
|
}
|