@pisell/pisellos 2.2.199 → 2.2.201
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/modules/Order/index.js +2 -2
- package/dist/solution/BaseSales/index.js +2 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +23 -0
- package/dist/solution/BookingTicket/index.js +291 -196
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +70 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Order/index.js +2 -2
- package/lib/solution/BaseSales/index.js +2 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +23 -0
- package/lib/solution/BookingTicket/index.js +60 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +40 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +44 -2
- package/package.json +1 -1
|
@@ -9,6 +9,21 @@
|
|
|
9
9
|
* 字段含义严格对齐既有协议(OrderTempOrder / parseSalesResponse),
|
|
10
10
|
* 不发明等价关系。
|
|
11
11
|
*/
|
|
12
|
+
/**
|
|
13
|
+
* 子预约状态机转移动作(POST /schedule/booking-transition/{schedule_event_id})。
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* await bookingTicket.transitionChildBooking({
|
|
17
|
+
* schedule_event_id: 301,
|
|
18
|
+
* action: 'confirm',
|
|
19
|
+
* });
|
|
20
|
+
*/
|
|
21
|
+
export type BookingTransitionAction = 'confirm' | 'reject' | 'arrive' | 'start' | 'complete' | 'cancel' | 'no_show' | 'reschedule';
|
|
22
|
+
/** 子预约状态转移入参 */
|
|
23
|
+
export interface TransitionChildBookingParams {
|
|
24
|
+
schedule_event_id: number | string;
|
|
25
|
+
action: BookingTransitionAction;
|
|
26
|
+
}
|
|
12
27
|
/**
|
|
13
28
|
* 从 tempOrder 解析用于调用 appointment-status 接口的 schedule id。
|
|
14
29
|
*
|
|
@@ -35,3 +50,28 @@ export declare function applyBookingsStatus(bookings: any[] | null | undefined,
|
|
|
35
50
|
* 长度不一致时按较短一方对齐(防御式编程,正常路径不会发生)。
|
|
36
51
|
*/
|
|
37
52
|
export declare function restoreBookingsStatus(bookings: any[] | null | undefined, previous: Array<string | undefined>): void;
|
|
53
|
+
/**
|
|
54
|
+
* 将状态机 action 解析为转移后的 `appointment_status`。
|
|
55
|
+
*
|
|
56
|
+
* `reschedule` 暂未在状态矩阵启用,返回 null 表示跳过乐观更新。
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* resolveStatusAfterTransition('confirm'); // 'confirmed'
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveStatusAfterTransition(action: BookingTransitionAction): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* 在 bookings 中按 `schedule_event_id` 定位子预约并乐观写入 `appointment_status`。
|
|
64
|
+
*
|
|
65
|
+
* @returns 写入前的 status;未命中时返回 undefined(调用方跳过回滚)
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* const prev = applyChildBookingStatus(tempOrder.bookings, 301, 'confirmed');
|
|
69
|
+
*/
|
|
70
|
+
export declare function applyChildBookingStatus(bookings: any[] | null | undefined, scheduleEventId: number | string, status: string): string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* 撤销 applyChildBookingStatus 对单条子预约的乐观写入。
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* restoreChildBookingStatus(tempOrder.bookings, 301, prev);
|
|
76
|
+
*/
|
|
77
|
+
export declare function restoreChildBookingStatus(bookings: any[] | null | undefined, scheduleEventId: number | string, previous: string | undefined): void;
|
|
@@ -10,6 +10,18 @@
|
|
|
10
10
|
* 不发明等价关系。
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* 子预约状态机转移动作(POST /schedule/booking-transition/{schedule_event_id})。
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* await bookingTicket.transitionChildBooking({
|
|
18
|
+
* schedule_event_id: 301,
|
|
19
|
+
* action: 'confirm',
|
|
20
|
+
* });
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** 子预约状态转移入参 */
|
|
24
|
+
|
|
13
25
|
/**
|
|
14
26
|
* 从 tempOrder 解析用于调用 appointment-status 接口的 schedule id。
|
|
15
27
|
*
|
|
@@ -63,4 +75,62 @@ export function restoreBookingsStatus(bookings, previous) {
|
|
|
63
75
|
var b = bookings[i];
|
|
64
76
|
if (b) b.appointment_status = previous[i];
|
|
65
77
|
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 将状态机 action 解析为转移后的 `appointment_status`。
|
|
82
|
+
*
|
|
83
|
+
* `reschedule` 暂未在状态矩阵启用,返回 null 表示跳过乐观更新。
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* resolveStatusAfterTransition('confirm'); // 'confirmed'
|
|
87
|
+
*/
|
|
88
|
+
export function resolveStatusAfterTransition(action) {
|
|
89
|
+
var _map$action;
|
|
90
|
+
var map = {
|
|
91
|
+
confirm: 'confirmed',
|
|
92
|
+
reject: 'rejected',
|
|
93
|
+
arrive: 'arrived',
|
|
94
|
+
start: 'started',
|
|
95
|
+
complete: 'completed',
|
|
96
|
+
cancel: 'cancelled',
|
|
97
|
+
no_show: 'no_show',
|
|
98
|
+
reschedule: null
|
|
99
|
+
};
|
|
100
|
+
return (_map$action = map[action]) !== null && _map$action !== void 0 ? _map$action : null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 在 bookings 中按 `schedule_event_id` 定位子预约并乐观写入 `appointment_status`。
|
|
105
|
+
*
|
|
106
|
+
* @returns 写入前的 status;未命中时返回 undefined(调用方跳过回滚)
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* const prev = applyChildBookingStatus(tempOrder.bookings, 301, 'confirmed');
|
|
110
|
+
*/
|
|
111
|
+
export function applyChildBookingStatus(bookings, scheduleEventId, status) {
|
|
112
|
+
var _bookings$idx;
|
|
113
|
+
if (!Array.isArray(bookings)) return undefined;
|
|
114
|
+
var idx = bookings.findIndex(function (b) {
|
|
115
|
+
return b && String(b.schedule_event_id) === String(scheduleEventId);
|
|
116
|
+
});
|
|
117
|
+
if (idx === -1) return undefined;
|
|
118
|
+
var previous = (_bookings$idx = bookings[idx]) === null || _bookings$idx === void 0 ? void 0 : _bookings$idx.appointment_status;
|
|
119
|
+
bookings[idx].appointment_status = status;
|
|
120
|
+
return previous;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 撤销 applyChildBookingStatus 对单条子预约的乐观写入。
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* restoreChildBookingStatus(tempOrder.bookings, 301, prev);
|
|
128
|
+
*/
|
|
129
|
+
export function restoreChildBookingStatus(bookings, scheduleEventId, previous) {
|
|
130
|
+
if (!Array.isArray(bookings) || previous === undefined) return;
|
|
131
|
+
var idx = bookings.findIndex(function (b) {
|
|
132
|
+
return b && String(b.schedule_event_id) === String(scheduleEventId);
|
|
133
|
+
});
|
|
134
|
+
if (idx === -1) return;
|
|
135
|
+
bookings[idx].appointment_status = previous;
|
|
66
136
|
}
|
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -730,8 +730,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
730
730
|
normalizePaymentSource(payment, options) {
|
|
731
731
|
const paymentRecord = payment;
|
|
732
732
|
const metadata = paymentRecord.metadata && typeof paymentRecord.metadata === "object" ? { ...paymentRecord.metadata } : {};
|
|
733
|
-
if (!metadata.
|
|
734
|
-
metadata.
|
|
733
|
+
if (!metadata.unique_payment_number) {
|
|
734
|
+
metadata.unique_payment_number = (0, import_utils.createUuidV4)();
|
|
735
735
|
}
|
|
736
736
|
const normalized = {
|
|
737
737
|
...paymentRecord,
|
|
@@ -1253,8 +1253,8 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1253
1253
|
if (shopWalletPassId !== void 0 && shopWalletPassId !== null) {
|
|
1254
1254
|
metadata.shop_wallet_pass_id = shopWalletPassId;
|
|
1255
1255
|
}
|
|
1256
|
-
if (!metadata.
|
|
1257
|
-
metadata.
|
|
1256
|
+
if (!metadata.unique_payment_number) {
|
|
1257
|
+
metadata.unique_payment_number = (0, import_utils.createUuidV4)();
|
|
1258
1258
|
}
|
|
1259
1259
|
const payments = this.store.order.addOrderPayment({
|
|
1260
1260
|
...paymentRecord,
|
|
@@ -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 | 2 | 1 | 6 | 3 | 4 | 5;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -12,6 +12,8 @@ import { AddProductDecideContext, AddProductRequiresDetailPayload } from './util
|
|
|
12
12
|
import { type BuildCacheItemFromOrderLineInput } from '../../modules/BookingContext/utils/buildCacheItemFromOrderLine';
|
|
13
13
|
import { type BuildNormalProductCacheItemFromOrderLineInput } from '../../modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine';
|
|
14
14
|
import type { AddProductBookingInput, OrderProduct, OrderProductIdentity, UpdateOrderProductParams } from '../../modules/Order/types';
|
|
15
|
+
import { type TransitionChildBookingParams } from './utils/bookingStatus';
|
|
16
|
+
export type { BookingTransitionAction, TransitionChildBookingParams, } from './utils/bookingStatus';
|
|
15
17
|
export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
16
18
|
protected defaultName: string;
|
|
17
19
|
protected defaultVersion: string;
|
|
@@ -68,6 +70,27 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
68
70
|
* @returns 接口返回的 data
|
|
69
71
|
*/
|
|
70
72
|
setBookingStatus(status: string): Promise<any>;
|
|
73
|
+
/**
|
|
74
|
+
* 子预约状态机转移(POST /schedule/booking-transition/{schedule_event_id})。
|
|
75
|
+
*
|
|
76
|
+
* 与 `setBookingStatus`(父预约 PUT appointment-status)不同,本方法按子预约
|
|
77
|
+
* `schedule_event_id` 调用状态转移接口,body 为 `{ action }`。
|
|
78
|
+
*
|
|
79
|
+
* 流程:能解析出目标状态时先乐观更新对应子预约的 `appointment_status`,
|
|
80
|
+
* 再调 POST;成功后强制刷新销售详情;失败则回滚该子预约本地状态并抛错。
|
|
81
|
+
* `reschedule` 暂未启用状态矩阵,跳过乐观更新仅调接口。
|
|
82
|
+
*
|
|
83
|
+
* @param params.schedule_event_id 子预约 schedule_event_id
|
|
84
|
+
* @param params.action 转移动作:confirm | reject | arrive | start | complete | cancel | no_show | reschedule
|
|
85
|
+
* @returns 接口返回的 data
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* await bookingTicket.transitionChildBooking({
|
|
89
|
+
* schedule_event_id: 301,
|
|
90
|
+
* action: 'confirm',
|
|
91
|
+
* });
|
|
92
|
+
*/
|
|
93
|
+
transitionChildBooking(params: TransitionChildBookingParams): Promise<any>;
|
|
71
94
|
/**
|
|
72
95
|
* 基于当前 tempOrder.order_id 强制从远端重新拉取销售详情。
|
|
73
96
|
*
|
|
@@ -274,6 +274,66 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
274
274
|
throw error;
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* 子预约状态机转移(POST /schedule/booking-transition/{schedule_event_id})。
|
|
279
|
+
*
|
|
280
|
+
* 与 `setBookingStatus`(父预约 PUT appointment-status)不同,本方法按子预约
|
|
281
|
+
* `schedule_event_id` 调用状态转移接口,body 为 `{ action }`。
|
|
282
|
+
*
|
|
283
|
+
* 流程:能解析出目标状态时先乐观更新对应子预约的 `appointment_status`,
|
|
284
|
+
* 再调 POST;成功后强制刷新销售详情;失败则回滚该子预约本地状态并抛错。
|
|
285
|
+
* `reschedule` 暂未启用状态矩阵,跳过乐观更新仅调接口。
|
|
286
|
+
*
|
|
287
|
+
* @param params.schedule_event_id 子预约 schedule_event_id
|
|
288
|
+
* @param params.action 转移动作:confirm | reject | arrive | start | complete | cancel | no_show | reschedule
|
|
289
|
+
* @returns 接口返回的 data
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* await bookingTicket.transitionChildBooking({
|
|
293
|
+
* schedule_event_id: 301,
|
|
294
|
+
* action: 'confirm',
|
|
295
|
+
* });
|
|
296
|
+
*/
|
|
297
|
+
async transitionChildBooking(params) {
|
|
298
|
+
var _a, _b;
|
|
299
|
+
const { schedule_event_id, action } = params;
|
|
300
|
+
if (schedule_event_id === void 0 || schedule_event_id === null || schedule_event_id === "") {
|
|
301
|
+
throw new Error("transitionChildBooking: schedule_event_id 不能为空");
|
|
302
|
+
}
|
|
303
|
+
if (!action) {
|
|
304
|
+
throw new Error("transitionChildBooking: action 不能为空");
|
|
305
|
+
}
|
|
306
|
+
const tempOrder = (_b = (_a = this.store.order) == null ? void 0 : _a.getTempOrder) == null ? void 0 : _b.call(_a);
|
|
307
|
+
if (!tempOrder) {
|
|
308
|
+
throw new Error("transitionChildBooking: tempOrder 未加载");
|
|
309
|
+
}
|
|
310
|
+
const orderId = tempOrder.order_id;
|
|
311
|
+
if (orderId === void 0 || orderId === null) {
|
|
312
|
+
throw new Error("transitionChildBooking: tempOrder.order_id 缺失");
|
|
313
|
+
}
|
|
314
|
+
const bookings = Array.isArray(tempOrder.bookings) ? tempOrder.bookings : [];
|
|
315
|
+
const targetStatus = (0, import_bookingStatus.resolveStatusAfterTransition)(action);
|
|
316
|
+
const previous = targetStatus !== null ? (0, import_bookingStatus.applyChildBookingStatus)(bookings, schedule_event_id, targetStatus) : void 0;
|
|
317
|
+
try {
|
|
318
|
+
const res = await this.request.post(
|
|
319
|
+
`/schedule/booking-transition/${schedule_event_id}`,
|
|
320
|
+
{ action }
|
|
321
|
+
);
|
|
322
|
+
await this.refreshSalesDetail();
|
|
323
|
+
this.core.effects.emit(`${this.name}:onChildBookingStatusChange`, {
|
|
324
|
+
orderId,
|
|
325
|
+
schedule_event_id,
|
|
326
|
+
action,
|
|
327
|
+
status: targetStatus
|
|
328
|
+
});
|
|
329
|
+
return (res == null ? void 0 : res.data) ?? res;
|
|
330
|
+
} catch (error) {
|
|
331
|
+
if (previous !== void 0) {
|
|
332
|
+
(0, import_bookingStatus.restoreChildBookingStatus)(bookings, schedule_event_id, previous);
|
|
333
|
+
}
|
|
334
|
+
throw error;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
277
337
|
/**
|
|
278
338
|
* 基于当前 tempOrder.order_id 强制从远端重新拉取销售详情。
|
|
279
339
|
*
|
|
@@ -9,6 +9,21 @@
|
|
|
9
9
|
* 字段含义严格对齐既有协议(OrderTempOrder / parseSalesResponse),
|
|
10
10
|
* 不发明等价关系。
|
|
11
11
|
*/
|
|
12
|
+
/**
|
|
13
|
+
* 子预约状态机转移动作(POST /schedule/booking-transition/{schedule_event_id})。
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* await bookingTicket.transitionChildBooking({
|
|
17
|
+
* schedule_event_id: 301,
|
|
18
|
+
* action: 'confirm',
|
|
19
|
+
* });
|
|
20
|
+
*/
|
|
21
|
+
export type BookingTransitionAction = 'confirm' | 'reject' | 'arrive' | 'start' | 'complete' | 'cancel' | 'no_show' | 'reschedule';
|
|
22
|
+
/** 子预约状态转移入参 */
|
|
23
|
+
export interface TransitionChildBookingParams {
|
|
24
|
+
schedule_event_id: number | string;
|
|
25
|
+
action: BookingTransitionAction;
|
|
26
|
+
}
|
|
12
27
|
/**
|
|
13
28
|
* 从 tempOrder 解析用于调用 appointment-status 接口的 schedule id。
|
|
14
29
|
*
|
|
@@ -35,3 +50,28 @@ export declare function applyBookingsStatus(bookings: any[] | null | undefined,
|
|
|
35
50
|
* 长度不一致时按较短一方对齐(防御式编程,正常路径不会发生)。
|
|
36
51
|
*/
|
|
37
52
|
export declare function restoreBookingsStatus(bookings: any[] | null | undefined, previous: Array<string | undefined>): void;
|
|
53
|
+
/**
|
|
54
|
+
* 将状态机 action 解析为转移后的 `appointment_status`。
|
|
55
|
+
*
|
|
56
|
+
* `reschedule` 暂未在状态矩阵启用,返回 null 表示跳过乐观更新。
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* resolveStatusAfterTransition('confirm'); // 'confirmed'
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveStatusAfterTransition(action: BookingTransitionAction): string | null;
|
|
62
|
+
/**
|
|
63
|
+
* 在 bookings 中按 `schedule_event_id` 定位子预约并乐观写入 `appointment_status`。
|
|
64
|
+
*
|
|
65
|
+
* @returns 写入前的 status;未命中时返回 undefined(调用方跳过回滚)
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* const prev = applyChildBookingStatus(tempOrder.bookings, 301, 'confirmed');
|
|
69
|
+
*/
|
|
70
|
+
export declare function applyChildBookingStatus(bookings: any[] | null | undefined, scheduleEventId: number | string, status: string): string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* 撤销 applyChildBookingStatus 对单条子预约的乐观写入。
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* restoreChildBookingStatus(tempOrder.bookings, 301, prev);
|
|
76
|
+
*/
|
|
77
|
+
export declare function restoreChildBookingStatus(bookings: any[] | null | undefined, scheduleEventId: number | string, previous: string | undefined): void;
|
|
@@ -20,8 +20,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var bookingStatus_exports = {};
|
|
21
21
|
__export(bookingStatus_exports, {
|
|
22
22
|
applyBookingsStatus: () => applyBookingsStatus,
|
|
23
|
+
applyChildBookingStatus: () => applyChildBookingStatus,
|
|
23
24
|
resolveScheduleId: () => resolveScheduleId,
|
|
24
|
-
|
|
25
|
+
resolveStatusAfterTransition: () => resolveStatusAfterTransition,
|
|
26
|
+
restoreBookingsStatus: () => restoreBookingsStatus,
|
|
27
|
+
restoreChildBookingStatus: () => restoreChildBookingStatus
|
|
25
28
|
});
|
|
26
29
|
module.exports = __toCommonJS(bookingStatus_exports);
|
|
27
30
|
function resolveScheduleId(tempOrder) {
|
|
@@ -57,9 +60,48 @@ function restoreBookingsStatus(bookings, previous) {
|
|
|
57
60
|
b.appointment_status = previous[i];
|
|
58
61
|
}
|
|
59
62
|
}
|
|
63
|
+
function resolveStatusAfterTransition(action) {
|
|
64
|
+
const map = {
|
|
65
|
+
confirm: "confirmed",
|
|
66
|
+
reject: "rejected",
|
|
67
|
+
arrive: "arrived",
|
|
68
|
+
start: "started",
|
|
69
|
+
complete: "completed",
|
|
70
|
+
cancel: "cancelled",
|
|
71
|
+
no_show: "no_show",
|
|
72
|
+
reschedule: null
|
|
73
|
+
};
|
|
74
|
+
return map[action] ?? null;
|
|
75
|
+
}
|
|
76
|
+
function applyChildBookingStatus(bookings, scheduleEventId, status) {
|
|
77
|
+
var _a;
|
|
78
|
+
if (!Array.isArray(bookings))
|
|
79
|
+
return void 0;
|
|
80
|
+
const idx = bookings.findIndex(
|
|
81
|
+
(b) => b && String(b.schedule_event_id) === String(scheduleEventId)
|
|
82
|
+
);
|
|
83
|
+
if (idx === -1)
|
|
84
|
+
return void 0;
|
|
85
|
+
const previous = (_a = bookings[idx]) == null ? void 0 : _a.appointment_status;
|
|
86
|
+
bookings[idx].appointment_status = status;
|
|
87
|
+
return previous;
|
|
88
|
+
}
|
|
89
|
+
function restoreChildBookingStatus(bookings, scheduleEventId, previous) {
|
|
90
|
+
if (!Array.isArray(bookings) || previous === void 0)
|
|
91
|
+
return;
|
|
92
|
+
const idx = bookings.findIndex(
|
|
93
|
+
(b) => b && String(b.schedule_event_id) === String(scheduleEventId)
|
|
94
|
+
);
|
|
95
|
+
if (idx === -1)
|
|
96
|
+
return;
|
|
97
|
+
bookings[idx].appointment_status = previous;
|
|
98
|
+
}
|
|
60
99
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
100
|
0 && (module.exports = {
|
|
62
101
|
applyBookingsStatus,
|
|
102
|
+
applyChildBookingStatus,
|
|
63
103
|
resolveScheduleId,
|
|
64
|
-
|
|
104
|
+
resolveStatusAfterTransition,
|
|
105
|
+
restoreBookingsStatus,
|
|
106
|
+
restoreChildBookingStatus
|
|
65
107
|
});
|