@pisell/pisellos 2.2.210 → 2.2.211
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/BookingContext/index.d.ts +13 -2
- package/dist/modules/BookingContext/index.js +198 -68
- package/dist/modules/Order/index.d.ts +1 -0
- package/dist/modules/Order/index.js +62 -28
- package/dist/modules/Order/types.d.ts +4 -1
- package/dist/modules/Order/utils.d.ts +1 -0
- package/dist/modules/Order/utils.js +11 -6
- package/dist/modules/Quotation/index.js +2 -1
- package/dist/modules/SalesSummary/index.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +29 -15
- package/dist/modules/SurchargeList/index.d.ts +16 -0
- package/dist/modules/SurchargeList/index.js +162 -0
- package/dist/modules/SurchargeList/types.d.ts +11 -0
- package/dist/modules/SurchargeList/types.js +1 -0
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.js +1075 -915
- package/dist/server/modules/order/index.d.ts +9 -0
- package/dist/server/modules/order/index.js +557 -411
- package/dist/server/modules/order/utils/filterOrders.js +3 -2
- package/dist/server/test.json +713 -0
- package/dist/server/utils/small-ticket.d.ts +1 -1
- package/dist/server/utils/small-ticket.js +1 -1
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.js +22 -20
- package/lib/modules/BookingContext/index.d.ts +13 -2
- package/lib/modules/BookingContext/index.js +99 -28
- package/lib/modules/Order/index.d.ts +1 -0
- package/lib/modules/Order/index.js +12 -1
- package/lib/modules/Order/types.d.ts +4 -1
- package/lib/modules/Order/utils.d.ts +1 -0
- package/lib/modules/Order/utils.js +10 -3
- package/lib/modules/Quotation/index.js +1 -1
- package/lib/modules/SalesSummary/index.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +11 -1
- package/lib/modules/SurchargeList/index.d.ts +16 -0
- package/lib/modules/SurchargeList/index.js +89 -0
- package/lib/modules/SurchargeList/types.d.ts +11 -0
- package/lib/modules/SurchargeList/types.js +17 -0
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +2 -0
- package/lib/server/index.d.ts +8 -0
- package/lib/server/index.js +134 -19
- package/lib/server/modules/order/index.d.ts +9 -0
- package/lib/server/modules/order/index.js +107 -19
- package/lib/server/modules/order/utils/filterOrders.js +3 -2
- package/lib/server/test.json +713 -0
- package/lib/server/utils/small-ticket.d.ts +1 -1
- package/lib/server/utils/small-ticket.js +1 -35
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.js +12 -7
- package/package.json +1 -1
|
@@ -3,6 +3,13 @@ import { BaseModule } from '../BaseModule';
|
|
|
3
3
|
import { BookingContextConfig, BookingContextDateInput, BookingContextModuleAPI, BookingContextResource, BookingContextResourceMap, BookingContextState, InitBookingContextParams, LoadBookingConfigParams, LoadBookingResourcesParams } from './types';
|
|
4
4
|
export * from './types';
|
|
5
5
|
export * from './utils';
|
|
6
|
+
/**
|
|
7
|
+
* 清理跨实例共享缓存,仅供单元测试隔离使用。
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* __clearBookingContextSharedCacheForTest();
|
|
11
|
+
*/
|
|
12
|
+
export declare function __clearBookingContextSharedCacheForTest(): void;
|
|
6
13
|
/** 稳定序列化 config 查询参数,用于判断是否与上次 loadBookingConfig 一致。 */
|
|
7
14
|
export declare function buildBookingConfigQueryKey(params?: LoadBookingConfigParams): string;
|
|
8
15
|
/** 稳定序列化资源列表查询(date + bookingIds),用于跳过重复 loadResources。 */
|
|
@@ -18,8 +25,12 @@ export declare class BookingContextModule extends BaseModule implements Module,
|
|
|
18
25
|
private lastResourcesQueryKey;
|
|
19
26
|
constructor(name?: string, version?: string);
|
|
20
27
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
21
|
-
loadBookingConfig(params?: LoadBookingConfigParams
|
|
22
|
-
|
|
28
|
+
loadBookingConfig(params?: LoadBookingConfigParams, options?: {
|
|
29
|
+
forceRefresh?: boolean;
|
|
30
|
+
}): Promise<BookingContextConfig | null>;
|
|
31
|
+
loadResources(params?: LoadBookingResourcesParams, options?: {
|
|
32
|
+
forceRefresh?: boolean;
|
|
33
|
+
}): Promise<BookingContextResource[]>;
|
|
23
34
|
/**
|
|
24
35
|
* store 内是否已具备与本次 init 入参等价的 config / resources(不再打接口)。
|
|
25
36
|
*/
|
|
@@ -55,6 +55,50 @@ var RESOURCE_LIST_CACHE = {
|
|
|
55
55
|
type: 'memory'
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
+
var requestScopeIds = new WeakMap();
|
|
59
|
+
var nextRequestScopeId = 1;
|
|
60
|
+
var sharedBookingConfigCache = new Map();
|
|
61
|
+
var sharedBookingConfigPending = new Map();
|
|
62
|
+
var sharedResourcesCache = new Map();
|
|
63
|
+
var sharedResourcesPending = new Map();
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 为 request 插件生成稳定作用域,避免不同 request 客户端之间共享缓存数据。
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* const scopedKey = buildSharedCacheKey(requestPlugin, '{"sub_type":"ticket"}');
|
|
70
|
+
*/
|
|
71
|
+
function getRequestScopeId(request) {
|
|
72
|
+
var key = request;
|
|
73
|
+
var existed = requestScopeIds.get(key);
|
|
74
|
+
if (existed) return existed;
|
|
75
|
+
var id = nextRequestScopeId++;
|
|
76
|
+
requestScopeIds.set(key, id);
|
|
77
|
+
return id;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 共享缓存 key = request 作用域 + 已稳定序列化的业务参数。
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* const cacheKey = buildSharedCacheKey(requestPlugin, '2026-06-10|1,2');
|
|
85
|
+
*/
|
|
86
|
+
function buildSharedCacheKey(request, queryKey) {
|
|
87
|
+
return "".concat(getRequestScopeId(request), ":").concat(queryKey);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 清理跨实例共享缓存,仅供单元测试隔离使用。
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* __clearBookingContextSharedCacheForTest();
|
|
95
|
+
*/
|
|
96
|
+
export function __clearBookingContextSharedCacheForTest() {
|
|
97
|
+
sharedBookingConfigCache.clear();
|
|
98
|
+
sharedBookingConfigPending.clear();
|
|
99
|
+
sharedResourcesCache.clear();
|
|
100
|
+
sharedResourcesPending.clear();
|
|
101
|
+
}
|
|
58
102
|
|
|
59
103
|
/**
|
|
60
104
|
* 把多形态 date 入参 normalize 成字符串。
|
|
@@ -188,40 +232,82 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
188
232
|
}, {
|
|
189
233
|
key: "loadBookingConfig",
|
|
190
234
|
value: function () {
|
|
191
|
-
var _loadBookingConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
192
|
-
var
|
|
235
|
+
var _loadBookingConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
236
|
+
var _this2 = this;
|
|
193
237
|
var params,
|
|
238
|
+
options,
|
|
194
239
|
configKey,
|
|
195
240
|
query,
|
|
196
|
-
|
|
241
|
+
sharedKey,
|
|
242
|
+
_sharedBookingConfigC,
|
|
243
|
+
cached,
|
|
244
|
+
pending,
|
|
245
|
+
requestPromise,
|
|
197
246
|
config,
|
|
198
|
-
|
|
199
|
-
return _regeneratorRuntime().wrap(function
|
|
200
|
-
while (1) switch (
|
|
247
|
+
_args3 = arguments;
|
|
248
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
249
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
201
250
|
case 0:
|
|
202
|
-
params =
|
|
251
|
+
params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
|
|
252
|
+
options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
203
253
|
configKey = buildBookingConfigQueryKey(params);
|
|
204
|
-
if (!(this.store.bookingConfig != null && this.lastConfigQueryKey === configKey)) {
|
|
205
|
-
|
|
254
|
+
if (!(!options.forceRefresh && this.store.bookingConfig != null && this.lastConfigQueryKey === configKey)) {
|
|
255
|
+
_context3.next = 5;
|
|
206
256
|
break;
|
|
207
257
|
}
|
|
208
|
-
return
|
|
209
|
-
case
|
|
258
|
+
return _context3.abrupt("return", this.store.bookingConfig);
|
|
259
|
+
case 5:
|
|
210
260
|
query = _objectSpread(_objectSpread({}, DEFAULT_BOOKING_CONFIG_PARAMS), params);
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
261
|
+
sharedKey = buildSharedCacheKey(this.request, configKey);
|
|
262
|
+
if (!(!options.forceRefresh && sharedBookingConfigCache.has(sharedKey))) {
|
|
263
|
+
_context3.next = 12;
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
cached = (_sharedBookingConfigC = sharedBookingConfigCache.get(sharedKey)) !== null && _sharedBookingConfigC !== void 0 ? _sharedBookingConfigC : null;
|
|
267
|
+
this.setBookingConfig(cached);
|
|
268
|
+
this.lastConfigQueryKey = configKey;
|
|
269
|
+
return _context3.abrupt("return", cached);
|
|
270
|
+
case 12:
|
|
271
|
+
pending = !options.forceRefresh ? sharedBookingConfigPending.get(sharedKey) : undefined;
|
|
272
|
+
if (!pending) {
|
|
273
|
+
requestPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
274
|
+
var _res$data, res, _config;
|
|
275
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
276
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
277
|
+
case 0:
|
|
278
|
+
_context2.prev = 0;
|
|
279
|
+
_context2.next = 3;
|
|
280
|
+
return _this2.request.get('/core/board/management/config', query, BOARD_CONFIG_CACHE);
|
|
281
|
+
case 3:
|
|
282
|
+
res = _context2.sent;
|
|
283
|
+
_config = (_res$data = res === null || res === void 0 ? void 0 : res.data) !== null && _res$data !== void 0 ? _res$data : null;
|
|
284
|
+
sharedBookingConfigCache.set(sharedKey, _config);
|
|
285
|
+
return _context2.abrupt("return", _config);
|
|
286
|
+
case 7:
|
|
287
|
+
_context2.prev = 7;
|
|
288
|
+
sharedBookingConfigPending.delete(sharedKey);
|
|
289
|
+
return _context2.finish(7);
|
|
290
|
+
case 10:
|
|
291
|
+
case "end":
|
|
292
|
+
return _context2.stop();
|
|
293
|
+
}
|
|
294
|
+
}, _callee2, null, [[0,, 7, 10]]);
|
|
295
|
+
}))();
|
|
296
|
+
pending = requestPromise;
|
|
297
|
+
sharedBookingConfigPending.set(sharedKey, requestPromise);
|
|
298
|
+
}
|
|
299
|
+
_context3.next = 16;
|
|
300
|
+
return pending;
|
|
301
|
+
case 16:
|
|
302
|
+
config = _context3.sent;
|
|
217
303
|
this.setBookingConfig(config);
|
|
218
|
-
this.lastConfigQueryKey =
|
|
219
|
-
return
|
|
220
|
-
case
|
|
304
|
+
this.lastConfigQueryKey = configKey;
|
|
305
|
+
return _context3.abrupt("return", config);
|
|
306
|
+
case 20:
|
|
221
307
|
case "end":
|
|
222
|
-
return
|
|
308
|
+
return _context3.stop();
|
|
223
309
|
}
|
|
224
|
-
},
|
|
310
|
+
}, _callee3, this);
|
|
225
311
|
}));
|
|
226
312
|
function loadBookingConfig() {
|
|
227
313
|
return _loadBookingConfig.apply(this, arguments);
|
|
@@ -231,48 +317,88 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
231
317
|
}, {
|
|
232
318
|
key: "loadResources",
|
|
233
319
|
value: function () {
|
|
234
|
-
var _loadResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
235
|
-
var _params$date
|
|
320
|
+
var _loadResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
321
|
+
var _params$date,
|
|
322
|
+
_this3 = this;
|
|
236
323
|
var params,
|
|
324
|
+
options,
|
|
237
325
|
date,
|
|
238
326
|
resourcesKey,
|
|
239
|
-
|
|
240
|
-
|
|
327
|
+
sharedKey,
|
|
328
|
+
_sharedResourcesCache,
|
|
329
|
+
cached,
|
|
330
|
+
pending,
|
|
331
|
+
requestPromise,
|
|
241
332
|
list,
|
|
242
|
-
|
|
243
|
-
return _regeneratorRuntime().wrap(function
|
|
244
|
-
while (1) switch (
|
|
333
|
+
_args5 = arguments;
|
|
334
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
335
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
245
336
|
case 0:
|
|
246
|
-
params =
|
|
337
|
+
params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
|
|
338
|
+
options = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
|
|
247
339
|
date = toScheduleQueryDate((_params$date = params.date) !== null && _params$date !== void 0 ? _params$date : this.store.date);
|
|
248
340
|
resourcesKey = buildBookingResourcesQueryKey({
|
|
249
341
|
date: date,
|
|
250
342
|
bookingIds: params.bookingIds
|
|
251
343
|
});
|
|
252
|
-
if (!(this.lastResourcesQueryKey === resourcesKey)) {
|
|
253
|
-
|
|
344
|
+
if (!(!options.forceRefresh && this.lastResourcesQueryKey === resourcesKey)) {
|
|
345
|
+
_context5.next = 6;
|
|
254
346
|
break;
|
|
255
347
|
}
|
|
256
|
-
return
|
|
257
|
-
case
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
this.
|
|
266
|
-
this.
|
|
267
|
-
date: date,
|
|
268
|
-
bookingIds: params.bookingIds
|
|
269
|
-
});
|
|
270
|
-
return _context3.abrupt("return", list);
|
|
348
|
+
return _context5.abrupt("return", this.getResourcesOrigin());
|
|
349
|
+
case 6:
|
|
350
|
+
sharedKey = buildSharedCacheKey(this.request, resourcesKey);
|
|
351
|
+
if (!(!options.forceRefresh && sharedResourcesCache.has(sharedKey))) {
|
|
352
|
+
_context5.next = 12;
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
cached = (_sharedResourcesCache = sharedResourcesCache.get(sharedKey)) !== null && _sharedResourcesCache !== void 0 ? _sharedResourcesCache : [];
|
|
356
|
+
this.setResources(cached);
|
|
357
|
+
this.lastResourcesQueryKey = resourcesKey;
|
|
358
|
+
return _context5.abrupt("return", this.getResourcesOrigin());
|
|
271
359
|
case 12:
|
|
360
|
+
pending = !options.forceRefresh ? sharedResourcesPending.get(sharedKey) : undefined;
|
|
361
|
+
if (!pending) {
|
|
362
|
+
requestPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
363
|
+
var res, _formatResourceListAn, _list;
|
|
364
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
365
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
366
|
+
case 0:
|
|
367
|
+
_context4.prev = 0;
|
|
368
|
+
_context4.next = 3;
|
|
369
|
+
return _this3.request.get('/schedule/resource/list', {
|
|
370
|
+
date: date
|
|
371
|
+
}, RESOURCE_LIST_CACHE);
|
|
372
|
+
case 3:
|
|
373
|
+
res = _context4.sent;
|
|
374
|
+
_formatResourceListAn = formatResourceListAndMap(res === null || res === void 0 ? void 0 : res.data, params.bookingIds || []), _list = _formatResourceListAn.list;
|
|
375
|
+
sharedResourcesCache.set(sharedKey, _list);
|
|
376
|
+
return _context4.abrupt("return", _list);
|
|
377
|
+
case 7:
|
|
378
|
+
_context4.prev = 7;
|
|
379
|
+
sharedResourcesPending.delete(sharedKey);
|
|
380
|
+
return _context4.finish(7);
|
|
381
|
+
case 10:
|
|
382
|
+
case "end":
|
|
383
|
+
return _context4.stop();
|
|
384
|
+
}
|
|
385
|
+
}, _callee4, null, [[0,, 7, 10]]);
|
|
386
|
+
}))();
|
|
387
|
+
pending = requestPromise;
|
|
388
|
+
sharedResourcesPending.set(sharedKey, requestPromise);
|
|
389
|
+
}
|
|
390
|
+
_context5.next = 16;
|
|
391
|
+
return pending;
|
|
392
|
+
case 16:
|
|
393
|
+
list = _context5.sent;
|
|
394
|
+
this.setResources(list);
|
|
395
|
+
this.lastResourcesQueryKey = resourcesKey;
|
|
396
|
+
return _context5.abrupt("return", this.getResourcesOrigin());
|
|
397
|
+
case 20:
|
|
272
398
|
case "end":
|
|
273
|
-
return
|
|
399
|
+
return _context5.stop();
|
|
274
400
|
}
|
|
275
|
-
},
|
|
401
|
+
}, _callee5, this);
|
|
276
402
|
}));
|
|
277
403
|
function loadResources() {
|
|
278
404
|
return _loadResources.apply(this, arguments);
|
|
@@ -285,10 +411,10 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
285
411
|
}, {
|
|
286
412
|
key: "isBookingContextReady",
|
|
287
413
|
value: function isBookingContextReady() {
|
|
288
|
-
var
|
|
414
|
+
var _ref3, _params$date2;
|
|
289
415
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
290
416
|
var configKey = buildBookingConfigQueryKey(params.bookingConfigParams);
|
|
291
|
-
var dateInput = (
|
|
417
|
+
var dateInput = (_ref3 = (_params$date2 = params.date) !== null && _params$date2 !== void 0 ? _params$date2 : this.store.date) !== null && _ref3 !== void 0 ? _ref3 : dayjs();
|
|
292
418
|
var queryDate = toScheduleQueryDate(dateInput);
|
|
293
419
|
var resourcesKey = buildBookingResourcesQueryKey({
|
|
294
420
|
date: queryDate,
|
|
@@ -301,8 +427,8 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
301
427
|
}, {
|
|
302
428
|
key: "initBookingContext",
|
|
303
429
|
value: function () {
|
|
304
|
-
var _initBookingContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
305
|
-
var
|
|
430
|
+
var _initBookingContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
431
|
+
var _ref4, _params$date3;
|
|
306
432
|
var params,
|
|
307
433
|
dateInput,
|
|
308
434
|
queryDate,
|
|
@@ -310,19 +436,19 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
310
436
|
resourcesKey,
|
|
311
437
|
needConfig,
|
|
312
438
|
needResources,
|
|
313
|
-
|
|
314
|
-
return _regeneratorRuntime().wrap(function
|
|
315
|
-
while (1) switch (
|
|
439
|
+
_args6 = arguments;
|
|
440
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
441
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
316
442
|
case 0:
|
|
317
|
-
params =
|
|
318
|
-
dateInput = (
|
|
443
|
+
params = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
|
|
444
|
+
dateInput = (_ref4 = (_params$date3 = params.date) !== null && _params$date3 !== void 0 ? _params$date3 : this.store.date) !== null && _ref4 !== void 0 ? _ref4 : dayjs();
|
|
319
445
|
queryDate = toScheduleQueryDate(dateInput);
|
|
320
446
|
this.setDate(dateInput);
|
|
321
447
|
if (!(!params.forceRefresh && this.isBookingContextReady(params))) {
|
|
322
|
-
|
|
448
|
+
_context6.next = 6;
|
|
323
449
|
break;
|
|
324
450
|
}
|
|
325
|
-
return
|
|
451
|
+
return _context6.abrupt("return", this.getState());
|
|
326
452
|
case 6:
|
|
327
453
|
configKey = buildBookingConfigQueryKey(params.bookingConfigParams);
|
|
328
454
|
resourcesKey = buildBookingResourcesQueryKey({
|
|
@@ -332,28 +458,32 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
332
458
|
needConfig = params.forceRefresh || this.store.bookingConfig == null || this.lastConfigQueryKey !== configKey;
|
|
333
459
|
needResources = params.loadResources !== false && (params.forceRefresh || this.lastResourcesQueryKey !== resourcesKey);
|
|
334
460
|
if (!needConfig) {
|
|
335
|
-
|
|
461
|
+
_context6.next = 13;
|
|
336
462
|
break;
|
|
337
463
|
}
|
|
338
|
-
|
|
339
|
-
return this.loadBookingConfig(params.bookingConfigParams
|
|
464
|
+
_context6.next = 13;
|
|
465
|
+
return this.loadBookingConfig(params.bookingConfigParams, {
|
|
466
|
+
forceRefresh: params.forceRefresh
|
|
467
|
+
});
|
|
340
468
|
case 13:
|
|
341
469
|
if (!needResources) {
|
|
342
|
-
|
|
470
|
+
_context6.next = 16;
|
|
343
471
|
break;
|
|
344
472
|
}
|
|
345
|
-
|
|
473
|
+
_context6.next = 16;
|
|
346
474
|
return this.loadResources({
|
|
347
475
|
date: queryDate,
|
|
348
476
|
bookingIds: params.bookingIds
|
|
477
|
+
}, {
|
|
478
|
+
forceRefresh: params.forceRefresh
|
|
349
479
|
});
|
|
350
480
|
case 16:
|
|
351
|
-
return
|
|
481
|
+
return _context6.abrupt("return", this.getState());
|
|
352
482
|
case 17:
|
|
353
483
|
case "end":
|
|
354
|
-
return
|
|
484
|
+
return _context6.stop();
|
|
355
485
|
}
|
|
356
|
-
},
|
|
486
|
+
}, _callee6, this);
|
|
357
487
|
}));
|
|
358
488
|
function initBookingContext() {
|
|
359
489
|
return _initBookingContext.apply(this, arguments);
|
|
@@ -328,6 +328,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
328
328
|
}): Promise<T>;
|
|
329
329
|
private markLocalOrderSynced;
|
|
330
330
|
private isSubmitResponseRejected;
|
|
331
|
+
private isLocalPendingSubmitResult;
|
|
331
332
|
private isSubmitErrorResponse;
|
|
332
333
|
private extractSubmitErrorResponse;
|
|
333
334
|
private logSubmitBackendRejected;
|
|
@@ -3412,6 +3412,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3412
3412
|
businessCode: (_ref64 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.businessCode) !== null && _ref64 !== void 0 ? _ref64 : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.business_code,
|
|
3413
3413
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
3414
3414
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
3415
|
+
summary: this.store.summary || createEmptySummary(),
|
|
3415
3416
|
enhance: function enhance(nextPayload) {
|
|
3416
3417
|
var _ref65, _tempOrder$order_numb, _ref66, _tempOrder$shop_order, _ref67, _tempOrder$shop_full_;
|
|
3417
3418
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
@@ -3475,12 +3476,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3475
3476
|
value: (function () {
|
|
3476
3477
|
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
3477
3478
|
var _params$cacheId2, _this$otherParams4, _ref68, _params$businessCode2, _this$otherParams5, _this$otherParams6;
|
|
3478
|
-
var tempOrder, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
3479
|
+
var tempOrder, latestSummary, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
3479
3480
|
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
3480
3481
|
while (1) switch (_context26.prev = _context26.next) {
|
|
3481
3482
|
case 0:
|
|
3482
3483
|
tempOrder = this.ensureTempOrder();
|
|
3483
3484
|
this.persistTempOrder();
|
|
3485
|
+
_context26.next = 4;
|
|
3486
|
+
return this.recalculateSummary({
|
|
3487
|
+
createIfMissing: true
|
|
3488
|
+
});
|
|
3489
|
+
case 4:
|
|
3490
|
+
_context26.t1 = _context26.sent;
|
|
3491
|
+
if (_context26.t1) {
|
|
3492
|
+
_context26.next = 7;
|
|
3493
|
+
break;
|
|
3494
|
+
}
|
|
3495
|
+
_context26.t1 = this.store.summary;
|
|
3496
|
+
case 7:
|
|
3497
|
+
_context26.t0 = _context26.t1;
|
|
3498
|
+
if (_context26.t0) {
|
|
3499
|
+
_context26.next = 10;
|
|
3500
|
+
break;
|
|
3501
|
+
}
|
|
3502
|
+
_context26.t0 = createEmptySummary();
|
|
3503
|
+
case 10:
|
|
3504
|
+
latestSummary = _context26.t0;
|
|
3484
3505
|
effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
|
|
3485
3506
|
hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
|
|
3486
3507
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
@@ -3503,13 +3524,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3503
3524
|
businessCode: (_ref68 = (_params$businessCode2 = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.businessCode) !== null && _ref68 !== void 0 ? _ref68 : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.business_code,
|
|
3504
3525
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
3505
3526
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
3527
|
+
summary: latestSummary,
|
|
3506
3528
|
enhance: enhancePayload
|
|
3507
3529
|
}); // TODO: 前端生成的时间现在是有问题的,后面要统一优化
|
|
3508
|
-
payload.created_at
|
|
3509
|
-
|
|
3530
|
+
if (!payload.created_at) {
|
|
3531
|
+
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
3532
|
+
}
|
|
3533
|
+
_context26.next = 20;
|
|
3510
3534
|
return this.saveDraft();
|
|
3511
|
-
case
|
|
3512
|
-
_context26.prev =
|
|
3535
|
+
case 20:
|
|
3536
|
+
_context26.prev = 20;
|
|
3513
3537
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
3514
3538
|
orderId: payload.order_id,
|
|
3515
3539
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -3518,65 +3542,69 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3518
3542
|
paymentsCount: ((_payload$payments = payload.payments) === null || _payload$payments === void 0 ? void 0 : _payload$payments.length) || 0,
|
|
3519
3543
|
smallTicketDataFlag: payload.small_ticket_data_flag
|
|
3520
3544
|
});
|
|
3521
|
-
_context26.next =
|
|
3545
|
+
_context26.next = 24;
|
|
3522
3546
|
return this.submitSalesOrder({
|
|
3523
3547
|
query: payload
|
|
3524
3548
|
});
|
|
3525
|
-
case
|
|
3549
|
+
case 24:
|
|
3526
3550
|
result = _context26.sent;
|
|
3527
|
-
_context26.next =
|
|
3551
|
+
_context26.next = 37;
|
|
3528
3552
|
break;
|
|
3529
|
-
case
|
|
3530
|
-
_context26.prev =
|
|
3531
|
-
_context26.
|
|
3532
|
-
backendErrorResponse = this.extractSubmitErrorResponse(_context26.
|
|
3553
|
+
case 27:
|
|
3554
|
+
_context26.prev = 27;
|
|
3555
|
+
_context26.t2 = _context26["catch"](20);
|
|
3556
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context26.t2);
|
|
3533
3557
|
if (!backendErrorResponse) {
|
|
3534
|
-
_context26.next =
|
|
3558
|
+
_context26.next = 34;
|
|
3535
3559
|
break;
|
|
3536
3560
|
}
|
|
3537
3561
|
this.store.syncState = 'failed';
|
|
3538
3562
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
3539
3563
|
return _context26.abrupt("return", backendErrorResponse);
|
|
3540
|
-
case
|
|
3564
|
+
case 34:
|
|
3541
3565
|
this.store.syncState = 'failed';
|
|
3542
3566
|
this.logError('submitTempOrder failed', {
|
|
3543
|
-
error: _context26.
|
|
3567
|
+
error: _context26.t2 instanceof Error ? _context26.t2.message : String(_context26.t2),
|
|
3544
3568
|
orderId: payload.order_id,
|
|
3545
3569
|
externalSaleNumber: payload.external_sale_number,
|
|
3546
3570
|
paymentStatus: payload.payment_status,
|
|
3547
3571
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
3548
3572
|
});
|
|
3549
|
-
throw _context26.
|
|
3550
|
-
case
|
|
3573
|
+
throw _context26.t2;
|
|
3574
|
+
case 37:
|
|
3551
3575
|
if (!this.isSubmitResponseRejected(result)) {
|
|
3552
|
-
_context26.next =
|
|
3576
|
+
_context26.next = 41;
|
|
3553
3577
|
break;
|
|
3554
3578
|
}
|
|
3555
3579
|
this.store.syncState = 'failed';
|
|
3556
3580
|
this.logSubmitBackendRejected(result, payload);
|
|
3557
3581
|
return _context26.abrupt("return", result);
|
|
3558
|
-
case
|
|
3582
|
+
case 41:
|
|
3559
3583
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
3560
3584
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
3561
|
-
_context26.next =
|
|
3585
|
+
_context26.next = 49;
|
|
3562
3586
|
break;
|
|
3563
3587
|
}
|
|
3564
3588
|
tempOrder.order_id = submittedOrderId;
|
|
3565
3589
|
resultRecord = result;
|
|
3566
|
-
_context26.next =
|
|
3590
|
+
_context26.next = 47;
|
|
3567
3591
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
3568
|
-
case
|
|
3569
|
-
_context26.next =
|
|
3592
|
+
case 47:
|
|
3593
|
+
_context26.next = 50;
|
|
3570
3594
|
break;
|
|
3571
|
-
case
|
|
3572
|
-
this.
|
|
3573
|
-
|
|
3595
|
+
case 49:
|
|
3596
|
+
if (this.isLocalPendingSubmitResult(result)) {
|
|
3597
|
+
this.store.syncState = 'local';
|
|
3598
|
+
} else {
|
|
3599
|
+
this.store.syncState = 'submitted';
|
|
3600
|
+
}
|
|
3601
|
+
case 50:
|
|
3574
3602
|
return _context26.abrupt("return", result);
|
|
3575
|
-
case
|
|
3603
|
+
case 51:
|
|
3576
3604
|
case "end":
|
|
3577
3605
|
return _context26.stop();
|
|
3578
3606
|
}
|
|
3579
|
-
}, _callee24, this, [[
|
|
3607
|
+
}, _callee24, this, [[20, 27]]);
|
|
3580
3608
|
}));
|
|
3581
3609
|
function submitTempOrder(_x26) {
|
|
3582
3610
|
return _submitTempOrder.apply(this, arguments);
|
|
@@ -3617,6 +3645,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3617
3645
|
var isErrorSuccess = (response === null || response === void 0 ? void 0 : response.success) === false;
|
|
3618
3646
|
return isErrorCode || isErrorStatus || isErrorSuccess;
|
|
3619
3647
|
}
|
|
3648
|
+
}, {
|
|
3649
|
+
key: "isLocalPendingSubmitResult",
|
|
3650
|
+
value: function isLocalPendingSubmitResult(response) {
|
|
3651
|
+
var data = response !== null && response !== void 0 && response.data && _typeof(response.data) === 'object' ? response.data : response;
|
|
3652
|
+
return Number(data === null || data === void 0 ? void 0 : data.need_sync) === 1;
|
|
3653
|
+
}
|
|
3620
3654
|
}, {
|
|
3621
3655
|
key: "isSubmitErrorResponse",
|
|
3622
3656
|
value: function isSubmitErrorResponse(response) {
|
|
@@ -249,7 +249,7 @@ export interface OrderTempOrder {
|
|
|
249
249
|
delivery_type?: string;
|
|
250
250
|
table_number?: Record<string, any>;
|
|
251
251
|
schedule_date: string;
|
|
252
|
-
created_at: string;
|
|
252
|
+
created_at: string | undefined;
|
|
253
253
|
request_unique_idempotency_token?: string;
|
|
254
254
|
products: OrderProduct[];
|
|
255
255
|
bookings: any[];
|
|
@@ -261,6 +261,7 @@ export interface OrderTempOrder {
|
|
|
261
261
|
contacts_info: Record<string, any> | null;
|
|
262
262
|
holder: Record<string, any> | null;
|
|
263
263
|
metadata: Record<string, any>;
|
|
264
|
+
summary?: OrderSummary;
|
|
264
265
|
_extend?: {
|
|
265
266
|
productsByUid?: Record<string, Record<string, any>>;
|
|
266
267
|
[key: string]: any;
|
|
@@ -280,6 +281,7 @@ export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'p
|
|
|
280
281
|
form_record_id: number | string;
|
|
281
282
|
}>;
|
|
282
283
|
products: OrderSubmitProduct[];
|
|
284
|
+
summary?: OrderSummary;
|
|
283
285
|
small_ticket_data_flag?: number;
|
|
284
286
|
}
|
|
285
287
|
export interface OrderState {
|
|
@@ -410,6 +412,7 @@ export interface SubmitSalesOrderParams {
|
|
|
410
412
|
contacts_info: Record<string, any> | null;
|
|
411
413
|
holder: Record<string, any> | null;
|
|
412
414
|
metadata: Record<string, any>;
|
|
415
|
+
summary?: OrderSummary;
|
|
413
416
|
small_ticket_data_flag?: number;
|
|
414
417
|
};
|
|
415
418
|
}
|
|
@@ -187,6 +187,7 @@ export declare function buildSubmitPayload(params: {
|
|
|
187
187
|
businessCode?: string;
|
|
188
188
|
channel?: string;
|
|
189
189
|
type?: string;
|
|
190
|
+
summary?: OrderSummary | null;
|
|
190
191
|
enhance?: SubmitPayloadEnhancer;
|
|
191
192
|
}): OrderSubmitPayload;
|
|
192
193
|
export declare function mapPaymentItemToOrderPayment(paymentItem: OrderPaymentSource): OrderPaymentData;
|