@pisell/pisellos 2.1.128 → 2.1.129
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.
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// 导出评估器
|
|
2
|
-
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
-
|
|
4
|
-
// 导出适配器
|
|
5
|
-
export { PromotionAdapter } from "./adapter";
|
|
6
|
-
export { default } from "./adapter";
|
|
7
|
-
|
|
8
|
-
// 导出策略配置示例常量
|
|
9
|
-
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
|
|
@@ -1792,7 +1792,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1792
1792
|
key: "setDiscountSelected",
|
|
1793
1793
|
value: (function () {
|
|
1794
1794
|
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
|
|
1795
|
-
var _tempOrder$holder, _this$store$order$get, _this$store$order$get2, list, beforeTarget, updated, updatedTarget, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator9, _step9, d, selectedResourceIds, _iterator10, _step10, _product$
|
|
1795
|
+
var _tempOrder$holder, _this$store$order$get, _this$store$order$get2, list, beforeTarget, updated, updatedTarget, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator9, _step9, d, selectedResourceIds, _iterator10, _step10, _product$_origin, product, totalPerUnitDiscount, newSellingPrice, afterApplyTarget, finalSummary, finalProduct, finalTarget;
|
|
1796
1796
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1797
1797
|
while (1) switch (_context21.prev = _context21.next) {
|
|
1798
1798
|
case 0:
|
|
@@ -1872,70 +1872,71 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1872
1872
|
return d.isSelected;
|
|
1873
1873
|
}).map(function (d) {
|
|
1874
1874
|
return d.id;
|
|
1875
|
-
}));
|
|
1875
|
+
})); // 无条件归一化:不论 Rules 是否清空 discount_list、长度是否变化,
|
|
1876
|
+
// 都以 original_price - Σ (当前选中 discount_list.amount) 重算 selling_price。
|
|
1877
|
+
// 目的:避免 unselect 后 selling_price 残留、reselect 时把残留价带进下一轮 Rules 造成双折扣。
|
|
1878
|
+
// 手动改价商品(_origin.isManualDiscount=true)不参与券流程归一化,保留手工价。
|
|
1876
1879
|
_iterator10 = _createForOfIteratorHelper(tempOrder.products);
|
|
1877
1880
|
_context21.prev = 19;
|
|
1878
1881
|
_iterator10.s();
|
|
1879
1882
|
case 21:
|
|
1880
1883
|
if ((_step10 = _iterator10.n()).done) {
|
|
1881
|
-
_context21.next =
|
|
1884
|
+
_context21.next = 32;
|
|
1882
1885
|
break;
|
|
1883
1886
|
}
|
|
1884
1887
|
product = _step10.value;
|
|
1885
|
-
if ((_product$
|
|
1888
|
+
if (!((_product$_origin = product._origin) !== null && _product$_origin !== void 0 && _product$_origin.isManualDiscount)) {
|
|
1886
1889
|
_context21.next = 25;
|
|
1887
1890
|
break;
|
|
1888
1891
|
}
|
|
1889
|
-
return _context21.abrupt("continue",
|
|
1892
|
+
return _context21.abrupt("continue", 30);
|
|
1890
1893
|
case 25:
|
|
1891
|
-
|
|
1892
|
-
product.discount_list = product.discount_list.filter(function (pd) {
|
|
1894
|
+
// 1. 把 product.discount_list 和当前选中的 discount 对齐(剔除已取消的券)
|
|
1895
|
+
product.discount_list = (product.discount_list || []).filter(function (pd) {
|
|
1893
1896
|
var _pd$discount$resource, _pd$discount;
|
|
1894
1897
|
var rid = (_pd$discount$resource = (_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) !== null && _pd$discount$resource !== void 0 ? _pd$discount$resource : pd.id;
|
|
1895
1898
|
return rid != null && selectedResourceIds.has(rid);
|
|
1896
1899
|
});
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
product.metadata.main_product_selling_price = newSellingPrice;
|
|
1907
|
-
}
|
|
1900
|
+
|
|
1901
|
+
// 2. 以 original_price 为基准重算 selling_price
|
|
1902
|
+
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
1903
|
+
return sum + (pd.amount || 0);
|
|
1904
|
+
}, 0);
|
|
1905
|
+
newSellingPrice = new Decimal(product.original_price || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1906
|
+
product.selling_price = newSellingPrice;
|
|
1907
|
+
if (product.metadata) {
|
|
1908
|
+
product.metadata.main_product_selling_price = newSellingPrice;
|
|
1908
1909
|
}
|
|
1909
|
-
case 28:
|
|
1910
|
-
_context21.next = 21;
|
|
1911
|
-
break;
|
|
1912
1910
|
case 30:
|
|
1913
|
-
_context21.next =
|
|
1911
|
+
_context21.next = 21;
|
|
1914
1912
|
break;
|
|
1915
1913
|
case 32:
|
|
1916
|
-
_context21.
|
|
1914
|
+
_context21.next = 37;
|
|
1915
|
+
break;
|
|
1916
|
+
case 34:
|
|
1917
|
+
_context21.prev = 34;
|
|
1917
1918
|
_context21.t0 = _context21["catch"](19);
|
|
1918
1919
|
_iterator10.e(_context21.t0);
|
|
1919
|
-
case
|
|
1920
|
-
_context21.prev =
|
|
1920
|
+
case 37:
|
|
1921
|
+
_context21.prev = 37;
|
|
1921
1922
|
_iterator10.f();
|
|
1922
|
-
return _context21.finish(
|
|
1923
|
-
case
|
|
1923
|
+
return _context21.finish(37);
|
|
1924
|
+
case 40:
|
|
1924
1925
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1925
|
-
_context21.next =
|
|
1926
|
+
_context21.next = 43;
|
|
1926
1927
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1927
|
-
case
|
|
1928
|
+
case 43:
|
|
1928
1929
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
1929
1930
|
return d.isSelected;
|
|
1930
1931
|
});
|
|
1931
1932
|
afterApplyTarget = this.store.order.getDiscountList().find(function (d) {
|
|
1932
1933
|
return d.id === params.discountId;
|
|
1933
1934
|
}) || null;
|
|
1934
|
-
_context21.next =
|
|
1935
|
+
_context21.next = 47;
|
|
1935
1936
|
return this.store.order.recalculateSummary({
|
|
1936
1937
|
createIfMissing: true
|
|
1937
1938
|
});
|
|
1938
|
-
case
|
|
1939
|
+
case 47:
|
|
1939
1940
|
this.store.order.persistTempOrder();
|
|
1940
1941
|
finalSummary = ((_this$store$order$get = this.store.order.getTempOrder()) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.summary) || null;
|
|
1941
1942
|
finalProduct = ((_this$store$order$get2 = this.store.order.getTempOrder()) === null || _this$store$order$get2 === void 0 || (_this$store$order$get2 = _this$store$order$get2.products) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2[0]) || null;
|
|
@@ -1944,16 +1945,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1944
1945
|
return d.id === params.discountId;
|
|
1945
1946
|
}) || null;
|
|
1946
1947
|
return _context21.abrupt("return", this.store.order.getDiscountList());
|
|
1947
|
-
case
|
|
1948
|
-
_context21.prev =
|
|
1948
|
+
case 55:
|
|
1949
|
+
_context21.prev = 55;
|
|
1949
1950
|
_context21.t1 = _context21["catch"](1);
|
|
1950
1951
|
this.logMethodError('setDiscountSelected', _context21.t1);
|
|
1951
1952
|
throw _context21.t1;
|
|
1952
|
-
case
|
|
1953
|
+
case 59:
|
|
1953
1954
|
case "end":
|
|
1954
1955
|
return _context21.stop();
|
|
1955
1956
|
}
|
|
1956
|
-
}, _callee21, this, [[1,
|
|
1957
|
+
}, _callee21, this, [[1, 55], [19, 34, 37, 40]]);
|
|
1957
1958
|
}));
|
|
1958
1959
|
function setDiscountSelected(_x14) {
|
|
1959
1960
|
return _setDiscountSelected.apply(this, arguments);
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
});
|
|
@@ -1152,24 +1152,21 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1152
1152
|
nextDiscountList.filter((d) => d.isSelected).map((d) => d.id)
|
|
1153
1153
|
);
|
|
1154
1154
|
for (const product of tempOrder.products) {
|
|
1155
|
-
if (
|
|
1155
|
+
if ((_c = product._origin) == null ? void 0 : _c.isManualDiscount)
|
|
1156
1156
|
continue;
|
|
1157
|
-
|
|
1158
|
-
product.discount_list = product.discount_list.filter((pd) => {
|
|
1157
|
+
product.discount_list = (product.discount_list || []).filter((pd) => {
|
|
1159
1158
|
var _a2;
|
|
1160
1159
|
const rid = ((_a2 = pd.discount) == null ? void 0 : _a2.resource_id) ?? pd.id;
|
|
1161
1160
|
return rid != null && selectedResourceIds.has(rid);
|
|
1162
1161
|
});
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
product.metadata.main_product_selling_price = newSellingPrice;
|
|
1172
|
-
}
|
|
1162
|
+
const totalPerUnitDiscount = (product.discount_list || []).reduce(
|
|
1163
|
+
(sum, pd) => sum + (pd.amount || 0),
|
|
1164
|
+
0
|
|
1165
|
+
);
|
|
1166
|
+
const newSellingPrice = new import_decimal.default(product.original_price || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1167
|
+
product.selling_price = newSellingPrice;
|
|
1168
|
+
if (product.metadata) {
|
|
1169
|
+
product.metadata.main_product_selling_price = newSellingPrice;
|
|
1173
1170
|
}
|
|
1174
1171
|
}
|
|
1175
1172
|
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|