@pisell/pisellos 0.0.147 → 0.0.149
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.
|
@@ -28,6 +28,7 @@ import { BaseModule } from "../../modules/BaseModule";
|
|
|
28
28
|
import { ShopDiscountHooks } from "./types";
|
|
29
29
|
import { DiscountModule } from "../../modules/Discount";
|
|
30
30
|
import { RulesModule } from "../../modules/Rules";
|
|
31
|
+
import Decimal from 'decimal.js';
|
|
31
32
|
export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
32
33
|
_inherits(ShopDiscountImpl, _BaseModule);
|
|
33
34
|
var _super = _createSuper(ShopDiscountImpl);
|
|
@@ -442,24 +443,26 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
442
443
|
(item.discount_list || []).forEach(function (discount) {
|
|
443
444
|
if (discount.id && ['good_pass', 'discount_card'].includes(discount.type)) {
|
|
444
445
|
var index = editModeDiscountList.findIndex(function (n) {
|
|
445
|
-
|
|
446
|
+
var _discount$discount;
|
|
447
|
+
return n.id === ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
|
|
446
448
|
});
|
|
447
449
|
if (index !== -1) {
|
|
448
450
|
editModeDiscountList[index] = _objectSpread(_objectSpread({}, editModeDiscountList[index]), {}, {
|
|
449
|
-
amount: discount.amount
|
|
451
|
+
amount: new Decimal(discount.amount || 0).plus(new Decimal(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
452
|
+
savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.num) || 1).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
450
453
|
});
|
|
451
454
|
} else {
|
|
452
|
-
var _discount$
|
|
455
|
+
var _discount$discount2, _discount$discount3, _discount$discount4;
|
|
453
456
|
editModeDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
|
|
454
457
|
isEditMode: true,
|
|
455
458
|
limited_relation_product_data: {},
|
|
456
459
|
savedAmount: discount.amount * ((product === null || product === void 0 ? void 0 : product.num) || 1),
|
|
457
460
|
isAvailable: true,
|
|
458
|
-
id: ((_discount$
|
|
459
|
-
format_title: ((_discount$
|
|
461
|
+
id: ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) || discount.id,
|
|
462
|
+
format_title: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.title) || discount.format_title,
|
|
460
463
|
isDisabled: true,
|
|
461
464
|
isSelected: true,
|
|
462
|
-
product_id: ((_discount$
|
|
465
|
+
product_id: ((_discount$discount4 = discount.discount) === null || _discount$discount4 === void 0 ? void 0 : _discount$discount4.product_id) || discount.product_id
|
|
463
466
|
}));
|
|
464
467
|
}
|
|
465
468
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/solution/ShopDiscount/index.ts
|
|
@@ -27,6 +37,7 @@ var import_BaseModule = require("../../modules/BaseModule");
|
|
|
27
37
|
var import_types = require("./types");
|
|
28
38
|
var import_Discount = require("../../modules/Discount");
|
|
29
39
|
var import_Rules = require("../../modules/Rules");
|
|
40
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
30
41
|
var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
31
42
|
constructor(name, version) {
|
|
32
43
|
super(name, version);
|
|
@@ -276,11 +287,15 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
276
287
|
(item.discount_list || []).forEach((discount) => {
|
|
277
288
|
var _a3, _b, _c;
|
|
278
289
|
if (discount.id && ["good_pass", "discount_card"].includes(discount.type)) {
|
|
279
|
-
const index = editModeDiscountList.findIndex((n) =>
|
|
290
|
+
const index = editModeDiscountList.findIndex((n) => {
|
|
291
|
+
var _a4;
|
|
292
|
+
return n.id === ((_a4 = discount.discount) == null ? void 0 : _a4.resource_id) || discount.id;
|
|
293
|
+
});
|
|
280
294
|
if (index !== -1) {
|
|
281
295
|
editModeDiscountList[index] = {
|
|
282
296
|
...editModeDiscountList[index],
|
|
283
|
-
amount: discount.amount
|
|
297
|
+
amount: new import_decimal.default(discount.amount || 0).plus(new import_decimal.default(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
298
|
+
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.num) || 1).plus(new import_decimal.default(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
284
299
|
};
|
|
285
300
|
} else {
|
|
286
301
|
editModeDiscountList.push({
|