@pisell/pisellos 2.3.92 → 2.3.94

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.
@@ -218,7 +218,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
218
218
  open_quotation: 1
219
219
  }), {}, {
220
220
  open_bundle: 0,
221
- exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item', 'appointment_ticket'],
221
+ exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item'],
222
222
  with: _toConsumableArray(PRODUCT_QUERY_DATA_VARIANT_RELATIONS),
223
223
  status: status,
224
224
  num: 500,
@@ -14,8 +14,8 @@ import { AvailabilityError } from "./types";
14
14
  import { addLocalCalendarDays, addLocalHours, addLocalMinutes, captureRuntimeOffsetMinutes, ceilLocalScalarToTenMinutes, dateOrdinalFromLocalDate, extractFixedOffsetMinutes, formatLocalDate, formatLocalDateTime, formatLocalTime, localDateTimeToScalar, localDateToScalar, localDateToScalarStart, nextDate as getNextLocalDate, parseLocalDate, parseLocalDateTime, weekdayFromLocalDate } from "./localClock";
15
15
  var DEFAULT_SLOT_STEP_MINUTES = 30;
16
16
  var DEFAULT_BUSINESS_HOURS = {
17
- startTime: '09:00',
18
- endTime: '18:00'
17
+ startTime: '00:00',
18
+ endTime: '00:00'
19
19
  };
20
20
  function availabilityError(code, message, details) {
21
21
  return new AvailabilityError(code, message, details);
@@ -1072,7 +1072,9 @@ export function getProductTimeRanges(projection) {
1072
1072
  var startsInOperatingRange = operatingRanges.some(function (range) {
1073
1073
  return range.start <= start && start < range.end;
1074
1074
  });
1075
- if (!startsInOperatingRange) return;
1075
+ if (!startsInOperatingRange && !request.allowOutsideOperatingHoursForRequestedStartTimes) {
1076
+ return;
1077
+ }
1076
1078
  ranges.push(createDurationTimeRange(product, start, durationMinutes, projection, fixedOffsetMinutes));
1077
1079
  });
1078
1080
  }
@@ -234,6 +234,11 @@ export interface GetProductTimeRangesRequest {
234
234
  partySize?: number;
235
235
  durationMinutesByProductId?: Record<string, number>;
236
236
  durationStartTimesByProductId?: Record<string, string[]>;
237
+ /**
238
+ * POS 手工输入时间的兼容开关:只为明确请求的 start time 补候选,
239
+ * 不改变常规候选列表仍按营业时间生成的规则。
240
+ */
241
+ allowOutsideOperatingHoursForRequestedStartTimes?: boolean;
237
242
  }
