@pisell/pisellos 2.3.160 → 2.3.162

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.
@@ -5468,7 +5468,7 @@ class Server {
5468
5468
  }
5469
5469
  buildOrderSalesDetailBackendPath(lookup, data) {
5470
5470
  const rawWith = data && typeof data === 'object' ? data.with : undefined;
5471
- const withFields = Array.isArray(rawWith) && rawWith.length > 0 ? rawWith : ['products', 'scheduleEvents'];
5471
+ const withFields = Array.isArray(rawWith) && rawWith.length > 0 ? rawWith : ['all'];
5472
5472
  const searchParams = new URLSearchParams();
5473
5473
  withFields.forEach(field => {
5474
5474
  if (field === undefined || field === null || field === '') return;
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
328
328
  date: string;
329
329
  status: string;
330
330
  week: string;
331
- weekNum: 0 | 1 | 2 | 6 | 3 | 4 | 5;
331
+ weekNum: 0 | 5 | 3 | 1 | 2 | 4 | 6;
332
332
  }[]>;
333
333
  submitTimeSlot(timeSlots: TimeSliceItem): void;
334
334
  private getScheduleDataByIds;
@@ -347,7 +347,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
347
347
  count: number;
348
348
  left: number;
349
349
  summaryCount: number;
350
- status: "lots_of_space" | "filling_up_fast" | "sold_out";
350
+ status: "sold_out" | "lots_of_space" | "filling_up_fast";
351
351
  }[];
352
352
  /**
353
353
  * 找到多个资源的公共可用时间段
@@ -274,7 +274,7 @@ class SalesImpl extends _BaseModule.BaseModule {
274
274
  } : {
275
275
  external_sale_number: normalizedLookup
276
276
  };
277
- return this.request.post('/local/print-order', {
277
+ return this.request.post('/shop/local/print-order', {
278
278
  ...lookupPayload,
279
279
  lookup_order_from_db: 1,
280
280
  small_ticket_data_flag: 1,
@@ -105,6 +105,12 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
105
105
  private normalizeAvailabilityIdList;
106
106
  private normalizeAvailabilityStringList;
107
107
  private normalizeAvailabilityPrepareDescriptor;
108
+ /**
109
+ * 列表直加没有经过 SKU availability flow,legacy cacheItem 的灵活时长可能落到
110
+ * 23:59。提交前用同一套营业排期补齐结束时间,保留已选开始时间、资源和 Holder。
111
+ * 仅供直加调用;手动时间选择和 availability candidate 不经过此方法。
112
+ */
113
+ prepareDirectAddFlexibleBooking(cacheItem: any): Promise<any>;
108
114
  private resolveAvailabilityPrepareDefaults;
109
115
  private buildAvailabilityPrepareKey;
110
116
  private clearAvailabilityRemoteResourceState;
@@ -33,8 +33,8 @@ var _dayjs = _interopRequireDefault(require("dayjs"));
33
33
  var _lodashEs = require("lodash-es");
34
34
  var _modules = require("../../modules");
35
35
  var _pickupTiming = require("../../modules/Order/pickupTiming");
36
- var _utils = require("../../modules/BookingContext/utils");
37
36
  var _cacheItemToBookingInput = require("../../modules/BookingContext/utils/cacheItemToBookingInput");
37
+ var _utils = require("../../modules/BookingContext/utils");
38
38
  var _OpenData = require("../../modules/OpenData");
39
39
  var _getDateIsInSchedule = require("../../modules/Schedule/getDateIsInSchedule");
40
40
  var _ResourcePlanner = require("../../modules/ResourcePlanner");
@@ -1385,6 +1385,90 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1385
1385
  mode
1386
1386
  });
1387
1387
  }
