@pisell/pisellos 0.10.51 → 0.10.53
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/Schedule/index.d.ts +8 -0
- package/dist/modules/Schedule/index.js +141 -39
- package/dist/solution/BaseSales/index.d.ts +1 -0
- package/dist/solution/BaseSales/index.js +22 -11
- package/dist/solution/BaseSales/pickupTiming.d.ts +8 -2
- package/dist/solution/BaseSales/pickupTiming.js +266 -159
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +2 -2
- package/dist/solution/UnifiedBookingSales/index.d.ts +12 -5
- package/dist/solution/UnifiedBookingSales/index.js +854 -741
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Schedule/index.d.ts +8 -0
- package/lib/modules/Schedule/index.js +68 -12
- package/lib/solution/BaseSales/index.d.ts +1 -0
- package/lib/solution/BaseSales/index.js +7 -0
- package/lib/solution/BaseSales/pickupTiming.d.ts +8 -2
- package/lib/solution/BaseSales/pickupTiming.js +89 -42
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +2 -2
- package/lib/solution/UnifiedBookingSales/index.d.ts +12 -5
- package/lib/solution/UnifiedBookingSales/index.js +121 -57
- package/package.json +1 -1
|
@@ -1,46 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _adapter.PromotionAdapter;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _evaluator.PromotionEvaluator;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "default", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _adapter.default;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
var _evaluator = require("./evaluator");
|
|
43
|
-
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
-
var _examples = require("./examples");
|
|
45
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
1
|
+
"use strict";
|
|
@@ -10,6 +10,10 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
10
10
|
private openCache;
|
|
11
11
|
private fatherModule;
|
|
12
12
|
private hasLoadedScheduleList;
|
|
13
|
+
private scheduleListPromise;
|
|
14
|
+
private scheduleListRequestVersion;
|
|
15
|
+
private scheduleCatalogScope;
|
|
16
|
+
private otherParams;
|
|
13
17
|
constructor(name?: string, version?: string);
|
|
14
18
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
15
19
|
/**
|
|
@@ -19,6 +23,9 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
19
23
|
* scheduleModule.updateOtherParams({ openCache: true, cacheId: 'cache-2' });
|
|
20
24
|
*/
|
|
21
25
|
updateOtherParams(params: Record<string, any>): void;
|
|
26
|
+
private syncScheduleCatalogScope;
|
|
27
|
+
private resetScheduleCatalog;
|
|
28
|
+
destroy(): void;
|
|
22
29
|
/**
|
|
23
30
|
* 加载当前店铺下所有 schedule
|
|
24
31
|
*
|
|
@@ -27,6 +34,7 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
|
|
|
27
34
|
loadAllSchedule(options?: {
|
|
28
35
|
useCache?: boolean;
|
|
29
36
|
}): Promise<void>;
|
|
37
|
+
private loadScheduleCatalog;
|
|
30
38
|
setScheduleList(list: ScheduleItem[]): void;
|
|
31
39
|
private syncScheduleMap;
|
|
32
40
|
getScheduleList(): ScheduleItem[];
|
|
@@ -24,10 +24,18 @@ class ScheduleModule extends _BaseModule.BaseModule {
|
|
|
24
24
|
openCache = false;
|
|
25
25
|
fatherModule;
|
|
26
26
|
hasLoadedScheduleList = false;
|
|
27
|
+
scheduleListPromise = null;
|
|
28
|
+
scheduleListRequestVersion = 0;
|
|
29
|
+
scheduleCatalogScope = '';
|
|
30
|
+
otherParams = {};
|
|
27
31
|
constructor(name, version) {
|
|
28
32
|
super(name, version);
|
|
29
33
|
}
|
|
30
34
|
async initialize(core, options) {
|
|
35
|
+
// The store proxies initialState, so capture its input before resets write through it.
|
|
36
|
+
const initialScheduleList = options.initialState?.scheduleList;
|
|
37
|
+
const hasInitialScheduleList = Array.isArray(initialScheduleList);
|
|
38
|
+
this.resetScheduleCatalog();
|
|
31
39
|
this.core = core;
|
|
32
40
|
|
|
33
41
|
// 获取依赖的插件
|
|
@@ -40,24 +48,18 @@ class ScheduleModule extends _BaseModule.BaseModule {
|
|
|
40
48
|
// this.state = { ...this.state, ...options.initialState }
|
|
41
49
|
// }
|
|
42
50
|
this.store = options?.store;
|
|
51
|
+
this.updateOtherParams(options.otherParams || {});
|
|
43
52
|
if (options.initialState) {
|
|
44
|
-
this.store.scheduleList =
|
|
53
|
+
this.store.scheduleList = hasInitialScheduleList ? initialScheduleList : [];
|
|
45
54
|
this.syncScheduleMap();
|
|
46
55
|
this.store.availabilityDateList = options.initialState.availabilityDateList;
|
|
47
|
-
this.hasLoadedScheduleList =
|
|
56
|
+
this.hasLoadedScheduleList = hasInitialScheduleList;
|
|
48
57
|
} else {
|
|
49
58
|
this.store.scheduleList = [];
|
|
50
59
|
this.store.map = new Map();
|
|
51
60
|
this.store.availabilityDateList = [];
|
|
52
61
|
this.hasLoadedScheduleList = false;
|
|
53
62
|
}
|
|
54
|
-
if (options.otherParams?.cacheId) {
|
|
55
|
-
this.openCache = options.otherParams.openCache;
|
|
56
|
-
this.cacheId = options.otherParams.cacheId;
|
|
57
|
-
}
|
|
58
|
-
if (options.otherParams?.fatherModule) {
|
|
59
|
-
this.fatherModule = options.otherParams.fatherModule;
|
|
60
|
-
}
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
/**
|
|
@@ -68,9 +70,34 @@ class ScheduleModule extends _BaseModule.BaseModule {
|
|
|
68
70
|
*/
|
|
69
71
|
updateOtherParams(params) {
|
|
70
72
|
const otherParams = params || {};
|
|
73
|
+
this.otherParams = {
|
|
74
|
+
...otherParams
|
|
75
|
+
};
|
|
71
76
|
this.openCache = otherParams.openCache ?? false;
|
|
72
77
|
this.cacheId = otherParams.cacheId;
|
|
73
78
|
this.fatherModule = otherParams.fatherModule;
|
|
79
|
+
this.syncScheduleCatalogScope();
|
|
80
|
+
}
|
|
81
|
+
syncScheduleCatalogScope() {
|
|
82
|
+
const context = this.core?.context;
|
|
83
|
+
const shopId = typeof context?.getData === 'function' ? context.getData('shop_id') : context?.shop_id;
|
|
84
|
+
const params = this.otherParams;
|
|
85
|
+
const scope = JSON.stringify([this.cacheId, this.fatherModule, params.businessCode ?? params.business_code, params.channel, params.platform, params.businessTimezone, shopId].map(value => String(value ?? '').trim()));
|
|
86
|
+
if (scope !== this.scheduleCatalogScope) {
|
|
87
|
+
this.resetScheduleCatalog();
|
|
88
|
+
this.scheduleCatalogScope = scope;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
resetScheduleCatalog() {
|
|
92
|
+
this.scheduleListRequestVersion += 1;
|
|
93
|
+
this.scheduleListPromise = null;
|
|
94
|
+
this.hasLoadedScheduleList = false;
|
|
95
|
+
this.store.scheduleList = [];
|
|
96
|
+
this.store.map = new Map();
|
|
97
|
+
}
|
|
98
|
+
destroy() {
|
|
99
|
+
this.resetScheduleCatalog();
|
|
100
|
+
super.destroy();
|
|
74
101
|
}
|
|
75
102
|
|
|
76
103
|
/**
|
|
@@ -79,14 +106,40 @@ class ScheduleModule extends _BaseModule.BaseModule {
|
|
|
79
106
|
* @memberof ScheduleModule
|
|
80
107
|
*/
|
|
81
108
|
async loadAllSchedule(options = {}) {
|
|
82
|
-
|
|
109
|
+
this.syncScheduleCatalogScope();
|
|
110
|
+
const useCache = options.useCache ?? true;
|
|
111
|
+
if (useCache) {
|
|
112
|
+
if (this.scheduleListPromise) return this.scheduleListPromise;
|
|
113
|
+
if (this.hasLoadedScheduleList) return;
|
|
114
|
+
}
|
|
115
|
+
const requestVersion = ++this.scheduleListRequestVersion;
|
|
116
|
+
const promise = this.loadScheduleCatalog(useCache, requestVersion);
|
|
117
|
+
this.scheduleListPromise = promise;
|
|
118
|
+
try {
|
|
119
|
+
await promise;
|
|
120
|
+
} finally {
|
|
121
|
+
if (this.scheduleListPromise === promise) {
|
|
122
|
+
this.scheduleListPromise = null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async loadScheduleCatalog(useCache, requestVersion) {
|
|
127
|
+
const response = await this.request.get(`/schedule`, {
|
|
83
128
|
num: 999
|
|
84
129
|
}, {
|
|
85
|
-
useCache
|
|
130
|
+
useCache
|
|
86
131
|
});
|
|
87
|
-
|
|
132
|
+
if (response.code !== undefined && Number(response.code) !== 200 || response.status === false || typeof response.status === 'number' && response.status >= 400 || response.success === false) {
|
|
133
|
+
throw new Error(response.message || 'Schedule catalog request failed');
|
|
134
|
+
}
|
|
135
|
+
this.syncScheduleCatalogScope();
|
|
136
|
+
// A refresh or a different runtime may have superseded this request.
|
|
137
|
+
if (requestVersion === this.scheduleListRequestVersion) {
|
|
138
|
+
this.setScheduleList(response.data?.list || []);
|
|
139
|
+
}
|
|
88
140
|
}
|
|
89
141
|
setScheduleList(list) {
|
|
142
|
+
this.syncScheduleCatalogScope();
|
|
90
143
|
this.store.scheduleList = list;
|
|
91
144
|
this.syncScheduleMap();
|
|
92
145
|
this.hasLoadedScheduleList = true;
|
|
@@ -95,9 +148,11 @@ class ScheduleModule extends _BaseModule.BaseModule {
|
|
|
95
148
|
this.store.map = new Map((this.store.scheduleList || []).map(schedule => [Number(schedule.id), schedule]));
|
|
96
149
|
}
|
|
97
150
|
getScheduleList() {
|
|
151
|
+
this.syncScheduleCatalogScope();
|
|
98
152
|
return this.store.scheduleList || [];
|
|
99
153
|
}
|
|
100
154
|
isScheduleListLoaded() {
|
|
155
|
+
this.syncScheduleCatalogScope();
|
|
101
156
|
return this.hasLoadedScheduleList;
|
|
102
157
|
}
|
|
103
158
|
async loadScheduleAvailableDate({
|
|
@@ -149,6 +204,7 @@ class ScheduleModule extends _BaseModule.BaseModule {
|
|
|
149
204
|
return dates;
|
|
150
205
|
}
|
|
151
206
|
getScheduleListByIds(ids) {
|
|
207
|
+
this.syncScheduleCatalogScope();
|
|
152
208
|
const idSet = new Set(ids.map(id => String(id)));
|
|
153
209
|
if (this.store.map instanceof Map && this.store.map.size > 0) {
|
|
154
210
|
return ids.map(id => this.store.map.get(Number(id))).filter(Boolean);
|
|
@@ -160,6 +160,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
160
160
|
protected isPickupTimingEnabled(): boolean;
|
|
161
161
|
protected getPickupTimingContextData(key: string): unknown;
|
|
162
162
|
protected getPickupTimingScope(): string;
|
|
163
|
+
protected resetPickupTimingCache(): void;
|
|
163
164
|
private getPickupTimingController;
|
|
164
165
|
getPickupTimingAvailability(params?: {
|
|
165
166
|
date?: string;
|
|
@@ -1172,6 +1172,9 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
1172
1172
|
cacheId: this.cacheId
|
|
1173
1173
|
});
|
|
1174
1174
|
}
|
|
1175
|
+
resetPickupTimingCache() {
|
|
1176
|
+
this.pickupTimingController?.invalidate();
|
|
1177
|
+
}
|
|
1175
1178
|
getPickupTimingController() {
|
|
1176
1179
|
if (!this.pickupTimingController) {
|
|
1177
1180
|
this.pickupTimingController = new _pickupTiming2.PickupTimingController({
|
|
@@ -1453,6 +1456,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
1453
1456
|
return isChanged;
|
|
1454
1457
|
}
|
|
1455
1458
|
async initialize(core, options = {}) {
|
|
1459
|
+
this.resetPickupTimingCache();
|
|
1456
1460
|
this.core = core;
|
|
1457
1461
|
this.initializeOptions = options || {};
|
|
1458
1462
|
this.paymentNumberDevicePrefix = null;
|
|
@@ -1504,6 +1508,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
1504
1508
|
this.core.effects.emit(`${this.name}:onInited`, {});
|
|
1505
1509
|
}
|
|
1506
1510
|
async destroy() {
|
|
1511
|
+
this.resetPickupTimingCache();
|
|
1507
1512
|
this.serverOrderChangeUnsubscribe?.();
|
|
1508
1513
|
this.serverOrderChangeUnsubscribe = null;
|
|
1509
1514
|
Object.keys(this.store).forEach(key => {
|
|
@@ -4090,6 +4095,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
4090
4095
|
async setOtherParams(params, {
|
|
4091
4096
|
cover = false
|
|
4092
4097
|
} = {}) {
|
|
4098
|
+
const previousPickupTimingScope = this.getPickupTimingScope();
|
|
4093
4099
|
if (cover) {
|
|
4094
4100
|
this.otherParams = {
|
|
4095
4101
|
...params
|
|
@@ -4101,6 +4107,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
4101
4107
|
};
|
|
4102
4108
|
}
|
|
4103
4109
|
this.cacheId = this.otherParams?.cacheId;
|
|
4110
|
+
if (previousPickupTimingScope !== this.getPickupTimingScope()) this.resetPickupTimingCache();
|
|
4104
4111
|
await this.syncOtherParamsToSubModules(params, {
|
|
4105
4112
|
cover
|
|
4106
4113
|
});
|
|
@@ -10,14 +10,20 @@ interface PickupTimingHost {
|
|
|
10
10
|
isPos: () => boolean;
|
|
11
11
|
now?: () => Date;
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
13
|
+
/** Reuses runtime configuration and schedules; every calculation still uses the live clock. */
|
|
14
14
|
export declare class PickupTimingController {
|
|
15
15
|
private readonly host;
|
|
16
16
|
private latest?;
|
|
17
|
-
private
|
|
17
|
+
private runtime?;
|
|
18
18
|
private writeSequence;
|
|
19
19
|
constructor(host: PickupTimingHost);
|
|
20
20
|
private now;
|
|
21
|
+
/** A new solution context or an explicit settings refresh invalidates pending work too. */
|
|
22
|
+
invalidate(): void;
|
|
23
|
+
private assertCurrentRuntime;
|
|
24
|
+
private getRuntime;
|
|
25
|
+
private loadConfig;
|
|
26
|
+
private loadSchedules;
|
|
21
27
|
private snapshot;
|
|
22
28
|
getAvailability(params?: {
|
|
23
29
|
date?: string;
|
|
@@ -17,10 +17,10 @@ async function withTimeout(request) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
/**
|
|
20
|
+
/** Reuses runtime configuration and schedules; every calculation still uses the live clock. */
|
|
21
21
|
class PickupTimingController {
|
|
22
22
|
latest;
|
|
23
|
-
|
|
23
|
+
runtime;
|
|
24
24
|
writeSequence = 0;
|
|
25
25
|
constructor(host) {
|
|
26
26
|
this.host = host;
|
|
@@ -28,52 +28,99 @@ class PickupTimingController {
|
|
|
28
28
|
now() {
|
|
29
29
|
return this.host.now?.() ?? new Date();
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
/** A new solution context or an explicit settings refresh invalidates pending work too. */
|
|
33
|
+
invalidate() {
|
|
34
|
+
this.runtime = undefined;
|
|
35
|
+
this.latest = undefined;
|
|
36
|
+
this.writeSequence += 1;
|
|
37
|
+
}
|
|
38
|
+
assertCurrentRuntime(runtime) {
|
|
39
|
+
if (this.runtime !== runtime || runtime.scope !== this.host.getScope()) {
|
|
40
|
+
throw new Error('Store settings changed. Please try again.');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
getRuntime() {
|
|
32
44
|
const scope = this.host.getScope();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
schedules = (0, _lodashEs.cloneDeep)(schedule.getScheduleListByIds(ids) || []);
|
|
50
|
-
} catch (reason) {
|
|
51
|
-
if (!tolerateScheduleError) throw reason;
|
|
52
|
-
error = reason instanceof Error ? reason.message : 'Pickup schedule is unavailable. Please try again.';
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (scope !== this.host.getScope()) throw new Error('Store settings changed. Please try again.');
|
|
56
|
-
return {
|
|
57
|
-
config,
|
|
58
|
-
timezone,
|
|
59
|
-
schedules,
|
|
60
|
-
scope,
|
|
61
|
-
error
|
|
62
|
-
};
|
|
45
|
+
if (this.runtime?.scope !== scope) {
|
|
46
|
+
this.latest = undefined;
|
|
47
|
+
this.runtime = {
|
|
48
|
+
scope
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return this.runtime;
|
|
52
|
+
}
|
|
53
|
+
async loadConfig(runtime) {
|
|
54
|
+
if (runtime.config) return runtime.config;
|
|
55
|
+
if (!runtime.configRequest) {
|
|
56
|
+
const request = (async () => {
|
|
57
|
+
const config = (0, _FulfillmentTiming.normalizePickupTimingConfig)(await withTimeout(this.host.loadOpenData(false)));
|
|
58
|
+
this.assertCurrentRuntime(runtime);
|
|
59
|
+
runtime.config = config;
|
|
60
|
+
return config;
|
|
63
61
|
})();
|
|
64
|
-
|
|
62
|
+
runtime.configRequest = request;
|
|
65
63
|
}
|
|
64
|
+
const request = runtime.configRequest;
|
|
66
65
|
try {
|
|
67
|
-
|
|
68
|
-
if (scope !== this.host.getScope()) throw new Error('Store settings changed. Please try again.');
|
|
69
|
-
this.latest = result;
|
|
70
|
-
return result;
|
|
66
|
+
return await request;
|
|
71
67
|
} finally {
|
|
72
|
-
if (
|
|
68
|
+
if (runtime.configRequest === request) runtime.configRequest = undefined;
|
|
73
69
|
}
|
|
74
70
|
}
|
|
71
|
+
async loadSchedules(runtime, config) {
|
|
72
|
+
if (runtime.schedules) return runtime.schedules;
|
|
73
|
+
if (!runtime.scheduleRequest) {
|
|
74
|
+
const request = (async () => {
|
|
75
|
+
const schedule = this.host.getSchedule();
|
|
76
|
+
if (!schedule) throw new Error('Pickup schedule is unavailable. Please try again.');
|
|
77
|
+
// Reuse the catalog loaded by solution initialization, including its in-flight request.
|
|
78
|
+
await withTimeout(schedule.loadAllSchedule({
|
|
79
|
+
useCache: true
|
|
80
|
+
}));
|
|
81
|
+
this.assertCurrentRuntime(runtime);
|
|
82
|
+
const ids = [...new Set([...config.scheduleIds, ...(config.operatingHoursScheduleIds || [])])];
|
|
83
|
+
const schedules = (0, _lodashEs.cloneDeep)(schedule.getScheduleListByIds(ids) || []);
|
|
84
|
+
runtime.schedules = schedules;
|
|
85
|
+
return schedules;
|
|
86
|
+
})();
|
|
87
|
+
runtime.scheduleRequest = request;
|
|
88
|
+
}
|
|
89
|
+
const request = runtime.scheduleRequest;
|
|
90
|
+
try {
|
|
91
|
+
return await request;
|
|
92
|
+
} finally {
|
|
93
|
+
if (runtime.scheduleRequest === request) runtime.scheduleRequest = undefined;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async snapshot(includeSchedule, tolerateScheduleError = false) {
|
|
97
|
+
const runtime = this.getRuntime();
|
|
98
|
+
const config = await this.loadConfig(runtime);
|
|
99
|
+
this.assertCurrentRuntime(runtime);
|
|
100
|
+
let schedules = [];
|
|
101
|
+
let error;
|
|
102
|
+
if (includeSchedule && config.handoverModes.includes('pick_up') && config.timingMode !== 'asap_only' && config.scheduleIds.length) {
|
|
103
|
+
try {
|
|
104
|
+
schedules = await this.loadSchedules(runtime, config);
|
|
105
|
+
} catch (reason) {
|
|
106
|
+
if (!tolerateScheduleError) throw reason;
|
|
107
|
+
error = reason instanceof Error ? reason.message : 'Pickup schedule is unavailable. Please try again.';
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
this.assertCurrentRuntime(runtime);
|
|
111
|
+
const result = {
|
|
112
|
+
config,
|
|
113
|
+
timezone: this.host.getTimezone(),
|
|
114
|
+
schedules,
|
|
115
|
+
scope: runtime.scope,
|
|
116
|
+
error
|
|
117
|
+
};
|
|
118
|
+
this.latest = result;
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
75
121
|
async getAvailability(params = {}) {
|
|
76
|
-
|
|
122
|
+
// `force` remains accepted for older callers; refresh recomputes time using the runtime catalog.
|
|
123
|
+
const snapshot = await this.snapshot(true, true);
|
|
77
124
|
const now = this.now();
|
|
78
125
|
try {
|
|
79
126
|
return {
|
|
@@ -121,7 +168,7 @@ class PickupTimingController {
|
|
|
121
168
|
};
|
|
122
169
|
}
|
|
123
170
|
async validateSnapshot(selection) {
|
|
124
|
-
const snapshot = await this.snapshot(
|
|
171
|
+
const snapshot = await this.snapshot(selection.serviceType === 'pick_up' && selection.mode === 'scheduled' && selection.source !== 'pos_manual');
|
|
125
172
|
const now = this.now();
|
|
126
173
|
const result = (0, _FulfillmentTiming.validatePickupTimingSelection)(selection, {
|
|
127
174
|
...snapshot,
|
|
@@ -205,7 +252,7 @@ class PickupTimingController {
|
|
|
205
252
|
}
|
|
206
253
|
return this.getSelection();
|
|
207
254
|
}
|
|
208
|
-
const snapshot = await this.snapshot(
|
|
255
|
+
const snapshot = await this.snapshot(false);
|
|
209
256
|
if (order !== this.host.getOrder() || order.getTempOrder() !== tempOrder || sequence !== this.writeSequence) {
|
|
210
257
|
throw new Error('The order changed. Please choose the pickup time again.');
|
|
211
258
|
}
|
|
@@ -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 | 2 | 1 | 5 | 4 | 3 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -52,10 +52,10 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
52
52
|
* 在解决方案对外 ready 前准备 Invoice Document;失败只降级模板,不阻断销售。
|
|
53
53
|
* 已由页面取得的 OpenData 直接交给模块接管,没有注入数据时再走 target-scoped 加载。
|
|
54
54
|
*/
|
|
55
|
-
|
|
55
|
+
protected prepareInvoiceTemplateAtSolutionReady(injectedOpenData?: OpenDataConfig): Promise<void>;
|
|
56
56
|
protected getBookingTicketBusinessCode(): string | null;
|
|
57
57
|
private getIdGeneratorPlugin;
|
|
58
|
-
|
|
58
|
+
protected loadOpenDataConfig(): Promise<OpenDataConfig | null>;
|
|
59
59
|
getOpenData(): Promise<OpenDataConfig | null>;
|
|
60
60
|
getInvoiceLayoutConfig(): Promise<InvoiceLayoutConfig>;
|
|
61
61
|
getInvoiceTemplateSettings(): Promise<InvoiceTemplateSettings>;
|
|
@@ -60,6 +60,12 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
60
60
|
protected defaultVersion: string;
|
|
61
61
|
protected store: UnifiedBookingSalesState;
|
|
62
62
|
protected pickupTimingEnabled: boolean;
|
|
63
|
+
private runtimeOpenDataScope;
|
|
64
|
+
private runtimeOpenDataSnapshot;
|
|
65
|
+
private runtimeOpenDataModule;
|
|
66
|
+
private runtimeOpenDataCore;
|
|
67
|
+
private runtimeOpenDataGeneration;
|
|
68
|
+
private runtimeOpenDataDestroyed;
|
|
63
69
|
private unifiedProductCatalog;
|
|
64
70
|
private availabilityRuntimeOffsetMinutes;
|
|
65
71
|
private availabilityScheduleCatalog;
|
|
@@ -143,13 +149,14 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
143
149
|
private resolveDiscountAction;
|
|
144
150
|
private resetCachedCustomerDiscountState;
|
|
145
151
|
private refreshLegacySessionCustomerDiscounts;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
152
|
+
private getRuntimeOpenDataScope;
|
|
153
|
+
private resetRuntimeOpenData;
|
|
154
|
+
protected prepareInvoiceTemplateAtSolutionReady(injectedOpenData?: OpenDataConfig): Promise<void>;
|
|
155
|
+
protected loadOpenDataConfig(): Promise<OpenDataConfig | null>;
|
|
156
|
+
/** A successful configuration belongs to this business runtime until an explicit refresh. */
|
|
150
157
|
loadOpenData(params: UnifiedBookingSalesLoadOpenDataParams): Promise<OpenDataConfig>;
|
|
151
158
|
getOpenData(): Promise<OpenDataConfig | null>;
|
|
152
|
-
protected loadPickupTimingOpenData(
|
|
159
|
+
protected loadPickupTimingOpenData(_force: boolean): Promise<Record<string, unknown>>;
|
|
153
160
|
private resetAllergyItemRuleState;
|
|
154
161
|
private fetchAllergyItemRuleConfigs;
|
|
155
162
|
private ensureAllergyItemRuleConfigsLoaded;
|