@pisell/pisellos 0.0.168 → 0.0.170
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/AccountList/index.js +1 -1
- package/dist/modules/Cart/utils/cartProduct.js +4 -1
- package/dist/modules/Rules/index.js +3 -3
- package/lib/modules/AccountList/index.js +1 -1
- package/lib/modules/Cart/utils/cartProduct.js +3 -1
- package/lib/modules/Rules/index.js +3 -3
- package/package.json +1 -1
|
@@ -326,7 +326,7 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
326
326
|
});
|
|
327
327
|
|
|
328
328
|
// 检测 如果被删除的是活跃账号,则默认把第一个账号设置为 activeAccount
|
|
329
|
-
if (((_this$getActiveAccoun = this.getActiveAccount()) === null || _this$getActiveAccoun === void 0 ? void 0 : _this$getActiveAccoun.getId()) === id) {
|
|
329
|
+
if (!this.getActiveAccount() || ((_this$getActiveAccoun = this.getActiveAccount()) === null || _this$getActiveAccoun === void 0 ? void 0 : _this$getActiveAccoun.getId()) === id || this.store.accounts.length === 1) {
|
|
330
330
|
this.setActiveAccount(this.store.accounts[0].getId());
|
|
331
331
|
}
|
|
332
332
|
_context6.next = 12;
|
|
@@ -28,7 +28,10 @@ export var handleVariantProduct = function handleVariantProduct(product) {
|
|
|
28
28
|
});
|
|
29
29
|
if (targetVariant) {
|
|
30
30
|
product.price = targetVariant.price;
|
|
31
|
-
|
|
31
|
+
// 如果 original_price 为 0,就不改了
|
|
32
|
+
if (Number(targetVariant.original_price) > 0) {
|
|
33
|
+
product.original_price = targetVariant.original_price;
|
|
34
|
+
}
|
|
32
35
|
product.is_charge_tax = targetVariant.is_charge_tax;
|
|
33
36
|
}
|
|
34
37
|
}
|
|
@@ -422,14 +422,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
422
422
|
var appliedProducts = appliedDiscountProducts.get(_selectedDiscount.id) || [];
|
|
423
423
|
|
|
424
424
|
// 计算使用折扣卡/商品券以后,单个商品的总 total
|
|
425
|
-
var targetProductTotal = _selectedDiscount.tag === 'good_pass' ? new Decimal(product.
|
|
425
|
+
var targetProductTotal = _selectedDiscount.tag === 'good_pass' ? new Decimal(product.total || 0).minus(new Decimal(product.price || 0)).toNumber() : new Decimal(100).minus(_selectedDiscount.par_value || 0).div(100).mul(new Decimal(product.total || 0)).toNumber();
|
|
426
426
|
var discountDetail = {
|
|
427
|
-
amount: new Decimal(product.
|
|
427
|
+
amount: new Decimal(product.total || 0).minus(new Decimal(targetProductTotal)).toNumber(),
|
|
428
428
|
type: _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount.tag,
|
|
429
429
|
discount: {
|
|
430
430
|
resource_id: _selectedDiscount.id,
|
|
431
431
|
title: _selectedDiscount.format_title,
|
|
432
|
-
original_amount: product.
|
|
432
|
+
original_amount: product.total,
|
|
433
433
|
product_id: originProduct.id,
|
|
434
434
|
percent: _selectedDiscount.par_value
|
|
435
435
|
},
|
|
@@ -195,7 +195,7 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
195
195
|
this.store.accountList = this.store.accountList.filter(
|
|
196
196
|
(account) => account.id !== id
|
|
197
197
|
);
|
|
198
|
-
if (((_a = this.getActiveAccount()) == null ? void 0 : _a.getId()) === id) {
|
|
198
|
+
if (!this.getActiveAccount() || ((_a = this.getActiveAccount()) == null ? void 0 : _a.getId()) === id || this.store.accounts.length === 1) {
|
|
199
199
|
this.setActiveAccount(this.store.accounts[0].getId());
|
|
200
200
|
}
|
|
201
201
|
await this.core.effects.emit(
|
|
@@ -51,7 +51,9 @@ var handleVariantProduct = (product) => {
|
|
|
51
51
|
);
|
|
52
52
|
if (targetVariant) {
|
|
53
53
|
product.price = targetVariant.price;
|
|
54
|
-
|
|
54
|
+
if (Number(targetVariant.original_price) > 0) {
|
|
55
|
+
product.original_price = targetVariant.original_price;
|
|
56
|
+
}
|
|
55
57
|
product.is_charge_tax = targetVariant.is_charge_tax;
|
|
56
58
|
}
|
|
57
59
|
}
|
|
@@ -293,14 +293,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
293
293
|
const selectedDiscount2 = applicableDiscounts[i2];
|
|
294
294
|
usedDiscounts.set(selectedDiscount2.id, true);
|
|
295
295
|
const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
|
|
296
|
-
const targetProductTotal = selectedDiscount2.tag === "good_pass" ? new import_decimal.default(product.
|
|
296
|
+
const targetProductTotal = selectedDiscount2.tag === "good_pass" ? new import_decimal.default(product.total || 0).minus(new import_decimal.default(product.price || 0)).toNumber() : new import_decimal.default(100).minus(selectedDiscount2.par_value || 0).div(100).mul(new import_decimal.default(product.total || 0)).toNumber();
|
|
297
297
|
const discountDetail = {
|
|
298
|
-
amount: new import_decimal.default(product.
|
|
298
|
+
amount: new import_decimal.default(product.total || 0).minus(new import_decimal.default(targetProductTotal)).toNumber(),
|
|
299
299
|
type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag,
|
|
300
300
|
discount: {
|
|
301
301
|
resource_id: selectedDiscount2.id,
|
|
302
302
|
title: selectedDiscount2.format_title,
|
|
303
|
-
original_amount: product.
|
|
303
|
+
original_amount: product.total,
|
|
304
304
|
product_id: originProduct.id,
|
|
305
305
|
percent: selectedDiscount2.par_value
|
|
306
306
|
},
|