@pisell/pisellos 0.10.81 → 0.10.83
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/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +5 -0
- package/dist/modules/ResourcePlanner/planner.js +2 -1
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -13
- package/dist/solution/BookingTicket/index.js +36 -31
- package/dist/solution/ScanOrder/index.d.ts +0 -1
- package/dist/solution/ScanOrder/index.js +62 -59
- package/dist/solution/ScanOrder/types.d.ts +2 -0
- package/dist/solution/ScanOrder/types.js +2 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +12 -1
- package/dist/solution/UnifiedBookingSales/index.js +1471 -1143
- package/dist/solution/UnifiedBookingSales/types.d.ts +6 -0
- package/dist/solution/VenueBooking/index.js +111 -104
- package/dist/solution/VenueBooking/types.d.ts +2 -0
- package/dist/solution/VenueBooking/types.js +3 -1
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/smartPricing.js +6 -1
- package/dist/utils/hostLogger.d.ts +10 -0
- package/dist/utils/hostLogger.js +20 -0
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +5 -0
- package/lib/modules/ResourcePlanner/planner.js +2 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +1 -13
- package/lib/solution/BookingTicket/index.js +5 -4
- package/lib/solution/ScanOrder/index.d.ts +0 -1
- package/lib/solution/ScanOrder/index.js +47 -41
- package/lib/solution/ScanOrder/types.d.ts +2 -0
- package/lib/solution/ScanOrder/types.js +1 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +12 -1
- package/lib/solution/UnifiedBookingSales/index.js +249 -29
- package/lib/solution/UnifiedBookingSales/types.d.ts +6 -0
- package/lib/solution/VenueBooking/index.js +38 -47
- package/lib/solution/VenueBooking/types.d.ts +2 -0
- package/lib/solution/VenueBooking/types.js +3 -1
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/smartPricing.js +6 -1
- package/lib/utils/hostLogger.d.ts +10 -0
- package/lib/utils/hostLogger.js +25 -0
- package/package.json +1 -1
|
@@ -22,6 +22,7 @@ Object.keys(_types).forEach(function (key) {
|
|
|
22
22
|
});
|
|
23
23
|
var _utils = require("./utils");
|
|
24
24
|
var _types2 = require("../BookingByStep/types");
|
|
25
|
+
var _hostLogger = require("../../utils/hostLogger");
|
|
25
26
|
var _ProductList = require("../../modules/ProductList");
|
|
26
27
|
var _Date = require("../../modules/Date");
|
|
27
28
|
var _Schedule = require("../../modules/Schedule");
|
|
@@ -107,7 +108,11 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
|
|
|
107
108
|
return {
|
|
108
109
|
cacheId: this.cacheId,
|
|
109
110
|
solutionName: this.name,
|
|
110
|
-
moduleName: 'venueBooking'
|
|
111
|
+
moduleName: 'venueBooking',
|
|
112
|
+
host: this.window?.location?.host,
|
|
113
|
+
platform: this.otherParams?.platform,
|
|
114
|
+
channel: this.otherParams?.channel,
|
|
115
|
+
businessCode: this.otherParams?.businessCode
|
|
111
116
|
};
|
|
112
117
|
}
|
|
113
118
|
safeStringify(value) {
|
|
@@ -163,20 +168,19 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
|
|
|
163
168
|
const extra = {
|
|
164
169
|
...(params.extra || {})
|
|
165
170
|
};
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
extra
|
|
171
|
+
(0, _hostLogger.writeHostLog)(this.core, {
|
|
172
|
+
type: params.level || 'info',
|
|
173
|
+
title: params.title,
|
|
174
|
+
...(params.timestamp ? {
|
|
175
|
+
date: params.timestamp
|
|
176
|
+
} : {}),
|
|
177
|
+
metadata: {
|
|
178
|
+
module: 'venueBooking',
|
|
179
|
+
action: params.payload?.method || 'addLog',
|
|
180
|
+
payload,
|
|
181
|
+
extra,
|
|
182
|
+
context: this.getLoggerContext()
|
|
183
|
+
}
|
|
180
184
|
});
|
|
181
185
|
}
|
|
182
186
|
logMethodStart(method, payload = {}) {
|
|
@@ -223,12 +227,10 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
|
|
|
223
227
|
super(name, version);
|
|
224
228
|
}
|
|
225
229
|
getRegisteredModuleNames() {
|
|
226
|
-
return ['
|
|
230
|
+
return ['products', 'order', 'salesSummary', 'venueProducts', 'addonProducts', 'date', 'schedule', 'quotation', 'openData'];
|
|
227
231
|
}
|
|
228
232
|
createSubModule(moduleName) {
|
|
229
233
|
switch (moduleName) {
|
|
230
|
-
case 'scanOrderLogger':
|
|
231
|
-
return (0, _types2.createModule)('scanOrderLogger', this.name);
|
|
232
234
|
case 'venueProducts':
|
|
233
235
|
return new _ProductList.ProductList(`${this.name}_venueProducts`);
|
|
234
236
|
case 'addonProducts':
|
|
@@ -323,9 +325,8 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
|
|
|
323
325
|
useCache: true
|
|
324
326
|
});
|
|
325
327
|
} catch (error) {
|
|
326
|
-
|
|
327
|
-
formId
|
|
328
|
-
error
|
|
328
|
+
this.logMethodError('preloadHolderForms', error, {
|
|
329
|
+
formId
|
|
329
330
|
});
|
|
330
331
|
}
|
|
331
332
|
}
|
|
@@ -421,6 +422,9 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
|
|
|
421
422
|
}
|
|
422
423
|
}
|
|
423
424
|
async initialize(core, options = {}) {
|
|
425
|
+
this.core = core;
|
|
426
|
+
this.otherParams = options.otherParams || {};
|
|
427
|
+
this.cacheId = this.otherParams.cacheId;
|
|
424
428
|
this.logMethodStart('initialize');
|
|
425
429
|
this.store = {
|
|
426
430
|
...this.store,
|
|
@@ -443,8 +447,6 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
|
|
|
443
447
|
this.store.slotConfig = {
|
|
444
448
|
...this.baseSlotConfig
|
|
445
449
|
};
|
|
446
|
-
this.otherParams = options.otherParams || {};
|
|
447
|
-
this.cacheId = this.otherParams?.cacheId;
|
|
448
450
|
this.itemRuleRuntimeConfig = this.otherParams?.venueBookingItemRule || this.otherParams?.itemRule || {};
|
|
449
451
|
this.itemRuleConfigs = [];
|
|
450
452
|
this.itemRuleConfigsPromise = null;
|
|
@@ -455,18 +457,9 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
|
|
|
455
457
|
failures: []
|
|
456
458
|
};
|
|
457
459
|
await super.initialize(core, options);
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
feishu: {
|
|
462
|
-
webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/8f069b14-9d39-4728-8f78-b56f393bfde8',
|
|
463
|
-
errorHook: 'https://open.feishu.cn/open-apis/bot/v2/hook/bdefae5e-f233-4705-8688-946887d9543d'
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
this.store.scanOrderLogger.setContext(this.getLoggerContext());
|
|
467
|
-
}
|
|
468
|
-
// 注册基础模块(order, salesSummary, products, logger)
|
|
469
|
-
const baseModules = ['scanOrderLogger', 'products', 'order', 'salesSummary'];
|
|
460
|
+
|
|
461
|
+
// 注册基础业务模块;日志统一使用 app 插件提供的宿主 logger。
|
|
462
|
+
const baseModules = ['products', 'order', 'salesSummary'];
|
|
470
463
|
baseModules.forEach(step => {
|
|
471
464
|
const targetModule = (0, _types2.createModule)(step, this.name);
|
|
472
465
|
if (targetModule) {
|
|
@@ -474,13 +467,6 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
|
|
|
474
467
|
const initialState = step === 'salesSummary' ? {
|
|
475
468
|
summary: this.store.order?.getTempOrder()?.summary || (0, _utils.createEmptySummary)()
|
|
476
469
|
} : {};
|
|
477
|
-
const loggerProvider = this.otherParams?.loggerProvider || 'feishu';
|
|
478
|
-
const loggerConfig = this.otherParams?.loggerConfig || {
|
|
479
|
-
// feishu: {
|
|
480
|
-
// webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/8f069b14-9d39-4728-8f78-b56f393bfde8',
|
|
481
|
-
// errorHook: 'https://open.feishu.cn/open-apis/bot/v2/hook/bdefae5e-f233-4705-8688-946887d9543d',
|
|
482
|
-
// },
|
|
483
|
-
};
|
|
484
470
|
this.core.registerModule(targetModule, {
|
|
485
471
|
initialState,
|
|
486
472
|
otherParams: {
|
|
@@ -488,10 +474,7 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
|
|
|
488
474
|
fatherModule: this.name,
|
|
489
475
|
openCache: this.otherParams?.cacheId ? true : false,
|
|
490
476
|
cacheId: this.otherParams?.cacheId,
|
|
491
|
-
salesSummaryModuleName: `${this.name}_salesSummary
|
|
492
|
-
provider: loggerProvider,
|
|
493
|
-
providerConfig: loggerConfig,
|
|
494
|
-
context: this.getLoggerContext()
|
|
477
|
+
salesSummaryModuleName: `${this.name}_salesSummary`
|
|
495
478
|
}
|
|
496
479
|
});
|
|
497
480
|
} else {
|
|
@@ -610,7 +593,6 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
|
|
|
610
593
|
} catch (error) {
|
|
611
594
|
this.store.status = 'error';
|
|
612
595
|
this.store.error = error instanceof Error ? error.message : '初始化失败';
|
|
613
|
-
console.error('[VenueBooking] 初始化失败', error);
|
|
614
596
|
this.logMethodError('initialize', error, {
|
|
615
597
|
status: this.store.status
|
|
616
598
|
});
|
|
@@ -690,6 +672,15 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
|
|
|
690
672
|
const walletIds = this.smartPricingCustomerId === null ? [] : orderWalletIds?.length ? orderWalletIds : fallbackWalletIds;
|
|
691
673
|
return {
|
|
692
674
|
evaluator: this.core?.context?.dataVariantEvaluator,
|
|
675
|
+
reportWarning: title => {
|
|
676
|
+
void this.addVenueBookingLog({
|
|
677
|
+
level: 'warning',
|
|
678
|
+
title,
|
|
679
|
+
payload: {
|
|
680
|
+
method: 'smartPricing'
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
},
|
|
693
684
|
scheduleList: this.store.schedule?.getScheduleList?.() || [],
|
|
694
685
|
menuList: this.otherParams?.menuList || this.otherParams?.openData?.menuList || this.core?.context?.menuList || [],
|
|
695
686
|
customerId: this.resolveCustomerIdForSmartPricing(),
|
|
@@ -133,6 +133,7 @@ export interface VenueBookingState {
|
|
|
133
133
|
products?: ProductList;
|
|
134
134
|
order?: OrderModule;
|
|
135
135
|
salesSummary?: SalesSummaryModule;
|
|
136
|
+
/** @deprecated Retained for compatibility; solution logs use app.getApp().logger. */
|
|
136
137
|
scanOrderLogger?: ScanOrderLoggerModule;
|
|
137
138
|
venueProducts?: ProductList;
|
|
138
139
|
addonProducts?: ProductList;
|
|
@@ -149,6 +150,7 @@ export interface VenueBookingState {
|
|
|
149
150
|
};
|
|
150
151
|
holder?: HolderModule;
|
|
151
152
|
}
|
|
153
|
+
/** @deprecated Configure the host app logger; VenueBooking no longer selects a provider. */
|
|
152
154
|
export interface VenueBookingLoggerRuntimeConfig {
|
|
153
155
|
provider?: ScanOrderLoggerProviderType;
|
|
154
156
|
providerConfig?: ScanOrderLoggerProviderConfig;
|
|
@@ -16,6 +16,7 @@ export interface VenueBookingSmartPricingContext {
|
|
|
16
16
|
orderType?: string;
|
|
17
17
|
strategy_context?: Record<string, any>;
|
|
18
18
|
strategyConfigs?: StrategyConfig[];
|
|
19
|
+
reportWarning?: (message: string) => void;
|
|
19
20
|
}
|
|
20
21
|
/** 从商品上读取展示/算价用的 price 字段 */
|
|
21
22
|
export declare function extractProductPrice(product: DataVariantProduct): string | null;
|
|
@@ -49,7 +49,12 @@ function buildDataVariantBusinessData(products, context, scheduleDateTime) {
|
|
|
49
49
|
function formatProductsWithDataVariant(products, context, scheduleDateTime) {
|
|
50
50
|
const evaluator = context.evaluator;
|
|
51
51
|
if (!evaluator || typeof evaluator.resolveProducts !== 'function') {
|
|
52
|
-
|
|
52
|
+
const message = '[VenueBooking][smartPricing] dataVariantEvaluator 未注入,跳过智能定价格式化';
|
|
53
|
+
try {
|
|
54
|
+
if (context.reportWarning) context.reportWarning(message);else console.warn(message);
|
|
55
|
+
} catch {
|
|
56
|
+
console.warn(message);
|
|
57
|
+
}
|
|
53
58
|
return products;
|
|
54
59
|
}
|
|
55
60
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LogConsoleType } from '../plugins/app-types/logger';
|
|
2
|
+
import type { PisellCore } from '../types';
|
|
3
|
+
export interface HostLogItem {
|
|
4
|
+
type: LogConsoleType;
|
|
5
|
+
title: string;
|
|
6
|
+
date?: string;
|
|
7
|
+
metadata?: Record<string, any>;
|
|
8
|
+
}
|
|
9
|
+
/** Use the same host logger as Order, without letting diagnostics interrupt sales. */
|
|
10
|
+
export declare function writeHostLog(core: PisellCore | undefined, log: HostLogItem): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.writeHostLog = writeHostLog;
|
|
7
|
+
/** Use the same host logger as Order, without letting diagnostics interrupt sales. */
|
|
8
|
+
function writeHostLog(core, log) {
|
|
9
|
+
const fallback = () => {
|
|
10
|
+
const method = log.type === 'warning' ? 'warn' : log.type;
|
|
11
|
+
};
|
|
12
|
+
try {
|
|
13
|
+
const logger = core?.getPlugin('app')?.getApp?.()?.logger;
|
|
14
|
+
if (typeof logger?.addLog !== 'function') {
|
|
15
|
+
fallback();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const result = logger.addLog(log);
|
|
19
|
+
if (result && typeof result.then === 'function') {
|
|
20
|
+
void Promise.resolve(result).catch(fallback);
|
|
21
|
+
}
|
|
22
|
+
} catch {
|
|
23
|
+
fallback();
|
|
24
|
+
}
|
|
25
|
+
}
|