@pisell/pisellos 2.2.109 → 2.2.110
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,
|
|
@@ -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;
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
+
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
+
default: () => import_adapter2.default
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
+
var import_evaluator = require("./evaluator");
|
|
40
|
+
var import_adapter = require("./adapter");
|
|
41
|
+
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
+
var import_examples = require("./examples");
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
+
PromotionAdapter,
|
|
47
|
+
PromotionEvaluator,
|
|
48
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
+
});
|
|
@@ -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,
|
|
@@ -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;
|