@pisell/pisellos 0.0.134 → 0.0.135
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/Discount/index.js +1 -1
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Rules/index.js +7 -5
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +8 -4
- package/dist/solution/ShopDiscount/index.js +1 -1
- package/lib/modules/Discount/index.js +1 -1
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Rules/index.js +7 -5
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +2 -0
- package/lib/solution/ShopDiscount/index.js +1 -1
- package/package.json +1 -1
|
@@ -206,7 +206,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
206
206
|
}
|
|
207
207
|
if (discount.appliedProductDetails) {
|
|
208
208
|
return discount.appliedProductDetails.reduce(function (total, product) {
|
|
209
|
-
var price = new Decimal((product === null || product === void 0 ? void 0 : product.amount) || 0);
|
|
209
|
+
var price = new Decimal((product === null || product === void 0 ? void 0 : product.amount) || 0).mul((product === null || product === void 0 ? void 0 : product.num) || 1);
|
|
210
210
|
return new Decimal(total).plus(price).toNumber();
|
|
211
211
|
}, 0);
|
|
212
212
|
}
|
|
@@ -242,7 +242,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
242
242
|
|
|
243
243
|
// 编辑的商品 使用了优惠券不可用
|
|
244
244
|
var isAvailableProduct = !(product !== null && product !== void 0 && product.booking_id && product !== null && product !== void 0 && (_product$discount_lis = product.discount_list) !== null && _product$discount_lis !== void 0 && _product$discount_lis.length && product !== null && product !== void 0 && (_product$discount_lis2 = product.discount_list) !== null && _product$discount_lis2 !== void 0 && _product$discount_lis2.every(function (discount) {
|
|
245
|
-
return discount.id &&
|
|
245
|
+
return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.type);
|
|
246
246
|
}));
|
|
247
247
|
|
|
248
248
|
// 判断优惠券是否适用于该商品
|
|
@@ -261,7 +261,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
261
261
|
title: discount.format_title,
|
|
262
262
|
original_amount: product.origin_total,
|
|
263
263
|
pre_value: discount.par_value
|
|
264
|
-
}
|
|
264
|
+
},
|
|
265
|
+
num: product.num || 1
|
|
265
266
|
});
|
|
266
267
|
discountApplicableProducts.set(discount.id, applicableProducts);
|
|
267
268
|
}
|
|
@@ -273,7 +274,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
273
274
|
var _product$discount_lis3, _product$discount_lis4, _product$discount_lis5, _product$discount_lis6, _product$discount_lis7;
|
|
274
275
|
var product = _this3.hooks.getProduct(originProduct);
|
|
275
276
|
if (product !== null && product !== void 0 && product.booking_id && (_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.length && product !== null && product !== void 0 && (_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.every(function (discount) {
|
|
276
|
-
return discount.id &&
|
|
277
|
+
return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.type);
|
|
277
278
|
})) {
|
|
278
279
|
processedProductsMap.set(product._id, originProduct);
|
|
279
280
|
return;
|
|
@@ -358,7 +359,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
358
359
|
original_amount: product.price,
|
|
359
360
|
product_id: selectedDiscount.product_id,
|
|
360
361
|
percent: selectedDiscount.par_value
|
|
361
|
-
}
|
|
362
|
+
},
|
|
363
|
+
num: product.num || 1
|
|
362
364
|
};
|
|
363
365
|
appliedProducts.push(discountDetail);
|
|
364
366
|
appliedDiscountProducts.set(selectedDiscount.id, appliedProducts);
|
|
@@ -388,7 +390,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
388
390
|
processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, {
|
|
389
391
|
discount_list: [discountDetail],
|
|
390
392
|
price: new Decimal(targetProductPrice).toNumber(),
|
|
391
|
-
total: new Decimal(product.origin_total || product.total || 0).minus(new Decimal(product.price || 0)).toNumber(),
|
|
393
|
+
total: new Decimal(product.origin_total || product.total || 0).minus(new Decimal(product.price || 0).minus(new Decimal(targetProductPrice))).toNumber(),
|
|
392
394
|
origin_total: product.origin_total || product.total
|
|
393
395
|
}));
|
|
394
396
|
}
|
|
@@ -568,7 +568,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
568
568
|
_ref4 = productData || {}, bundle = _ref4.bundle, options = _ref4.options, origin = _ref4.origin, product_variant_id = _ref4.product_variant_id, _ref4$quantity = _ref4.quantity, quantity = _ref4$quantity === void 0 ? 1 : _ref4$quantity, rowKey = _ref4.rowKey; // 检查购物车里是否已经存在 rowKey相同的数据,如果是则更新数量
|
|
569
569
|
cartItems = this.store.cart.getItems();
|
|
570
570
|
if (!rowKey) {
|
|
571
|
-
_context8.next =
|
|
571
|
+
_context8.next = 9;
|
|
572
572
|
break;
|
|
573
573
|
}
|
|
574
574
|
targetCartItem = cartItems.find(function (n) {
|
|
@@ -576,7 +576,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
576
576
|
return ((_n$_productOrigin = n._productOrigin) === null || _n$_productOrigin === void 0 ? void 0 : _n$_productOrigin.rowKey) === rowKey;
|
|
577
577
|
});
|
|
578
578
|
if (!(targetCartItem && isNormalProduct(targetCartItem._productOrigin))) {
|
|
579
|
-
_context8.next =
|
|
579
|
+
_context8.next = 9;
|
|
580
580
|
break;
|
|
581
581
|
}
|
|
582
582
|
this.store.cart.updateItem({
|
|
@@ -584,8 +584,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
584
584
|
product: _objectSpread({}, targetCartItem._productOrigin),
|
|
585
585
|
quantity: (targetCartItem.num || 1) + quantity
|
|
586
586
|
});
|
|
587
|
+
// 这里需要单独触发一个,购物车商品数量发生改变的 hook
|
|
588
|
+
this.core.effects.emit("".concat(this.store.cart.name, ":onUpdateCartItemNums"), {});
|
|
587
589
|
return _context8.abrupt("return");
|
|
588
|
-
case
|
|
590
|
+
case 9:
|
|
589
591
|
product = _objectSpread(_objectSpread({}, origin), {}, {
|
|
590
592
|
product_variant_id: product_variant_id,
|
|
591
593
|
rowKey: rowKey
|
|
@@ -600,7 +602,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
600
602
|
addCartItem.account = activeAccount;
|
|
601
603
|
}
|
|
602
604
|
this.store.cart.addItem(addCartItem);
|
|
603
|
-
case
|
|
605
|
+
case 13:
|
|
604
606
|
case "end":
|
|
605
607
|
return _context8.stop();
|
|
606
608
|
}
|
|
@@ -2630,6 +2632,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2630
2632
|
options: targetCartItem._optionsOrigin,
|
|
2631
2633
|
quantity: (targetCartItem.num || 1) + quantity
|
|
2632
2634
|
});
|
|
2635
|
+
// 这里需要单独触发一个,购物车商品数量发生改变的 hook
|
|
2636
|
+
this.core.effects.emit("".concat(this.store.cart.name, ":onUpdateCartItemNums"), {});
|
|
2633
2637
|
return;
|
|
2634
2638
|
}
|
|
2635
2639
|
}
|
|
@@ -434,7 +434,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
434
434
|
productList.forEach(function (item) {
|
|
435
435
|
if (item.booking_id) {
|
|
436
436
|
(item.discount_list || []).forEach(function (discount) {
|
|
437
|
-
if (discount.id && discount.type
|
|
437
|
+
if (discount.id && ['good_pass', 'discount_card'].includes(discount.type)) {
|
|
438
438
|
var _discount$discount, _discount$discount2, _discount$discount3;
|
|
439
439
|
editModeDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
|
|
440
440
|
isEditMode: true,
|
|
@@ -122,7 +122,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
122
122
|
}
|
|
123
123
|
if (discount.appliedProductDetails) {
|
|
124
124
|
return discount.appliedProductDetails.reduce((total, product) => {
|
|
125
|
-
const price = new import_decimal.default((product == null ? void 0 : product.amount) || 0);
|
|
125
|
+
const price = new import_decimal.default((product == null ? void 0 : product.amount) || 0).mul((product == null ? void 0 : product.num) || 1);
|
|
126
126
|
return new import_decimal.default(total).plus(price).toNumber();
|
|
127
127
|
}, 0);
|
|
128
128
|
}
|
|
@@ -164,7 +164,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
164
164
|
var _a, _b, _c;
|
|
165
165
|
const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
|
|
166
166
|
const isLimitedProduct = limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id);
|
|
167
|
-
const isAvailableProduct = !((product == null ? void 0 : product.booking_id) && ((_a = product == null ? void 0 : product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount2) => discount2.id &&
|
|
167
|
+
const isAvailableProduct = !((product == null ? void 0 : product.booking_id) && ((_a = product == null ? void 0 : product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount2) => discount2.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount2.type))));
|
|
168
168
|
if (isAvailableProduct && isLimitedProduct) {
|
|
169
169
|
(_c = discountApplicability.get(discount.id)) == null ? void 0 : _c.push(product.id);
|
|
170
170
|
const applicableProducts = discountApplicableProducts.get(discount.id) || [];
|
|
@@ -176,7 +176,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
176
176
|
title: discount.format_title,
|
|
177
177
|
original_amount: product.origin_total,
|
|
178
178
|
pre_value: discount.par_value
|
|
179
|
-
}
|
|
179
|
+
},
|
|
180
|
+
num: product.num || 1
|
|
180
181
|
});
|
|
181
182
|
discountApplicableProducts.set(discount.id, applicableProducts);
|
|
182
183
|
}
|
|
@@ -185,7 +186,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
185
186
|
sortedProductList.forEach((originProduct) => {
|
|
186
187
|
var _a, _b, _c, _d, _e;
|
|
187
188
|
const product = this.hooks.getProduct(originProduct);
|
|
188
|
-
if ((product == null ? void 0 : product.booking_id) && ((_a = product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount) => discount.id &&
|
|
189
|
+
if ((product == null ? void 0 : product.booking_id) && ((_a = product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount) => discount.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount.type)))) {
|
|
189
190
|
processedProductsMap.set(product._id, originProduct);
|
|
190
191
|
return;
|
|
191
192
|
}
|
|
@@ -259,7 +260,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
259
260
|
original_amount: product.price,
|
|
260
261
|
product_id: selectedDiscount.product_id,
|
|
261
262
|
percent: selectedDiscount.par_value
|
|
262
|
-
}
|
|
263
|
+
},
|
|
264
|
+
num: product.num || 1
|
|
263
265
|
};
|
|
264
266
|
appliedProducts.push(discountDetail);
|
|
265
267
|
appliedDiscountProducts.set(selectedDiscount.id, appliedProducts);
|
|
@@ -291,7 +293,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
291
293
|
this.hooks.setProduct(originProduct, {
|
|
292
294
|
discount_list: [discountDetail],
|
|
293
295
|
price: new import_decimal.default(targetProductPrice).toNumber(),
|
|
294
|
-
total: new import_decimal.default(product.origin_total || product.total || 0).minus(new import_decimal.default(product.price || 0)).toNumber(),
|
|
296
|
+
total: new import_decimal.default(product.origin_total || product.total || 0).minus(new import_decimal.default(product.price || 0).minus(new import_decimal.default(targetProductPrice))).toNumber(),
|
|
295
297
|
origin_total: product.origin_total || product.total
|
|
296
298
|
})
|
|
297
299
|
);
|
|
@@ -359,6 +359,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
359
359
|
},
|
|
360
360
|
quantity: (targetCartItem.num || 1) + quantity
|
|
361
361
|
});
|
|
362
|
+
this.core.effects.emit(`${this.store.cart.name}:onUpdateCartItemNums`, {});
|
|
362
363
|
return;
|
|
363
364
|
}
|
|
364
365
|
}
|
|
@@ -1829,6 +1830,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1829
1830
|
options: targetCartItem._optionsOrigin,
|
|
1830
1831
|
quantity: (targetCartItem.num || 1) + quantity
|
|
1831
1832
|
});
|
|
1833
|
+
this.core.effects.emit(`${this.store.cart.name}:onUpdateCartItemNums`, {});
|
|
1832
1834
|
return;
|
|
1833
1835
|
}
|
|
1834
1836
|
}
|
|
@@ -271,7 +271,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
271
271
|
if (item.booking_id) {
|
|
272
272
|
(item.discount_list || []).forEach((discount) => {
|
|
273
273
|
var _a2, _b, _c;
|
|
274
|
-
if (discount.id && discount.type
|
|
274
|
+
if (discount.id && ["good_pass", "discount_card"].includes(discount.type)) {
|
|
275
275
|
editModeDiscountList.push({
|
|
276
276
|
...discount,
|
|
277
277
|
isEditMode: true,
|