1388
+
1389
+ /**
1390
+ * 列表直加没有经过 SKU availability flow,legacy cacheItem 的灵活时长可能落到
1391
+ * 23:59。提交前用同一套营业排期补齐结束时间,保留已选开始时间、资源和 Holder。
1392
+ * 仅供直加调用;手动时间选择和 availability candidate 不经过此方法。
1393
+ */
1394
+ async prepareDirectAddFlexibleBooking(cacheItem) {
1395
+ if (!(0, _utils.isProductFlexibleDuration)(cacheItem?.duration) || (0, _utils.isSessionProduct)(cacheItem)) {
1396
+ return cacheItem;
1397
+ }
1398
+ const extend = cacheItem?._extend;
1399
+ const {
1400
+ startDate
1401
+ } = (0, _utils.getServiceTimes)(cacheItem);
1402
+ if (!extend?.start_date || !extend?.start_time || !startDate.isValid()) {
1403
+ throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', '灵活时长商品缺少有效开始时间');
1404
+ }
1405
+ const date = startDate.format('YYYY-MM-DD');
1406
+ // 带上前一天,覆盖凌晨仍处在前一营业时段内的情况。
1407
+ const dateRange = {
1408
+ startDate: startDate.subtract(1, 'day').format('YYYY-MM-DD'),
1409
+ endDate: date
1410
+ };
1411
+ const prepare = await this.resolveAvailabilityPrepareDefaults({
1412
+ dateRange
1413
+ });
1414
+ if (prepare._availabilityOperatingHours?.source !== 'open_data_schedule') {
1415
+ return cacheItem;
1416
+ }
1417
+ const operatingHours = this.buildAvailabilityOperatingHoursSnapshot({
1418
+ prepare,
1419
+ dateRange,
1420
+ scheduleList: this.getAvailabilityScheduleCatalog(),
1421
+ businessHours: DEFAULT_AVAILABILITY_BUSINESS_HOURS
1422
+ });
1423
+ if (operatingHours.missingScheduleIds.length > 0) {
1424
+ throw new _ResourcePlanner.AvailabilityError('OPERATING_HOURS_RESOLVE_FAILED', '店铺营业时间排期缺失,请重试', {
1425
+ missingScheduleIds: operatingHours.missingScheduleIds
1426
+ });
1427
+ }
1428
+ const start = (0, _localClock.localDateTimeToScalar)((0, _localClock.parseLocalDateTime)(startDate.format('YYYY-MM-DDTHH:mm:00')));
1429
+ const nextDay = (0, _localClock.localDateTimeToScalar)((0, _localClock.parseLocalDateTime)(`${startDate.add(1, 'day').format('YYYY-MM-DD')}T00:00:00`));
1430
+ const windows = operatingHours.windows.map(window => ({
1431
+ start: (0, _localClock.localDateTimeToScalar)((0, _localClock.parseLocalDateTime)(window.startAt)),
1432
+ end: (0, _localClock.localDateTimeToScalar)((0, _localClock.parseLocalDateTime)(window.endAt))
1433
+ })).filter(window => window.end > start && window.start < nextDay).sort((left, right) => left.start - right.start);
1434
+ const merged = [];
1435
+ for (const window of windows) {
1436
+ const previous = merged[merged.length - 1];
1437
+ if (previous && window.start <= previous.end) {
1438
+ previous.end = Math.max(previous.end, window.end);
1439
+ } else {
1440
+ merged.push({
1441
+ ...window
1442
+ });
1443
+ }
1444
+ }
1445
+ // POS 可以提前售票;保留开始分钟,结束取当前或当天下一段营业时间。
1446
+ // 不跨越午休,也不把闭店后的直加顺延到次日。
1447
+ let end = merged[0]?.end;
1448
+ const resourceEndAt = (0, _utils.getUsableTime)(cacheItem)?._extend?.usableTime?.end_at;
1449
+ if (resourceEndAt) {
1450
+ const resourceEnd = (0, _localClock.localDateTimeToScalar)((0, _localClock.parseLocalDateTime)((0, _dayjs.default)(resourceEndAt).format('YYYY-MM-DDTHH:mm:00')));
1451
+ if (end !== undefined) end = Math.min(end, resourceEnd);
1452
+ }
1453
+ if (end === undefined || end <= start) {
1454
+ throw new _ResourcePlanner.AvailabilityError('REVALIDATION_FAILED', '当前时间没有可用营业时段,请选择预约时间');
1455
+ }
1456
+ const duration = Math.floor((end - start) / 60000);
1457
+ if (duration <= 0) {
1458
+ throw new _ResourcePlanner.AvailabilityError('REVALIDATION_FAILED', '灵活时长商品的结束时间必须晚于开始时间');
1459
+ }
1460
+ const endDate = (0, _dayjs.default)((0, _localClock.formatLocalDateTime)(start + duration * 60000));
1461
+ return {
1462
+ ...cacheItem,
1463
+ _extend: {
1464
+ ...extend,
1465
+ duration: _utils.flexibleObj.create(duration),
1466
+ endDate,
1467
+ end_date: endDate.format('YYYY-MM-DD'),
1468
+ end_time: endDate.format('HH:mm')
1469
+ }
1470
+ };
1471
+ }
1388
1472
  async resolveAvailabilityPrepareDefaults(params) {
1389
1473
  const needsOperatingHours = params.businessHours === undefined;
1390
1474
  const needsTimeSlice = params.slotStepMinutes === undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.160",
4
+ "version": "2.3.162",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",