@pisell/pisellos 2.3.105 → 2.3.107
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/Discount/index.js +4 -1
- package/dist/modules/Discount/types.d.ts +10 -0
- package/dist/modules/OpenData/index.d.ts +15 -2
- package/dist/modules/OpenData/index.js +307 -19
- package/dist/modules/OpenData/types.d.ts +55 -0
- package/dist/modules/OpenData/types.js +7 -1
- package/dist/modules/OpenData/utils.d.ts +21 -1
- package/dist/modules/OpenData/utils.js +138 -0
- package/dist/modules/Order/index.d.ts +3 -1
- package/dist/modules/Order/index.js +89 -16
- package/dist/modules/Order/types.d.ts +13 -0
- package/dist/modules/Order/utils.d.ts +4 -1
- package/dist/modules/Order/utils.js +57 -3
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -2
- package/dist/modules/ResourcePlanner/planner.js +172 -49
- package/dist/modules/ResourcePlanner/types.d.ts +19 -0
- package/dist/modules/Rules/index.js +1 -1
- package/dist/plugins/request.d.ts +2 -1
- package/dist/plugins/request.js +4 -2
- package/dist/server/index.d.ts +15 -0
- package/dist/server/index.js +1734 -1285
- package/dist/server/modules/order/types.d.ts +50 -0
- package/dist/server/modules/order/types.js +2 -0
- package/dist/server/utils/small-ticket.d.ts +4 -1
- package/dist/server/utils/small-ticket.js +461 -96
- package/dist/solution/BaseSales/index.d.ts +5 -1
- package/dist/solution/BaseSales/index.js +120 -45
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +8 -3
- package/dist/solution/BookingTicket/index.js +558 -443
- package/dist/solution/Sales/index.d.ts +16 -1
- package/dist/solution/Sales/index.js +338 -63
- package/dist/solution/Sales/types.d.ts +10 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/dist/solution/UnifiedBookingSales/index.js +614 -462
- package/dist/solution/UnifiedBookingSales/types.d.ts +7 -1
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Discount/index.js +4 -1
- package/lib/modules/Discount/types.d.ts +10 -0
- package/lib/modules/OpenData/index.d.ts +15 -2
- package/lib/modules/OpenData/index.js +230 -3
- package/lib/modules/OpenData/types.d.ts +55 -0
- package/lib/modules/OpenData/types.js +9 -1
- package/lib/modules/OpenData/utils.d.ts +21 -1
- package/lib/modules/OpenData/utils.js +126 -0
- package/lib/modules/Order/index.d.ts +3 -1
- package/lib/modules/Order/index.js +69 -1
- package/lib/modules/Order/types.d.ts +13 -0
- package/lib/modules/Order/utils.d.ts +4 -1
- package/lib/modules/Order/utils.js +58 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -2
- package/lib/modules/ResourcePlanner/planner.js +141 -35
- package/lib/modules/ResourcePlanner/types.d.ts +19 -0
- package/lib/modules/Rules/index.js +1 -1
- package/lib/plugins/request.d.ts +2 -1
- package/lib/plugins/request.js +3 -2
- package/lib/server/index.d.ts +15 -0
- package/lib/server/index.js +455 -105
- package/lib/server/modules/order/types.d.ts +50 -0
- package/lib/server/modules/order/types.js +1 -0
- package/lib/server/utils/small-ticket.d.ts +4 -1
- package/lib/server/utils/small-ticket.js +427 -72
- package/lib/solution/BaseSales/index.d.ts +5 -1
- package/lib/solution/BaseSales/index.js +84 -7
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +8 -3
- package/lib/solution/BookingTicket/index.js +60 -15
- package/lib/solution/Sales/index.d.ts +16 -1
- package/lib/solution/Sales/index.js +168 -1
- package/lib/solution/Sales/types.d.ts +10 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/lib/solution/UnifiedBookingSales/index.js +128 -35
- package/lib/solution/UnifiedBookingSales/types.d.ts +7 -1
- package/package.json +1 -1
|
@@ -151,9 +151,13 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
151
151
|
private getAuthoritativeBundleUnitPrice;
|
|
152
152
|
private mergeProductForPriceQuery;
|
|
153
153
|
protected getSubmitOrderSalesChannel(): string | undefined;
|
|
154
|
+
/** Subclasses with target-scoped OpenData override this guard before reusing the cache. */
|
|
155
|
+
protected isInvoiceOpenDataCacheCurrent(): boolean;
|
|
154
156
|
private getFulfillmentRefModeConfigs;
|
|
155
157
|
private getFulfillmentRefMode;
|
|
156
|
-
private
|
|
158
|
+
private getCachedInvoiceLayoutConfig;
|
|
159
|
+
private getCachedInvoiceTemplateSettings;
|
|
160
|
+
private buildSubmitPayloadEnhancerWithOpenDataConfig;
|
|
157
161
|
/**
|
|
158
162
|
* 工厂入口:根据子模块名实例化对应模块。
|
|
159
163
|
* 默认使用 BookingByStep 公共 `createModule`。子类若需引入额外类型(如 customer),
|
|
@@ -38,6 +38,8 @@ var _quotationPrice = require("./utils/quotationPrice");
|
|
|
38
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
39
|
const SERVER_ORDER_CHANGED_EVENT = 'order:onOrdersChanged';
|
|
40
40
|
const OS_FULFILLMENT_REF_MODE_FIELD = '_os_fulfillment_ref_mode';
|
|
41
|
+
const OS_INVOICE_LAYOUT_CONFIG_FIELD = '_os_invoice_layout_config';
|
|
42
|
+
const OS_INVOICE_TEMPLATE_SETTINGS_FIELD = '_os_invoice_template_settings';
|
|
41
43
|
const WALLET_PAYMENT_CODE_BY_TAG = {
|
|
42
44
|
product_voucher: 'PRODUCTVOUCHER',
|
|
43
45
|
gift_card: 'GIFTCARD',
|
|
@@ -257,6 +259,22 @@ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
|
|
|
257
259
|
}
|
|
258
260
|
return normalizedRecord;
|
|
259
261
|
}
|
|
262
|
+
function isValidBaseSalesSmallTicketDataSnapshot(value) {
|
|
263
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return false;
|
|
264
|
+
const localeSnapshots = Object.values(value);
|
|
265
|
+
return localeSnapshots.length > 0 && localeSnapshots.some(localeSnapshot => localeSnapshot !== null && typeof localeSnapshot === 'object' && !Array.isArray(localeSnapshot));
|
|
266
|
+
}
|
|
267
|
+
function mergeBaseSalesSmallTicketDataSnapshot(currentValue, loadedValue) {
|
|
268
|
+
if (isValidBaseSalesSmallTicketDataSnapshot(loadedValue)) {
|
|
269
|
+
return (0, _lodashEs.cloneDeep)(loadedValue);
|
|
270
|
+
}
|
|
271
|
+
if (isValidBaseSalesSmallTicketDataSnapshot(currentValue)) {
|
|
272
|
+
return (0, _lodashEs.cloneDeep)(currentValue);
|
|
273
|
+
}
|
|
274
|
+
if (loadedValue !== undefined) return (0, _lodashEs.cloneDeep)(loadedValue);
|
|
275
|
+
if (currentValue !== undefined) return (0, _lodashEs.cloneDeep)(currentValue);
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
260
278
|
function getBaseSalesMetadataUid(item, metadataKey) {
|
|
261
279
|
const uid = item?.metadata?.[metadataKey] ?? item?.[metadataKey];
|
|
262
280
|
if (uid === undefined || uid === null || uid === '') return null;
|
|
@@ -351,6 +369,11 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
351
369
|
}
|
|
352
370
|
if (Array.isArray(loadedValue)) return (0, _lodashEs.cloneDeep)(loadedValue);
|
|
353
371
|
}
|
|
372
|
+
// small_ticket_data 是由 Server 一次性生成的完整展示快照,不能递归进入
|
|
373
|
+
// locale 内部继续套用订单集合或普通数组的合并规则。
|
|
374
|
+
if (key === 'small_ticket_data') {
|
|
375
|
+
return mergeBaseSalesSmallTicketDataSnapshot(currentValue, loadedValue);
|
|
376
|
+
}
|
|
354
377
|
const collectionKind = getBaseSalesOrderCollectionKind(key);
|
|
355
378
|
if (collectionKind && Array.isArray(loadedValue)) {
|
|
356
379
|
return mergeBaseSalesOrderCollection(collectionKind, Array.isArray(currentValue) ? currentValue : [], loadedValue, strategy, uidRemaps);
|
|
@@ -1115,6 +1138,11 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
1115
1138
|
getSubmitOrderSalesChannel() {
|
|
1116
1139
|
return this.otherParams?.channel;
|
|
1117
1140
|
}
|
|
1141
|
+
|
|
1142
|
+
/** Subclasses with target-scoped OpenData override this guard before reusing the cache. */
|
|
1143
|
+
isInvoiceOpenDataCacheCurrent() {
|
|
1144
|
+
return true;
|
|
1145
|
+
}
|
|
1118
1146
|
getFulfillmentRefModeConfigs() {
|
|
1119
1147
|
const candidates = [this.otherParams?.openData, this.otherParams?.dineInConfig, this.store?.openData?.getOpenData?.()];
|
|
1120
1148
|
return candidates.filter(candidate => candidate && typeof candidate === 'object' && !Array.isArray(candidate));
|
|
@@ -1128,14 +1156,52 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
1128
1156
|
}
|
|
1129
1157
|
return undefined;
|
|
1130
1158
|
}
|
|
1131
|
-
|
|
1159
|
+
getCachedInvoiceLayoutConfig() {
|
|
1160
|
+
const openDataModule = this.store?.openData;
|
|
1161
|
+
if (typeof openDataModule?.getInvoiceLayoutConfig !== 'function') return undefined;
|
|
1162
|
+
if (!this.isInvoiceOpenDataCacheCurrent()) return undefined;
|
|
1163
|
+
try {
|
|
1164
|
+
return openDataModule.getInvoiceLayoutConfig();
|
|
1165
|
+
} catch (error) {
|
|
1166
|
+
this.logWarning('读取 Invoice OpenData 布局失败,提交时不注入布局配置', {
|
|
1167
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1168
|
+
});
|
|
1169
|
+
return undefined;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
getCachedInvoiceTemplateSettings() {
|
|
1173
|
+
const openDataModule = this.store?.openData;
|
|
1174
|
+
if (typeof openDataModule?.getInvoiceTemplateSettings !== 'function') return undefined;
|
|
1175
|
+
if (!this.isInvoiceOpenDataCacheCurrent()) return undefined;
|
|
1176
|
+
try {
|
|
1177
|
+
return openDataModule.getInvoiceTemplateSettings();
|
|
1178
|
+
} catch (error) {
|
|
1179
|
+
this.logWarning('读取 Invoice OpenData 模板配置失败,提交时不注入模板配置', {
|
|
1180
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1181
|
+
});
|
|
1182
|
+
return undefined;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
buildSubmitPayloadEnhancerWithOpenDataConfig(enhancePayload) {
|
|
1132
1186
|
const fulfillmentRefMode = this.getFulfillmentRefMode();
|
|
1133
|
-
|
|
1187
|
+
const invoiceLayoutConfig = this.getCachedInvoiceLayoutConfig();
|
|
1188
|
+
const invoiceTemplateSettings = this.getCachedInvoiceTemplateSettings();
|
|
1189
|
+
if (!fulfillmentRefMode && !invoiceLayoutConfig && !invoiceTemplateSettings) {
|
|
1190
|
+
return enhancePayload;
|
|
1191
|
+
}
|
|
1134
1192
|
return (payload, ctx) => {
|
|
1135
1193
|
const enhancedPayload = enhancePayload ? enhancePayload(payload, ctx) : payload;
|
|
1136
1194
|
return {
|
|
1137
1195
|
...enhancedPayload,
|
|
1138
|
-
|
|
1196
|
+
...(fulfillmentRefMode ? {
|
|
1197
|
+
[OS_FULFILLMENT_REF_MODE_FIELD]: fulfillmentRefMode
|
|
1198
|
+
} : {}),
|
|
1199
|
+
...(invoiceLayoutConfig ? {
|
|
1200
|
+
[OS_INVOICE_LAYOUT_CONFIG_FIELD]: (0, _lodashEs.cloneDeep)(invoiceLayoutConfig)
|
|
1201
|
+
} : {}),
|
|
1202
|
+
...(invoiceTemplateSettings ? {
|
|
1203
|
+
[OS_INVOICE_TEMPLATE_SETTINGS_FIELD]: (0, _lodashEs.cloneDeep)(invoiceTemplateSettings)
|
|
1204
|
+
} : {})
|
|
1139
1205
|
};
|
|
1140
1206
|
};
|
|
1141
1207
|
}
|
|
@@ -2332,7 +2398,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2332
2398
|
// this.store.order.persistTempOrder();
|
|
2333
2399
|
const inferredPaymentStatus = this.getSubmitPaymentStatus(params?.paymentStatus);
|
|
2334
2400
|
const smallTicketDataFlag = params?.smallTicketDataFlag ?? this.getDefaultCheckoutSmallTicketDataFlag();
|
|
2335
|
-
const enhancePayload = this.
|
|
2401
|
+
const enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params?.enhancePayload);
|
|
2336
2402
|
const submitParams = {
|
|
2337
2403
|
cacheId: this.cacheId,
|
|
2338
2404
|
platform: this.otherParams?.platform,
|
|
@@ -2403,7 +2469,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2403
2469
|
}
|
|
2404
2470
|
const inferredPaymentStatus = this.getSubmitPaymentStatus(params?.paymentStatus);
|
|
2405
2471
|
const smallTicketDataFlag = params?.smallTicketDataFlag ?? this.getDefaultCheckoutSmallTicketDataFlag();
|
|
2406
|
-
const enhancePayload = this.
|
|
2472
|
+
const enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params?.enhancePayload);
|
|
2407
2473
|
const submitParams = {
|
|
2408
2474
|
cacheId: this.cacheId,
|
|
2409
2475
|
platform: this.otherParams?.platform,
|
|
@@ -2474,7 +2540,18 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2474
2540
|
channel: context.channel,
|
|
2475
2541
|
type: context.type
|
|
2476
2542
|
});
|
|
2477
|
-
const
|
|
2543
|
+
const invoiceLayoutConfig = this.getCachedInvoiceLayoutConfig();
|
|
2544
|
+
const invoiceTemplateSettings = this.getCachedInvoiceTemplateSettings();
|
|
2545
|
+
const printPayload = {
|
|
2546
|
+
...payload,
|
|
2547
|
+
...(invoiceLayoutConfig ? {
|
|
2548
|
+
invoice: (0, _lodashEs.cloneDeep)(invoiceLayoutConfig)
|
|
2549
|
+
} : {}),
|
|
2550
|
+
...(invoiceTemplateSettings ? {
|
|
2551
|
+
template_settings: (0, _lodashEs.cloneDeep)(invoiceTemplateSettings)
|
|
2552
|
+
} : {})
|
|
2553
|
+
};
|
|
2554
|
+
const response = await this.request.post('/local/print-order', printPayload, {
|
|
2478
2555
|
osServer: true,
|
|
2479
2556
|
customToast: () => {}
|
|
2480
2557
|
});
|
|
@@ -2497,7 +2574,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2497
2574
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2498
2575
|
const businessCode = params.businessCode ?? this.otherParams?.businessCode ?? this.otherParams?.business_code;
|
|
2499
2576
|
const channel = params.channel ?? this.getSubmitOrderSalesChannel();
|
|
2500
|
-
const enhancePayload = this.
|
|
2577
|
+
const enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params.enhancePayload);
|
|
2501
2578
|
const syncParams = {
|
|
2502
2579
|
...params,
|
|
2503
2580
|
checkoutSyncTaskEnabled: this.shouldUseCheckoutSyncTask(),
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* - 不在此处发明等价关系;UI 侧(ticketBooking)若需要别的字段,由 view-model 适配层做转换
|
|
15
15
|
*/
|
|
16
16
|
import type { BaseSalesOrderProduct } from '../types';
|
|
17
|
+
import type { OrderMetaList } from '../../../modules/Order/types';
|
|
17
18
|
export interface ISalesDetailHeader {
|
|
18
19
|
order_id: number | string | null;
|
|
19
20
|
order_number?: string;
|
|
@@ -47,6 +48,7 @@ export interface ISalesDetailHeader {
|
|
|
47
48
|
schedule_date?: string;
|
|
48
49
|
created_at?: string;
|
|
49
50
|
updated_at?: string | number;
|
|
51
|
+
order_meta_list?: OrderMetaList;
|
|
50
52
|
metadata?: Record<string, any> | null;
|
|
51
53
|
total_amount?: string | number;
|
|
52
54
|
[key: string]: any;
|
|
@@ -22,7 +22,7 @@ var _orderCollectionIdentity = require("../../../modules/Order/utils/orderCollec
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
/** OrderData 中除大数组外的"顶层 header 字段"白名单,按需扩展。 */
|
|
25
|
-
const HEADER_KEYS = ['order_id', 'order_number', 'shop_order_number', 'shop_full_order_number', 'type', 'business_code', 'platform', 'sales_channel', 'order_sales_channel', 'vouchers', 'status', 'payment_status', 'shipping_status', 'customer_id', 'customer_name', 'country_calling_code', 'phone', 'email', 'is_price_include_tax', 'tax_title', 'tax_country_code', 'currency_code', 'currency_symbol', 'currency_format', 'is_deposit', 'deposit_amount', 'shop_discount', 'surcharge_fee', 'note', 'schedule_date', 'created_at', 'updated_at', 'metadata', 'total_amount', 'shop_id', 'create_date', 'holder', 'relation_forms', 'contacts', 'contacts_info'];
|
|
25
|
+
const HEADER_KEYS = ['order_id', 'order_number', 'shop_order_number', 'shop_full_order_number', 'type', 'business_code', 'platform', 'sales_channel', 'order_sales_channel', 'vouchers', 'status', 'payment_status', 'shipping_status', 'customer_id', 'customer_name', 'country_calling_code', 'phone', 'email', 'is_price_include_tax', 'tax_title', 'tax_country_code', 'currency_code', 'currency_symbol', 'currency_format', 'is_deposit', 'deposit_amount', 'shop_discount', 'surcharge_fee', 'note', 'schedule_date', 'created_at', 'updated_at', 'order_meta_list', 'metadata', 'total_amount', 'shop_id', 'create_date', 'holder', 'relation_forms', 'contacts', 'contacts_info'];
|
|
26
26
|
function pickHeader(raw) {
|
|
27
27
|
const header = {
|
|
28
28
|
order_id: raw?.order_id ?? null
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 |
|
|
329
|
+
weekNum: 0 | 5 | 3 | 1 | 2 | 4 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
2
|
import { BookingTicketCartView, BookingTicketProductCatalogView, BookingTicketState, IGetCustomerListParams, ICustomer, ILoadProductsParams, ILoadProductDetailParams, IScanResult } from './types';
|
|
3
3
|
import type { ProductData } from '../../modules';
|
|
4
|
-
import type
|
|
4
|
+
import { type InvoiceLayoutConfig, type InvoiceTemplateSettings, type OpenDataConfig } from '../../modules/OpenData';
|
|
5
5
|
import { type BookingContextConfig, type BookingContextDateInput, type BookingContextResource, type BookingContextResourceMap, type BookingContextState, type InitBookingContextParams, type LoadBookingConfigParams, type LoadBookingResourcesParams, type ResourceError, type BookingCalcContext } from '../../modules/BookingContext';
|
|
6
6
|
import type { OrderCustomerView, OrderCustomerChangePayload } from '../../modules/Order/types';
|
|
7
7
|
import { BaseSalesImpl } from '../BaseSales';
|
|
@@ -30,7 +30,9 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
30
30
|
private orderCustomerDiscountRefreshInFlight;
|
|
31
31
|
private orderCustomerDiscountRefreshCustomerId;
|
|
32
32
|
private orderCustomerPromotionRefreshInFlight;
|
|
33
|
-
|
|
33
|
+
protected loadOpenDataInFlight: Promise<OpenDataConfig> | null;
|
|
34
|
+
protected loadOpenDataInFlightTarget: string | null;
|
|
35
|
+
protected openDataTarget: string | null;
|
|
34
36
|
/**
|
|
35
37
|
* 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext。
|
|
36
38
|
* bookingContext 是 SalesSdk 加车下沉所需的「预约 UI 上下文」(bookingConfig / resourcesOrigin / date)。
|
|
@@ -43,10 +45,13 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
43
45
|
*/
|
|
44
46
|
protected createSubModule(moduleName: string): Module | null;
|
|
45
47
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
46
|
-
|
|
48
|
+
protected getBookingTicketBusinessCode(): string | null;
|
|
47
49
|
private getIdGeneratorPlugin;
|
|
48
50
|
private loadOpenDataConfig;
|
|
49
51
|
getOpenData(): Promise<OpenDataConfig | null>;
|
|
52
|
+
getInvoiceLayoutConfig(): Promise<InvoiceLayoutConfig>;
|
|
53
|
+
getInvoiceTemplateSettings(): Promise<InvoiceTemplateSettings>;
|
|
54
|
+
protected isInvoiceOpenDataCacheCurrent(): boolean;
|
|
50
55
|
/** 清除店铺级 OpenData;下一次 getOpenData 时会重新拉取。 */
|
|
51
56
|
clearOpenDataCache(): void;
|
|
52
57
|
private getShortNumberOrDeviceId;
|
|
@@ -21,6 +21,7 @@ Object.keys(_types).forEach(function (key) {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
|
+
var _OpenData = require("../../modules/OpenData");
|
|
24
25
|
var _BookingContext = require("../../modules/BookingContext");
|
|
25
26
|
var _BaseSales = require("../BaseSales");
|
|
26
27
|
var _scan = _interopRequireDefault(require("./utils/scan"));
|
|
@@ -39,7 +40,7 @@ var _bookingStatus = require("./utils/bookingStatus");
|
|
|
39
40
|
var _resolveBestAddTimePlan = require("./utils/resolveBestAddTimePlan");
|
|
40
41
|
var _utils = require("../../modules/Order/utils");
|
|
41
42
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
42
|
-
const OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow'];
|
|
43
|
+
const OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'documents'];
|
|
43
44
|
const OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
|
|
44
45
|
const USER_PLATFORM = ['pc', 'h5'];
|
|
45
46
|
|
|
@@ -160,7 +161,9 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
160
161
|
orderCustomerDiscountRefreshInFlight = null;
|
|
161
162
|
orderCustomerDiscountRefreshCustomerId = null;
|
|
162
163
|
orderCustomerPromotionRefreshInFlight = null;
|
|
163
|
-
|
|
164
|
+
loadOpenDataInFlight = null;
|
|
165
|
+
loadOpenDataInFlightTarget = null;
|
|
166
|
+
openDataTarget = null;
|
|
164
167
|
|
|
165
168
|
/**
|
|
166
169
|
* 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext。
|
|
@@ -193,10 +196,13 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
193
196
|
await this.configureIdGeneratorFromOpenData();
|
|
194
197
|
}
|
|
195
198
|
getBookingTicketBusinessCode() {
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
199
|
+
const candidates = [this.otherParams?.businessCode, this.otherParams?.business_code, this.getOrderHeader()?.business_code, this.store.order?.getTempOrder()?.business_code, this.getSalesOrder()?.raw?.business_code];
|
|
200
|
+
for (const candidate of candidates) {
|
|
201
|
+
if (candidate === undefined || candidate === null) continue;
|
|
202
|
+
const normalized = String(candidate).trim();
|
|
203
|
+
if (normalized) return normalized;
|
|
204
|
+
}
|
|
205
|
+
return null;
|
|
200
206
|
}
|
|
201
207
|
getIdGeneratorPlugin() {
|
|
202
208
|
const appPlugin = this.core.getPlugin('app');
|
|
@@ -210,35 +216,72 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
210
216
|
console.warn('[BookingTicket] businessCode 缺失,跳过 OpenData 配置加载,当前 module name: ', this.name);
|
|
211
217
|
return null;
|
|
212
218
|
}
|
|
219
|
+
const channel = this.getSubmitOrderSalesChannel();
|
|
220
|
+
const target = `${businessCode}+${channel}`;
|
|
213
221
|
const lastFetchedAt = this.store.openData.getLastFetchedAt();
|
|
214
222
|
const cachedData = this.store.openData.getOpenData();
|
|
215
|
-
if (cachedData && lastFetchedAt && Date.now() - lastFetchedAt < OPEN_DATA_CACHE_TTL) {
|
|
223
|
+
if (cachedData && this.openDataTarget === target && lastFetchedAt && Date.now() - lastFetchedAt < OPEN_DATA_CACHE_TTL) {
|
|
224
|
+
if (typeof this.store.openData.ensureInvoiceTemplateSettings === 'function') {
|
|
225
|
+
await this.store.openData.ensureInvoiceTemplateSettings(target);
|
|
226
|
+
}
|
|
216
227
|
this.otherParams.openData = cachedData;
|
|
217
228
|
return cachedData;
|
|
218
229
|
}
|
|
219
|
-
if (this.
|
|
220
|
-
|
|
221
|
-
|
|
230
|
+
if (this.loadOpenDataInFlight) {
|
|
231
|
+
if (this.loadOpenDataInFlightTarget === target) {
|
|
232
|
+
return await this.loadOpenDataInFlight;
|
|
233
|
+
}
|
|
234
|
+
await this.loadOpenDataInFlight;
|
|
235
|
+
return this.loadOpenDataConfig();
|
|
236
|
+
}
|
|
237
|
+
this.loadOpenDataInFlightTarget = target;
|
|
238
|
+
const request = this.store.openData.fetchOpenData({
|
|
222
239
|
scope: 'board',
|
|
223
|
-
target
|
|
240
|
+
target,
|
|
224
241
|
// target: `dine_in+pos`,
|
|
225
242
|
section_code: [...OPEN_DATA_SECTION_CODES]
|
|
226
243
|
});
|
|
244
|
+
this.loadOpenDataInFlight = request;
|
|
227
245
|
try {
|
|
228
|
-
const openDataConfig = await
|
|
229
|
-
|
|
246
|
+
const openDataConfig = await request;
|
|
247
|
+
// clearOpenDataCache() 或新请求已接管时,旧响应只能返回给原调用方,不能复活缓存归属。
|
|
248
|
+
if (this.loadOpenDataInFlight === request) {
|
|
249
|
+
this.openDataTarget = target;
|
|
250
|
+
this.otherParams.openData = openDataConfig;
|
|
251
|
+
}
|
|
230
252
|
return openDataConfig;
|
|
231
253
|
} finally {
|
|
232
|
-
this.
|
|
254
|
+
if (this.loadOpenDataInFlight === request) {
|
|
255
|
+
this.loadOpenDataInFlight = null;
|
|
256
|
+
this.loadOpenDataInFlightTarget = null;
|
|
257
|
+
}
|
|
233
258
|
}
|
|
234
259
|
}
|
|
235
260
|
async getOpenData() {
|
|
236
261
|
return this.loadOpenDataConfig();
|
|
237
262
|
}
|
|
263
|
+
async getInvoiceLayoutConfig() {
|
|
264
|
+
const openData = await this.loadOpenDataConfig();
|
|
265
|
+
if (!openData) return (0, _OpenData.getDefaultInvoiceLayoutConfig)();
|
|
266
|
+
return this.store.openData.getInvoiceLayoutConfig();
|
|
267
|
+
}
|
|
268
|
+
async getInvoiceTemplateSettings() {
|
|
269
|
+
const openData = await this.loadOpenDataConfig();
|
|
270
|
+
if (!openData) return (0, _OpenData.getDefaultInvoiceTemplateSettings)();
|
|
271
|
+
return this.store.openData.getInvoiceTemplateSettings();
|
|
272
|
+
}
|
|
273
|
+
isInvoiceOpenDataCacheCurrent() {
|
|
274
|
+
const businessCode = this.getBookingTicketBusinessCode();
|
|
275
|
+
const channel = this.getSubmitOrderSalesChannel();
|
|
276
|
+
if (!businessCode || !channel) return false;
|
|
277
|
+
return this.openDataTarget === `${businessCode}+${channel}`;
|
|
278
|
+
}
|
|
238
279
|
|
|
239
280
|
/** 清除店铺级 OpenData;下一次 getOpenData 时会重新拉取。 */
|
|
240
281
|
clearOpenDataCache() {
|
|
241
|
-
this.
|
|
282
|
+
this.loadOpenDataInFlight = null;
|
|
283
|
+
this.loadOpenDataInFlightTarget = null;
|
|
284
|
+
this.openDataTarget = null;
|
|
242
285
|
this.otherParams.openData = null;
|
|
243
286
|
this.store.openData?.clearCache();
|
|
244
287
|
}
|
|
@@ -1743,6 +1786,8 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1743
1786
|
});
|
|
1744
1787
|
if (params?.businessCode !== undefined || params?.business_code !== undefined) {
|
|
1745
1788
|
await this.configureIdGeneratorFromOpenData();
|
|
1789
|
+
} else if (params?.channel !== undefined) {
|
|
1790
|
+
await this.loadOpenDataConfig();
|
|
1746
1791
|
}
|
|
1747
1792
|
}
|
|
1748
1793
|
getDeviceTaskPlugin() {
|
|
@@ -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, SalesResourceBookingItemWithGroups, SalesTimelineHighlights, ChangeBookingStatusParams, GetResourceBookingItemParams } from './types';
|
|
5
|
+
import { SalesState, SalesModuleAPI, Reservation, SalesResourceBookingItem, SalesResourceBookingItemWithGroups, SalesTimelineHighlights, ChangeBookingStatusParams, GetResourceBookingItemParams, SalesPrintLocalOrderReceiptOptions } from './types';
|
|
6
6
|
import type { BookingData } from '../../server/modules/order/types';
|
|
7
7
|
export * from './types';
|
|
8
8
|
/**
|
|
@@ -26,6 +26,10 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
26
26
|
protected otherParams: Record<string, any>;
|
|
27
27
|
protected request: RequestPlugin;
|
|
28
28
|
private logger;
|
|
29
|
+
private invoiceOpenDataModule;
|
|
30
|
+
private invoiceOpenDataTarget;
|
|
31
|
+
private invoiceOpenDataInFlight;
|
|
32
|
+
private invoiceOpenDataInFlightTarget;
|
|
29
33
|
constructor(name?: string, version?: string);
|
|
30
34
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
31
35
|
/** 获取当前 store 快照 */
|
|
@@ -42,6 +46,17 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
42
46
|
resetReservationList(): Reservation[];
|
|
43
47
|
cancelOrder(orderIds: Array<number | string>): Promise<any>;
|
|
44
48
|
changeBookingStatus(params: ChangeBookingStatusParams): Promise<any>;
|
|
49
|
+
/**
|
|
50
|
+
* 将显式 channel 或当前运行上下文归一为 Invoice OpenData 使用的销售入口。
|
|
51
|
+
* Legacy Sales 的系统上下文没有可打印的 system target,因此统一回退 pos。
|
|
52
|
+
*/
|
|
53
|
+
private getInvoiceSalesChannel;
|
|
54
|
+
private loadInvoiceOpenData;
|
|
55
|
+
private logInvoiceOpenDataFallback;
|
|
56
|
+
private resolveInvoiceConfigs;
|
|
57
|
+
printLocalOrderReceipt<T = any>(lookup: string | number, options: SalesPrintLocalOrderReceiptOptions): Promise<T>;
|
|
58
|
+
/** 清除独立 Documents 缓存;下一次打印会按当前 target 重新获取。 */
|
|
59
|
+
clearOpenDataCache(): void;
|
|
45
60
|
destroy(): Promise<void>;
|
|
46
61
|
/**
|
|
47
62
|
* 时间轴粒度(分钟)
|
|
@@ -9,6 +9,7 @@ var _exportNames = {
|
|
|
9
9
|
};
|
|
10
10
|
exports.default = exports.SalesImpl = exports.Sales = void 0;
|
|
11
11
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
12
|
+
var _lodashEs = require("lodash-es");
|
|
12
13
|
var _BaseModule = require("../../modules/BaseModule");
|
|
13
14
|
var _types = require("./types");
|
|
14
15
|
Object.keys(_types).forEach(function (key) {
|
|
@@ -22,8 +23,11 @@ Object.keys(_types).forEach(function (key) {
|
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
25
|
});
|
|
26
|
+
var _OpenData = require("../../modules/OpenData");
|
|
25
27
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
28
|
const UNPAID_PAYMENT_STATUSES = new Set(['unpaid', 'partially_paid', 'payment_processing']);
|
|
29
|
+
const INVOICE_OPEN_DATA_SECTION_CODES = ['documents'];
|
|
30
|
+
const INVOICE_OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
|
|
27
31
|
|
|
28
32
|
/**
|
|
29
33
|
* Sales 解决方案基础骨架
|
|
@@ -46,11 +50,22 @@ class SalesImpl extends _BaseModule.BaseModule {
|
|
|
46
50
|
otherParams = {};
|
|
47
51
|
request;
|
|
48
52
|
logger; // LoggerManager 实例
|
|
49
|
-
|
|
53
|
+
invoiceOpenDataModule = null;
|
|
54
|
+
invoiceOpenDataTarget = null;
|
|
55
|
+
invoiceOpenDataInFlight = null;
|
|
56
|
+
invoiceOpenDataInFlightTarget = null;
|
|
50
57
|
constructor(name, version) {
|
|
51
58
|
super(name, version);
|
|
52
59
|
}
|
|
53
60
|
async initialize(core, options = {}) {
|
|
61
|
+
if (this.invoiceOpenDataModule) {
|
|
62
|
+
try {
|
|
63
|
+
this.clearOpenDataCache();
|
|
64
|
+
this.invoiceOpenDataModule.destroy();
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.warn('[Sales] 旧 Invoice OpenData 子模块销毁失败', error);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
54
69
|
this.core = core;
|
|
55
70
|
this.options = options;
|
|
56
71
|
this.otherParams = options.otherParams || {};
|
|
@@ -71,6 +86,18 @@ class SalesImpl extends _BaseModule.BaseModule {
|
|
|
71
86
|
// 在这里补充从 Server/Order 读取 currentDay 原始数据并转换为预约列表。
|
|
72
87
|
|
|
73
88
|
this.logger = appPlugin?.getApp().logger;
|
|
89
|
+
this.invoiceOpenDataTarget = null;
|
|
90
|
+
this.invoiceOpenDataInFlight = null;
|
|
91
|
+
this.invoiceOpenDataInFlightTarget = null;
|
|
92
|
+
this.invoiceOpenDataModule = new _OpenData.OpenDataModule(`${this.name}_invoiceOpenData`);
|
|
93
|
+
this.core.registerModule(this.invoiceOpenDataModule, {
|
|
94
|
+
initialState: {},
|
|
95
|
+
otherParams: {
|
|
96
|
+
fatherModule: this.name,
|
|
97
|
+
openCache: false,
|
|
98
|
+
platform: this.otherParams?.platform
|
|
99
|
+
}
|
|
100
|
+
});
|
|
74
101
|
await this.core.effects.emit(`${this.name}:onInited`, {});
|
|
75
102
|
}
|
|
76
103
|
|
|
@@ -139,11 +166,151 @@ class SalesImpl extends _BaseModule.BaseModule {
|
|
|
139
166
|
return orderModule.changeBookingStatus(params);
|
|
140
167
|
}
|
|
141
168
|
|
|
169
|
+
/**
|
|
170
|
+
* 将显式 channel 或当前运行上下文归一为 Invoice OpenData 使用的销售入口。
|
|
171
|
+
* Legacy Sales 的系统上下文没有可打印的 system target,因此统一回退 pos。
|
|
172
|
+
*/
|
|
173
|
+
getInvoiceSalesChannel(channel) {
|
|
174
|
+
const contextChannel = this.core?.context?.getChannel?.();
|
|
175
|
+
const normalized = String(channel ?? contextChannel ?? '').trim();
|
|
176
|
+
return !normalized || normalized === 'system' ? 'pos' : normalized;
|
|
177
|
+
}
|
|
178
|
+
async loadInvoiceOpenData(businessCode, channel) {
|
|
179
|
+
if (!this.invoiceOpenDataModule) {
|
|
180
|
+
throw new Error('Sales Invoice OpenData 模块未初始化');
|
|
181
|
+
}
|
|
182
|
+
const target = `${businessCode}+${channel}`;
|
|
183
|
+
const cachedData = this.invoiceOpenDataModule.getOpenData();
|
|
184
|
+
const lastFetchedAt = this.invoiceOpenDataModule.getLastFetchedAt();
|
|
185
|
+
if (cachedData && this.invoiceOpenDataTarget === target && typeof lastFetchedAt === 'number' && Date.now() - lastFetchedAt < INVOICE_OPEN_DATA_CACHE_TTL) {
|
|
186
|
+
if (typeof this.invoiceOpenDataModule.ensureInvoiceTemplateSettings === 'function') {
|
|
187
|
+
await this.invoiceOpenDataModule.ensureInvoiceTemplateSettings(target);
|
|
188
|
+
}
|
|
189
|
+
return cachedData;
|
|
190
|
+
}
|
|
191
|
+
if (this.invoiceOpenDataInFlight) {
|
|
192
|
+
if (this.invoiceOpenDataInFlightTarget === target) {
|
|
193
|
+
return this.invoiceOpenDataInFlight;
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
await this.invoiceOpenDataInFlight;
|
|
197
|
+
} catch {
|
|
198
|
+
// 另一 target 的失败不应阻断当前 target 获取自己的 Documents 配置。
|
|
199
|
+
}
|
|
200
|
+
return this.loadInvoiceOpenData(businessCode, channel);
|
|
201
|
+
}
|
|
202
|
+
const request = this.invoiceOpenDataModule.fetchOpenData({
|
|
203
|
+
scope: 'board',
|
|
204
|
+
target,
|
|
205
|
+
section_code: [...INVOICE_OPEN_DATA_SECTION_CODES]
|
|
206
|
+
});
|
|
207
|
+
this.invoiceOpenDataInFlight = request;
|
|
208
|
+
this.invoiceOpenDataInFlightTarget = target;
|
|
209
|
+
try {
|
|
210
|
+
const openData = await request;
|
|
211
|
+
// clearOpenDataCache() 或后续请求接管后,旧响应不得复活 target 归属。
|
|
212
|
+
if (this.invoiceOpenDataInFlight === request) {
|
|
213
|
+
this.invoiceOpenDataTarget = target;
|
|
214
|
+
}
|
|
215
|
+
return openData;
|
|
216
|
+
} finally {
|
|
217
|
+
if (this.invoiceOpenDataInFlight === request) {
|
|
218
|
+
this.invoiceOpenDataInFlight = null;
|
|
219
|
+
this.invoiceOpenDataInFlightTarget = null;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
logInvoiceOpenDataFallback(error) {
|
|
224
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
225
|
+
if (this.logger?.addLog) {
|
|
226
|
+
this.logger.addLog({
|
|
227
|
+
type: 'warning',
|
|
228
|
+
title: 'Sales Invoice OpenData 加载失败,使用默认配置',
|
|
229
|
+
metadata: {
|
|
230
|
+
message
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
console.warn('[Sales] Invoice OpenData 加载失败,使用默认配置', error);
|
|
236
|
+
}
|
|
237
|
+
async resolveInvoiceConfigs(businessCode, channel) {
|
|
238
|
+
try {
|
|
239
|
+
await this.loadInvoiceOpenData(businessCode, channel);
|
|
240
|
+
if (this.invoiceOpenDataTarget !== `${businessCode}+${channel}`) {
|
|
241
|
+
return {
|
|
242
|
+
invoice: (0, _OpenData.getDefaultInvoiceLayoutConfig)(),
|
|
243
|
+
templateSettings: (0, _OpenData.getDefaultInvoiceTemplateSettings)()
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
invoice: this.invoiceOpenDataModule?.getInvoiceLayoutConfig() ?? (0, _OpenData.getDefaultInvoiceLayoutConfig)(),
|
|
248
|
+
templateSettings: this.invoiceOpenDataModule?.getInvoiceTemplateSettings() ?? (0, _OpenData.getDefaultInvoiceTemplateSettings)()
|
|
249
|
+
};
|
|
250
|
+
} catch (error) {
|
|
251
|
+
this.logInvoiceOpenDataFallback(error);
|
|
252
|
+
return {
|
|
253
|
+
invoice: (0, _OpenData.getDefaultInvoiceLayoutConfig)(),
|
|
254
|
+
templateSettings: (0, _OpenData.getDefaultInvoiceTemplateSettings)()
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async printLocalOrderReceipt(lookup, options) {
|
|
259
|
+
const normalizedLookup = typeof lookup === 'string' ? lookup.trim() : lookup;
|
|
260
|
+
if (normalizedLookup === '' || normalizedLookup === null || normalizedLookup === undefined) {
|
|
261
|
+
throw new Error('Sales 本地小票打印需要订单标识');
|
|
262
|
+
}
|
|
263
|
+
const businessCode = String(options?.businessCode ?? '').trim();
|
|
264
|
+
if (!businessCode) {
|
|
265
|
+
throw new Error('Sales 本地小票打印需要 businessCode');
|
|
266
|
+
}
|
|
267
|
+
const channel = this.getInvoiceSalesChannel(options?.channel);
|
|
268
|
+
const {
|
|
269
|
+
invoice,
|
|
270
|
+
templateSettings
|
|
271
|
+
} = await this.resolveInvoiceConfigs(businessCode, channel);
|
|
272
|
+
const lookupPayload = typeof normalizedLookup === 'number' ? {
|
|
273
|
+
order_id: normalizedLookup
|
|
274
|
+
} : {
|
|
275
|
+
external_sale_number: normalizedLookup
|
|
276
|
+
};
|
|
277
|
+
return this.request.post('/local/print-order', {
|
|
278
|
+
...lookupPayload,
|
|
279
|
+
lookup_order_from_db: 1,
|
|
280
|
+
small_ticket_data_flag: 1,
|
|
281
|
+
business_code: businessCode,
|
|
282
|
+
order_sales_channel: channel,
|
|
283
|
+
invoice: (0, _lodashEs.cloneDeep)(invoice),
|
|
284
|
+
template_settings: (0, _lodashEs.cloneDeep)(templateSettings)
|
|
285
|
+
}, {
|
|
286
|
+
osServer: true,
|
|
287
|
+
customToast: () => {}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** 清除独立 Documents 缓存;下一次打印会按当前 target 重新获取。 */
|
|
292
|
+
clearOpenDataCache() {
|
|
293
|
+
this.invoiceOpenDataInFlight = null;
|
|
294
|
+
this.invoiceOpenDataInFlightTarget = null;
|
|
295
|
+
this.invoiceOpenDataTarget = null;
|
|
296
|
+
this.invoiceOpenDataModule?.clearCache();
|
|
297
|
+
}
|
|
298
|
+
|
|
142
299
|
// -------------------------------------------------------------------------
|
|
143
300
|
// 生命周期
|
|
144
301
|
// -------------------------------------------------------------------------
|
|
145
302
|
|
|
146
303
|
async destroy() {
|
|
304
|
+
this.clearOpenDataCache();
|
|
305
|
+
const invoiceOpenDataModule = this.invoiceOpenDataModule;
|
|
306
|
+
this.invoiceOpenDataModule = null;
|
|
307
|
+
if (invoiceOpenDataModule) {
|
|
308
|
+
try {
|
|
309
|
+
await invoiceOpenDataModule.destroy();
|
|
310
|
+
} catch (error) {
|
|
311
|
+
console.warn('[Sales] Invoice OpenData 子模块销毁失败', error);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
147
314
|
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
148
315
|
super.destroy();
|
|
149
316
|
}
|
|
@@ -50,6 +50,12 @@ export interface GetResourceBookingItemParams {
|
|
|
50
50
|
bookingList: BookingData[];
|
|
51
51
|
deviceTime?: string;
|
|
52
52
|
}
|
|
53
|
+
export interface SalesPrintLocalOrderReceiptOptions {
|
|
54
|
+
/** 当前销售业务类型,用于隔离 Documents Invoice 配置。 */
|
|
55
|
+
businessCode: string;
|
|
56
|
+
/** 当前销售入口;缺失或为 system 时按 pos 处理。 */
|
|
57
|
+
channel?: string;
|
|
58
|
+
}
|
|
53
59
|
/**
|
|
54
60
|
* Sales 解决方案状态
|
|
55
61
|
*
|
|
@@ -82,6 +88,10 @@ export interface SalesModuleAPI {
|
|
|
82
88
|
cancelOrder: (orderIds: Array<number | string>) => Promise<any>;
|
|
83
89
|
/** 变更预约状态 */
|
|
84
90
|
changeBookingStatus: (params: ChangeBookingStatusParams) => Promise<any>;
|
|
91
|
+
/** 按本地订单标识打印小票;本地未命中时由 OS Server 负责远端兜底。 */
|
|
92
|
+
printLocalOrderReceipt: <T = any>(lookup: string | number, options: SalesPrintLocalOrderReceiptOptions) => Promise<T>;
|
|
93
|
+
/** 清除 Legacy Sales 独立维护的 Documents OpenData 缓存。 */
|
|
94
|
+
clearOpenDataCache: () => void;
|
|
85
95
|
/** 获取资源维度的预约占用列表 */
|
|
86
96
|
getResourceBookingList: (currentTime: string, bookingList: BookingData[], deviceTime?: string) => Promise<SalesResourceBookingItem[]>;
|
|
87
97
|
/** 获取单个资源维度的预约占用、已完成、未支付列表 */
|