@pisell/pisellos 0.0.474 → 0.0.475
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.
|
@@ -1178,18 +1178,21 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1178
1178
|
discount_list: _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1179
1179
|
}))]);
|
|
1180
1180
|
} else {
|
|
1181
|
-
var
|
|
1181
|
+
var _ref8, _product$_promotion$f, _product13, _product$origin_total, _product$price2;
|
|
1182
|
+
var total = product.inPromotion ? (_ref8 = (_product$_promotion$f = (_product13 = product) === null || _product13 === void 0 || (_product13 = _product13._promotion) === null || _product13 === void 0 ? void 0 : _product13.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref8 !== void 0 ? _ref8 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
|
|
1182
1183
|
var main_product_selling_price = (_product$price2 = product.price) !== null && _product$price2 !== void 0 ? _product$price2 : product.main_product_selling_price;
|
|
1183
|
-
if (product.
|
|
1184
|
-
|
|
1185
|
-
|
|
1184
|
+
if ((product.discount_list || []).some(function (item) {
|
|
1185
|
+
return item.type === 'promotion';
|
|
1186
|
+
}) || isBoolean(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
1187
|
+
var _product$total, _product$main_product;
|
|
1188
|
+
total = (_product$total = product.total) !== null && _product$total !== void 0 ? _product$total : product.origin_total;
|
|
1189
|
+
main_product_selling_price = (_product$main_product = product.main_product_selling_price) !== null && _product$main_product !== void 0 ? _product$main_product : main_product_selling_price;
|
|
1186
1190
|
}
|
|
1187
1191
|
processedProductsMap.set(product._id, [_this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {
|
|
1188
|
-
price: product.price
|
|
1189
|
-
main_product_selling_price: main_product_selling_price
|
|
1192
|
+
price: product.price
|
|
1190
1193
|
} : {
|
|
1191
1194
|
_id: product._id.split('___')[0] + '___' + index,
|
|
1192
|
-
total:
|
|
1195
|
+
total: total,
|
|
1193
1196
|
price: product.price,
|
|
1194
1197
|
main_product_selling_price: main_product_selling_price
|
|
1195
1198
|
}), {}, {
|
|
@@ -1339,13 +1342,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1339
1342
|
};
|
|
1340
1343
|
appliedProducts.push(discountDetail);
|
|
1341
1344
|
appliedDiscountProducts.set(currentSelectedDiscount.id, appliedProducts);
|
|
1342
|
-
var
|
|
1345
|
+
var _total = targetProductTotal;
|
|
1343
1346
|
if (product.options) {
|
|
1344
|
-
|
|
1347
|
+
_total = product.options.reduce(function (accumulator, currentValue) {
|
|
1345
1348
|
var currentPrice = new Decimal(currentValue.price || 0);
|
|
1346
1349
|
var currentNum = new Decimal(currentValue.num || 0);
|
|
1347
1350
|
return accumulator.add(currentPrice.mul(currentNum));
|
|
1348
|
-
}, new Decimal(
|
|
1351
|
+
}, new Decimal(_total)).toNumber();
|
|
1349
1352
|
}
|
|
1350
1353
|
|
|
1351
1354
|
// 记录应用了优惠券的商品
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
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
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
-
var promotion_exports = {};
|
|
31
|
-
__export(promotion_exports, {
|
|
32
|
-
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
-
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
-
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
-
default: () => import_adapter2.default
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
-
var import_evaluator = require("./evaluator");
|
|
40
|
-
var import_adapter = require("./adapter");
|
|
41
|
-
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
-
var import_examples = require("./examples");
|
|
43
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
-
0 && (module.exports = {
|
|
45
|
-
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
-
PromotionAdapter,
|
|
47
|
-
PromotionEvaluator,
|
|
48
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
-
});
|
|
@@ -869,18 +869,19 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
869
869
|
})
|
|
870
870
|
]);
|
|
871
871
|
} else {
|
|
872
|
+
let total = product.inPromotion ? ((_u = product == null ? void 0 : product._promotion) == null ? void 0 : _u.finalPrice) ?? product.origin_total ?? product.total : product.origin_total ?? product.total;
|
|
872
873
|
let main_product_selling_price = product.price ?? product.main_product_selling_price;
|
|
873
|
-
if (product.
|
|
874
|
-
|
|
874
|
+
if ((product.discount_list || []).some((item) => item.type === "promotion") || (0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
875
|
+
total = product.total ?? product.origin_total;
|
|
876
|
+
main_product_selling_price = product.main_product_selling_price ?? main_product_selling_price;
|
|
875
877
|
}
|
|
876
878
|
processedProductsMap.set(product._id, [
|
|
877
879
|
this.hooks.setProduct(originProduct, {
|
|
878
880
|
...isManualDiscount ? {
|
|
879
|
-
price: product.price
|
|
880
|
-
main_product_selling_price
|
|
881
|
+
price: product.price
|
|
881
882
|
} : {
|
|
882
883
|
_id: product._id.split("___")[0] + "___" + index,
|
|
883
|
-
total
|
|
884
|
+
total,
|
|
884
885
|
price: product.price,
|
|
885
886
|
main_product_selling_price
|
|
886
887
|
},
|