@pisell/pisellos 2.2.271 → 2.2.272
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/Rules/index.js +31 -31
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/modules/Rules/index.js +1 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -440,6 +440,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
440
440
|
// 2. 展开 bundle 子商品
|
|
441
441
|
if (product.bundle && Array.isArray(product.bundle) && product.bundle.length > 0) {
|
|
442
442
|
product.bundle.forEach(function (bundleItem, bundleIndex) {
|
|
443
|
+
var _ref3, _bundleItem$bundle_pr;
|
|
443
444
|
flattened.push({
|
|
444
445
|
type: 'bundle',
|
|
445
446
|
originProduct: originProduct,
|
|
@@ -448,8 +449,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
448
449
|
bundleIndex: bundleIndex,
|
|
449
450
|
// 虚拟商品属性
|
|
450
451
|
price: Number(bundleItem.price || 0),
|
|
451
|
-
id: bundleItem._bundle_product_id,
|
|
452
|
-
// 🔥 使用 _bundle_product_id
|
|
452
|
+
id: (_ref3 = (_bundleItem$bundle_pr = bundleItem.bundle_product_id) !== null && _bundleItem$bundle_pr !== void 0 ? _bundleItem$bundle_pr : bundleItem._bundle_product_id) !== null && _ref3 !== void 0 ? _ref3 : bundleItem.product_id,
|
|
453
453
|
_id: "".concat(product._id, "_bundle_").concat(bundleIndex),
|
|
454
454
|
parentId: product._id,
|
|
455
455
|
num: bundleItem.num || 1,
|
|
@@ -598,10 +598,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
598
598
|
|
|
599
599
|
// 对扁平化后的列表按价格降序排序(用于应用优惠券时优先选择高价商品)
|
|
600
600
|
var sortedFlattenedList = flattenedList.sort(function (a, b) {
|
|
601
|
-
var
|
|
601
|
+
var _ref4, _a$original_price, _ref5, _b$original_price;
|
|
602
602
|
// 子商品优先使用 original_price,主商品使用 price
|
|
603
|
-
var priceA = new Decimal(a.type === 'bundle' ? (
|
|
604
|
-
var priceB = new Decimal(b.type === 'bundle' ? (
|
|
603
|
+
var priceA = new Decimal(a.type === 'bundle' ? (_ref4 = (_a$original_price = a.original_price) !== null && _a$original_price !== void 0 ? _a$original_price : a.price) !== null && _ref4 !== void 0 ? _ref4 : '0' : a.price || '0');
|
|
604
|
+
var priceB = new Decimal(b.type === 'bundle' ? (_ref5 = (_b$original_price = b.original_price) !== null && _b$original_price !== void 0 ? _b$original_price : b.price) !== null && _ref5 !== void 0 ? _ref5 : '0' : b.price || '0');
|
|
605
605
|
if (priceA.equals(priceB)) {
|
|
606
606
|
// 价格相同时,主商品优先
|
|
607
607
|
if (a.type !== b.type) {
|
|
@@ -846,7 +846,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
846
846
|
// 收集该折扣卡适用的商品(排除被其他专属折扣卡占用的商品)
|
|
847
847
|
var applicableProducts = [];
|
|
848
848
|
sortedFlattenedList.forEach(function (flatItem) {
|
|
849
|
-
var _flatItem$parentProdu2, _flatItem$parentProdu3, _product$price,
|
|
849
|
+
var _flatItem$parentProdu2, _flatItem$parentProdu3, _product$price, _ref6, _flatItem$original_pr;
|
|
850
850
|
// 🔥 检查该商品是否被其他专属折扣卡占用
|
|
851
851
|
var occupyingDiscountId = occupiedItems.get(flatItem._id);
|
|
852
852
|
if (occupyingDiscountId !== undefined && occupyingDiscountId !== discount.id) {
|
|
@@ -874,7 +874,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
874
874
|
|
|
875
875
|
// 对于主商品:使用 price
|
|
876
876
|
// 对于子商品:优先使用 flatItem.original_price,否则使用 flatItem.price
|
|
877
|
-
var originalAmount = flatItem.type === 'main' ? Number((_product$price = product.price) !== null && _product$price !== void 0 ? _product$price : 0) : Number((
|
|
877
|
+
var originalAmount = flatItem.type === 'main' ? Number((_product$price = product.price) !== null && _product$price !== void 0 ? _product$price : 0) : Number((_ref6 = (_flatItem$original_pr = flatItem.original_price) !== null && _flatItem$original_pr !== void 0 ? _flatItem$original_pr : flatItem.price) !== null && _ref6 !== void 0 ? _ref6 : 0);
|
|
878
878
|
|
|
879
879
|
// 传递 parentQuantity 用于差值处理时判断是否是真正的"数量为1"
|
|
880
880
|
var productData = {
|
|
@@ -1003,13 +1003,13 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1003
1003
|
};
|
|
1004
1004
|
var optionDiscountAmount = 0;
|
|
1005
1005
|
var discountedOptions = options.map(function (option) {
|
|
1006
|
-
var
|
|
1006
|
+
var _ref7, _ref8, _option$_original_pri, _ref9, _option$num, _rest$price, _option$_original_pri2;
|
|
1007
1007
|
// 折前单价:优先 price,缺失再 add_price;已写回折后价时用 _original_price(或旧字段 _original_add_price)
|
|
1008
|
-
var rawUnit = (
|
|
1008
|
+
var rawUnit = (_ref7 = (_ref8 = (_option$_original_pri = option._original_price) !== null && _option$_original_pri !== void 0 ? _option$_original_pri : option._original_add_price) !== null && _ref8 !== void 0 ? _ref8 : option.price) !== null && _ref7 !== void 0 ? _ref7 : option.add_price;
|
|
1009
1009
|
var baseUnitNum = Number(rawUnit !== null && rawUnit !== void 0 ? rawUnit : 0);
|
|
1010
1010
|
if (baseUnitNum <= 0) return option;
|
|
1011
1011
|
var discountedPrice = getDiscountAmount(discount, baseUnitNum, baseUnitNum);
|
|
1012
|
-
var optQty = Number((
|
|
1012
|
+
var optQty = Number((_ref9 = (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity) !== null && _ref9 !== void 0 ? _ref9 : 1);
|
|
1013
1013
|
optionDiscountAmount = new Decimal(optionDiscountAmount).plus(new Decimal(baseUnitNum).minus(discountedPrice).mul(optQty)).toNumber();
|
|
1014
1014
|
var _original_add_price = option._original_add_price,
|
|
1015
1015
|
rest = _objectWithoutProperties(option, _excluded);
|
|
@@ -1043,9 +1043,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1043
1043
|
var getOptionTotal = function getOptionTotal(options) {
|
|
1044
1044
|
if (!(options !== null && options !== void 0 && options.length)) return 0;
|
|
1045
1045
|
return options.reduce(function (sum, opt) {
|
|
1046
|
-
var
|
|
1047
|
-
var unit = Number((
|
|
1048
|
-
var n = Number((
|
|
1046
|
+
var _ref10, _opt$price, _ref11, _opt$num;
|
|
1047
|
+
var unit = Number((_ref10 = (_opt$price = opt.price) !== null && _opt$price !== void 0 ? _opt$price : opt.add_price) !== null && _ref10 !== void 0 ? _ref10 : 0);
|
|
1048
|
+
var n = Number((_ref11 = (_opt$num = opt.num) !== null && _opt$num !== void 0 ? _opt$num : opt.quantity) !== null && _ref11 !== void 0 ? _ref11 : 1);
|
|
1049
1049
|
return new Decimal(sum).plus(new Decimal(unit).mul(n)).toNumber();
|
|
1050
1050
|
}, 0);
|
|
1051
1051
|
};
|
|
@@ -1201,8 +1201,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1201
1201
|
isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : ((_product$discount_lis5 = product.discount_list) === null || _product$discount_lis5 === void 0 ? void 0 : _product$discount_lis5.some(function (item) {
|
|
1202
1202
|
return item.type === 'product';
|
|
1203
1203
|
})) || product.total != product.origin_total && (product.bundle || []).every(function (item) {
|
|
1204
|
-
var
|
|
1205
|
-
return !((
|
|
1204
|
+
var _ref12;
|
|
1205
|
+
return !((_ref12 = item.discount_list || []) !== null && _ref12 !== void 0 && _ref12.length);
|
|
1206
1206
|
}) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || ((_product12 = product) === null || _product12 === void 0 || (_product12 = _product12.discount_list) === null || _product12 === void 0 || (_product12$every = _product12.every) === null || _product12$every === void 0 ? void 0 : _product12$every.call(_product12, function (item) {
|
|
1207
1207
|
return item.type === 'product';
|
|
1208
1208
|
})));
|
|
@@ -1218,8 +1218,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1218
1218
|
isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : ((_parentProduct$discou = parentProduct.discount_list) === null || _parentProduct$discou === void 0 ? void 0 : _parentProduct$discou.some(function (item) {
|
|
1219
1219
|
return item.type === 'product';
|
|
1220
1220
|
})) || parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
|
|
1221
|
-
var
|
|
1222
|
-
return !((
|
|
1221
|
+
var _ref13;
|
|
1222
|
+
return !((_ref13 = item.discount_list || []) !== null && _ref13 !== void 0 && _ref13.length);
|
|
1223
1223
|
}) && (!((_parentProduct$discou2 = parentProduct.discount_list) !== null && _parentProduct$discou2 !== void 0 && _parentProduct$discou2.length) || (parentProduct === null || parentProduct === void 0 || (_parentProduct$discou3 = parentProduct.discount_list) === null || _parentProduct$discou3 === void 0 || (_parentProduct$discou4 = _parentProduct$discou3.every) === null || _parentProduct$discou4 === void 0 ? void 0 : _parentProduct$discou4.call(_parentProduct$discou3, function (item) {
|
|
1224
1224
|
return item.type === 'product';
|
|
1225
1225
|
})));
|
|
@@ -1312,8 +1312,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1312
1312
|
discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(product.discount_list) : _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1313
1313
|
}))]);
|
|
1314
1314
|
} else {
|
|
1315
|
-
var
|
|
1316
|
-
var total = product.inPromotion ? (
|
|
1315
|
+
var _ref14, _product$_promotion$f, _product13, _product$origin_total;
|
|
1316
|
+
var total = product.inPromotion ? (_ref14 = (_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 && _ref14 !== void 0 ? _ref14 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
|
|
1317
1317
|
var main_product_selling_price = product.price;
|
|
1318
1318
|
if ((product.discount_list || []).some(function (item) {
|
|
1319
1319
|
return item.type === 'promotion';
|
|
@@ -1960,7 +1960,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1960
1960
|
} else {
|
|
1961
1961
|
// 🔥 没有子商品被拆分,使用原有逻辑
|
|
1962
1962
|
mainProductArr.forEach(function (mainProduct) {
|
|
1963
|
-
var
|
|
1963
|
+
var _ref16, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
|
|
1964
1964
|
var mainProductData = _this3.hooks.getProduct(mainProduct);
|
|
1965
1965
|
|
|
1966
1966
|
// 重组bundle
|
|
@@ -1975,9 +1975,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1975
1975
|
} else {
|
|
1976
1976
|
// 🔥 关键:拆分后的bundle item
|
|
1977
1977
|
processedBundleItems.forEach(function (item) {
|
|
1978
|
-
var _item$price,
|
|
1978
|
+
var _item$price, _ref15, _item$bundle_selling_;
|
|
1979
1979
|
var nextBundlePrice = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : bundleItem.price;
|
|
1980
|
-
var nextBundleSellingPrice = (
|
|
1980
|
+
var nextBundleSellingPrice = (_ref15 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref15 !== void 0 ? _ref15 : bundleItem.bundle_selling_price;
|
|
1981
1981
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
1982
1982
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1983
1983
|
var _discount$metadata10;
|
|
@@ -2004,7 +2004,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2004
2004
|
|
|
2005
2005
|
// 主商品已经在前面的 setProduct 中应用过折扣;这里只替换 bundle,
|
|
2006
2006
|
// 避免把主商品 discount_list 再扣一次。
|
|
2007
|
-
var mainSellingPrice = (
|
|
2007
|
+
var mainSellingPrice = (_ref16 = (_mainProductData$main = mainProductData.main_product_selling_price) !== null && _mainProductData$main !== void 0 ? _mainProductData$main : mainProductData.price) !== null && _ref16 !== void 0 ? _ref16 : 0;
|
|
2008
2008
|
var newTotal = Number(mainSellingPrice || 0);
|
|
2009
2009
|
var newOriginTotal = Number(mainProductData.original_price || mainProductData.price || 0);
|
|
2010
2010
|
|
|
@@ -2152,14 +2152,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2152
2152
|
var ruleType = usageRules.type;
|
|
2153
2153
|
// 套餐适用范围配置
|
|
2154
2154
|
var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
|
|
2155
|
-
var
|
|
2156
|
-
scopeType =
|
|
2157
|
-
|
|
2158
|
-
exclude_bundle_product_ids =
|
|
2159
|
-
|
|
2160
|
-
include_bundle_product_ids =
|
|
2161
|
-
|
|
2162
|
-
filter =
|
|
2155
|
+
var _ref17 = packageScope || {},
|
|
2156
|
+
scopeType = _ref17.type,
|
|
2157
|
+
_ref17$exclude_bundle = _ref17.exclude_bundle_product_ids,
|
|
2158
|
+
exclude_bundle_product_ids = _ref17$exclude_bundle === void 0 ? [] : _ref17$exclude_bundle,
|
|
2159
|
+
_ref17$include_bundle = _ref17.include_bundle_product_ids,
|
|
2160
|
+
include_bundle_product_ids = _ref17$include_bundle === void 0 ? [] : _ref17$include_bundle,
|
|
2161
|
+
_ref17$filter = _ref17.filter,
|
|
2162
|
+
filter = _ref17$filter === void 0 ? 0 : _ref17$filter;
|
|
2163
2163
|
var isMainProduct = flatItem.type === 'main'; // 单独购买
|
|
2164
2164
|
var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
|
|
2165
2165
|
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -326,7 +326,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
326
326
|
* 获取当前的客户搜索条件
|
|
327
327
|
* @returns 当前搜索条件
|
|
328
328
|
*/
|
|
329
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
329
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
330
330
|
/**
|
|
331
331
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
332
332
|
* @returns 客户状态
|
|
@@ -1,51 +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
|
-
ITEM_REWARD_STRATEGY: () => import_examples.ITEM_REWARD_STRATEGY,
|
|
34
|
-
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
35
|
-
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
36
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
37
|
-
default: () => import_adapter2.default
|
|
38
|
-
});
|
|
39
|
-
module.exports = __toCommonJS(promotion_exports);
|
|
40
|
-
var import_evaluator = require("./evaluator");
|
|
41
|
-
var import_adapter = require("./adapter");
|
|
42
|
-
var import_adapter2 = __toESM(require("./adapter"));
|
|
43
|
-
var import_examples = require("./examples");
|
|
44
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
-
0 && (module.exports = {
|
|
46
|
-
BUY_X_GET_Y_FREE_STRATEGY,
|
|
47
|
-
ITEM_REWARD_STRATEGY,
|
|
48
|
-
PromotionAdapter,
|
|
49
|
-
PromotionEvaluator,
|
|
50
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
51
|
-
});
|
|
@@ -312,8 +312,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
312
312
|
bundleIndex,
|
|
313
313
|
// 虚拟商品属性
|
|
314
314
|
price: Number(bundleItem.price || 0),
|
|
315
|
-
id: bundleItem._bundle_product_id,
|
|
316
|
-
// 🔥 使用 _bundle_product_id
|
|
315
|
+
id: bundleItem.bundle_product_id ?? bundleItem._bundle_product_id ?? bundleItem.product_id,
|
|
317
316
|
_id: `${product._id}_bundle_${bundleIndex}`,
|
|
318
317
|
parentId: product._id,
|
|
319
318
|
num: bundleItem.num || 1,
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -326,7 +326,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
326
326
|
* 获取当前的客户搜索条件
|
|
327
327
|
* @returns 当前搜索条件
|
|
328
328
|
*/
|
|
329
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
329
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
330
330
|
/**
|
|
331
331
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
332
332
|
* @returns 客户状态
|