@pisell/pisellos 2.2.270 → 2.2.271
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 +10 -4
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +5 -3
- package/dist/solution/BookingTicket/index.js +81 -17
- package/lib/model/strategy/adapter/promotion/index.js +51 -0
- package/lib/modules/Rules/index.js +6 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +5 -3
- 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";
|
|
@@ -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
|
// 如果是手动折扣,则不适用优惠券
|
|
@@ -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 | 1 | 2 | 6 | 4 | 3 | 5;
|
|
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 参数
|
|
@@ -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;
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
});
|
|
@@ -856,9 +856,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
856
856
|
}
|
|
857
857
|
return false;
|
|
858
858
|
});
|
|
859
|
-
const
|
|
859
|
+
const explicitlySelectedDiscountCard = (options == null ? void 0 : options.isSelected) === true && options.discountId !== void 0 ? applicableDiscounts.find((discount) => {
|
|
860
|
+
const discountType = discount.tag || discount.type;
|
|
861
|
+
return String(discount.id) === String(options.discountId) && ["discount_card", "product_discount_card"].includes(discountType);
|
|
862
|
+
}) : void 0;
|
|
863
|
+
const scannedSelectedDiscountCard = applicableDiscounts.find(
|
|
860
864
|
(n) => n.isScan && n.isSelected && (n.tag || n.type) !== "good_pass"
|
|
861
865
|
);
|
|
866
|
+
const selectedDiscountCard = explicitlySelectedDiscountCard || scannedSelectedDiscountCard;
|
|
862
867
|
const selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
|
|
863
868
|
let isManualDiscount = false;
|
|
864
869
|
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 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 6 | 4 | 3 | 5;
|
|
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 参数
|
|
@@ -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
|
* 获取日程时间段点
|