@pisell/pisellos 2.2.109 → 2.2.111
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.
|
@@ -321,7 +321,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
321
321
|
key: "getBookingStatus",
|
|
322
322
|
value: function getBookingStatus(appointmentStatus) {
|
|
323
323
|
if (appointmentStatus === 'started') return 'occupied';
|
|
324
|
-
if (appointmentStatus === '
|
|
324
|
+
if (appointmentStatus === 'confirmed' || appointmentStatus === 'arrived') {
|
|
325
325
|
return 'reserved';
|
|
326
326
|
}
|
|
327
327
|
// TODO: locked 的业务规则后续补充。
|
|
@@ -383,6 +383,9 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
383
383
|
return startAt.isValid() && startAt.valueOf() === nextStartAt;
|
|
384
384
|
});
|
|
385
385
|
if (nextStartGroup.length === 0) return selectedBookings;
|
|
386
|
+
nextStartGroup.forEach(function (booking) {
|
|
387
|
+
booking.isNext = true;
|
|
388
|
+
});
|
|
386
389
|
return [].concat(_toConsumableArray(selectedBookings), _toConsumableArray(nextStartGroup));
|
|
387
390
|
};
|
|
388
391
|
|
|
@@ -431,7 +434,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
431
434
|
value: function normalizeMatchedBooking(current, deviceCurrent, booking) {
|
|
432
435
|
var _ref3, _booking$appointment_;
|
|
433
436
|
var appointmentStatus = String((_ref3 = (_booking$appointment_ = booking.appointment_status) !== null && _booking$appointment_ !== void 0 ? _booking$appointment_ : booking.status) !== null && _ref3 !== void 0 ? _ref3 : '');
|
|
434
|
-
if (appointmentStatus === 'rejected' || appointmentStatus === 'cancelled' || appointmentStatus === 'completed') {
|
|
437
|
+
if (appointmentStatus === 'new' || appointmentStatus === 'rejected' || appointmentStatus === 'cancelled' || appointmentStatus === 'completed') {
|
|
435
438
|
return null;
|
|
436
439
|
}
|
|
437
440
|
var endAt = this.toBookingDateTime(booking.end_date, booking.end_time);
|
|
@@ -463,6 +466,25 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
463
466
|
lateTime = Math.max(current.diff(startAt, 'minute'), 0);
|
|
464
467
|
}
|
|
465
468
|
}
|
|
469
|
+
|
|
470
|
+
// 未来查询投影:查询时间晚于设备时间时,预留+迟到且 end_time 仍在查询时间之后的预约强制视为占用
|
|
471
|
+
if (current.isAfter(deviceCurrent) && bookingStatus === 'reserved' && reservedStatus === 'late' && endAt.isValid() && endAt.isAfter(current)) {
|
|
472
|
+
bookingStatus = 'occupied';
|
|
473
|
+
reservedStatus = undefined;
|
|
474
|
+
lateTime = undefined;
|
|
475
|
+
remainingReserveTime = undefined;
|
|
476
|
+
isTimeout = false;
|
|
477
|
+
timeoutTime = undefined;
|
|
478
|
+
progressPercent = function () {
|
|
479
|
+
if (!startAt.isValid() || !endAt.isValid()) return 0;
|
|
480
|
+
var totalMinutes = endAt.diff(startAt, 'minute');
|
|
481
|
+
if (totalMinutes <= 0) return 0;
|
|
482
|
+
var elapsedMinutes = current.diff(startAt, 'minute');
|
|
483
|
+
if (elapsedMinutes <= 0) return 0;
|
|
484
|
+
if (elapsedMinutes >= totalMinutes) return 100;
|
|
485
|
+
return Math.floor(elapsedMinutes / totalMinutes * 100);
|
|
486
|
+
}();
|
|
487
|
+
}
|
|
466
488
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
467
489
|
status: bookingStatus,
|
|
468
490
|
isTimeout: isTimeout,
|
|
@@ -533,6 +555,8 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
533
555
|
return _this3.normalizeMatchedBooking(current, deviceCurrent, booking);
|
|
534
556
|
}).filter(function (booking) {
|
|
535
557
|
return Boolean(booking);
|
|
558
|
+
}).filter(function (booking) {
|
|
559
|
+
return !booking.status;
|
|
536
560
|
}).sort(function (left, right) {
|
|
537
561
|
var leftStartAt = _this3.toBookingDateTime(left.start_date, left.start_time).valueOf();
|
|
538
562
|
var rightStartAt = _this3.toBookingDateTime(right.start_date, right.start_time).valueOf();
|
|
@@ -20,6 +20,7 @@ export type SalesBookingStatus = 'reserved' | 'occupied' | 'locked' | undefined;
|
|
|
20
20
|
export type SalesReservedStatus = 'not_arrived' | 'late' | undefined;
|
|
21
21
|
export interface SalesResourceMatchedBooking extends Omit<BookingData, 'status'> {
|
|
22
22
|
status: SalesBookingStatus;
|
|
23
|
+
isNext?: boolean;
|
|
23
24
|
isTimeout: boolean;
|
|
24
25
|
timeoutTime?: number;
|
|
25
26
|
progressPercent?: number;
|
|
@@ -218,7 +218,7 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
218
218
|
getBookingStatus(appointmentStatus) {
|
|
219
219
|
if (appointmentStatus === "started")
|
|
220
220
|
return "occupied";
|
|
221
|
-
if (appointmentStatus === "
|
|
221
|
+
if (appointmentStatus === "confirmed" || appointmentStatus === "arrived") {
|
|
222
222
|
return "reserved";
|
|
223
223
|
}
|
|
224
224
|
if (appointmentStatus === "locked")
|
|
@@ -278,6 +278,9 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
278
278
|
});
|
|
279
279
|
if (nextStartGroup.length === 0)
|
|
280
280
|
return selectedBookings;
|
|
281
|
+
nextStartGroup.forEach((booking) => {
|
|
282
|
+
booking.isNext = true;
|
|
283
|
+
});
|
|
281
284
|
return [...selectedBookings, ...nextStartGroup];
|
|
282
285
|
};
|
|
283
286
|
const activeBookings = dayScopedBookings.filter((booking) => {
|
|
@@ -317,18 +320,18 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
317
320
|
*/
|
|
318
321
|
normalizeMatchedBooking(current, deviceCurrent, booking) {
|
|
319
322
|
const appointmentStatus = String(booking.appointment_status ?? booking.status ?? "");
|
|
320
|
-
if (appointmentStatus === "rejected" || appointmentStatus === "cancelled" || appointmentStatus === "completed") {
|
|
323
|
+
if (appointmentStatus === "new" || appointmentStatus === "rejected" || appointmentStatus === "cancelled" || appointmentStatus === "completed") {
|
|
321
324
|
return null;
|
|
322
325
|
}
|
|
323
326
|
const endAt = this.toBookingDateTime(booking.end_date, booking.end_time);
|
|
324
327
|
const shouldFilterHistoryByCurrent = deviceCurrent.isBefore(current);
|
|
325
328
|
if (shouldFilterHistoryByCurrent && endAt.isValid() && endAt.isBefore(current))
|
|
326
329
|
return null;
|
|
327
|
-
|
|
330
|
+
let bookingStatus = this.getBookingStatus(appointmentStatus);
|
|
328
331
|
const startAt = this.toBookingDateTime(booking.start_date, booking.start_time);
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
+
let isTimeout = bookingStatus === "occupied" && endAt.isValid() && current.isAfter(endAt);
|
|
333
|
+
let timeoutTime = isTimeout ? current.diff(endAt, "minute") : void 0;
|
|
334
|
+
let progressPercent = (() => {
|
|
332
335
|
if (bookingStatus !== "occupied")
|
|
333
336
|
return 0;
|
|
334
337
|
if (!startAt.isValid() || !endAt.isValid())
|
|
@@ -355,6 +358,27 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
355
358
|
lateTime = Math.max(current.diff(startAt, "minute"), 0);
|
|
356
359
|
}
|
|
357
360
|
}
|
|
361
|
+
if (current.isAfter(deviceCurrent) && bookingStatus === "reserved" && reservedStatus === "late" && endAt.isValid() && endAt.isAfter(current)) {
|
|
362
|
+
bookingStatus = "occupied";
|
|
363
|
+
reservedStatus = void 0;
|
|
364
|
+
lateTime = void 0;
|
|
365
|
+
remainingReserveTime = void 0;
|
|
366
|
+
isTimeout = false;
|
|
367
|
+
timeoutTime = void 0;
|
|
368
|
+
progressPercent = (() => {
|
|
369
|
+
if (!startAt.isValid() || !endAt.isValid())
|
|
370
|
+
return 0;
|
|
371
|
+
const totalMinutes = endAt.diff(startAt, "minute");
|
|
372
|
+
if (totalMinutes <= 0)
|
|
373
|
+
return 0;
|
|
374
|
+
const elapsedMinutes = current.diff(startAt, "minute");
|
|
375
|
+
if (elapsedMinutes <= 0)
|
|
376
|
+
return 0;
|
|
377
|
+
if (elapsedMinutes >= totalMinutes)
|
|
378
|
+
return 100;
|
|
379
|
+
return Math.floor(elapsedMinutes / totalMinutes * 100);
|
|
380
|
+
})();
|
|
381
|
+
}
|
|
358
382
|
return {
|
|
359
383
|
...booking,
|
|
360
384
|
status: bookingStatus,
|
|
@@ -383,7 +407,7 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
383
407
|
const resourceList = ((_a = resourceResponse == null ? void 0 : resourceResponse.data) == null ? void 0 : _a.list) ?? [];
|
|
384
408
|
if (!Array.isArray(resourceList) || resourceList.length === 0)
|
|
385
409
|
return [];
|
|
386
|
-
const normalizedBookings = bookingList.map((booking) => this.normalizeMatchedBooking(current, deviceCurrent, booking)).filter((booking) => Boolean(booking)).sort((left, right) => {
|
|
410
|
+
const normalizedBookings = bookingList.map((booking) => this.normalizeMatchedBooking(current, deviceCurrent, booking)).filter((booking) => Boolean(booking)).filter((booking) => !booking.status).sort((left, right) => {
|
|
387
411
|
const leftStartAt = this.toBookingDateTime(left.start_date, left.start_time).valueOf();
|
|
388
412
|
const rightStartAt = this.toBookingDateTime(right.start_date, right.start_time).valueOf();
|
|
389
413
|
return leftStartAt - rightStartAt;
|
|
@@ -20,6 +20,7 @@ export type SalesBookingStatus = 'reserved' | 'occupied' | 'locked' | undefined;
|
|
|
20
20
|
export type SalesReservedStatus = 'not_arrived' | 'late' | undefined;
|
|
21
21
|
export interface SalesResourceMatchedBooking extends Omit<BookingData, 'status'> {
|
|
22
22
|
status: SalesBookingStatus;
|
|
23
|
+
isNext?: boolean;
|
|
23
24
|
isTimeout: boolean;
|
|
24
25
|
timeoutTime?: number;
|
|
25
26
|
progressPercent?: number;
|