@pisell/pisellos 2.2.135 → 2.2.136
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.d.ts +3 -1
- package/dist/modules/Order/index.js +98 -15
- package/dist/modules/Order/types.d.ts +25 -0
- package/dist/modules/Order/types.js +8 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Sales/index.d.ts +3 -1
- package/dist/solution/Sales/index.js +80 -26
- package/dist/solution/Sales/types.d.ts +8 -0
- package/lib/modules/Order/index.d.ts +3 -1
- package/lib/modules/Order/index.js +36 -0
- package/lib/modules/Order/types.d.ts +25 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Sales/index.d.ts +3 -1
- package/lib/solution/Sales/index.js +14 -0
- package/lib/solution/Sales/types.d.ts +8 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { OrderModuleAPI, CommitOrderParams, CheckoutOrderParams } from './types';
|
|
3
|
+
import { OrderModuleAPI, CommitOrderParams, CheckoutOrderParams, CancelOrderParams, ChangeBookingStatusParams } from './types';
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
5
|
export declare class OrderModule extends BaseModule implements Module, OrderModuleAPI {
|
|
6
6
|
protected defaultName: string;
|
|
@@ -39,6 +39,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
39
39
|
type: 'holder' | 'account';
|
|
40
40
|
}): boolean;
|
|
41
41
|
submitOrder(order: CommitOrderParams): Promise<void>;
|
|
42
|
+
cancelOrder(params: CancelOrderParams): Promise<any>;
|
|
43
|
+
changeBookingStatus(params: ChangeBookingStatusParams): Promise<any>;
|
|
42
44
|
/**
|
|
43
45
|
* Checkout 专用:创建订单到后端
|
|
44
46
|
*
|
|
@@ -238,6 +238,89 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
238
238
|
}
|
|
239
239
|
return submitOrder;
|
|
240
240
|
}()
|
|
241
|
+
}, {
|
|
242
|
+
key: "cancelOrder",
|
|
243
|
+
value: function () {
|
|
244
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
245
|
+
var payload;
|
|
246
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
247
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
248
|
+
case 0:
|
|
249
|
+
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
250
|
+
_context3.next = 2;
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
throw new Error('取消订单失败:order_ids 不能为空');
|
|
254
|
+
case 2:
|
|
255
|
+
payload = {
|
|
256
|
+
order_ids: params.order_ids,
|
|
257
|
+
status: 'cancelled',
|
|
258
|
+
change_schedule_event_appointment_status: 1,
|
|
259
|
+
is_void: 1
|
|
260
|
+
};
|
|
261
|
+
this.logInfo('cancelOrder called', {
|
|
262
|
+
url: '/order/update-status',
|
|
263
|
+
method: 'PUT',
|
|
264
|
+
orderIdsCount: params.order_ids.length
|
|
265
|
+
});
|
|
266
|
+
return _context3.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
267
|
+
isShopApi: true
|
|
268
|
+
}));
|
|
269
|
+
case 5:
|
|
270
|
+
case "end":
|
|
271
|
+
return _context3.stop();
|
|
272
|
+
}
|
|
273
|
+
}, _callee3, this);
|
|
274
|
+
}));
|
|
275
|
+
function cancelOrder(_x4) {
|
|
276
|
+
return _cancelOrder.apply(this, arguments);
|
|
277
|
+
}
|
|
278
|
+
return cancelOrder;
|
|
279
|
+
}()
|
|
280
|
+
}, {
|
|
281
|
+
key: "changeBookingStatus",
|
|
282
|
+
value: function () {
|
|
283
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
284
|
+
var url, payload;
|
|
285
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
286
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
287
|
+
case 0:
|
|
288
|
+
if (params.booking_id) {
|
|
289
|
+
_context4.next = 2;
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
293
|
+
case 2:
|
|
294
|
+
if (params.appointment_status) {
|
|
295
|
+
_context4.next = 4;
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
299
|
+
case 4:
|
|
300
|
+
url = "/schedule/booking/appointment-status/".concat(params.booking_id);
|
|
301
|
+
payload = {
|
|
302
|
+
appointment_status: params.appointment_status
|
|
303
|
+
};
|
|
304
|
+
this.logInfo('changeBookingStatus called', {
|
|
305
|
+
url: url,
|
|
306
|
+
method: 'PUT',
|
|
307
|
+
bookingId: params.booking_id,
|
|
308
|
+
appointmentStatus: params.appointment_status
|
|
309
|
+
});
|
|
310
|
+
return _context4.abrupt("return", this.request.put(url, payload, {
|
|
311
|
+
isShopApi: true
|
|
312
|
+
}));
|
|
313
|
+
case 8:
|
|
314
|
+
case "end":
|
|
315
|
+
return _context4.stop();
|
|
316
|
+
}
|
|
317
|
+
}, _callee4, this);
|
|
318
|
+
}));
|
|
319
|
+
function changeBookingStatus(_x5) {
|
|
320
|
+
return _changeBookingStatus.apply(this, arguments);
|
|
321
|
+
}
|
|
322
|
+
return changeBookingStatus;
|
|
323
|
+
}()
|
|
241
324
|
/**
|
|
242
325
|
* Checkout 专用:创建订单到后端
|
|
243
326
|
*
|
|
@@ -251,11 +334,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
251
334
|
}, {
|
|
252
335
|
key: "createOrderByCheckout",
|
|
253
336
|
value: (function () {
|
|
254
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
337
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
|
|
255
338
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
256
339
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
|
|
257
|
-
return _regeneratorRuntime().wrap(function
|
|
258
|
-
while (1) switch (
|
|
340
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
341
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
259
342
|
case 0:
|
|
260
343
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
261
344
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -289,7 +372,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
289
372
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
290
373
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
291
374
|
});
|
|
292
|
-
|
|
375
|
+
_context5.prev = 4;
|
|
293
376
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
294
377
|
orderData = _objectSpread({
|
|
295
378
|
sales_channel: 'my_pisel',
|
|
@@ -353,10 +436,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
353
436
|
});
|
|
354
437
|
|
|
355
438
|
// 调用后端接口
|
|
356
|
-
|
|
439
|
+
_context5.next = 12;
|
|
357
440
|
return this.request.post('/order/checkout', orderData);
|
|
358
441
|
case 12:
|
|
359
|
-
response =
|
|
442
|
+
response = _context5.sent;
|
|
360
443
|
this.logInfo('Order API called successfully', {
|
|
361
444
|
response: response
|
|
362
445
|
});
|
|
@@ -364,22 +447,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
364
447
|
success: !!response,
|
|
365
448
|
hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
|
|
366
449
|
});
|
|
367
|
-
return
|
|
450
|
+
return _context5.abrupt("return", response);
|
|
368
451
|
case 18:
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
452
|
+
_context5.prev = 18;
|
|
453
|
+
_context5.t0 = _context5["catch"](4);
|
|
454
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context5.t0);
|
|
372
455
|
this.logInfo('Order API called failed', {
|
|
373
|
-
error:
|
|
456
|
+
error: _context5.t0 instanceof Error ? _context5.t0.message : String(_context5.t0)
|
|
374
457
|
});
|
|
375
|
-
throw
|
|
458
|
+
throw _context5.t0;
|
|
376
459
|
case 23:
|
|
377
460
|
case "end":
|
|
378
|
-
return
|
|
461
|
+
return _context5.stop();
|
|
379
462
|
}
|
|
380
|
-
},
|
|
463
|
+
}, _callee5, this, [[4, 18]]);
|
|
381
464
|
}));
|
|
382
|
-
function createOrderByCheckout(
|
|
465
|
+
function createOrderByCheckout(_x6) {
|
|
383
466
|
return _createOrderByCheckout.apply(this, arguments);
|
|
384
467
|
}
|
|
385
468
|
return createOrderByCheckout;
|
|
@@ -58,6 +58,19 @@ export interface CheckoutOrderParams {
|
|
|
58
58
|
small_ticket_data_flag?: number;
|
|
59
59
|
[key: string]: any;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* 取消订单参数
|
|
63
|
+
*/
|
|
64
|
+
export interface CancelOrderParams {
|
|
65
|
+
order_ids: Array<number | string>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 变更预约状态参数
|
|
69
|
+
*/
|
|
70
|
+
export interface ChangeBookingStatusParams {
|
|
71
|
+
booking_id: number | string;
|
|
72
|
+
appointment_status: string;
|
|
73
|
+
}
|
|
61
74
|
/**
|
|
62
75
|
* 订单模块 API
|
|
63
76
|
*/
|
|
@@ -86,4 +99,16 @@ export interface OrderModuleAPI {
|
|
|
86
99
|
* @returns 后端返回的订单数据
|
|
87
100
|
*/
|
|
88
101
|
createOrderByCheckout: (params: CheckoutOrderParams) => Promise<any>;
|
|
102
|
+
/**
|
|
103
|
+
* 取消订单
|
|
104
|
+
* @param params 取消订单参数
|
|
105
|
+
* @returns 后端返回结果
|
|
106
|
+
*/
|
|
107
|
+
cancelOrder: (params: CancelOrderParams) => Promise<any>;
|
|
108
|
+
/**
|
|
109
|
+
* 变更预约状态
|
|
110
|
+
* @param params 预约状态参数
|
|
111
|
+
* @returns 后端返回结果
|
|
112
|
+
*/
|
|
113
|
+
changeBookingStatus: (params: ChangeBookingStatusParams) => Promise<any>;
|
|
89
114
|
}
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -136,7 +136,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
136
136
|
* 获取当前的客户搜索条件
|
|
137
137
|
* @returns 当前搜索条件
|
|
138
138
|
*/
|
|
139
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
139
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
140
140
|
/**
|
|
141
141
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
142
142
|
* @returns 客户状态
|
|
@@ -2,7 +2,7 @@ import dayjs from 'dayjs';
|
|
|
2
2
|
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
3
3
|
import { BaseModule } from '../../modules/BaseModule';
|
|
4
4
|
import type { RequestPlugin } from '../../plugins/request';
|
|
5
|
-
import { SalesState, SalesModuleAPI, Reservation, SalesResourceBookingItem, SalesTimelineHighlights } from './types';
|
|
5
|
+
import { SalesState, SalesModuleAPI, Reservation, SalesResourceBookingItem, SalesTimelineHighlights, ChangeBookingStatusParams } from './types';
|
|
6
6
|
import type { BookingData } from '../../server/modules/order/types';
|
|
7
7
|
export * from './types';
|
|
8
8
|
/**
|
|
@@ -39,6 +39,8 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
39
39
|
setReservationList(reservationList: Reservation[]): Reservation[];
|
|
40
40
|
/** 重置预约列表为空 */
|
|
41
41
|
resetReservationList(): Reservation[];
|
|
42
|
+
cancelOrder(orderIds: Array<number | string>): Promise<any>;
|
|
43
|
+
changeBookingStatus(params: ChangeBookingStatusParams): Promise<any>;
|
|
42
44
|
destroy(): Promise<void>;
|
|
43
45
|
/**
|
|
44
46
|
* 时间轴粒度(分钟)
|
|
@@ -161,26 +161,80 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
161
161
|
});
|
|
162
162
|
return [];
|
|
163
163
|
}
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
}, {
|
|
165
|
+
key: "cancelOrder",
|
|
166
|
+
value: function () {
|
|
167
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(orderIds) {
|
|
168
|
+
var orderModule;
|
|
169
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
170
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
171
|
+
case 0:
|
|
172
|
+
orderModule = this.core.getModule('order');
|
|
173
|
+
if (orderModule) {
|
|
174
|
+
_context2.next = 3;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
throw new Error('Sales 取消订单失败:Order 模块未注册');
|
|
178
|
+
case 3:
|
|
179
|
+
return _context2.abrupt("return", orderModule.cancelOrder({
|
|
180
|
+
order_ids: orderIds
|
|
181
|
+
}));
|
|
182
|
+
case 4:
|
|
183
|
+
case "end":
|
|
184
|
+
return _context2.stop();
|
|
185
|
+
}
|
|
186
|
+
}, _callee2, this);
|
|
187
|
+
}));
|
|
188
|
+
function cancelOrder(_x2) {
|
|
189
|
+
return _cancelOrder.apply(this, arguments);
|
|
190
|
+
}
|
|
191
|
+
return cancelOrder;
|
|
192
|
+
}()
|
|
193
|
+
}, {
|
|
194
|
+
key: "changeBookingStatus",
|
|
195
|
+
value: function () {
|
|
196
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
197
|
+
var orderModule;
|
|
198
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
199
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
200
|
+
case 0:
|
|
201
|
+
orderModule = this.core.getModule('order');
|
|
202
|
+
if (orderModule) {
|
|
203
|
+
_context3.next = 3;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
throw new Error('Sales 变更预约状态失败:Order 模块未注册');
|
|
207
|
+
case 3:
|
|
208
|
+
return _context3.abrupt("return", orderModule.changeBookingStatus(params));
|
|
209
|
+
case 4:
|
|
210
|
+
case "end":
|
|
211
|
+
return _context3.stop();
|
|
212
|
+
}
|
|
213
|
+
}, _callee3, this);
|
|
214
|
+
}));
|
|
215
|
+
function changeBookingStatus(_x3) {
|
|
216
|
+
return _changeBookingStatus.apply(this, arguments);
|
|
217
|
+
}
|
|
218
|
+
return changeBookingStatus;
|
|
219
|
+
}() // -------------------------------------------------------------------------
|
|
166
220
|
// 生命周期
|
|
167
221
|
// -------------------------------------------------------------------------
|
|
168
222
|
}, {
|
|
169
223
|
key: "destroy",
|
|
170
224
|
value: function () {
|
|
171
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
172
|
-
return _regeneratorRuntime().wrap(function
|
|
173
|
-
while (1) switch (
|
|
225
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
226
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
227
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
174
228
|
case 0:
|
|
175
|
-
|
|
229
|
+
_context4.next = 2;
|
|
176
230
|
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
177
231
|
case 2:
|
|
178
232
|
_get(_getPrototypeOf(SalesImpl.prototype), "destroy", this).call(this);
|
|
179
233
|
case 3:
|
|
180
234
|
case "end":
|
|
181
|
-
return
|
|
235
|
+
return _context4.stop();
|
|
182
236
|
}
|
|
183
|
-
},
|
|
237
|
+
}, _callee4, this);
|
|
184
238
|
}));
|
|
185
239
|
function destroy() {
|
|
186
240
|
return _destroy.apply(this, arguments);
|
|
@@ -561,7 +615,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
561
615
|
}, {
|
|
562
616
|
key: "getResourceBookingList",
|
|
563
617
|
value: function () {
|
|
564
|
-
var _getResourceBookingList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
618
|
+
var _getResourceBookingList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(currentTime) {
|
|
565
619
|
var _resourceResponse$dat,
|
|
566
620
|
_resourceResponse$dat2,
|
|
567
621
|
_this3 = this;
|
|
@@ -574,28 +628,28 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
574
628
|
normalizedBookings,
|
|
575
629
|
bookingMap,
|
|
576
630
|
list,
|
|
577
|
-
|
|
578
|
-
return _regeneratorRuntime().wrap(function
|
|
579
|
-
while (1) switch (
|
|
631
|
+
_args5 = arguments;
|
|
632
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
633
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
580
634
|
case 0:
|
|
581
|
-
bookingList =
|
|
582
|
-
deviceTime =
|
|
635
|
+
bookingList = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : [];
|
|
636
|
+
deviceTime = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : currentTime;
|
|
583
637
|
// currentTime 约定为完整 datetime;非法值直接返回空,避免误判
|
|
584
638
|
current = dayjs(currentTime);
|
|
585
639
|
if (current.isValid()) {
|
|
586
|
-
|
|
640
|
+
_context5.next = 5;
|
|
587
641
|
break;
|
|
588
642
|
}
|
|
589
|
-
return
|
|
643
|
+
return _context5.abrupt("return", []);
|
|
590
644
|
case 5:
|
|
591
645
|
deviceCurrent = dayjs(deviceTime);
|
|
592
646
|
if (deviceCurrent.isValid()) {
|
|
593
|
-
|
|
647
|
+
_context5.next = 8;
|
|
594
648
|
break;
|
|
595
649
|
}
|
|
596
|
-
return
|
|
650
|
+
return _context5.abrupt("return", []);
|
|
597
651
|
case 8:
|
|
598
|
-
|
|
652
|
+
_context5.next = 10;
|
|
599
653
|
return this.request.get('/shop/form/resource/page', {
|
|
600
654
|
skip: 1,
|
|
601
655
|
num: 999
|
|
@@ -606,13 +660,13 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
606
660
|
isShopApi: true
|
|
607
661
|
});
|
|
608
662
|
case 10:
|
|
609
|
-
resourceResponse =
|
|
663
|
+
resourceResponse = _context5.sent;
|
|
610
664
|
resourceList = (_resourceResponse$dat = resourceResponse === null || resourceResponse === void 0 || (_resourceResponse$dat2 = resourceResponse.data) === null || _resourceResponse$dat2 === void 0 ? void 0 : _resourceResponse$dat2.list) !== null && _resourceResponse$dat !== void 0 ? _resourceResponse$dat : [];
|
|
611
665
|
if (!(!Array.isArray(resourceList) || resourceList.length === 0)) {
|
|
612
|
-
|
|
666
|
+
_context5.next = 14;
|
|
613
667
|
break;
|
|
614
668
|
}
|
|
615
|
-
return
|
|
669
|
+
return _context5.abrupt("return", []);
|
|
616
670
|
case 14:
|
|
617
671
|
// 全局先做 booking 标准化 + start_time 升序,后续映射直接复用
|
|
618
672
|
normalizedBookings = bookingList.map(function (booking) {
|
|
@@ -662,14 +716,14 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
662
716
|
list: list === null || list === void 0 ? void 0 : list.length
|
|
663
717
|
}
|
|
664
718
|
});
|
|
665
|
-
return
|
|
719
|
+
return _context5.abrupt("return", list);
|
|
666
720
|
case 21:
|
|
667
721
|
case "end":
|
|
668
|
-
return
|
|
722
|
+
return _context5.stop();
|
|
669
723
|
}
|
|
670
|
-
},
|
|
724
|
+
}, _callee5, this);
|
|
671
725
|
}));
|
|
672
|
-
function getResourceBookingList(
|
|
726
|
+
function getResourceBookingList(_x4) {
|
|
673
727
|
return _getResourceBookingList.apply(this, arguments);
|
|
674
728
|
}
|
|
675
729
|
return getResourceBookingList;
|
|
@@ -33,6 +33,10 @@ export interface SalesResourceBookingItem extends Omit<ResourceData, 'bookings'>
|
|
|
33
33
|
bookings: SalesResourceMatchedBooking[];
|
|
34
34
|
}
|
|
35
35
|
export type SalesTimelineHighlights = number[];
|
|
36
|
+
export interface ChangeBookingStatusParams {
|
|
37
|
+
booking_id: number | string;
|
|
38
|
+
appointment_status: string;
|
|
39
|
+
}
|
|
36
40
|
/**
|
|
37
41
|
* Sales 解决方案状态
|
|
38
42
|
*
|
|
@@ -61,6 +65,10 @@ export interface SalesModuleAPI {
|
|
|
61
65
|
setReservationList: (reservationList: Reservation[]) => Reservation[];
|
|
62
66
|
/** 重置预约列表为空 */
|
|
63
67
|
resetReservationList: () => Reservation[];
|
|
68
|
+
/** 取消订单 */
|
|
69
|
+
cancelOrder: (orderIds: Array<number | string>) => Promise<any>;
|
|
70
|
+
/** 变更预约状态 */
|
|
71
|
+
changeBookingStatus: (params: ChangeBookingStatusParams) => Promise<any>;
|
|
64
72
|
/** 获取资源维度的预约占用列表 */
|
|
65
73
|
getResourceBookingList: (currentTime: string, bookingList: BookingData[], deviceTime?: string) => Promise<SalesResourceBookingItem[]>;
|
|
66
74
|
/** 获取时间轴每个时间片的预约数量 */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { OrderModuleAPI, CommitOrderParams, CheckoutOrderParams } from './types';
|
|
3
|
+
import { OrderModuleAPI, CommitOrderParams, CheckoutOrderParams, CancelOrderParams, ChangeBookingStatusParams } from './types';
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
5
|
export declare class OrderModule extends BaseModule implements Module, OrderModuleAPI {
|
|
6
6
|
protected defaultName: string;
|
|
@@ -39,6 +39,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
39
39
|
type: 'holder' | 'account';
|
|
40
40
|
}): boolean;
|
|
41
41
|
submitOrder(order: CommitOrderParams): Promise<void>;
|
|
42
|
+
cancelOrder(params: CancelOrderParams): Promise<any>;
|
|
43
|
+
changeBookingStatus(params: ChangeBookingStatusParams): Promise<any>;
|
|
42
44
|
/**
|
|
43
45
|
* Checkout 专用:创建订单到后端
|
|
44
46
|
*
|
|
@@ -182,6 +182,42 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
182
182
|
});
|
|
183
183
|
return this.request.post(fetchUrl, params);
|
|
184
184
|
}
|
|
185
|
+
async cancelOrder(params) {
|
|
186
|
+
if (!Array.isArray(params.order_ids) || params.order_ids.length === 0) {
|
|
187
|
+
throw new Error("取消订单失败:order_ids 不能为空");
|
|
188
|
+
}
|
|
189
|
+
const payload = {
|
|
190
|
+
order_ids: params.order_ids,
|
|
191
|
+
status: "cancelled",
|
|
192
|
+
change_schedule_event_appointment_status: 1,
|
|
193
|
+
is_void: 1
|
|
194
|
+
};
|
|
195
|
+
this.logInfo("cancelOrder called", {
|
|
196
|
+
url: "/order/update-status",
|
|
197
|
+
method: "PUT",
|
|
198
|
+
orderIdsCount: params.order_ids.length
|
|
199
|
+
});
|
|
200
|
+
return this.request.put("/order/update-status", payload, { isShopApi: true });
|
|
201
|
+
}
|
|
202
|
+
async changeBookingStatus(params) {
|
|
203
|
+
if (!params.booking_id) {
|
|
204
|
+
throw new Error("变更预约状态失败:booking_id 不能为空");
|
|
205
|
+
}
|
|
206
|
+
if (!params.appointment_status) {
|
|
207
|
+
throw new Error("变更预约状态失败:appointment_status 不能为空");
|
|
208
|
+
}
|
|
209
|
+
const url = `/schedule/booking/appointment-status/${params.booking_id}`;
|
|
210
|
+
const payload = {
|
|
211
|
+
appointment_status: params.appointment_status
|
|
212
|
+
};
|
|
213
|
+
this.logInfo("changeBookingStatus called", {
|
|
214
|
+
url,
|
|
215
|
+
method: "PUT",
|
|
216
|
+
bookingId: params.booking_id,
|
|
217
|
+
appointmentStatus: params.appointment_status
|
|
218
|
+
});
|
|
219
|
+
return this.request.put(url, payload, { isShopApi: true });
|
|
220
|
+
}
|
|
185
221
|
/**
|
|
186
222
|
* Checkout 专用:创建订单到后端
|
|
187
223
|
*
|
|
@@ -58,6 +58,19 @@ export interface CheckoutOrderParams {
|
|
|
58
58
|
small_ticket_data_flag?: number;
|
|
59
59
|
[key: string]: any;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* 取消订单参数
|
|
63
|
+
*/
|
|
64
|
+
export interface CancelOrderParams {
|
|
65
|
+
order_ids: Array<number | string>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 变更预约状态参数
|
|
69
|
+
*/
|
|
70
|
+
export interface ChangeBookingStatusParams {
|
|
71
|
+
booking_id: number | string;
|
|
72
|
+
appointment_status: string;
|
|
73
|
+
}
|
|
61
74
|
/**
|
|
62
75
|
* 订单模块 API
|
|
63
76
|
*/
|
|
@@ -86,4 +99,16 @@ export interface OrderModuleAPI {
|
|
|
86
99
|
* @returns 后端返回的订单数据
|
|
87
100
|
*/
|
|
88
101
|
createOrderByCheckout: (params: CheckoutOrderParams) => Promise<any>;
|
|
102
|
+
/**
|
|
103
|
+
* 取消订单
|
|
104
|
+
* @param params 取消订单参数
|
|
105
|
+
* @returns 后端返回结果
|
|
106
|
+
*/
|
|
107
|
+
cancelOrder: (params: CancelOrderParams) => Promise<any>;
|
|
108
|
+
/**
|
|
109
|
+
* 变更预约状态
|
|
110
|
+
* @param params 预约状态参数
|
|
111
|
+
* @returns 后端返回结果
|
|
112
|
+
*/
|
|
113
|
+
changeBookingStatus: (params: ChangeBookingStatusParams) => Promise<any>;
|
|
89
114
|
}
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -136,7 +136,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
136
136
|
* 获取当前的客户搜索条件
|
|
137
137
|
* @returns 当前搜索条件
|
|
138
138
|
*/
|
|
139
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
139
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
140
140
|
/**
|
|
141
141
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
142
142
|
* @returns 客户状态
|
|
@@ -2,7 +2,7 @@ import dayjs from 'dayjs';
|
|
|
2
2
|
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
3
3
|
import { BaseModule } from '../../modules/BaseModule';
|
|
4
4
|
import type { RequestPlugin } from '../../plugins/request';
|
|
5
|
-
import { SalesState, SalesModuleAPI, Reservation, SalesResourceBookingItem, SalesTimelineHighlights } from './types';
|
|
5
|
+
import { SalesState, SalesModuleAPI, Reservation, SalesResourceBookingItem, SalesTimelineHighlights, ChangeBookingStatusParams } from './types';
|
|
6
6
|
import type { BookingData } from '../../server/modules/order/types';
|
|
7
7
|
export * from './types';
|
|
8
8
|
/**
|
|
@@ -39,6 +39,8 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
39
39
|
setReservationList(reservationList: Reservation[]): Reservation[];
|
|
40
40
|
/** 重置预约列表为空 */
|
|
41
41
|
resetReservationList(): Reservation[];
|
|
42
|
+
cancelOrder(orderIds: Array<number | string>): Promise<any>;
|
|
43
|
+
changeBookingStatus(params: ChangeBookingStatusParams): Promise<any>;
|
|
42
44
|
destroy(): Promise<void>;
|
|
43
45
|
/**
|
|
44
46
|
* 时间轴粒度(分钟)
|
|
@@ -100,6 +100,20 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
100
100
|
this.core.effects.emit(import_types.SalesHooks.onReservationListChanged, { reservationList: [] });
|
|
101
101
|
return [];
|
|
102
102
|
}
|
|
103
|
+
async cancelOrder(orderIds) {
|
|
104
|
+
const orderModule = this.core.getModule("order");
|
|
105
|
+
if (!orderModule) {
|
|
106
|
+
throw new Error("Sales 取消订单失败:Order 模块未注册");
|
|
107
|
+
}
|
|
108
|
+
return orderModule.cancelOrder({ order_ids: orderIds });
|
|
109
|
+
}
|
|
110
|
+
async changeBookingStatus(params) {
|
|
111
|
+
const orderModule = this.core.getModule("order");
|
|
112
|
+
if (!orderModule) {
|
|
113
|
+
throw new Error("Sales 变更预约状态失败:Order 模块未注册");
|
|
114
|
+
}
|
|
115
|
+
return orderModule.changeBookingStatus(params);
|
|
116
|
+
}
|
|
103
117
|
// -------------------------------------------------------------------------
|
|
104
118
|
// 生命周期
|
|
105
119
|
// -------------------------------------------------------------------------
|
|
@@ -33,6 +33,10 @@ export interface SalesResourceBookingItem extends Omit<ResourceData, 'bookings'>
|
|
|
33
33
|
bookings: SalesResourceMatchedBooking[];
|
|
34
34
|
}
|
|
35
35
|
export type SalesTimelineHighlights = number[];
|
|
36
|
+
export interface ChangeBookingStatusParams {
|
|
37
|
+
booking_id: number | string;
|
|
38
|
+
appointment_status: string;
|
|
39
|
+
}
|
|
36
40
|
/**
|
|
37
41
|
* Sales 解决方案状态
|
|
38
42
|
*
|
|
@@ -61,6 +65,10 @@ export interface SalesModuleAPI {
|
|
|
61
65
|
setReservationList: (reservationList: Reservation[]) => Reservation[];
|
|
62
66
|
/** 重置预约列表为空 */
|
|
63
67
|
resetReservationList: () => Reservation[];
|
|
68
|
+
/** 取消订单 */
|
|
69
|
+
cancelOrder: (orderIds: Array<number | string>) => Promise<any>;
|
|
70
|
+
/** 变更预约状态 */
|
|
71
|
+
changeBookingStatus: (params: ChangeBookingStatusParams) => Promise<any>;
|
|
64
72
|
/** 获取资源维度的预约占用列表 */
|
|
65
73
|
getResourceBookingList: (currentTime: string, bookingList: BookingData[], deviceTime?: string) => Promise<SalesResourceBookingItem[]>;
|
|
66
74
|
/** 获取时间轴每个时间片的预约数量 */
|