@pisell/pisellos 0.0.169 → 0.0.171
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/Rules/index.js +5 -4
- package/dist/solution/ShopDiscount/index.js +9 -1
- package/lib/modules/AccountList/index.js +1 -1
- package/lib/modules/Rules/index.js +5 -4
- package/lib/solution/ShopDiscount/index.js +4 -1
- 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;
|
|
@@ -420,16 +420,17 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
420
420
|
|
|
421
421
|
// 记录实际应用了优惠券的商品信息
|
|
422
422
|
var appliedProducts = appliedDiscountProducts.get(_selectedDiscount.id) || [];
|
|
423
|
+
var productOriginTotal = product.origin_total || product.total || 0;
|
|
423
424
|
|
|
424
425
|
// 计算使用折扣卡/商品券以后,单个商品的总 total
|
|
425
|
-
var targetProductTotal = _selectedDiscount.tag === 'good_pass' ? new Decimal(
|
|
426
|
+
var targetProductTotal = _selectedDiscount.tag === 'good_pass' ? new Decimal(productOriginTotal).minus(new Decimal(product.price || 0)).toNumber() : new Decimal(100).minus(_selectedDiscount.par_value || 0).div(100).mul(new Decimal(productOriginTotal)).toNumber();
|
|
426
427
|
var discountDetail = {
|
|
427
|
-
amount: new Decimal(
|
|
428
|
+
amount: new Decimal(productOriginTotal).minus(new Decimal(targetProductTotal)).toNumber(),
|
|
428
429
|
type: _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount.tag,
|
|
429
430
|
discount: {
|
|
430
431
|
resource_id: _selectedDiscount.id,
|
|
431
432
|
title: _selectedDiscount.format_title,
|
|
432
|
-
original_amount:
|
|
433
|
+
original_amount: productOriginTotal,
|
|
433
434
|
product_id: originProduct.id,
|
|
434
435
|
percent: _selectedDiscount.par_value
|
|
435
436
|
},
|
|
@@ -463,7 +464,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
463
464
|
price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
|
|
464
465
|
quantity: isNeedSplit ? 1 : product.quantity,
|
|
465
466
|
total: targetProductTotal,
|
|
466
|
-
origin_total:
|
|
467
|
+
origin_total: productOriginTotal
|
|
467
468
|
}));
|
|
468
469
|
}
|
|
469
470
|
}
|
|
@@ -507,7 +507,15 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
507
507
|
return Number(product === null || product === void 0 ? void 0 : product.price) === 0;
|
|
508
508
|
};
|
|
509
509
|
var isAllProductUsedOrFree = (_item$applicableProdu = item.applicableProductIds) === null || _item$applicableProdu === void 0 ? void 0 : _item$applicableProdu.every(function (id) {
|
|
510
|
-
|
|
510
|
+
var _item$applicableProdu2;
|
|
511
|
+
// 检查当前 id是否在 item.applicableProductIds 里出现了几次,且要求次数和 item.applicableProductIds 里出现的次数一致
|
|
512
|
+
var sameIdTimes = ((_item$applicableProdu2 = item.applicableProductIds) === null || _item$applicableProdu2 === void 0 ? void 0 : _item$applicableProdu2.filter(function (n) {
|
|
513
|
+
return n === id;
|
|
514
|
+
}).length) || 1;
|
|
515
|
+
var targetIdTimes = (allUsedProductIds === null || allUsedProductIds === void 0 ? void 0 : allUsedProductIds.filter(function (n) {
|
|
516
|
+
return n === id;
|
|
517
|
+
}).length) || 0;
|
|
518
|
+
return targetIdTimes >= sameIdTimes || isProductFree(id);
|
|
511
519
|
});
|
|
512
520
|
if (!item.isSelected && isAllProductUsedOrFree) {
|
|
513
521
|
item.isDisabledForProductUsed = true;
|
|
@@ -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(
|
|
@@ -293,14 +293,15 @@ 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
|
|
296
|
+
const productOriginTotal = product.origin_total || product.total || 0;
|
|
297
|
+
const targetProductTotal = selectedDiscount2.tag === "good_pass" ? new import_decimal.default(productOriginTotal).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(productOriginTotal)).toNumber();
|
|
297
298
|
const discountDetail = {
|
|
298
|
-
amount: new import_decimal.default(
|
|
299
|
+
amount: new import_decimal.default(productOriginTotal).minus(new import_decimal.default(targetProductTotal)).toNumber(),
|
|
299
300
|
type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag,
|
|
300
301
|
discount: {
|
|
301
302
|
resource_id: selectedDiscount2.id,
|
|
302
303
|
title: selectedDiscount2.format_title,
|
|
303
|
-
original_amount:
|
|
304
|
+
original_amount: productOriginTotal,
|
|
304
305
|
product_id: originProduct.id,
|
|
305
306
|
percent: selectedDiscount2.par_value
|
|
306
307
|
},
|
|
@@ -331,7 +332,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
331
332
|
price: selectedDiscount2.tag === "good_pass" ? 0 : product.price,
|
|
332
333
|
quantity: isNeedSplit ? 1 : product.quantity,
|
|
333
334
|
total: targetProductTotal,
|
|
334
|
-
origin_total:
|
|
335
|
+
origin_total: productOriginTotal
|
|
335
336
|
}));
|
|
336
337
|
}
|
|
337
338
|
}
|
|
@@ -349,7 +349,10 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
349
349
|
return Number(product == null ? void 0 : product.price) === 0;
|
|
350
350
|
};
|
|
351
351
|
const isAllProductUsedOrFree = (_a2 = item.applicableProductIds) == null ? void 0 : _a2.every((id) => {
|
|
352
|
-
|
|
352
|
+
var _a3;
|
|
353
|
+
const sameIdTimes = ((_a3 = item.applicableProductIds) == null ? void 0 : _a3.filter((n) => n === id).length) || 1;
|
|
354
|
+
const targetIdTimes = (allUsedProductIds == null ? void 0 : allUsedProductIds.filter((n) => n === id).length) || 0;
|
|
355
|
+
return targetIdTimes >= sameIdTimes || isProductFree(id);
|
|
353
356
|
});
|
|
354
357
|
if (!item.isSelected && isAllProductUsedOrFree) {
|
|
355
358
|
item.isDisabledForProductUsed = true;
|