@pisell/pisellos 2.3.82 → 2.3.84
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 +3 -0
- package/dist/modules/BookingContext/index.js +42 -13
- package/dist/modules/BookingContext/types.d.ts +4 -4
- package/dist/modules/BookingContext/types.js +3 -3
- package/dist/modules/Quotation/index.d.ts +16 -0
- package/dist/modules/Quotation/index.js +241 -32
- package/dist/solution/BaseSales/index.js +92 -72
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/VenueBooking/index.d.ts +2 -0
- package/dist/solution/VenueBooking/index.js +542 -494
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +3 -1
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +3 -1
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/BookingContext/index.d.ts +3 -0
- package/lib/modules/BookingContext/index.js +35 -8
- package/lib/modules/BookingContext/types.d.ts +4 -4
- package/lib/modules/BookingContext/types.js +3 -3
- package/lib/modules/Quotation/index.d.ts +16 -0
- package/lib/modules/Quotation/index.js +117 -11
- package/lib/solution/BaseSales/index.js +25 -9
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/VenueBooking/index.d.ts +2 -0
- package/lib/solution/VenueBooking/index.js +28 -8
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +3 -1
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +3 -1
- package/package.json +1 -1
|
@@ -19,12 +19,15 @@ export declare class BookingContextModule extends BaseModule implements Module,
|
|
|
19
19
|
protected defaultVersion: string;
|
|
20
20
|
private request;
|
|
21
21
|
private store;
|
|
22
|
+
private otherParams;
|
|
22
23
|
/** 上次成功 loadBookingConfig 的 query key;命中则不再请求。 */
|
|
23
24
|
private lastConfigQueryKey;
|
|
24
25
|
/** 上次成功 loadResources 的 query key(date|bookingIds);命中则不再请求。 */
|
|
25
26
|
private lastResourcesQueryKey;
|
|
26
27
|
constructor(name?: string, version?: string);
|
|
27
28
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
29
|
+
/** 同步父级解决方案的运行态参数;platform 变化后会自然切换 config endpoint/cache key。 */
|
|
30
|
+
updateOtherParams(params: Record<string, any>): void;
|
|
28
31
|
loadBookingConfig(params?: LoadBookingConfigParams, options?: {
|
|
29
32
|
forceRefresh?: boolean;
|
|
30
33
|
}): Promise<BookingContextConfig | null>;
|
|
@@ -26,6 +26,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
26
26
|
import dayjs from 'dayjs';
|
|
27
27
|
import { BaseModule } from "../BaseModule";
|
|
28
28
|
import { RequestModeENUM } from "../../plugins/request";
|
|
29
|
+
import { normalizeRuntimePlatform } from "../../utils/platform";
|
|
29
30
|
import { BookingContextEvent } from "./types";
|
|
30
31
|
import { formatResourceListAndMap } from "./utils/formatResourceList";
|
|
31
32
|
export * from "./types";
|
|
@@ -40,6 +41,8 @@ var DEFAULT_BOOKING_CONFIG_PARAMS = {
|
|
|
40
41
|
item_type: 'appointment_booking',
|
|
41
42
|
sub_type: 'ticket'
|
|
42
43
|
};
|
|
44
|
+
var BOOKING_CONFIG_ENDPOINT = '/core/board/management/config';
|
|
45
|
+
var H5_BOOKING_CONFIG_ENDPOINT = '/core/board/config';
|
|
43
46
|
var BOARD_CONFIG_CACHE = {
|
|
44
47
|
useCache: true,
|
|
45
48
|
cache: {
|
|
@@ -153,6 +156,24 @@ export function buildBookingConfigQueryKey() {
|
|
|
153
156
|
});
|
|
154
157
|
return JSON.stringify(sorted);
|
|
155
158
|
}
|
|
159
|
+
function resolveBookingConfigRequest(platform) {
|
|
160
|
+
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
161
|
+
var isH5 = normalizeRuntimePlatform(platform) === 'h5';
|
|
162
|
+
var endpoint = isH5 ? H5_BOOKING_CONFIG_ENDPOINT : BOOKING_CONFIG_ENDPOINT;
|
|
163
|
+
var query = isH5 ? {
|
|
164
|
+
item_type: params.item_type || DEFAULT_BOOKING_CONFIG_PARAMS.item_type
|
|
165
|
+
} : _objectSpread(_objectSpread({}, DEFAULT_BOOKING_CONFIG_PARAMS), params);
|
|
166
|
+
var keys = Object.keys(query).sort();
|
|
167
|
+
var sortedQuery = {};
|
|
168
|
+
keys.forEach(function (key) {
|
|
169
|
+
sortedQuery[key] = query[key];
|
|
170
|
+
});
|
|
171
|
+
return {
|
|
172
|
+
endpoint: endpoint,
|
|
173
|
+
query: query,
|
|
174
|
+
key: "".concat(endpoint, ":").concat(JSON.stringify(sortedQuery))
|
|
175
|
+
};
|
|
176
|
+
}
|
|
156
177
|
|
|
157
178
|
/** 稳定序列化资源列表查询(date + bookingIds),用于跳过重复 loadResources。 */
|
|
158
179
|
export function buildBookingResourcesQueryKey() {
|
|
@@ -176,6 +197,7 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
176
197
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
177
198
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
178
199
|
_defineProperty(_assertThisInitialized(_this), "store", _objectSpread({}, EMPTY_STATE));
|
|
200
|
+
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
179
201
|
/** 上次成功 loadBookingConfig 的 query key;命中则不再请求。 */
|
|
180
202
|
_defineProperty(_assertThisInitialized(_this), "lastConfigQueryKey", null);
|
|
181
203
|
/** 上次成功 loadResources 的 query key(date|bookingIds);命中则不再请求。 */
|
|
@@ -201,6 +223,7 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
201
223
|
}
|
|
202
224
|
throw new Error('BookingContextModule 需要 request 插件支持');
|
|
203
225
|
case 5:
|
|
226
|
+
this.otherParams = options.otherParams || {};
|
|
204
227
|
this.store = {
|
|
205
228
|
bookingConfig: null,
|
|
206
229
|
resourcesOrigin: [],
|
|
@@ -218,7 +241,7 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
218
241
|
if (initialState.date) {
|
|
219
242
|
this.store.date = initialState.date;
|
|
220
243
|
}
|
|
221
|
-
case
|
|
244
|
+
case 11:
|
|
222
245
|
case "end":
|
|
223
246
|
return _context.stop();
|
|
224
247
|
}
|
|
@@ -228,16 +251,22 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
228
251
|
return _initialize.apply(this, arguments);
|
|
229
252
|
}
|
|
230
253
|
return initialize;
|
|
231
|
-
}()
|
|
254
|
+
}() /** 同步父级解决方案的运行态参数;platform 变化后会自然切换 config endpoint/cache key。 */
|
|
255
|
+
}, {
|
|
256
|
+
key: "updateOtherParams",
|
|
257
|
+
value: function updateOtherParams(params) {
|
|
258
|
+
this.otherParams = params || {};
|
|
259
|
+
}
|
|
232
260
|
}, {
|
|
233
261
|
key: "loadBookingConfig",
|
|
234
262
|
value: function () {
|
|
235
263
|
var _loadBookingConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
236
|
-
var
|
|
264
|
+
var _this$otherParams,
|
|
265
|
+
_this2 = this;
|
|
237
266
|
var params,
|
|
238
267
|
options,
|
|
268
|
+
requestConfig,
|
|
239
269
|
configKey,
|
|
240
|
-
query,
|
|
241
270
|
sharedKey,
|
|
242
271
|
_sharedBookingConfigC,
|
|
243
272
|
cached,
|
|
@@ -250,14 +279,14 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
250
279
|
case 0:
|
|
251
280
|
params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
|
|
252
281
|
options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
253
|
-
|
|
282
|
+
requestConfig = resolveBookingConfigRequest((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform, params);
|
|
283
|
+
configKey = requestConfig.key;
|
|
254
284
|
if (!(!options.forceRefresh && this.store.bookingConfig != null && this.lastConfigQueryKey === configKey)) {
|
|
255
|
-
_context3.next =
|
|
285
|
+
_context3.next = 6;
|
|
256
286
|
break;
|
|
257
287
|
}
|
|
258
288
|
return _context3.abrupt("return", this.store.bookingConfig);
|
|
259
|
-
case
|
|
260
|
-
query = _objectSpread(_objectSpread({}, DEFAULT_BOOKING_CONFIG_PARAMS), params);
|
|
289
|
+
case 6:
|
|
261
290
|
sharedKey = buildSharedCacheKey(this.request, configKey);
|
|
262
291
|
if (!(!options.forceRefresh && sharedBookingConfigCache.has(sharedKey))) {
|
|
263
292
|
_context3.next = 12;
|
|
@@ -277,7 +306,7 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
277
306
|
case 0:
|
|
278
307
|
_context2.prev = 0;
|
|
279
308
|
_context2.next = 3;
|
|
280
|
-
return _this2.request.get(
|
|
309
|
+
return _this2.request.get(requestConfig.endpoint, requestConfig.query, BOARD_CONFIG_CACHE);
|
|
281
310
|
case 3:
|
|
282
311
|
res = _context2.sent;
|
|
283
312
|
_config = (_res$data = res === null || res === void 0 ? void 0 : res.data) !== null && _res$data !== void 0 ? _res$data : null;
|
|
@@ -411,9 +440,9 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
411
440
|
}, {
|
|
412
441
|
key: "isBookingContextReady",
|
|
413
442
|
value: function isBookingContextReady() {
|
|
414
|
-
var _ref3, _params$date2;
|
|
443
|
+
var _this$otherParams2, _ref3, _params$date2;
|
|
415
444
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
416
|
-
var configKey =
|
|
445
|
+
var configKey = resolveBookingConfigRequest((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform, params.bookingConfigParams).key;
|
|
417
446
|
var dateInput = (_ref3 = (_params$date2 = params.date) !== null && _params$date2 !== void 0 ? _params$date2 : this.store.date) !== null && _ref3 !== void 0 ? _ref3 : dayjs();
|
|
418
447
|
var queryDate = toScheduleQueryDate(dateInput);
|
|
419
448
|
var resourcesKey = buildBookingResourcesQueryKey({
|
|
@@ -428,7 +457,7 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
428
457
|
key: "initBookingContext",
|
|
429
458
|
value: function () {
|
|
430
459
|
var _initBookingContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
431
|
-
var _ref4, _params$date3;
|
|
460
|
+
var _ref4, _params$date3, _this$otherParams3;
|
|
432
461
|
var params,
|
|
433
462
|
dateInput,
|
|
434
463
|
queryDate,
|
|
@@ -450,7 +479,7 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
450
479
|
}
|
|
451
480
|
return _context6.abrupt("return", this.getState());
|
|
452
481
|
case 6:
|
|
453
|
-
configKey =
|
|
482
|
+
configKey = resolveBookingConfigRequest((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform, params.bookingConfigParams).key;
|
|
454
483
|
resourcesKey = buildBookingResourcesQueryKey({
|
|
455
484
|
date: queryDate,
|
|
456
485
|
bookingIds: params.bookingIds
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BookingContext 子模块:承载「预约 UI 上下文」三件套。
|
|
3
3
|
*
|
|
4
|
-
* - bookingConfig:来自 `/core/board/management/config` 的整套预约配置(service_time / resource_tab /
|
|
4
|
+
* - bookingConfig:来自 staff `/core/board/management/config` 或 H5 `/core/board/config` 的整套预约配置(service_time / resource_tab /
|
|
5
5
|
* appointment_subject / subject_require / stock_setting / basic / capacity 等)。
|
|
6
6
|
* - resourcesOrigin / resourcesOriginMap:来自 `/schedule/resource/list` 的资源全集,含 times / event_list /
|
|
7
7
|
* combined_resource 等运行态信息,是 getResourceByIds / getResourceTimeIsUsable 的输入。
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* - 默认由 `loadBookingConfig` / `loadResources` 拉取并写入 store;也支持消费方 `set*` 直接灌入(复用 ticketBooking 已拉到的数据)。
|
|
12
12
|
* - 所有读 API 返回浅克隆(数组)或原引用(map / config),避免 UI 写穿。
|
|
13
13
|
*/
|
|
14
|
-
/** `loadBookingConfig`
|
|
14
|
+
/** `loadBookingConfig` 入参;H5 公共接口只消费 `item_type`。 */
|
|
15
15
|
export interface LoadBookingConfigParams {
|
|
16
16
|
item_type?: string;
|
|
17
17
|
sub_type?: string;
|
|
@@ -42,7 +42,7 @@ export interface InitBookingContextParams {
|
|
|
42
42
|
export type BookingContextResource = Record<string, any>;
|
|
43
43
|
export type BookingContextResourceMap = Record<string, BookingContextResource>;
|
|
44
44
|
/**
|
|
45
|
-
* 形参 booking_config(结构来自
|
|
45
|
+
* 形参 booking_config(结构来自 staff management 或 H5 board config 接口的 `data`)。
|
|
46
46
|
* OS 不强制 schema,保留 `Record<string, any>` 兼容现网;常用路径文档化在 SDK docs。
|
|
47
47
|
*/
|
|
48
48
|
export type BookingContextConfig = Record<string, any>;
|
|
@@ -80,7 +80,7 @@ export interface BookingContextModuleAPI {
|
|
|
80
80
|
getState(): BookingContextState;
|
|
81
81
|
/** 一键清空,destroy / 切租户场景用。 */
|
|
82
82
|
clear(): void;
|
|
83
|
-
/**
|
|
83
|
+
/** 按运行平台拉取 board config 并写入 store。 */
|
|
84
84
|
loadBookingConfig(params?: LoadBookingConfigParams): Promise<BookingContextConfig | null>;
|
|
85
85
|
/** 拉取资源全集并写入 store(`/schedule/resource/list`)。 */
|
|
86
86
|
loadResources(params?: LoadBookingResourcesParams): Promise<BookingContextResource[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BookingContext 子模块:承载「预约 UI 上下文」三件套。
|
|
3
3
|
*
|
|
4
|
-
* - bookingConfig:来自 `/core/board/management/config` 的整套预约配置(service_time / resource_tab /
|
|
4
|
+
* - bookingConfig:来自 staff `/core/board/management/config` 或 H5 `/core/board/config` 的整套预约配置(service_time / resource_tab /
|
|
5
5
|
* appointment_subject / subject_require / stock_setting / basic / capacity 等)。
|
|
6
6
|
* - resourcesOrigin / resourcesOriginMap:来自 `/schedule/resource/list` 的资源全集,含 times / event_list /
|
|
7
7
|
* combined_resource 等运行态信息,是 getResourceByIds / getResourceTimeIsUsable 的输入。
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* - 所有读 API 返回浅克隆(数组)或原引用(map / config),避免 UI 写穿。
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
/** `loadBookingConfig`
|
|
15
|
+
/** `loadBookingConfig` 入参;H5 公共接口只消费 `item_type`。 */
|
|
16
16
|
|
|
17
17
|
/** `loadResources` 入参,与 info2 `getResourceList` 一致。 */
|
|
18
18
|
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* 形参 booking_config(结构来自
|
|
27
|
+
* 形参 booking_config(结构来自 staff management 或 H5 board config 接口的 `data`)。
|
|
28
28
|
* OS 不强制 schema,保留 `Record<string, any>` 兼容现网;常用路径文档化在 SDK docs。
|
|
29
29
|
*/
|
|
30
30
|
|
|
@@ -11,12 +11,23 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
11
11
|
private scheduleResolver?;
|
|
12
12
|
private app;
|
|
13
13
|
private quotationListUpdatedListener?;
|
|
14
|
+
private quotationCache;
|
|
15
|
+
private quotationLoadPromises;
|
|
16
|
+
private quotationCacheVersions;
|
|
17
|
+
private lifecycleGeneration;
|
|
18
|
+
private activeChannelKey;
|
|
14
19
|
constructor(name?: string, version?: string);
|
|
15
20
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
16
21
|
loadQuotations(params?: {
|
|
17
22
|
channel?: string;
|
|
18
23
|
customer_id?: number | string;
|
|
19
24
|
}): Promise<void>;
|
|
25
|
+
ensureQuotations(params?: {
|
|
26
|
+
channel?: string;
|
|
27
|
+
customer_id?: number | string;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
invalidateQuotationCache(channel?: string): void;
|
|
30
|
+
private fetchQuotations;
|
|
20
31
|
getQuotationList(): QuotationItem[];
|
|
21
32
|
setQuotationListUpdatedListener(listener?: () => void): void;
|
|
22
33
|
getQuotationCustomerScopeInfo(): QuotationCustomerScopeInfo;
|
|
@@ -60,12 +71,17 @@ export declare class QuotationModule extends BaseModule implements Module {
|
|
|
60
71
|
buildProductPriceMap(params: {
|
|
61
72
|
productIds: number[];
|
|
62
73
|
timePoints: string[];
|
|
74
|
+
channel?: string;
|
|
63
75
|
customer_id?: number | string;
|
|
64
76
|
}): Map<string, string | null>;
|
|
65
77
|
setScheduleResolver(resolver: (id: number) => ScheduleItem | undefined): void;
|
|
66
78
|
private applyQuotationResponse;
|
|
67
79
|
private notifyQuotationListUpdated;
|
|
68
80
|
private getQuotationCacheKeyData;
|
|
81
|
+
private normalizeChannel;
|
|
82
|
+
private activateChannel;
|
|
83
|
+
private getQuotationCacheVersion;
|
|
84
|
+
private bumpQuotationCacheVersion;
|
|
69
85
|
private isQuotationVisibleForCustomer;
|
|
70
86
|
private hasValidCustomerId;
|
|
71
87
|
private normalizeCustomerId;
|