@pisell/pisellos 0.10.51 → 0.10.52
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 +134 -37
- 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 +64 -11
- 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
|
@@ -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[];
|
|
@@ -10,6 +10,8 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
10
10
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
11
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
12
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
14
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
13
15
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
14
16
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
15
17
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -45,32 +47,37 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
45
47
|
_defineProperty(_assertThisInitialized(_this), "openCache", false);
|
|
46
48
|
_defineProperty(_assertThisInitialized(_this), "fatherModule", void 0);
|
|
47
49
|
_defineProperty(_assertThisInitialized(_this), "hasLoadedScheduleList", false);
|
|
50
|
+
_defineProperty(_assertThisInitialized(_this), "scheduleListPromise", null);
|
|
51
|
+
_defineProperty(_assertThisInitialized(_this), "scheduleListRequestVersion", 0);
|
|
52
|
+
_defineProperty(_assertThisInitialized(_this), "scheduleCatalogScope", '');
|
|
53
|
+
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
48
54
|
return _this;
|
|
49
55
|
}
|
|
50
56
|
_createClass(ScheduleModule, [{
|
|
51
57
|
key: "initialize",
|
|
52
58
|
value: function () {
|
|
53
59
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
54
|
-
var _options$otherParams, _options$otherParams2;
|
|
55
60
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
56
61
|
while (1) switch (_context.prev = _context.next) {
|
|
57
62
|
case 0:
|
|
63
|
+
this.resetScheduleCatalog();
|
|
58
64
|
this.core = core;
|
|
59
65
|
|
|
60
66
|
// 获取依赖的插件
|
|
61
67
|
this.request = core.getPlugin('request');
|
|
62
68
|
if (this.request) {
|
|
63
|
-
_context.next =
|
|
69
|
+
_context.next = 5;
|
|
64
70
|
break;
|
|
65
71
|
}
|
|
66
72
|
throw new Error('ScheduleModule 需要 request 插件支持');
|
|
67
|
-
case
|
|
73
|
+
case 5:
|
|
68
74
|
// if (options?.initialState) {
|
|
69
75
|
// this.state = { ...this.state, ...options.initialState }
|
|
70
76
|
// }
|
|
71
77
|
this.store = options === null || options === void 0 ? void 0 : options.store;
|
|
78
|
+
this.updateOtherParams(options.otherParams || {});
|
|
72
79
|
if (options.initialState) {
|
|
73
|
-
this.store.scheduleList = options.initialState.scheduleList;
|
|
80
|
+
this.store.scheduleList = options.initialState.scheduleList || [];
|
|
74
81
|
this.syncScheduleMap();
|
|
75
82
|
this.store.availabilityDateList = options.initialState.availabilityDateList;
|
|
76
83
|
this.hasLoadedScheduleList = Array.isArray(options.initialState.scheduleList);
|
|
@@ -80,13 +87,6 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
80
87
|
this.store.availabilityDateList = [];
|
|
81
88
|
this.hasLoadedScheduleList = false;
|
|
82
89
|
}
|
|
83
|
-
if ((_options$otherParams = options.otherParams) !== null && _options$otherParams !== void 0 && _options$otherParams.cacheId) {
|
|
84
|
-
this.openCache = options.otherParams.openCache;
|
|
85
|
-
this.cacheId = options.otherParams.cacheId;
|
|
86
|
-
}
|
|
87
|
-
if ((_options$otherParams2 = options.otherParams) !== null && _options$otherParams2 !== void 0 && _options$otherParams2.fatherModule) {
|
|
88
|
-
this.fatherModule = options.otherParams.fatherModule;
|
|
89
|
-
}
|
|
90
90
|
case 8:
|
|
91
91
|
case "end":
|
|
92
92
|
return _context.stop();
|
|
@@ -109,9 +109,41 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
109
109
|
value: function updateOtherParams(params) {
|
|
110
110
|
var _otherParams$openCach;
|
|
111
111
|
var otherParams = params || {};
|
|
112
|
+
this.otherParams = _objectSpread({}, otherParams);
|
|
112
113
|
this.openCache = (_otherParams$openCach = otherParams.openCache) !== null && _otherParams$openCach !== void 0 ? _otherParams$openCach : false;
|
|
113
114
|
this.cacheId = otherParams.cacheId;
|
|
114
115
|
this.fatherModule = otherParams.fatherModule;
|
|
116
|
+
this.syncScheduleCatalogScope();
|
|
117
|
+
}
|
|
118
|
+
}, {
|
|
119
|
+
key: "syncScheduleCatalogScope",
|
|
120
|
+
value: function syncScheduleCatalogScope() {
|
|
121
|
+
var _this$core, _params$businessCode;
|
|
122
|
+
var context = (_this$core = this.core) === null || _this$core === void 0 ? void 0 : _this$core.context;
|
|
123
|
+
var shopId = typeof (context === null || context === void 0 ? void 0 : context.getData) === 'function' ? context.getData('shop_id') : context === null || context === void 0 ? void 0 : context.shop_id;
|
|
124
|
+
var params = this.otherParams;
|
|
125
|
+
var scope = JSON.stringify([this.cacheId, this.fatherModule, (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : params.business_code, params.channel, params.platform, params.businessTimezone, shopId].map(function (value) {
|
|
126
|
+
return String(value !== null && value !== void 0 ? value : '').trim();
|
|
127
|
+
}));
|
|
128
|
+
if (scope !== this.scheduleCatalogScope) {
|
|
129
|
+
this.resetScheduleCatalog();
|
|
130
|
+
this.scheduleCatalogScope = scope;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}, {
|
|
134
|
+
key: "resetScheduleCatalog",
|
|
135
|
+
value: function resetScheduleCatalog() {
|
|
136
|
+
this.scheduleListRequestVersion += 1;
|
|
137
|
+
this.scheduleListPromise = null;
|
|
138
|
+
this.hasLoadedScheduleList = false;
|
|
139
|
+
this.store.scheduleList = [];
|
|
140
|
+
this.store.map = new Map();
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
key: "destroy",
|
|
144
|
+
value: function destroy() {
|
|
145
|
+
this.resetScheduleCatalog();
|
|
146
|
+
_get(_getPrototypeOf(ScheduleModule.prototype), "destroy", this).call(this);
|
|
115
147
|
}
|
|
116
148
|
|
|
117
149
|
/**
|
|
@@ -123,37 +155,99 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
123
155
|
key: "loadAllSchedule",
|
|
124
156
|
value: (function () {
|
|
125
157
|
var _loadAllSchedule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
126
|
-
var _options$useCache
|
|
158
|
+
var _options$useCache;
|
|
127
159
|
var options,
|
|
128
|
-
|
|
160
|
+
useCache,
|
|
161
|
+
requestVersion,
|
|
162
|
+
promise,
|
|
129
163
|
_args2 = arguments;
|
|
130
164
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
131
165
|
while (1) switch (_context2.prev = _context2.next) {
|
|
132
166
|
case 0:
|
|
133
167
|
options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
168
|
+
this.syncScheduleCatalogScope();
|
|
169
|
+
useCache = (_options$useCache = options.useCache) !== null && _options$useCache !== void 0 ? _options$useCache : true;
|
|
170
|
+
if (!useCache) {
|
|
171
|
+
_context2.next = 8;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
if (!this.scheduleListPromise) {
|
|
175
|
+
_context2.next = 6;
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
return _context2.abrupt("return", this.scheduleListPromise);
|
|
179
|
+
case 6:
|
|
180
|
+
if (!this.hasLoadedScheduleList) {
|
|
181
|
+
_context2.next = 8;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
return _context2.abrupt("return");
|
|
185
|
+
case 8:
|
|
186
|
+
requestVersion = ++this.scheduleListRequestVersion;
|
|
187
|
+
promise = this.loadScheduleCatalog(useCache, requestVersion);
|
|
188
|
+
this.scheduleListPromise = promise;
|
|
189
|
+
_context2.prev = 11;
|
|
190
|
+
_context2.next = 14;
|
|
191
|
+
return promise;
|
|
192
|
+
case 14:
|
|
193
|
+
_context2.prev = 14;
|
|
194
|
+
if (this.scheduleListPromise === promise) {
|
|
195
|
+
this.scheduleListPromise = null;
|
|
196
|
+
}
|
|
197
|
+
return _context2.finish(14);
|
|
198
|
+
case 17:
|
|
144
199
|
case "end":
|
|
145
200
|
return _context2.stop();
|
|
146
201
|
}
|
|
147
|
-
}, _callee2, this);
|
|
202
|
+
}, _callee2, this, [[11,, 14, 17]]);
|
|
148
203
|
}));
|
|
149
204
|
function loadAllSchedule() {
|
|
150
205
|
return _loadAllSchedule.apply(this, arguments);
|
|
151
206
|
}
|
|
152
207
|
return loadAllSchedule;
|
|
153
208
|
}())
|
|
209
|
+
}, {
|
|
210
|
+
key: "loadScheduleCatalog",
|
|
211
|
+
value: function () {
|
|
212
|
+
var _loadScheduleCatalog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(useCache, requestVersion) {
|
|
213
|
+
var response, _response$data;
|
|
214
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
215
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
216
|
+
case 0:
|
|
217
|
+
_context3.next = 2;
|
|
218
|
+
return this.request.get("/schedule", {
|
|
219
|
+
num: 999
|
|
220
|
+
}, {
|
|
221
|
+
useCache: useCache
|
|
222
|
+
});
|
|
223
|
+
case 2:
|
|
224
|
+
response = _context3.sent;
|
|
225
|
+
if (!(response.code !== undefined && Number(response.code) !== 200 || response.status === false || typeof response.status === 'number' && response.status >= 400 || response.success === false)) {
|
|
226
|
+
_context3.next = 5;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
throw new Error(response.message || 'Schedule catalog request failed');
|
|
230
|
+
case 5:
|
|
231
|
+
this.syncScheduleCatalogScope();
|
|
232
|
+
// A refresh or a different runtime may have superseded this request.
|
|
233
|
+
if (requestVersion === this.scheduleListRequestVersion) {
|
|
234
|
+
this.setScheduleList(((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) || []);
|
|
235
|
+
}
|
|
236
|
+
case 7:
|
|
237
|
+
case "end":
|
|
238
|
+
return _context3.stop();
|
|
239
|
+
}
|
|
240
|
+
}, _callee3, this);
|
|
241
|
+
}));
|
|
242
|
+
function loadScheduleCatalog(_x3, _x4) {
|
|
243
|
+
return _loadScheduleCatalog.apply(this, arguments);
|
|
244
|
+
}
|
|
245
|
+
return loadScheduleCatalog;
|
|
246
|
+
}()
|
|
154
247
|
}, {
|
|
155
248
|
key: "setScheduleList",
|
|
156
249
|
value: function setScheduleList(list) {
|
|
250
|
+
this.syncScheduleCatalogScope();
|
|
157
251
|
this.store.scheduleList = list;
|
|
158
252
|
this.syncScheduleMap();
|
|
159
253
|
this.hasLoadedScheduleList = true;
|
|
@@ -168,20 +262,22 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
168
262
|
}, {
|
|
169
263
|
key: "getScheduleList",
|
|
170
264
|
value: function getScheduleList() {
|
|
265
|
+
this.syncScheduleCatalogScope();
|
|
171
266
|
return this.store.scheduleList || [];
|
|
172
267
|
}
|
|
173
268
|
}, {
|
|
174
269
|
key: "isScheduleListLoaded",
|
|
175
270
|
value: function isScheduleListLoaded() {
|
|
271
|
+
this.syncScheduleCatalogScope();
|
|
176
272
|
return this.hasLoadedScheduleList;
|
|
177
273
|
}
|
|
178
274
|
}, {
|
|
179
275
|
key: "loadScheduleAvailableDate",
|
|
180
276
|
value: function () {
|
|
181
|
-
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
277
|
+
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref) {
|
|
182
278
|
var startDate, endDate, custom_page_id, channel, dates, res, responseData, dateList, otherProductIds;
|
|
183
|
-
return _regeneratorRuntime().wrap(function
|
|
184
|
-
while (1) switch (
|
|
279
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
280
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
185
281
|
case 0:
|
|
186
282
|
startDate = _ref.startDate, endDate = _ref.endDate, custom_page_id = _ref.custom_page_id, channel = _ref.channel;
|
|
187
283
|
// 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天,需要把 startDate 置为今天
|
|
@@ -193,12 +289,12 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
193
289
|
dates = disableAllDates(dates);
|
|
194
290
|
// 如果 endDate 在今天之前,则不用查接口,直接返回 dates
|
|
195
291
|
if (!dayjs(endDate).isBefore(dayjs(), 'day')) {
|
|
196
|
-
|
|
292
|
+
_context4.next = 6;
|
|
197
293
|
break;
|
|
198
294
|
}
|
|
199
|
-
return
|
|
295
|
+
return _context4.abrupt("return", dates);
|
|
200
296
|
case 6:
|
|
201
|
-
|
|
297
|
+
_context4.next = 8;
|
|
202
298
|
return this.request.get("/schedule/product/availability/v2", {
|
|
203
299
|
start_date: startDate,
|
|
204
300
|
end_date: endDate,
|
|
@@ -206,7 +302,7 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
206
302
|
channel: channel
|
|
207
303
|
});
|
|
208
304
|
case 8:
|
|
209
|
-
res =
|
|
305
|
+
res = _context4.sent;
|
|
210
306
|
responseData = res.data || {};
|
|
211
307
|
dateList = Array.isArray(responseData.date_list) ? responseData.date_list : [];
|
|
212
308
|
otherProductIds = Array.isArray(responseData.other_product_ids) ? responseData.other_product_ids : [];
|
|
@@ -214,10 +310,10 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
214
310
|
this.setOtherProductsIds(otherProductIds);
|
|
215
311
|
// 如果没有schedule或者结束日期在今天之前,则所有日期均不可用
|
|
216
312
|
if (!(!dateList.length && !otherProductIds.length || dayjs(endDate).isBefore(dayjs(), 'day'))) {
|
|
217
|
-
|
|
313
|
+
_context4.next = 16;
|
|
218
314
|
break;
|
|
219
315
|
}
|
|
220
|
-
return
|
|
316
|
+
return _context4.abrupt("return", dates);
|
|
221
317
|
case 16:
|
|
222
318
|
if (otherProductIds.length) {
|
|
223
319
|
// 如果后端有返回 other_product_ids ,意味着有 duration 商品,则今天以及今天以后的日期均可用
|
|
@@ -235,14 +331,14 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
235
331
|
});
|
|
236
332
|
}
|
|
237
333
|
dates = disableDatesBeforeOneDay(dates);
|
|
238
|
-
return
|
|
334
|
+
return _context4.abrupt("return", dates);
|
|
239
335
|
case 19:
|
|
240
336
|
case "end":
|
|
241
|
-
return
|
|
337
|
+
return _context4.stop();
|
|
242
338
|
}
|
|
243
|
-
},
|
|
339
|
+
}, _callee4, this);
|
|
244
340
|
}));
|
|
245
|
-
function loadScheduleAvailableDate(
|
|
341
|
+
function loadScheduleAvailableDate(_x5) {
|
|
246
342
|
return _loadScheduleAvailableDate.apply(this, arguments);
|
|
247
343
|
}
|
|
248
344
|
return loadScheduleAvailableDate;
|
|
@@ -252,6 +348,7 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
252
348
|
value: function getScheduleListByIds(ids) {
|
|
253
349
|
var _this2 = this,
|
|
254
350
|
_this$store$scheduleL;
|
|
351
|
+
this.syncScheduleCatalogScope();
|
|
255
352
|
var idSet = new Set(ids.map(function (id) {
|
|
256
353
|
return String(id);
|
|
257
354
|
}));
|
|
@@ -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;
|
|
@@ -1623,6 +1623,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1623
1623
|
cacheId: this.cacheId
|
|
1624
1624
|
});
|
|
1625
1625
|
}
|
|
1626
|
+
}, {
|
|
1627
|
+
key: "resetPickupTimingCache",
|
|
1628
|
+
value: function resetPickupTimingCache() {
|
|
1629
|
+
var _this$pickupTimingCon;
|
|
1630
|
+
(_this$pickupTimingCon = this.pickupTimingController) === null || _this$pickupTimingCon === void 0 || _this$pickupTimingCon.invalidate();
|
|
1631
|
+
}
|
|
1626
1632
|
}, {
|
|
1627
1633
|
key: "getPickupTimingController",
|
|
1628
1634
|
value: function getPickupTimingController() {
|
|
@@ -2044,6 +2050,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2044
2050
|
while (1) switch (_context13.prev = _context13.next) {
|
|
2045
2051
|
case 0:
|
|
2046
2052
|
options = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : {};
|
|
2053
|
+
this.resetPickupTimingCache();
|
|
2047
2054
|
this.core = core;
|
|
2048
2055
|
this.initializeOptions = options || {};
|
|
2049
2056
|
this.paymentNumberDevicePrefix = null;
|
|
@@ -2085,21 +2092,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2085
2092
|
}));
|
|
2086
2093
|
});
|
|
2087
2094
|
if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
|
|
2088
|
-
_context13.next =
|
|
2095
|
+
_context13.next = 20;
|
|
2089
2096
|
break;
|
|
2090
2097
|
}
|
|
2091
|
-
_context13.next =
|
|
2098
|
+
_context13.next = 20;
|
|
2092
2099
|
return this.store.schedule.loadAllSchedule();
|
|
2093
|
-
case
|
|
2100
|
+
case 20:
|
|
2094
2101
|
if (this.store.order && typeof ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.enableTempOrderPersist) === 'boolean') {
|
|
2095
2102
|
this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
|
|
2096
2103
|
}
|
|
2097
|
-
_context13.next =
|
|
2104
|
+
_context13.next = 23;
|
|
2098
2105
|
return this.getPaymentMethodsAsync();
|
|
2099
|
-
case
|
|
2106
|
+
case 23:
|
|
2100
2107
|
this.registerServerOrderChangeSync();
|
|
2101
2108
|
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
2102
|
-
case
|
|
2109
|
+
case 25:
|
|
2103
2110
|
case "end":
|
|
2104
2111
|
return _context13.stop();
|
|
2105
2112
|
}
|
|
@@ -2119,6 +2126,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2119
2126
|
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
2120
2127
|
while (1) switch (_context14.prev = _context14.next) {
|
|
2121
2128
|
case 0:
|
|
2129
|
+
this.resetPickupTimingCache();
|
|
2122
2130
|
(_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
|
|
2123
2131
|
this.serverOrderChangeUnsubscribe = null;
|
|
2124
2132
|
Object.keys(this.store).forEach(function (key) {
|
|
@@ -2137,11 +2145,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2137
2145
|
this.queuedServerOrderChanges = [];
|
|
2138
2146
|
this.salesDetailLoadSequence += 1;
|
|
2139
2147
|
this.walletAssetsRefreshSequence += 1;
|
|
2140
|
-
_context14.next =
|
|
2148
|
+
_context14.next = 11;
|
|
2141
2149
|
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
2142
|
-
case 10:
|
|
2143
|
-
_get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
|
|
2144
2150
|
case 11:
|
|
2151
|
+
_get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
|
|
2152
|
+
case 12:
|
|
2145
2153
|
case "end":
|
|
2146
2154
|
return _context14.stop();
|
|
2147
2155
|
}
|
|
@@ -6831,22 +6839,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
6831
6839
|
var _ref55,
|
|
6832
6840
|
_ref55$cover,
|
|
6833
6841
|
cover,
|
|
6842
|
+
previousPickupTimingScope,
|
|
6834
6843
|
_args71 = arguments;
|
|
6835
6844
|
return _regeneratorRuntime().wrap(function _callee71$(_context71) {
|
|
6836
6845
|
while (1) switch (_context71.prev = _context71.next) {
|
|
6837
6846
|
case 0:
|
|
6838
6847
|
_ref55 = _args71.length > 1 && _args71[1] !== undefined ? _args71[1] : {}, _ref55$cover = _ref55.cover, cover = _ref55$cover === void 0 ? false : _ref55$cover;
|
|
6848
|
+
previousPickupTimingScope = this.getPickupTimingScope();
|
|
6839
6849
|
if (cover) {
|
|
6840
6850
|
this.otherParams = _objectSpread({}, params);
|
|
6841
6851
|
} else {
|
|
6842
6852
|
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
6843
6853
|
}
|
|
6844
6854
|
this.cacheId = (_this$otherParams41 = this.otherParams) === null || _this$otherParams41 === void 0 ? void 0 : _this$otherParams41.cacheId;
|
|
6845
|
-
|
|
6855
|
+
if (previousPickupTimingScope !== this.getPickupTimingScope()) this.resetPickupTimingCache();
|
|
6856
|
+
_context71.next = 7;
|
|
6846
6857
|
return this.syncOtherParamsToSubModules(params, {
|
|
6847
6858
|
cover: cover
|
|
6848
6859
|
});
|
|
6849
|
-
case
|
|
6860
|
+
case 7:
|
|
6850
6861
|
case "end":
|
|
6851
6862
|
return _context71.stop();
|
|
6852
6863
|
}
|
|
@@ -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;
|