@pisell/pisellos 2.2.209 → 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 +1076 -916
- 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 +24 -22
- 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 +136 -21
- 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 +14 -9
- package/package.json +1 -1
|
@@ -127,7 +127,7 @@ function buildLocaleData(params) {
|
|
|
127
127
|
}),
|
|
128
128
|
customer: buildCustomer(order, locale),
|
|
129
129
|
appointment: buildAppointment(order, locale),
|
|
130
|
-
delivery: buildDelivery(order, locale),
|
|
130
|
+
// delivery: buildDelivery(order, locale),
|
|
131
131
|
resources: buildResources(order, locale),
|
|
132
132
|
payment_data: buildPaymentData({
|
|
133
133
|
order: order,
|
|
@@ -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 | 1 | 2 | 5 | 3 |
|
|
314
|
+
weekNum: 0 | 1 | 2 | 5 | 3 | 4 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -330,7 +330,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
330
330
|
count: number;
|
|
331
331
|
left: number;
|
|
332
332
|
summaryCount: number;
|
|
333
|
-
status: "
|
|
333
|
+
status: "sold_out" | "lots_of_space" | "filling_up_fast";
|
|
334
334
|
}[];
|
|
335
335
|
/**
|
|
336
336
|
* 找到多个资源的公共可用时间段
|
|
@@ -250,13 +250,13 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
250
250
|
return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
|
|
251
251
|
case 4:
|
|
252
252
|
res = _context3.sent;
|
|
253
|
-
if (!res.short_number) {
|
|
253
|
+
if (!(res !== null && res !== void 0 && res.short_number)) {
|
|
254
254
|
_context3.next = 7;
|
|
255
255
|
break;
|
|
256
256
|
}
|
|
257
|
-
return _context3.abrupt("return", res.short_number);
|
|
257
|
+
return _context3.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
|
|
258
258
|
case 7:
|
|
259
|
-
return _context3.abrupt("return", this.getAppData('device_id') || 0);
|
|
259
|
+
return _context3.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
|
|
260
260
|
case 8:
|
|
261
261
|
case "end":
|
|
262
262
|
return _context3.stop();
|
|
@@ -272,8 +272,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
272
272
|
key: "configureIdGeneratorFromOpenData",
|
|
273
273
|
value: function () {
|
|
274
274
|
var _configureIdGeneratorFromOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
275
|
-
var _openDataConfig, _openDataConfig2, _openDataConfig3, _openDataConfig4, _openDataConfig5;
|
|
276
|
-
var openDataConfig, idGenerator, receiptSequenceLength, receiptSequenceStart, prefix, resetReceiptSequenceDaily, operatingDayBoundary, deviceId;
|
|
275
|
+
var _openDataConfig, _openDataConfig2, _openDataConfig3, _openDataConfig4, _openDataConfig5, _openDataConfig6;
|
|
276
|
+
var openDataConfig, idGenerator, receiptSequenceLength, receiptSequenceStart, prefix, shopOrderPrefix, resetReceiptSequenceDaily, operatingDayBoundary, deviceId;
|
|
277
277
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
278
278
|
while (1) switch (_context4.prev = _context4.next) {
|
|
279
279
|
case 0:
|
|
@@ -300,17 +300,18 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
300
300
|
console.warn('[BookingTicket] idGenerator 插件不可用,跳过配置');
|
|
301
301
|
return _context4.abrupt("return");
|
|
302
302
|
case 15:
|
|
303
|
-
receiptSequenceLength = this.normalizePositiveInteger((_openDataConfig = openDataConfig) === null || _openDataConfig === void 0 ? void 0 : _openDataConfig['sale.short_number_digits'],
|
|
303
|
+
receiptSequenceLength = this.normalizePositiveInteger((_openDataConfig = openDataConfig) === null || _openDataConfig === void 0 ? void 0 : _openDataConfig['sale.short_number_digits'], 2);
|
|
304
304
|
receiptSequenceStart = this.normalizePositiveInteger((_openDataConfig2 = openDataConfig) === null || _openDataConfig2 === void 0 ? void 0 : _openDataConfig2['sale.short_number_start_number'], 1);
|
|
305
|
-
prefix = this.normalizeIdPrefix((_openDataConfig3 = openDataConfig) === null || _openDataConfig3 === void 0 ? void 0 : _openDataConfig3['sale.short_number_prefix'], '
|
|
306
|
-
|
|
305
|
+
prefix = this.normalizeIdPrefix((_openDataConfig3 = openDataConfig) === null || _openDataConfig3 === void 0 ? void 0 : _openDataConfig3['sale.short_number_prefix'], '');
|
|
306
|
+
shopOrderPrefix = this.normalizeIdPrefix((_openDataConfig4 = openDataConfig) === null || _openDataConfig4 === void 0 ? void 0 : _openDataConfig4['sale.sale_number_prefix'], '');
|
|
307
|
+
resetReceiptSequenceDaily = typeof ((_openDataConfig5 = openDataConfig) === null || _openDataConfig5 === void 0 ? void 0 : _openDataConfig5['sale.short_number_daily_reset']) === 'boolean' ? (_openDataConfig6 = openDataConfig) === null || _openDataConfig6 === void 0 ? void 0 : _openDataConfig6['sale.short_number_daily_reset'] : false;
|
|
307
308
|
operatingDayBoundary = this.getAppData('operating_day_boundary');
|
|
308
|
-
_context4.next =
|
|
309
|
+
_context4.next = 23;
|
|
309
310
|
return this.getShortNumberOrDeviceId();
|
|
310
|
-
case
|
|
311
|
+
case 23:
|
|
311
312
|
deviceId = _context4.sent;
|
|
312
|
-
_context4.prev =
|
|
313
|
-
_context4.next =
|
|
313
|
+
_context4.prev = 24;
|
|
314
|
+
_context4.next = 27;
|
|
314
315
|
return idGenerator.configure({
|
|
315
316
|
biz: this.getBookingTicketBusinessCode() || 'ticket',
|
|
316
317
|
config: {
|
|
@@ -321,21 +322,22 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
321
322
|
receiptSequenceLength: receiptSequenceLength,
|
|
322
323
|
resetReceiptSequenceDaily: resetReceiptSequenceDaily,
|
|
323
324
|
receiptSequenceResetTime: operatingDayBoundary.time,
|
|
324
|
-
receiptSequenceStart: receiptSequenceStart
|
|
325
|
+
receiptSequenceStart: receiptSequenceStart,
|
|
326
|
+
shopOrderPrefix: shopOrderPrefix
|
|
325
327
|
}
|
|
326
328
|
});
|
|
327
|
-
case
|
|
328
|
-
_context4.next =
|
|
329
|
+
case 27:
|
|
330
|
+
_context4.next = 32;
|
|
329
331
|
break;
|
|
330
|
-
case
|
|
331
|
-
_context4.prev =
|
|
332
|
-
_context4.t1 = _context4["catch"](
|
|
332
|
+
case 29:
|
|
333
|
+
_context4.prev = 29;
|
|
334
|
+
_context4.t1 = _context4["catch"](24);
|
|
333
335
|
console.warn('[BookingTicket] idGenerator 配置失败', _context4.t1);
|
|
334
|
-
case
|
|
336
|
+
case 32:
|
|
335
337
|
case "end":
|
|
336
338
|
return _context4.stop();
|
|
337
339
|
}
|
|
338
|
-
}, _callee4, this, [[1, 7], [
|
|
340
|
+
}, _callee4, this, [[1, 7], [24, 29]]);
|
|
339
341
|
}));
|
|
340
342
|
function configureIdGeneratorFromOpenData() {
|
|
341
343
|
return _configureIdGeneratorFromOpenData.apply(this, arguments);
|
|
@@ -807,8 +809,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
807
809
|
throw new Error('refreshSalesDetail: tempOrder.order_id 缺失');
|
|
808
810
|
case 6:
|
|
809
811
|
return _context11.abrupt("return", this.loadSalesDetail({
|
|
810
|
-
orderId: Number(orderId)
|
|
811
|
-
forceRemote: true
|
|
812
|
+
orderId: Number(orderId)
|
|
813
|
+
// forceRemote: true,
|
|
812
814
|
}));
|
|
813
815
|
case 7:
|
|
814
816
|
case "end":
|
|
@@ -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
|
*/
|
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var BookingContext_exports = {};
|
|
32
32
|
__export(BookingContext_exports, {
|
|
33
33
|
BookingContextModule: () => BookingContextModule,
|
|
34
|
+
__clearBookingContextSharedCacheForTest: () => __clearBookingContextSharedCacheForTest,
|
|
34
35
|
buildBookingConfigQueryKey: () => buildBookingConfigQueryKey,
|
|
35
36
|
buildBookingResourcesQueryKey: () => buildBookingResourcesQueryKey
|
|
36
37
|
});
|
|
@@ -67,6 +68,30 @@ var RESOURCE_LIST_CACHE = {
|
|
|
67
68
|
type: "memory"
|
|
68
69
|
}
|
|
69
70
|
};
|
|
71
|
+
var requestScopeIds = /* @__PURE__ */ new WeakMap();
|
|
72
|
+
var nextRequestScopeId = 1;
|
|
73
|
+
var sharedBookingConfigCache = /* @__PURE__ */ new Map();
|
|
74
|
+
var sharedBookingConfigPending = /* @__PURE__ */ new Map();
|
|
75
|
+
var sharedResourcesCache = /* @__PURE__ */ new Map();
|
|
76
|
+
var sharedResourcesPending = /* @__PURE__ */ new Map();
|
|
77
|
+
function getRequestScopeId(request) {
|
|
78
|
+
const key = request;
|
|
79
|
+
const existed = requestScopeIds.get(key);
|
|
80
|
+
if (existed)
|
|
81
|
+
return existed;
|
|
82
|
+
const id = nextRequestScopeId++;
|
|
83
|
+
requestScopeIds.set(key, id);
|
|
84
|
+
return id;
|
|
85
|
+
}
|
|
86
|
+
function buildSharedCacheKey(request, queryKey) {
|
|
87
|
+
return `${getRequestScopeId(request)}:${queryKey}`;
|
|
88
|
+
}
|
|
89
|
+
function __clearBookingContextSharedCacheForTest() {
|
|
90
|
+
sharedBookingConfigCache.clear();
|
|
91
|
+
sharedBookingConfigPending.clear();
|
|
92
|
+
sharedResourcesCache.clear();
|
|
93
|
+
sharedResourcesPending.clear();
|
|
94
|
+
}
|
|
70
95
|
function normalizeDate(input) {
|
|
71
96
|
if (input === null || input === void 0)
|
|
72
97
|
return null;
|
|
@@ -148,47 +173,85 @@ var BookingContextModule = class extends import_BaseModule.BaseModule {
|
|
|
148
173
|
this.store.date = initialState.date;
|
|
149
174
|
}
|
|
150
175
|
}
|
|
151
|
-
async loadBookingConfig(params = {}) {
|
|
176
|
+
async loadBookingConfig(params = {}, options = {}) {
|
|
152
177
|
const configKey = buildBookingConfigQueryKey(params);
|
|
153
|
-
if (this.store.bookingConfig != null && this.lastConfigQueryKey === configKey) {
|
|
178
|
+
if (!options.forceRefresh && this.store.bookingConfig != null && this.lastConfigQueryKey === configKey) {
|
|
154
179
|
return this.store.bookingConfig;
|
|
155
180
|
}
|
|
156
181
|
const query = {
|
|
157
182
|
...DEFAULT_BOOKING_CONFIG_PARAMS,
|
|
158
183
|
...params
|
|
159
184
|
};
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
185
|
+
const sharedKey = buildSharedCacheKey(this.request, configKey);
|
|
186
|
+
if (!options.forceRefresh && sharedBookingConfigCache.has(sharedKey)) {
|
|
187
|
+
const cached = sharedBookingConfigCache.get(sharedKey) ?? null;
|
|
188
|
+
this.setBookingConfig(cached);
|
|
189
|
+
this.lastConfigQueryKey = configKey;
|
|
190
|
+
return cached;
|
|
191
|
+
}
|
|
192
|
+
let pending = !options.forceRefresh ? sharedBookingConfigPending.get(sharedKey) : void 0;
|
|
193
|
+
if (!pending) {
|
|
194
|
+
const requestPromise = (async () => {
|
|
195
|
+
try {
|
|
196
|
+
const res = await this.request.get(
|
|
197
|
+
"/core/board/management/config",
|
|
198
|
+
query,
|
|
199
|
+
BOARD_CONFIG_CACHE
|
|
200
|
+
);
|
|
201
|
+
const config2 = (res == null ? void 0 : res.data) ?? null;
|
|
202
|
+
sharedBookingConfigCache.set(sharedKey, config2);
|
|
203
|
+
return config2;
|
|
204
|
+
} finally {
|
|
205
|
+
sharedBookingConfigPending.delete(sharedKey);
|
|
206
|
+
}
|
|
207
|
+
})();
|
|
208
|
+
pending = requestPromise;
|
|
209
|
+
sharedBookingConfigPending.set(sharedKey, requestPromise);
|
|
210
|
+
}
|
|
211
|
+
const config = await pending;
|
|
167
212
|
this.setBookingConfig(config);
|
|
168
|
-
this.lastConfigQueryKey =
|
|
213
|
+
this.lastConfigQueryKey = configKey;
|
|
169
214
|
return config;
|
|
170
215
|
}
|
|
171
|
-
async loadResources(params = {}) {
|
|
216
|
+
async loadResources(params = {}, options = {}) {
|
|
172
217
|
const date = toScheduleQueryDate(params.date ?? this.store.date);
|
|
173
218
|
const resourcesKey = buildBookingResourcesQueryKey({
|
|
174
219
|
date,
|
|
175
220
|
bookingIds: params.bookingIds
|
|
176
221
|
});
|
|
177
|
-
if (this.lastResourcesQueryKey === resourcesKey) {
|
|
222
|
+
if (!options.forceRefresh && this.lastResourcesQueryKey === resourcesKey) {
|
|
178
223
|
return this.getResourcesOrigin();
|
|
179
224
|
}
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
225
|
+
const sharedKey = buildSharedCacheKey(this.request, resourcesKey);
|
|
226
|
+
if (!options.forceRefresh && sharedResourcesCache.has(sharedKey)) {
|
|
227
|
+
const cached = sharedResourcesCache.get(sharedKey) ?? [];
|
|
228
|
+
this.setResources(cached);
|
|
229
|
+
this.lastResourcesQueryKey = resourcesKey;
|
|
230
|
+
return this.getResourcesOrigin();
|
|
231
|
+
}
|
|
232
|
+
let pending = !options.forceRefresh ? sharedResourcesPending.get(sharedKey) : void 0;
|
|
233
|
+
if (!pending) {
|
|
234
|
+
const requestPromise = (async () => {
|
|
235
|
+
try {
|
|
236
|
+
const res = await this.request.get(
|
|
237
|
+
"/schedule/resource/list",
|
|
238
|
+
{ date },
|
|
239
|
+
RESOURCE_LIST_CACHE
|
|
240
|
+
);
|
|
241
|
+
const { list: list2 } = (0, import_formatResourceList.formatResourceListAndMap)(res == null ? void 0 : res.data, params.bookingIds || []);
|
|
242
|
+
sharedResourcesCache.set(sharedKey, list2);
|
|
243
|
+
return list2;
|
|
244
|
+
} finally {
|
|
245
|
+
sharedResourcesPending.delete(sharedKey);
|
|
246
|
+
}
|
|
247
|
+
})();
|
|
248
|
+
pending = requestPromise;
|
|
249
|
+
sharedResourcesPending.set(sharedKey, requestPromise);
|
|
250
|
+
}
|
|
251
|
+
const list = await pending;
|
|
186
252
|
this.setResources(list);
|
|
187
|
-
this.lastResourcesQueryKey =
|
|
188
|
-
|
|
189
|
-
bookingIds: params.bookingIds
|
|
190
|
-
});
|
|
191
|
-
return list;
|
|
253
|
+
this.lastResourcesQueryKey = resourcesKey;
|
|
254
|
+
return this.getResourcesOrigin();
|
|
192
255
|
}
|
|
193
256
|
/**
|
|
194
257
|
* store 内是否已具备与本次 init 入参等价的 config / resources(不再打接口)。
|
|
@@ -220,13 +283,20 @@ var BookingContextModule = class extends import_BaseModule.BaseModule {
|
|
|
220
283
|
const needConfig = params.forceRefresh || this.store.bookingConfig == null || this.lastConfigQueryKey !== configKey;
|
|
221
284
|
const needResources = params.loadResources !== false && (params.forceRefresh || this.lastResourcesQueryKey !== resourcesKey);
|
|
222
285
|
if (needConfig) {
|
|
223
|
-
await this.loadBookingConfig(params.bookingConfigParams
|
|
286
|
+
await this.loadBookingConfig(params.bookingConfigParams, {
|
|
287
|
+
forceRefresh: params.forceRefresh
|
|
288
|
+
});
|
|
224
289
|
}
|
|
225
290
|
if (needResources) {
|
|
226
|
-
await this.loadResources(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
291
|
+
await this.loadResources(
|
|
292
|
+
{
|
|
293
|
+
date: queryDate,
|
|
294
|
+
bookingIds: params.bookingIds
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
forceRefresh: params.forceRefresh
|
|
298
|
+
}
|
|
299
|
+
);
|
|
230
300
|
}
|
|
231
301
|
return this.getState();
|
|
232
302
|
}
|
|
@@ -290,6 +360,7 @@ var BookingContextModule = class extends import_BaseModule.BaseModule {
|
|
|
290
360
|
// Annotate the CommonJS export names for ESM import in node:
|
|
291
361
|
0 && (module.exports = {
|
|
292
362
|
BookingContextModule,
|
|
363
|
+
__clearBookingContextSharedCacheForTest,
|
|
293
364
|
buildBookingConfigQueryKey,
|
|
294
365
|
buildBookingResourcesQueryKey,
|
|
295
366
|
...require("./types"),
|
|
@@ -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;
|
|
@@ -2538,6 +2538,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2538
2538
|
businessCode: (params == null ? void 0 : params.businessCode) ?? ((_b = this.otherParams) == null ? void 0 : _b.businessCode) ?? ((_c = this.otherParams) == null ? void 0 : _c.business_code),
|
|
2539
2539
|
channel: params == null ? void 0 : params.channel,
|
|
2540
2540
|
type: params == null ? void 0 : params.type,
|
|
2541
|
+
summary: this.store.summary || (0, import_utils.createEmptySummary)(),
|
|
2541
2542
|
enhance: (nextPayload) => ({
|
|
2542
2543
|
...nextPayload,
|
|
2543
2544
|
order_number: tempOrder.order_number ?? nextPayload.order_number ?? null,
|
|
@@ -2575,6 +2576,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2575
2576
|
var _a, _b, _c, _d, _e;
|
|
2576
2577
|
const tempOrder = this.ensureTempOrder();
|
|
2577
2578
|
this.persistTempOrder();
|
|
2579
|
+
const latestSummary = await this.recalculateSummary({ createIfMissing: true }) || this.store.summary || (0, import_utils.createEmptySummary)();
|
|
2578
2580
|
const effectiveCacheId = (params == null ? void 0 : params.cacheId) ?? this.cacheId;
|
|
2579
2581
|
const hasPaymentOverride = (params == null ? void 0 : params.payments) !== void 0;
|
|
2580
2582
|
const hasPaymentStatusOverride = (params == null ? void 0 : params.paymentStatus) !== void 0;
|
|
@@ -2600,9 +2602,12 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2600
2602
|
businessCode: (params == null ? void 0 : params.businessCode) ?? ((_b = this.otherParams) == null ? void 0 : _b.businessCode) ?? ((_c = this.otherParams) == null ? void 0 : _c.business_code),
|
|
2601
2603
|
channel: params == null ? void 0 : params.channel,
|
|
2602
2604
|
type: params == null ? void 0 : params.type,
|
|
2605
|
+
summary: latestSummary,
|
|
2603
2606
|
enhance: enhancePayload
|
|
2604
2607
|
});
|
|
2605
|
-
payload.created_at
|
|
2608
|
+
if (!payload.created_at) {
|
|
2609
|
+
payload.created_at = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
2610
|
+
}
|
|
2606
2611
|
await this.saveDraft();
|
|
2607
2612
|
let result;
|
|
2608
2613
|
try {
|
|
@@ -2647,6 +2652,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2647
2652
|
submittedOrderId,
|
|
2648
2653
|
(resultRecord == null ? void 0 : resultRecord.data) || resultRecord || {}
|
|
2649
2654
|
);
|
|
2655
|
+
} else if (this.isLocalPendingSubmitResult(result)) {
|
|
2656
|
+
this.store.syncState = "local";
|
|
2650
2657
|
} else {
|
|
2651
2658
|
this.store.syncState = "submitted";
|
|
2652
2659
|
}
|
|
@@ -2666,6 +2673,10 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2666
2673
|
const isErrorSuccess = (response == null ? void 0 : response.success) === false;
|
|
2667
2674
|
return isErrorCode || isErrorStatus || isErrorSuccess;
|
|
2668
2675
|
}
|
|
2676
|
+
isLocalPendingSubmitResult(response) {
|
|
2677
|
+
const data = (response == null ? void 0 : response.data) && typeof response.data === "object" ? response.data : response;
|
|
2678
|
+
return Number(data == null ? void 0 : data.need_sync) === 1;
|
|
2679
|
+
}
|
|
2669
2680
|
isSubmitErrorResponse(response) {
|
|
2670
2681
|
if (!response || typeof response !== "object")
|
|
2671
2682
|
return false;
|
|
@@ -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;
|
|
@@ -684,7 +684,7 @@ function createDefaultTempOrder(params) {
|
|
|
684
684
|
surcharge_fee: "0.00",
|
|
685
685
|
note: "",
|
|
686
686
|
schedule_date: params.now,
|
|
687
|
-
created_at:
|
|
687
|
+
created_at: void 0,
|
|
688
688
|
request_unique_idempotency_token: "",
|
|
689
689
|
vouchers: [],
|
|
690
690
|
products: [],
|
|
@@ -711,6 +711,7 @@ function buildSubmitPayload(params) {
|
|
|
711
711
|
businessCode,
|
|
712
712
|
channel,
|
|
713
713
|
type,
|
|
714
|
+
summary,
|
|
714
715
|
enhance
|
|
715
716
|
} = params;
|
|
716
717
|
const scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
|
|
@@ -778,7 +779,7 @@ function buildSubmitPayload(params) {
|
|
|
778
779
|
// contacts: tempOrder.contacts || [],
|
|
779
780
|
contacts_info: tempOrder.contacts_info && !Array.isArray(tempOrder.contacts_info) ? tempOrder.contacts_info : null,
|
|
780
781
|
// holder: tempOrder.holder || null,
|
|
781
|
-
|
|
782
|
+
summary: summary || tempOrder.summary || (0, import_utils.createEmptySummary)(),
|
|
782
783
|
metadata: (() => {
|
|
783
784
|
const {
|
|
784
785
|
collect_pax: _collectPax,
|
|
@@ -791,7 +792,13 @@ function buildSubmitPayload(params) {
|
|
|
791
792
|
(product) => normalizeSubmitProduct(product)
|
|
792
793
|
)
|
|
793
794
|
};
|
|
794
|
-
|
|
795
|
+
if (!enhance)
|
|
796
|
+
return payload;
|
|
797
|
+
const enhancedPayload = enhance(payload, { tempOrder, bookingUuid, now });
|
|
798
|
+
return {
|
|
799
|
+
...enhancedPayload,
|
|
800
|
+
summary: enhancedPayload.summary ?? payload.summary
|
|
801
|
+
};
|
|
795
802
|
}
|
|
796
803
|
function mapPaymentItemToOrderPayment(paymentItem) {
|
|
797
804
|
const item = paymentItem;
|
|
@@ -49,7 +49,7 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
|
|
|
49
49
|
const res = await this.request.get(
|
|
50
50
|
"/quotation/available",
|
|
51
51
|
query,
|
|
52
|
-
{ useCache: false }
|
|
52
|
+
{ useCache: false, osServer: true }
|
|
53
53
|
);
|
|
54
54
|
const list = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || (res == null ? void 0 : res.list) || [];
|
|
55
55
|
list.sort((a, b) => a.sort - b.sort);
|
|
@@ -8,6 +8,7 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
8
8
|
private appPlugin;
|
|
9
9
|
private store;
|
|
10
10
|
private request;
|
|
11
|
+
private surchargeListModuleName;
|
|
11
12
|
constructor(name?: string, version?: string);
|
|
12
13
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
13
14
|
getSurchargeList(): Promise<void>;
|
|
@@ -38,15 +38,17 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
38
38
|
super(name, version);
|
|
39
39
|
this.defaultName = "salesSummary";
|
|
40
40
|
this.defaultVersion = "1.0.0";
|
|
41
|
+
this.surchargeListModuleName = "surchargeList";
|
|
41
42
|
}
|
|
42
43
|
async initialize(core, options) {
|
|
43
|
-
var _a, _b;
|
|
44
|
+
var _a, _b, _c;
|
|
44
45
|
this.core = core;
|
|
45
46
|
this.store = options.store;
|
|
46
47
|
this.appPlugin = this.core.getPlugin("app");
|
|
47
48
|
this.request = this.core.getPlugin("request");
|
|
48
49
|
this.store.surchargeList = ((_a = options.initialState) == null ? void 0 : _a.surchargeList) || [];
|
|
49
50
|
this.store.summary = ((_b = options.initialState) == null ? void 0 : _b.summary) || (0, import_utils.createEmptySalesSummary)();
|
|
51
|
+
this.surchargeListModuleName = ((_c = options.otherParams) == null ? void 0 : _c.surchargeListModuleName) || "surchargeList";
|
|
50
52
|
if (!this.appPlugin) {
|
|
51
53
|
throw new Error("SalesSummaryModule 需要 app 插件支持");
|
|
52
54
|
}
|
|
@@ -57,9 +59,17 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
57
59
|
}
|
|
58
60
|
async getSurchargeList() {
|
|
59
61
|
try {
|
|
62
|
+
const surchargeListModule = this.core.getModule(
|
|
63
|
+
this.surchargeListModuleName
|
|
64
|
+
);
|
|
65
|
+
if (surchargeListModule == null ? void 0 : surchargeListModule.getSurchargeList) {
|
|
66
|
+
this.store.surchargeList = await surchargeListModule.getSurchargeList();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
60
69
|
const surchargeList = await this.request.get(
|
|
61
70
|
"/order/custom-surcharge/available/v2",
|
|
62
71
|
{
|
|
72
|
+
// TODO 真实的渠道
|
|
63
73
|
channel: "online-store",
|
|
64
74
|
is_assemble_product_data: 1,
|
|
65
75
|
is_assemble_schedule_data: 1,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import { SurchargeListItem, SurchargeListModuleAPI } from './types';
|
|
4
|
+
export * from './types';
|
|
5
|
+
export declare class SurchargeListModule extends BaseModule implements Module, SurchargeListModuleAPI {
|
|
6
|
+
protected defaultName: string;
|
|
7
|
+
protected defaultVersion: string;
|
|
8
|
+
private request;
|
|
9
|
+
private store;
|
|
10
|
+
private loadingPromise;
|
|
11
|
+
constructor(name?: string, version?: string);
|
|
12
|
+
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
13
|
+
getSurchargeList(): Promise<SurchargeListItem[]>;
|
|
14
|
+
refreshSurchargeList(): Promise<SurchargeListItem[]>;
|
|
15
|
+
private loadSurchargeList;
|
|
16
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/modules/SurchargeList/index.ts
|
|
21
|
+
var SurchargeList_exports = {};
|
|
22
|
+
__export(SurchargeList_exports, {
|
|
23
|
+
SurchargeListModule: () => SurchargeListModule
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(SurchargeList_exports);
|
|
26
|
+
var import_BaseModule = require("../BaseModule");
|
|
27
|
+
__reExport(SurchargeList_exports, require("./types"), module.exports);
|
|
28
|
+
var SurchargeListModule = class extends import_BaseModule.BaseModule {
|
|
29
|
+
constructor(name, version) {
|
|
30
|
+
super(name, version);
|
|
31
|
+
this.defaultName = "surchargeList";
|
|
32
|
+
this.defaultVersion = "1.0.0";
|
|
33
|
+
this.loadingPromise = null;
|
|
34
|
+
}
|
|
35
|
+
async initialize(core, options) {
|
|
36
|
+
var _a, _b, _c;
|
|
37
|
+
this.core = core;
|
|
38
|
+
this.store = options.store;
|
|
39
|
+
this.request = this.core.getPlugin("request");
|
|
40
|
+
const hasInitialSurchargeList = Array.isArray(
|
|
41
|
+
(_a = options.initialState) == null ? void 0 : _a.surchargeList
|
|
42
|
+
);
|
|
43
|
+
this.store.surchargeList = hasInitialSurchargeList ? (_b = options.initialState) == null ? void 0 : _b.surchargeList : [];
|
|
44
|
+
this.store.isLoaded = Boolean((_c = options.initialState) == null ? void 0 : _c.isLoaded) || hasInitialSurchargeList;
|
|
45
|
+
if (!this.request) {
|
|
46
|
+
throw new Error("SurchargeListModule 需要 request 插件支持");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async getSurchargeList() {
|
|
50
|
+
if (this.store.isLoaded)
|
|
51
|
+
return this.store.surchargeList;
|
|
52
|
+
if (this.loadingPromise)
|
|
53
|
+
return this.loadingPromise;
|
|
54
|
+
this.loadingPromise = this.loadSurchargeList();
|
|
55
|
+
return this.loadingPromise;
|
|
56
|
+
}
|
|
57
|
+
async refreshSurchargeList() {
|
|
58
|
+
this.loadingPromise = this.loadSurchargeList();
|
|
59
|
+
return this.loadingPromise;
|
|
60
|
+
}
|
|
61
|
+
async loadSurchargeList() {
|
|
62
|
+
try {
|
|
63
|
+
const surchargeList = await this.request.get(
|
|
64
|
+
"/order/custom-surcharge/available/v2",
|
|
65
|
+
{
|
|
66
|
+
channel: "online-store",
|
|
67
|
+
is_assemble_product_data: 1,
|
|
68
|
+
is_assemble_schedule_data: 1,
|
|
69
|
+
with: ["relationSchedule"]
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
this.store.surchargeList = (surchargeList == null ? void 0 : surchargeList.data) || [];
|
|
73
|
+
this.store.isLoaded = true;
|
|
74
|
+
return this.store.surchargeList;
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.warn("[SurchargeListModule] 加载附加费配置失败", error);
|
|
77
|
+
this.store.surchargeList = [];
|
|
78
|
+
this.store.isLoaded = true;
|
|
79
|
+
return this.store.surchargeList;
|
|
80
|
+
} finally {
|
|
81
|
+
this.loadingPromise = null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
SurchargeListModule,
|
|
88
|
+
...require("./types")
|
|
89
|
+
});
|