@pisell/pisellos 0.0.180 → 0.0.181
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.
|
@@ -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
|
})) {
|
|
@@ -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")
|