238
243
  export interface QueryAvailabilityBaseRequest {
239
244
  productIds?: AvailabilityId[];
@@ -202,8 +202,9 @@ function filterCustomerBoundDiscounts(discountList) {
202
202
  }
203
203
  var DEFAULT_AVAILABILITY_SLOT_STEP_MINUTES = 30;
204
204
  var DEFAULT_AVAILABILITY_BUSINESS_HOURS = {
205
- startTime: '09:00',
206
- endTime: '18:00'
205
+ // Same start/end is interpreted as an overnight range, i.e. 24 hours.
206
+ startTime: '00:00',
207
+ endTime: '00:00'
207
208
  };
208
209
  var MAX_AVAILABILITY_RANGE_DAYS = 90;
209
210
  var MAX_AVAILABILITY_CONTEXT_REGISTRY = 128;
@@ -4195,12 +4196,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4195
4196
  key: "getProductTimeRanges",
4196
4197
  value: (function () {
4197
4198
  var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(contextId) {
4198
- var _this9 = this;
4199
+ var _this$otherParams$pla,
4200
+ _this$otherParams17,
4201
+ _this9 = this;
4199
4202
  var request,
4200
4203
  _yield$this$ensureAva,
4201
4204
  context,
4202
4205
  projectionEntry,
4203
4206
  contextVersion,
4207
+ allowOutsideOperatingHoursForRequestedStartTimes,
4204
4208
  _args35 = arguments;
4205
4209
  return _regeneratorRuntime().wrap(function _callee35$(_context35) {
4206
4210
  while (1) switch (_context35.prev = _context35.next) {
@@ -4213,14 +4217,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4213
4217
  context = _yield$this$ensureAva.context;
4214
4218
  projectionEntry = _yield$this$ensureAva.projectionEntry;
4215
4219
  contextVersion = context.activeVersion;
4216
- return _context35.abrupt("return", getProjectionProductTimeRanges(projectionEntry.projection, request).map(function (group) {
4220
+ allowOutsideOperatingHoursForRequestedStartTimes = String((_this$otherParams$pla = (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.platform) !== null && _this$otherParams$pla !== void 0 ? _this$otherParams$pla : '').trim().toLowerCase() === 'pos' && Object.values(request.durationStartTimesByProductId || {}).some(function (startTimes) {
4221
+ return Array.isArray(startTimes) && startTimes.length > 0;
4222
+ });
4223
+ return _context35.abrupt("return", getProjectionProductTimeRanges(projectionEntry.projection, _objectSpread(_objectSpread({}, request), allowOutsideOperatingHoursForRequestedStartTimes ? {
4224
+ allowOutsideOperatingHoursForRequestedStartTimes: true
4225
+ } : {})).map(function (group) {
4217
4226
  return _objectSpread(_objectSpread({}, group), {}, {
4218
4227
  ranges: group.ranges.map(function (candidate) {
4219
4228
  return _this9.decorateAvailabilityCandidate(context.contextId, contextVersion, candidate);
4220
4229
  })
4221
4230
  });
4222
4231
  }));
4223
- case 8:
4232
+ case 9:
4224
4233
  case "end":
4225
4234
  return _context35.stop();
4226
4235
  }
@@ -4356,7 +4365,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4356
4365
  key: "commitAvailabilitySelection",
4357
4366
  value: (function () {
4358
4367
  var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(contextId, params) {
4359
- var normalizedContextId, _params$bookingCount, _ref46, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla, _this$otherParams17, _ref47, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref48, _ref49, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, refreshedRanges, refreshedCandidateBase, product, validation, allowPosAvailabilityOverride, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref50, _transformed$product_4, _this$getTempOrder4, _this$getTempOrder5, _this$getTempOrder6, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, nextContext, result;
4368
+ var normalizedContextId, _params$bookingCount, _ref46, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla2, _this$otherParams18, _ref47, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref48, _ref49, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref50, _transformed$product_4, _this$getTempOrder4, _this$getTempOrder5, _this$getTempOrder6, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, nextContext, result;
4360
4369
  return _regeneratorRuntime().wrap(function _callee37$(_context37) {
4361
4370
  while (1) switch (_context37.prev = _context37.next) {
4362
4371
  case 0:
@@ -4586,6 +4595,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4586
4595
  this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
4587
4596
  candidateDurationMinutes = getCandidateDurationMinutes(params.candidate);
4588
4597
  candidateStartTime = getCandidateStartTime(params.candidate);
4598
+ allowPosAvailabilityOverride = String((_this$otherParams$pla2 = (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
4589
4599
  refreshedRanges = getProjectionProductTimeRanges(refreshedProjection, _objectSpread({
4590
4600
  productIds: [params.candidate.productId],
4591
4601
  dateRange: {
@@ -4594,16 +4604,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4594
4604
  }
4595
4605
  }, candidateDurationMinutes ? _objectSpread({
4596
4606
  durationMinutesByProductId: _defineProperty({}, String(params.candidate.productId), candidateDurationMinutes)
4597
- }, candidateStartTime ? {
4607
+ }, candidateStartTime ? _objectSpread({
4598
4608
  durationStartTimesByProductId: _defineProperty({}, String(params.candidate.productId), [candidateStartTime])
4599
- } : {}) : {})).flatMap(function (group) {
4609
+ }, allowPosAvailabilityOverride ? {
4610
+ allowOutsideOperatingHoursForRequestedStartTimes: true
4611
+ } : {}) : {}) : {})).flatMap(function (group) {
4600
4612
  return group.ranges;
4601
4613
  });
4602
4614
  refreshedCandidateBase = refreshedRanges.find(function (candidate) {
4603
4615
  return candidate.startAt === params.candidate.startAt && candidate.endAt === params.candidate.endAt && candidate.bookingStartAt === params.candidate.bookingStartAt && candidate.bookingEndAt === params.candidate.bookingEndAt;
4604
4616
  });
4605
4617
  if (refreshedCandidateBase) {
4606
- _context37.next = 74;
4618
+ _context37.next = 75;
4607
4619
  break;
4608
4620
  }
4609
4621
  throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后候选时间已不在商品配置中', {
@@ -4611,25 +4623,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4611
4623
  candidate: params.candidate,
4612
4624
  refreshedSnapshotId: refreshedProjection.meta.snapshotId
4613
4625
  });
4614
- case 74:
4626
+ case 75:
4615
4627
  product = refreshedProjection.products.find(function (item) {
4616
4628
  return sameAvailabilityId(item.id, refreshedCandidateBase.productId);
4617
4629
  });
4618
4630
  if (product) {
4619
- _context37.next = 77;
4631
+ _context37.next = 78;
4620
4632
  break;
4621
4633
  }
4622
4634
  throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后商品不在 projection 中', {
4623
4635
  productId: refreshedCandidateBase.productId
4624
4636
  });
4625
- case 77:
4637
+ case 78:
4626
4638
  validation = validateAvailabilitySelection(refreshedProjection, {
4627
4639
  candidate: refreshedCandidateBase,
4628
4640
  requirementSelections: params.requirementSelections,
4629
4641
  partySize: partySize,
4630
4642
  bookingCount: bookingCount
4631
4643
  });
4632
- allowPosAvailabilityOverride = String((_this$otherParams$pla = (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.platform) !== null && _this$otherParams$pla !== void 0 ? _this$otherParams$pla : '').trim().toLowerCase() === 'pos';
4633
4644
  if (allowPosAvailabilityOverride && !validation.ok && validation.conflicts.every(function (conflict) {
4634
4645
  return POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES.has(conflict.code);
4635
4646
  })) {
@@ -126,7 +126,7 @@ class ProductList extends _BaseModule.BaseModule {
126
126
  open_quotation: 1
127
127
  }),
128
128
  open_bundle: 0,
129
- exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item', 'appointment_ticket'],
129
+ exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item'],
130
130
  with: [..._clientDataVariants.PRODUCT_QUERY_DATA_VARIANT_RELATIONS],
131
131
  status,
132
132
  num: 500,
@@ -11,8 +11,8 @@ var _types = require("./types");
11
11
  var _localClock = require("./localClock");
12
12
  const DEFAULT_SLOT_STEP_MINUTES = 30;
13
13
  const DEFAULT_BUSINESS_HOURS = {
14
- startTime: '09:00',
15
- endTime: '18:00'
14
+ startTime: '00:00',
15
+ endTime: '00:00'
16
16
  };
17
17
  function availabilityError(code, message, details) {
18
18
  return new _types.AvailabilityError(code, message, details);
@@ -959,7 +959,9 @@ function getProductTimeRanges(projection, request = {}) {
959
959
  if (!Number.isFinite(start)) return;
960
960
  const end = addMinutesZoned(start, durationMinutes, projection.meta.timezone);
961
961
  const startsInOperatingRange = operatingRanges.some(range => range.start <= start && start < range.end);
962
- if (!startsInOperatingRange) return;
962
+ if (!startsInOperatingRange && !request.allowOutsideOperatingHoursForRequestedStartTimes) {
963
+ return;
964
+ }
963
965
  ranges.push(createDurationTimeRange(product, start, durationMinutes, projection, fixedOffsetMinutes));
964
966
  });
965
967
  }
@@ -234,6 +234,11 @@ export interface GetProductTimeRangesRequest {
234
234
  partySize?: number;
235
235
  durationMinutesByProductId?: Record<string, number>;
236
236
  durationStartTimesByProductId?: Record<string, string[]>;
237
+ /**
238
+ * POS 手工输入时间的兼容开关:只为明确请求的 start time 补候选,
239
+ * 不改变常规候选列表仍按营业时间生成的规则。
240
+ */
241
+ allowOutsideOperatingHoursForRequestedStartTimes?: boolean;
237
242
  }
238
243
  export interface QueryAvailabilityBaseRequest {
239
244
  productIds?: AvailabilityId[];
@@ -190,8 +190,9 @@ function filterCustomerBoundDiscounts(discountList) {
190
190
  }
191
191
  const DEFAULT_AVAILABILITY_SLOT_STEP_MINUTES = 30;
192
192
  const DEFAULT_AVAILABILITY_BUSINESS_HOURS = {
193
- startTime: '09:00',
194
- endTime: '18:00'
193
+ // Same start/end is interpreted as an overnight range, i.e. 24 hours.
194
+ startTime: '00:00',
195
+ endTime: '00:00'
195
196
  };
196
197
  const MAX_AVAILABILITY_RANGE_DAYS = 90;
197
198
  const MAX_AVAILABILITY_CONTEXT_REGISTRY = 128;
@@ -2803,7 +2804,13 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2803
2804
  projectionEntry
2804
2805
  } = await this.ensureAvailabilityContextProjection(contextId, 'get_product_time_ranges');
2805
2806
  const contextVersion = context.activeVersion;
2806
- return (0, _ResourcePlanner.getProductTimeRanges)(projectionEntry.projection, request).map(group => ({
2807
+ const allowOutsideOperatingHoursForRequestedStartTimes = String(this.otherParams?.platform ?? '').trim().toLowerCase() === 'pos' && Object.values(request.durationStartTimesByProductId || {}).some(startTimes => Array.isArray(startTimes) && startTimes.length > 0);
2808
+ return (0, _ResourcePlanner.getProductTimeRanges)(projectionEntry.projection, {
2809
+ ...request,
2810
+ ...(allowOutsideOperatingHoursForRequestedStartTimes ? {
2811
+ allowOutsideOperatingHoursForRequestedStartTimes: true
2812
+ } : {})
2813
+ }).map(group => ({
2807
2814
  ...group,
2808
2815
  ranges: group.ranges.map(candidate => this.decorateAvailabilityCandidate(context.contextId, contextVersion, candidate))
2809
2816
  }));
@@ -3053,6 +3060,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3053
3060
  this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
3054
3061
  const candidateDurationMinutes = getCandidateDurationMinutes(params.candidate);
3055
3062
  const candidateStartTime = getCandidateStartTime(params.candidate);
3063
+ const allowPosAvailabilityOverride = String(this.otherParams?.platform ?? '').trim().toLowerCase() === 'pos';
3056
3064
  const refreshedRanges = (0, _ResourcePlanner.getProductTimeRanges)(refreshedProjection, {
3057
3065
  productIds: [params.candidate.productId],
3058
3066
  dateRange: {
@@ -3066,7 +3074,10 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3066
3074
  ...(candidateStartTime ? {
3067
3075
  durationStartTimesByProductId: {
3068
3076
  [String(params.candidate.productId)]: [candidateStartTime]
3069
- }
3077
+ },
3078
+ ...(allowPosAvailabilityOverride ? {
3079
+ allowOutsideOperatingHoursForRequestedStartTimes: true
3080
+ } : {})
3070
3081
  } : {})
3071
3082
  } : {})
3072
3083
  }).flatMap(group => group.ranges);
@@ -3090,7 +3101,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3090
3101
  partySize,
3091
3102
  bookingCount
3092
3103
  });
3093
- const allowPosAvailabilityOverride = String(this.otherParams?.platform ?? '').trim().toLowerCase() === 'pos';
3094
3104
  if (allowPosAvailabilityOverride && !validation.ok && validation.conflicts.every(conflict => POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES.has(conflict.code))) {
3095
3105
  const forced = buildPosForcedAvailabilityAssignments({
3096
3106
  product,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.92",
4
+ "version": "2.3.94",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",