@pisell/pisellos 2.2.270 → 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/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Rules/index.js +41 -35
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +6 -4
- package/dist/solution/BookingTicket/index.js +81 -17
- package/lib/modules/Rules/index.js +7 -3
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +6 -4
- package/lib/solution/BookingTicket/index.js +46 -4
- package/package.json +1 -1
|
@@ -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, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -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
|
};
|
|
@@ -1178,12 +1178,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1178
1178
|
return false;
|
|
1179
1179
|
});
|
|
1180
1180
|
|
|
1181
|
-
//
|
|
1182
|
-
//
|
|
1183
|
-
|
|
1184
|
-
|
|
1181
|
+
// 用户显式点击某张折扣卡时,本次选择优先于自动排序和扫码默认选择。
|
|
1182
|
+
// 目标仍必须在当前商品的 applicableDiscounts 中,因此不会绕过 Holder、时间或商品范围校验。
|
|
1183
|
+
var explicitlySelectedDiscountCard = (options === null || options === void 0 ? void 0 : options.isSelected) === true && options.discountId !== undefined ? applicableDiscounts.find(function (discount) {
|
|
1184
|
+
var discountType = discount.tag || discount.type;
|
|
1185
|
+
return String(discount.id) === String(options.discountId) && ['discount_card', 'product_discount_card'].includes(discountType);
|
|
1186
|
+
}) : undefined;
|
|
1187
|
+
|
|
1188
|
+
// 没有显式选择时保持现有行为:扫码且已选中的折扣卡优先,否则使用自动排序第一项。
|
|
1189
|
+
var scannedSelectedDiscountCard = applicableDiscounts.find(function (n) {
|
|
1185
1190
|
return n.isScan && n.isSelected && (n.tag || n.type) !== 'good_pass';
|
|
1186
1191
|
});
|
|
1192
|
+
var selectedDiscountCard = explicitlySelectedDiscountCard || scannedSelectedDiscountCard;
|
|
1187
1193
|
var selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
|
|
1188
1194
|
|
|
1189
1195
|
// 如果是手动折扣,则不适用优惠券
|
|
@@ -1195,8 +1201,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1195
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) {
|
|
1196
1202
|
return item.type === 'product';
|
|
1197
1203
|
})) || product.total != product.origin_total && (product.bundle || []).every(function (item) {
|
|
1198
|
-
var
|
|
1199
|
-
return !((
|
|
1204
|
+
var _ref12;
|
|
1205
|
+
return !((_ref12 = item.discount_list || []) !== null && _ref12 !== void 0 && _ref12.length);
|
|
1200
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) {
|
|
1201
1207
|
return item.type === 'product';
|
|
1202
1208
|
})));
|
|
@@ -1212,8 +1218,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1212
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) {
|
|
1213
1219
|
return item.type === 'product';
|
|
1214
1220
|
})) || parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
|
|
1215
|
-
var
|
|
1216
|
-
return !((
|
|
1221
|
+
var _ref13;
|
|
1222
|
+
return !((_ref13 = item.discount_list || []) !== null && _ref13 !== void 0 && _ref13.length);
|
|
1217
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) {
|
|
1218
1224
|
return item.type === 'product';
|
|
1219
1225
|
})));
|
|
@@ -1306,8 +1312,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1306
1312
|
discount_list: isManualDiscount ? _this3.resolveDiscountListForManualOverride(product.discount_list) : _this3.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1307
1313
|
}))]);
|
|
1308
1314
|
} else {
|
|
1309
|
-
var
|
|
1310
|
-
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;
|
|
1311
1317
|
var main_product_selling_price = product.price;
|
|
1312
1318
|
if ((product.discount_list || []).some(function (item) {
|
|
1313
1319
|
return item.type === 'promotion';
|
|
@@ -1954,7 +1960,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1954
1960
|
} else {
|
|
1955
1961
|
// 🔥 没有子商品被拆分,使用原有逻辑
|
|
1956
1962
|
mainProductArr.forEach(function (mainProduct) {
|
|
1957
|
-
var
|
|
1963
|
+
var _ref16, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
|
|
1958
1964
|
var mainProductData = _this3.hooks.getProduct(mainProduct);
|
|
1959
1965
|
|
|
1960
1966
|
// 重组bundle
|
|
@@ -1969,9 +1975,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1969
1975
|
} else {
|
|
1970
1976
|
// 🔥 关键:拆分后的bundle item
|
|
1971
1977
|
processedBundleItems.forEach(function (item) {
|
|
1972
|
-
var _item$price,
|
|
1978
|
+
var _item$price, _ref15, _item$bundle_selling_;
|
|
1973
1979
|
var nextBundlePrice = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : bundleItem.price;
|
|
1974
|
-
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;
|
|
1975
1981
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
1976
1982
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1977
1983
|
var _discount$metadata10;
|
|
@@ -1998,7 +2004,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1998
2004
|
|
|
1999
2005
|
// 主商品已经在前面的 setProduct 中应用过折扣;这里只替换 bundle,
|
|
2000
2006
|
// 避免把主商品 discount_list 再扣一次。
|
|
2001
|
-
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;
|
|
2002
2008
|
var newTotal = Number(mainSellingPrice || 0);
|
|
2003
2009
|
var newOriginTotal = Number(mainProductData.original_price || mainProductData.price || 0);
|
|
2004
2010
|
|
|
@@ -2146,14 +2152,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2146
2152
|
var ruleType = usageRules.type;
|
|
2147
2153
|
// 套餐适用范围配置
|
|
2148
2154
|
var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
|
|
2149
|
-
var
|
|
2150
|
-
scopeType =
|
|
2151
|
-
|
|
2152
|
-
exclude_bundle_product_ids =
|
|
2153
|
-
|
|
2154
|
-
include_bundle_product_ids =
|
|
2155
|
-
|
|
2156
|
-
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;
|
|
2157
2163
|
var isMainProduct = flatItem.type === 'main'; // 单独购买
|
|
2158
2164
|
var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
|
|
2159
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 | 2 | 1 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -191,10 +191,12 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
191
191
|
*/
|
|
192
192
|
getCustomer(): ICustomer | null;
|
|
193
193
|
/**
|
|
194
|
-
* 通过 ids
|
|
195
|
-
*
|
|
194
|
+
* 通过 ids 获取商品列表;默认只读取内存,显式开启 loadMissing 时按当前订单上下文补查缺失商品。
|
|
195
|
+
* 补查直接写入 ProductList,不更新 BookingTicket.productCatalog,避免当前商品列表被查询子集覆盖。
|
|
196
196
|
*/
|
|
197
|
-
getProductByIds(ids: number[]
|
|
197
|
+
getProductByIds(ids: number[], options?: {
|
|
198
|
+
loadMissing?: boolean;
|
|
199
|
+
}): Promise<ProductData[]>;
|
|
198
200
|
/**
|
|
199
201
|
* 获取日程时间段点
|
|
200
202
|
* @param params 参数
|
|
@@ -324,7 +326,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
324
326
|
* 获取当前的客户搜索条件
|
|
325
327
|
* @returns 当前搜索条件
|
|
326
328
|
*/
|
|
327
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
329
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
328
330
|
/**
|
|
329
331
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
330
332
|
* @returns 客户状态
|
|
@@ -1270,24 +1270,88 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1270
1270
|
}
|
|
1271
1271
|
|
|
1272
1272
|
/**
|
|
1273
|
-
* 通过 ids
|
|
1274
|
-
*
|
|
1273
|
+
* 通过 ids 获取商品列表;默认只读取内存,显式开启 loadMissing 时按当前订单上下文补查缺失商品。
|
|
1274
|
+
* 补查直接写入 ProductList,不更新 BookingTicket.productCatalog,避免当前商品列表被查询子集覆盖。
|
|
1275
1275
|
*/
|
|
1276
1276
|
}, {
|
|
1277
1277
|
key: "getProductByIds",
|
|
1278
1278
|
value: (function () {
|
|
1279
|
-
var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(ids) {
|
|
1279
|
+
var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(ids, options) {
|
|
1280
|
+
var _this$getOrderCustome, _this$getOrderCustome2, _this$getOrderCustome3;
|
|
1281
|
+
var normalizedIds, localProducts, localProductIds, missingIds, rawBookingDate, bookingDate, customerId, loadedProducts, productById;
|
|
1280
1282
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1281
1283
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1282
1284
|
case 0:
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
+
normalizedIds = Array.from(new Set((ids || []).map(function (id) {
|
|
1286
|
+
return Number(id);
|
|
1287
|
+
}).filter(function (id) {
|
|
1288
|
+
return Number.isFinite(id);
|
|
1289
|
+
})));
|
|
1290
|
+
_context18.next = 3;
|
|
1291
|
+
return this.store.products.getProductByIds(normalizedIds);
|
|
1292
|
+
case 3:
|
|
1293
|
+
_context18.t0 = _context18.sent;
|
|
1294
|
+
if (_context18.t0) {
|
|
1295
|
+
_context18.next = 6;
|
|
1296
|
+
break;
|
|
1297
|
+
}
|
|
1298
|
+
_context18.t0 = [];
|
|
1299
|
+
case 6:
|
|
1300
|
+
localProducts = _context18.t0;
|
|
1301
|
+
if (options !== null && options !== void 0 && options.loadMissing) {
|
|
1302
|
+
_context18.next = 9;
|
|
1303
|
+
break;
|
|
1304
|
+
}
|
|
1305
|
+
return _context18.abrupt("return", localProducts);
|
|
1306
|
+
case 9:
|
|
1307
|
+
localProductIds = new Set(localProducts.map(function (product) {
|
|
1308
|
+
return Number(product.id);
|
|
1309
|
+
}));
|
|
1310
|
+
missingIds = normalizedIds.filter(function (id) {
|
|
1311
|
+
return !localProductIds.has(id);
|
|
1312
|
+
});
|
|
1313
|
+
if (missingIds.length) {
|
|
1314
|
+
_context18.next = 13;
|
|
1315
|
+
break;
|
|
1316
|
+
}
|
|
1317
|
+
return _context18.abrupt("return", localProducts);
|
|
1318
|
+
case 13:
|
|
1319
|
+
rawBookingDate = this.getBookingDate();
|
|
1320
|
+
bookingDate = rawBookingDate && dayjs(rawBookingDate).isValid() ? dayjs(rawBookingDate) : null;
|
|
1321
|
+
customerId = Number((_this$getOrderCustome = (_this$getOrderCustome2 = this.getOrderCustomerSnapshot()) === null || _this$getOrderCustome2 === void 0 ? void 0 : _this$getOrderCustome2.id) !== null && _this$getOrderCustome !== void 0 ? _this$getOrderCustome : (_this$getOrderCustome3 = this.getOrderCustomer()) === null || _this$getOrderCustome3 === void 0 ? void 0 : _this$getOrderCustome3.customer_id);
|
|
1322
|
+
_context18.next = 18;
|
|
1323
|
+
return this.store.products.loadProducts(_objectSpread(_objectSpread({
|
|
1324
|
+
product_ids: missingIds,
|
|
1325
|
+
with_count: ['bundleGroup', 'optionGroup'],
|
|
1326
|
+
with_schedule: 1,
|
|
1327
|
+
cacheId: this.cacheId
|
|
1328
|
+
}, bookingDate ? {
|
|
1329
|
+
schedule_date: bookingDate.format('YYYY-MM-DD'),
|
|
1330
|
+
schedule_datetime: bookingDate.format('YYYY-MM-DD HH:mm:ss')
|
|
1331
|
+
} : {}), Number.isFinite(customerId) && customerId > 0 ? {
|
|
1332
|
+
customer_id: customerId
|
|
1333
|
+
} : {}));
|
|
1334
|
+
case 18:
|
|
1335
|
+
loadedProducts = _context18.sent;
|
|
1336
|
+
productById = new Map();
|
|
1337
|
+
[].concat(_toConsumableArray(localProducts), _toConsumableArray(loadedProducts || [])).forEach(function (product) {
|
|
1338
|
+
var productId = Number(product.id);
|
|
1339
|
+
if (Number.isFinite(productId)) {
|
|
1340
|
+
productById.set(productId, product);
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1343
|
+
return _context18.abrupt("return", normalizedIds.map(function (id) {
|
|
1344
|
+
return productById.get(id);
|
|
1345
|
+
}).filter(function (product) {
|
|
1346
|
+
return Boolean(product);
|
|
1347
|
+
}));
|
|
1348
|
+
case 22:
|
|
1285
1349
|
case "end":
|
|
1286
1350
|
return _context18.stop();
|
|
1287
1351
|
}
|
|
1288
1352
|
}, _callee18, this);
|
|
1289
1353
|
}));
|
|
1290
|
-
function getProductByIds(_x13) {
|
|
1354
|
+
function getProductByIds(_x13, _x14) {
|
|
1291
1355
|
return _getProductByIds.apply(this, arguments);
|
|
1292
1356
|
}
|
|
1293
1357
|
return getProductByIds;
|
|
@@ -1321,7 +1385,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1321
1385
|
}
|
|
1322
1386
|
}, _callee19, this);
|
|
1323
1387
|
}));
|
|
1324
|
-
function getScheduleTimePoints(
|
|
1388
|
+
function getScheduleTimePoints(_x15) {
|
|
1325
1389
|
return _getScheduleTimePoints.apply(this, arguments);
|
|
1326
1390
|
}
|
|
1327
1391
|
return getScheduleTimePoints;
|
|
@@ -1711,7 +1775,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1711
1775
|
}
|
|
1712
1776
|
}, _callee23, this, [[0, 7]]);
|
|
1713
1777
|
}));
|
|
1714
|
-
function changeCustomerPage(
|
|
1778
|
+
function changeCustomerPage(_x16, _x17) {
|
|
1715
1779
|
return _changeCustomerPage.apply(this, arguments);
|
|
1716
1780
|
}
|
|
1717
1781
|
return changeCustomerPage;
|
|
@@ -2165,10 +2229,10 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2165
2229
|
}, {
|
|
2166
2230
|
key: "buildAddProductCtx",
|
|
2167
2231
|
value: function buildAddProductCtx(extra) {
|
|
2168
|
-
var _extra$date2, _ref12, _this$
|
|
2232
|
+
var _extra$date2, _ref12, _this$getOrderCustome4, _this$getOrderCustome5, _this$store$order$get4, _extra$presetStartTim2;
|
|
2169
2233
|
var bookingContextState = this.store.bookingContext.getState();
|
|
2170
2234
|
var date = (_extra$date2 = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date2 !== void 0 ? _extra$date2 : bookingContextState.date;
|
|
2171
|
-
var orderCustomerId = (_ref12 = (_this$
|
|
2235
|
+
var orderCustomerId = (_ref12 = (_this$getOrderCustome4 = (_this$getOrderCustome5 = this.getOrderCustomerSnapshot()) === null || _this$getOrderCustome5 === void 0 ? void 0 : _this$getOrderCustome5.id) !== null && _this$getOrderCustome4 !== void 0 ? _this$getOrderCustome4 : (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.customer_id) !== null && _ref12 !== void 0 ? _ref12 : undefined;
|
|
2172
2236
|
return _objectSpread({
|
|
2173
2237
|
bookingConfig: bookingContextState.bookingConfig,
|
|
2174
2238
|
resourcesOrigin: bookingContextState.resourcesOrigin,
|
|
@@ -2285,7 +2349,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2285
2349
|
}
|
|
2286
2350
|
}, _callee27, this);
|
|
2287
2351
|
}));
|
|
2288
|
-
function updateProductInOrder(
|
|
2352
|
+
function updateProductInOrder(_x18) {
|
|
2289
2353
|
return _updateProductInOrder.apply(this, arguments);
|
|
2290
2354
|
}
|
|
2291
2355
|
return updateProductInOrder;
|
|
@@ -2394,7 +2458,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2394
2458
|
}
|
|
2395
2459
|
}, _callee28, this, [[4, 21]]);
|
|
2396
2460
|
}));
|
|
2397
|
-
function handleGlobalScanCode(
|
|
2461
|
+
function handleGlobalScanCode(_x19, _x20) {
|
|
2398
2462
|
return _handleGlobalScanCode.apply(this, arguments);
|
|
2399
2463
|
}
|
|
2400
2464
|
return handleGlobalScanCode;
|
|
@@ -2492,7 +2556,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2492
2556
|
}
|
|
2493
2557
|
}, _callee29, this);
|
|
2494
2558
|
}));
|
|
2495
|
-
function addAddTimeProductToBooking(
|
|
2559
|
+
function addAddTimeProductToBooking(_x21) {
|
|
2496
2560
|
return _addAddTimeProductToBooking.apply(this, arguments);
|
|
2497
2561
|
}
|
|
2498
2562
|
return addAddTimeProductToBooking;
|
|
@@ -2595,7 +2659,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2595
2659
|
}
|
|
2596
2660
|
}, _callee30, this, [[13, 31, 34, 37]]);
|
|
2597
2661
|
}));
|
|
2598
|
-
function addAddTimeProductsToBooking(
|
|
2662
|
+
function addAddTimeProductsToBooking(_x22) {
|
|
2599
2663
|
return _addAddTimeProductsToBooking.apply(this, arguments);
|
|
2600
2664
|
}
|
|
2601
2665
|
return addAddTimeProductsToBooking;
|
|
@@ -2629,7 +2693,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2629
2693
|
}
|
|
2630
2694
|
}, _callee31, this);
|
|
2631
2695
|
}));
|
|
2632
|
-
function setOtherParams(
|
|
2696
|
+
function setOtherParams(_x23) {
|
|
2633
2697
|
return _setOtherParams.apply(this, arguments);
|
|
2634
2698
|
}
|
|
2635
2699
|
return setOtherParams;
|
|
@@ -2700,7 +2764,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2700
2764
|
}
|
|
2701
2765
|
}, _callee32, this);
|
|
2702
2766
|
}));
|
|
2703
|
-
function handlePrintWristband(
|
|
2767
|
+
function handlePrintWristband(_x24) {
|
|
2704
2768
|
return _handlePrintWristband.apply(this, arguments);
|
|
2705
2769
|
}
|
|
2706
2770
|
return handlePrintWristband;
|
|
@@ -2775,7 +2839,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2775
2839
|
}
|
|
2776
2840
|
}, _callee33, this);
|
|
2777
2841
|
}));
|
|
2778
|
-
function handleRedeem(
|
|
2842
|
+
function handleRedeem(_x25) {
|
|
2779
2843
|
return _handleRedeem.apply(this, arguments);
|
|
2780
2844
|
}
|
|
2781
2845
|
return handleRedeem;
|
|
@@ -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,
|
|
@@ -856,9 +855,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
856
855
|
}
|
|
857
856
|
return false;
|
|
858
857
|
});
|
|
859
|
-
const
|
|
858
|
+
const explicitlySelectedDiscountCard = (options == null ? void 0 : options.isSelected) === true && options.discountId !== void 0 ? applicableDiscounts.find((discount) => {
|
|
859
|
+
const discountType = discount.tag || discount.type;
|
|
860
|
+
return String(discount.id) === String(options.discountId) && ["discount_card", "product_discount_card"].includes(discountType);
|
|
861
|
+
}) : void 0;
|
|
862
|
+
const scannedSelectedDiscountCard = applicableDiscounts.find(
|
|
860
863
|
(n) => n.isScan && n.isSelected && (n.tag || n.type) !== "good_pass"
|
|
861
864
|
);
|
|
865
|
+
const selectedDiscountCard = explicitlySelectedDiscountCard || scannedSelectedDiscountCard;
|
|
862
866
|
const selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
|
|
863
867
|
let isManualDiscount = false;
|
|
864
868
|
let isItemRewardProductDiscount = false;
|
|
@@ -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 | 2 | 1 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -191,10 +191,12 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
191
191
|
*/
|
|
192
192
|
getCustomer(): ICustomer | null;
|
|
193
193
|
/**
|
|
194
|
-
* 通过 ids
|
|
195
|
-
*
|
|
194
|
+
* 通过 ids 获取商品列表;默认只读取内存,显式开启 loadMissing 时按当前订单上下文补查缺失商品。
|
|
195
|
+
* 补查直接写入 ProductList,不更新 BookingTicket.productCatalog,避免当前商品列表被查询子集覆盖。
|
|
196
196
|
*/
|
|
197
|
-
getProductByIds(ids: number[]
|
|
197
|
+
getProductByIds(ids: number[], options?: {
|
|
198
|
+
loadMissing?: boolean;
|
|
199
|
+
}): Promise<ProductData[]>;
|
|
198
200
|
/**
|
|
199
201
|
* 获取日程时间段点
|
|
200
202
|
* @param params 参数
|
|
@@ -324,7 +326,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
324
326
|
* 获取当前的客户搜索条件
|
|
325
327
|
* @returns 当前搜索条件
|
|
326
328
|
*/
|
|
327
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
329
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
328
330
|
/**
|
|
329
331
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
330
332
|
* @returns 客户状态
|
|
@@ -722,11 +722,53 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
722
722
|
return this.getOrderCustomerSnapshot();
|
|
723
723
|
}
|
|
724
724
|
/**
|
|
725
|
-
* 通过 ids
|
|
726
|
-
*
|
|
725
|
+
* 通过 ids 获取商品列表;默认只读取内存,显式开启 loadMissing 时按当前订单上下文补查缺失商品。
|
|
726
|
+
* 补查直接写入 ProductList,不更新 BookingTicket.productCatalog,避免当前商品列表被查询子集覆盖。
|
|
727
727
|
*/
|
|
728
|
-
async getProductByIds(ids) {
|
|
729
|
-
|
|
728
|
+
async getProductByIds(ids, options) {
|
|
729
|
+
var _a, _b;
|
|
730
|
+
const normalizedIds = Array.from(
|
|
731
|
+
new Set(
|
|
732
|
+
(ids || []).map((id) => Number(id)).filter((id) => Number.isFinite(id))
|
|
733
|
+
)
|
|
734
|
+
);
|
|
735
|
+
const localProducts = await this.store.products.getProductByIds(normalizedIds) || [];
|
|
736
|
+
if (!(options == null ? void 0 : options.loadMissing)) {
|
|
737
|
+
return localProducts;
|
|
738
|
+
}
|
|
739
|
+
const localProductIds = new Set(
|
|
740
|
+
localProducts.map((product) => Number(product.id))
|
|
741
|
+
);
|
|
742
|
+
const missingIds = normalizedIds.filter(
|
|
743
|
+
(id) => !localProductIds.has(id)
|
|
744
|
+
);
|
|
745
|
+
if (!missingIds.length) {
|
|
746
|
+
return localProducts;
|
|
747
|
+
}
|
|
748
|
+
const rawBookingDate = this.getBookingDate();
|
|
749
|
+
const bookingDate = rawBookingDate && (0, import_dayjs.default)(rawBookingDate).isValid() ? (0, import_dayjs.default)(rawBookingDate) : null;
|
|
750
|
+
const customerId = Number(
|
|
751
|
+
((_a = this.getOrderCustomerSnapshot()) == null ? void 0 : _a.id) ?? ((_b = this.getOrderCustomer()) == null ? void 0 : _b.customer_id)
|
|
752
|
+
);
|
|
753
|
+
const loadedProducts = await this.store.products.loadProducts({
|
|
754
|
+
product_ids: missingIds,
|
|
755
|
+
with_count: ["bundleGroup", "optionGroup"],
|
|
756
|
+
with_schedule: 1,
|
|
757
|
+
cacheId: this.cacheId,
|
|
758
|
+
...bookingDate ? {
|
|
759
|
+
schedule_date: bookingDate.format("YYYY-MM-DD"),
|
|
760
|
+
schedule_datetime: bookingDate.format("YYYY-MM-DD HH:mm:ss")
|
|
761
|
+
} : {},
|
|
762
|
+
...Number.isFinite(customerId) && customerId > 0 ? { customer_id: customerId } : {}
|
|
763
|
+
});
|
|
764
|
+
const productById = /* @__PURE__ */ new Map();
|
|
765
|
+
[...localProducts, ...loadedProducts || []].forEach((product) => {
|
|
766
|
+
const productId = Number(product.id);
|
|
767
|
+
if (Number.isFinite(productId)) {
|
|
768
|
+
productById.set(productId, product);
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
return normalizedIds.map((id) => productById.get(id)).filter((product) => Boolean(product));
|
|
730
772
|
}
|
|
731
773
|
/**
|
|
732
774
|
* 获取日程时间段点
|