@pisell/pisellos 0.0.180 → 0.0.183
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/Rules/index.js +13 -9
- package/dist/modules/Schedule/utils.js +4 -0
- package/dist/solution/BookingByStep/index.js +17 -6
- package/lib/modules/Rules/index.js +5 -2
- package/lib/modules/Schedule/utils.js +4 -1
- package/lib/solution/BookingByStep/index.js +3 -2
- package/package.json +1 -1
|
@@ -109,8 +109,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
109
109
|
|
|
110
110
|
// 编辑商品已有商品券
|
|
111
111
|
if (productList.every(function (item) {
|
|
112
|
-
var
|
|
113
|
-
|
|
112
|
+
var _product$discount_lis;
|
|
113
|
+
var product = _this2.hooks.getProduct(item);
|
|
114
|
+
return product.booking_id && (((_product$discount_lis = product.discount_list) === null || _product$discount_lis === void 0 ? void 0 : _product$discount_lis.length) || (newDiscountList[0].tag === 'good_pass' ? product.price == 0 : product.total == 0));
|
|
114
115
|
})) {
|
|
115
116
|
return {
|
|
116
117
|
isAvailable: false,
|
|
@@ -276,14 +277,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
276
277
|
sortedProductList.forEach(function (originProduct) {
|
|
277
278
|
var product = _this3.hooks.getProduct(originProduct);
|
|
278
279
|
addModeDiscount.forEach(function (discount) {
|
|
279
|
-
var _product$
|
|
280
|
+
var _product$discount_lis2, _product$discount_lis3;
|
|
280
281
|
var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
|
|
281
282
|
|
|
282
283
|
// 是符合折扣的商品
|
|
283
284
|
var isLimitedProduct = limitedData.type === 'product_all' || limitedData.product_ids && limitedData.product_ids.includes(product.id);
|
|
284
285
|
|
|
285
286
|
// 编辑的商品 使用了优惠券不可用
|
|
286
|
-
var isAvailableProduct = !(product !== null && product !== void 0 && product.booking_id && product !== null && product !== void 0 && (_product$
|
|
287
|
+
var isAvailableProduct = !(product !== null && product !== void 0 && product.booking_id && product !== null && product !== void 0 && (_product$discount_lis2 = product.discount_list) !== null && _product$discount_lis2 !== void 0 && _product$discount_lis2.length && product !== null && product !== void 0 && (_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.every(function (discount) {
|
|
287
288
|
return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
|
|
288
289
|
}));
|
|
289
290
|
|
|
@@ -316,9 +317,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
316
317
|
|
|
317
318
|
// 然后再处理应用哪些优惠券,此时只考虑filteredDiscountList中的优惠券
|
|
318
319
|
sortedProductList.forEach(function (originProduct, i) {
|
|
319
|
-
var _product$
|
|
320
|
+
var _product$discount_lis4, _product$discount_lis5, _product$discount_lis6, _product$discount_lis7, _product$discount_lis8, _product$discount_lis9;
|
|
320
321
|
var product = _this3.hooks.getProduct(originProduct);
|
|
321
|
-
if (product !== null && product !== void 0 && product.booking_id && (_product$
|
|
322
|
+
if (product !== null && product !== void 0 && product.booking_id && (_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.length && product !== null && product !== void 0 && (_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.every(function (discount) {
|
|
322
323
|
return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.tag || discount.type);
|
|
323
324
|
})) {
|
|
324
325
|
processedProductsMap.set(product._id, [originProduct]);
|
|
@@ -328,7 +329,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
328
329
|
// 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
|
|
329
330
|
var applicableDiscounts = sortedDiscountList.filter(function (discount) {
|
|
330
331
|
// 如果商品价格为 0,其实不需要使用任何优惠券,直接 return true
|
|
331
|
-
|
|
332
|
+
// 商品券时主商品价格为0不可用
|
|
333
|
+
if ((Number(product.price) === 0 || !product.price) && (discount.tag || discount.type) === 'good_pass') return false;
|
|
334
|
+
// 折扣卡时总价为0时不可用
|
|
335
|
+
if ((Number(product.total) === 0 || !product.total) && (discount.tag || discount.type) !== 'good_pass') return false;
|
|
332
336
|
// 如果优惠券已被使用,则跳过
|
|
333
337
|
var targetUsedDiscounts = usedDiscounts.get(discount.id);
|
|
334
338
|
if (targetUsedDiscounts && (discount.tag || discount.type) === 'good_pass') return false;
|
|
@@ -347,12 +351,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
347
351
|
var selectedDiscount = applicableDiscounts[0];
|
|
348
352
|
|
|
349
353
|
// 如果是手动折扣,则不适用优惠券
|
|
350
|
-
var isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && (!((_product$
|
|
354
|
+
var isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || (product === null || product === void 0 || (_product$discount_lis7 = product.discount_list) === null || _product$discount_lis7 === void 0 || (_product$discount_lis8 = _product$discount_lis7.every) === null || _product$discount_lis8 === void 0 ? void 0 : _product$discount_lis8.call(_product$discount_lis7, function (item) {
|
|
351
355
|
return item.type === 'product';
|
|
352
356
|
})));
|
|
353
357
|
|
|
354
358
|
// 勾选时覆盖手动折扣
|
|
355
|
-
if (options !== null && options !== void 0 && options.discountId && (_product$
|
|
359
|
+
if (options !== null && options !== void 0 && options.discountId && (_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
|
|
356
360
|
var _item$discount;
|
|
357
361
|
return ((_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) === options.discountId;
|
|
358
362
|
})) {
|
|
@@ -140,7 +140,11 @@ var getDaysByRepeatWeek = function getDaysByRepeatWeek(params, isGetRange) {
|
|
|
140
140
|
for (var i = 0; i < frequency_date.length; i++) {
|
|
141
141
|
var item = frequency_date[i];
|
|
142
142
|
var _start = startTmp.day(item);
|
|
143
|
+
// 如果周结束的那一天还超过了deadline,则需要把_end置为deadline
|
|
143
144
|
var _end = _start.add(scheduleDiff, 'second');
|
|
145
|
+
if (_end.isAfter(deadline, 'day')) {
|
|
146
|
+
_end = deadline;
|
|
147
|
+
}
|
|
144
148
|
if (isGetRange) {
|
|
145
149
|
if (excludedDaysMap.has(_start.format('YYYY-MM-DD'))) {
|
|
146
150
|
startTmp = startTmp.day(1).add(frequency, 'day');
|
|
@@ -272,7 +272,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
272
272
|
value: (function () {
|
|
273
273
|
var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
|
|
274
274
|
var _schedule$product_ids;
|
|
275
|
-
var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, schedule, otherProductsIds, allProductIds;
|
|
275
|
+
var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, newProductIds, schedule, otherProductsIds, allProductIds;
|
|
276
276
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
277
277
|
while (1) switch (_context3.prev = _context3.next) {
|
|
278
278
|
case 0:
|
|
@@ -289,27 +289,38 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
289
289
|
week: '',
|
|
290
290
|
weekNum: 0
|
|
291
291
|
}]);
|
|
292
|
+
newProductIds = []; // const scheduleIds = scheduleList
|
|
293
|
+
// .filter((n) => n.date === date)
|
|
294
|
+
// .flatMap((n) => n.schedule_id)
|
|
295
|
+
// .filter((n) => n !== null && n !== undefined);
|
|
296
|
+
// 如果外面没传 product_ids,尝试从对应 schedule 里拿 product_ids
|
|
297
|
+
// if (!product_ids?.length) {
|
|
298
|
+
// const schedule = scheduleList.find((n) => n.date === date);
|
|
299
|
+
// if (schedule && schedule.product_ids?.length) {
|
|
300
|
+
// product_ids = schedule.product_ids;
|
|
301
|
+
// }
|
|
302
|
+
// }
|
|
292
303
|
// V2接口修改后,只能从schedule 接口里拿数据,不可以从外面拿,外面给的是装修数据
|
|
293
304
|
schedule = scheduleList.find(function (n) {
|
|
294
305
|
return n.date === date;
|
|
295
306
|
});
|
|
296
307
|
if (schedule && (_schedule$product_ids = schedule.product_ids) !== null && _schedule$product_ids !== void 0 && _schedule$product_ids.length) {
|
|
297
|
-
|
|
308
|
+
newProductIds = schedule.product_ids;
|
|
298
309
|
}
|
|
299
310
|
// 尝试去拿schedule 里的 other_product_ids 和 product_ids 拼在一起去重
|
|
300
311
|
otherProductsIds = this.store.schedule.getOtherProductsIds() || [];
|
|
301
|
-
allProductIds = [].concat(_toConsumableArray(
|
|
312
|
+
allProductIds = [].concat(_toConsumableArray(newProductIds), _toConsumableArray(otherProductsIds)).filter(function (n, index, self) {
|
|
302
313
|
return self.indexOf(n) === index;
|
|
303
314
|
});
|
|
304
|
-
_context3.next =
|
|
315
|
+
_context3.next = 10;
|
|
305
316
|
return this.loadProducts({
|
|
306
317
|
product_ids: allProductIds,
|
|
307
318
|
category_ids: category_ids,
|
|
308
319
|
schedule_date: date
|
|
309
320
|
});
|
|
310
|
-
case 9:
|
|
311
|
-
return _context3.abrupt("return", _context3.sent);
|
|
312
321
|
case 10:
|
|
322
|
+
return _context3.abrupt("return", _context3.sent);
|
|
323
|
+
case 11:
|
|
313
324
|
case "end":
|
|
314
325
|
return _context3.stop();
|
|
315
326
|
}
|
|
@@ -71,7 +71,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
71
71
|
}
|
|
72
72
|
if (productList.every((item) => {
|
|
73
73
|
var _a;
|
|
74
|
-
|
|
74
|
+
const product = this.hooks.getProduct(item);
|
|
75
|
+
return product.booking_id && (((_a = product.discount_list) == null ? void 0 : _a.length) || (newDiscountList[0].tag === "good_pass" ? product.price == 0 : product.total == 0));
|
|
75
76
|
})) {
|
|
76
77
|
return {
|
|
77
78
|
isAvailable: false,
|
|
@@ -213,7 +214,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
213
214
|
return;
|
|
214
215
|
}
|
|
215
216
|
const applicableDiscounts = sortedDiscountList.filter((discount) => {
|
|
216
|
-
if (Number(product.price) === 0 && discount.tag
|
|
217
|
+
if ((Number(product.price) === 0 || !product.price) && (discount.tag || discount.type) === "good_pass")
|
|
218
|
+
return false;
|
|
219
|
+
if ((Number(product.total) === 0 || !product.total) && (discount.tag || discount.type) !== "good_pass")
|
|
217
220
|
return false;
|
|
218
221
|
const targetUsedDiscounts = usedDiscounts.get(discount.id);
|
|
219
222
|
if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
|
|
@@ -140,7 +140,10 @@ var getDaysByRepeatWeek = (params, isGetRange) => {
|
|
|
140
140
|
for (let i = 0; i < frequency_date.length; i++) {
|
|
141
141
|
const item = frequency_date[i];
|
|
142
142
|
const _start = startTmp.day(item);
|
|
143
|
-
|
|
143
|
+
let _end = _start.add(scheduleDiff, "second");
|
|
144
|
+
if (_end.isAfter(deadline, "day")) {
|
|
145
|
+
_end = deadline;
|
|
146
|
+
}
|
|
144
147
|
if (isGetRange) {
|
|
145
148
|
if (excludedDaysMap.has(_start.format("YYYY-MM-DD"))) {
|
|
146
149
|
startTmp = startTmp.day(1).add(frequency, "day");
|
|
@@ -217,12 +217,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
217
217
|
{ date, status: "available", week: "", weekNum: 0 },
|
|
218
218
|
{ date, status: "available", week: "", weekNum: 0 }
|
|
219
219
|
]);
|
|
220
|
+
let newProductIds = [];
|
|
220
221
|
const schedule = scheduleList.find((n) => n.date === date);
|
|
221
222
|
if (schedule && ((_a = schedule.product_ids) == null ? void 0 : _a.length)) {
|
|
222
|
-
|
|
223
|
+
newProductIds = schedule.product_ids;
|
|
223
224
|
}
|
|
224
225
|
const otherProductsIds = this.store.schedule.getOtherProductsIds() || [];
|
|
225
|
-
const allProductIds = [...
|
|
226
|
+
const allProductIds = [...newProductIds, ...otherProductsIds].filter(
|
|
226
227
|
(n, index, self) => self.indexOf(n) === index
|
|
227
228
|
);
|
|
228
229
|
return await this.loadProducts({
|