@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
|
@@ -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,49 +47,52 @@ 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$
|
|
60
|
+
var _options$initialState;
|
|
61
|
+
var initialScheduleList, hasInitialScheduleList;
|
|
55
62
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
56
63
|
while (1) switch (_context.prev = _context.next) {
|
|
57
64
|
case 0:
|
|
65
|
+
// The store proxies initialState, so capture its input before resets write through it.
|
|
66
|
+
initialScheduleList = (_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.scheduleList;
|
|
67
|
+
hasInitialScheduleList = Array.isArray(initialScheduleList);
|
|
68
|
+
this.resetScheduleCatalog();
|
|
58
69
|
this.core = core;
|
|
59
70
|
|
|
60
71
|
// 获取依赖的插件
|
|
61
72
|
this.request = core.getPlugin('request');
|
|
62
73
|
if (this.request) {
|
|
63
|
-
_context.next =
|
|
74
|
+
_context.next = 7;
|
|
64
75
|
break;
|
|
65
76
|
}
|
|
66
77
|
throw new Error('ScheduleModule 需要 request 插件支持');
|
|
67
|
-
case
|
|
78
|
+
case 7:
|
|
68
79
|
// if (options?.initialState) {
|
|
69
80
|
// this.state = { ...this.state, ...options.initialState }
|
|
70
81
|
// }
|
|
71
82
|
this.store = options === null || options === void 0 ? void 0 : options.store;
|
|
83
|
+
this.updateOtherParams(options.otherParams || {});
|
|
72
84
|
if (options.initialState) {
|
|
73
|
-
this.store.scheduleList =
|
|
85
|
+
this.store.scheduleList = hasInitialScheduleList ? initialScheduleList : [];
|
|
74
86
|
this.syncScheduleMap();
|
|
75
87
|
this.store.availabilityDateList = options.initialState.availabilityDateList;
|
|
76
|
-
this.hasLoadedScheduleList =
|
|
88
|
+
this.hasLoadedScheduleList = hasInitialScheduleList;
|
|
77
89
|
} else {
|
|
78
90
|
this.store.scheduleList = [];
|
|
79
91
|
this.store.map = new Map();
|
|
80
92
|
this.store.availabilityDateList = [];
|
|
81
93
|
this.hasLoadedScheduleList = false;
|
|
82
94
|
}
|
|
83
|
-
|
|
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
|
-
case 8:
|
|
95
|
+
case 10:
|
|
91
96
|
case "end":
|
|
92
97
|
return _context.stop();
|
|
93
98
|
}
|
|
@@ -109,9 +114,41 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
109
114
|
value: function updateOtherParams(params) {
|
|
110
115
|
var _otherParams$openCach;
|
|
111
116
|
var otherParams = params || {};
|
|
117
|
+
this.otherParams = _objectSpread({}, otherParams);
|
|
112
118
|
this.openCache = (_otherParams$openCach = otherParams.openCache) !== null && _otherParams$openCach !== void 0 ? _otherParams$openCach : false;
|
|
113
119
|
this.cacheId = otherParams.cacheId;
|
|
114
120
|
this.fatherModule = otherParams.fatherModule;
|
|
121
|
+
this.syncScheduleCatalogScope();
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
key: "syncScheduleCatalogScope",
|
|
125
|
+
value: function syncScheduleCatalogScope() {
|
|
126
|
+
var _this$core, _params$businessCode;
|
|
127
|
+
var context = (_this$core = this.core) === null || _this$core === void 0 ? void 0 : _this$core.context;
|
|
128
|
+
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;
|
|
129
|
+
var params = this.otherParams;
|
|
130
|
+
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) {
|
|
131
|
+
return String(value !== null && value !== void 0 ? value : '').trim();
|
|
132
|
+
}));
|
|
133
|
+
if (scope !== this.scheduleCatalogScope) {
|
|
134
|
+
this.resetScheduleCatalog();
|
|
135
|
+
this.scheduleCatalogScope = scope;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}, {
|
|
139
|
+
key: "resetScheduleCatalog",
|
|
140
|
+
value: function resetScheduleCatalog() {
|
|
141
|
+
this.scheduleListRequestVersion += 1;
|
|
142
|
+
this.scheduleListPromise = null;
|
|
143
|
+
this.hasLoadedScheduleList = false;
|
|
144
|
+
this.store.scheduleList = [];
|
|
145
|
+
this.store.map = new Map();
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "destroy",
|
|
149
|
+
value: function destroy() {
|
|
150
|
+
this.resetScheduleCatalog();
|
|
151
|
+
_get(_getPrototypeOf(ScheduleModule.prototype), "destroy", this).call(this);
|
|
115
152
|
}
|
|
116
153
|
|
|
117
154
|
/**
|
|
@@ -123,37 +160,99 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
123
160
|
key: "loadAllSchedule",
|
|
124
161
|
value: (function () {
|
|
125
162
|
var _loadAllSchedule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
126
|
-
var _options$useCache
|
|
163
|
+
var _options$useCache;
|
|
127
164
|
var options,
|
|
128
|
-
|
|
165
|
+
useCache,
|
|
166
|
+
requestVersion,
|
|
167
|
+
promise,
|
|
129
168
|
_args2 = arguments;
|
|
130
169
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
131
170
|
while (1) switch (_context2.prev = _context2.next) {
|
|
132
171
|
case 0:
|
|
133
172
|
options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
173
|
+
this.syncScheduleCatalogScope();
|
|
174
|
+
useCache = (_options$useCache = options.useCache) !== null && _options$useCache !== void 0 ? _options$useCache : true;
|
|
175
|
+
if (!useCache) {
|
|
176
|
+
_context2.next = 8;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
if (!this.scheduleListPromise) {
|
|
180
|
+
_context2.next = 6;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
return _context2.abrupt("return", this.scheduleListPromise);
|
|
184
|
+
case 6:
|
|
185
|
+
if (!this.hasLoadedScheduleList) {
|
|
186
|
+
_context2.next = 8;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
return _context2.abrupt("return");
|
|
190
|
+
case 8:
|
|
191
|
+
requestVersion = ++this.scheduleListRequestVersion;
|
|
192
|
+
promise = this.loadScheduleCatalog(useCache, requestVersion);
|
|
193
|
+
this.scheduleListPromise = promise;
|
|
194
|
+
_context2.prev = 11;
|
|
195
|
+
_context2.next = 14;
|
|
196
|
+
return promise;
|
|
197
|
+
case 14:
|
|
198
|
+
_context2.prev = 14;
|
|
199
|
+
if (this.scheduleListPromise === promise) {
|
|
200
|
+
this.scheduleListPromise = null;
|
|
201
|
+
}
|
|
202
|
+
return _context2.finish(14);
|
|
203
|
+
case 17:
|
|
144
204
|
case "end":
|
|
145
205
|
return _context2.stop();
|
|
146
206
|
}
|
|
147
|
-
}, _callee2, this);
|
|
207
|
+
}, _callee2, this, [[11,, 14, 17]]);
|
|
148
208
|
}));
|
|
149
209
|
function loadAllSchedule() {
|
|
150
210
|
return _loadAllSchedule.apply(this, arguments);
|
|
151
211
|
}
|
|
152
212
|
return loadAllSchedule;
|
|
153
213
|
}())
|
|
214
|
+
}, {
|
|
215
|
+
key: "loadScheduleCatalog",
|
|
216
|
+
value: function () {
|
|
217
|
+
var _loadScheduleCatalog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(useCache, requestVersion) {
|
|
218
|
+
var response, _response$data;
|
|
219
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
220
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
221
|
+
case 0:
|
|
222
|
+
_context3.next = 2;
|
|
223
|
+
return this.request.get("/schedule", {
|
|
224
|
+
num: 999
|
|
225
|
+
}, {
|
|
226
|
+
useCache: useCache
|
|
227
|
+
});
|
|
228
|
+
case 2:
|
|
229
|
+
response = _context3.sent;
|
|
230
|
+
if (!(response.code !== undefined && Number(response.code) !== 200 || response.status === false || typeof response.status === 'number' && response.status >= 400 || response.success === false)) {
|
|
231
|
+
_context3.next = 5;
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
throw new Error(response.message || 'Schedule catalog request failed');
|
|
235
|
+
case 5:
|
|
236
|
+
this.syncScheduleCatalogScope();
|
|
237
|
+
// A refresh or a different runtime may have superseded this request.
|
|
238
|
+
if (requestVersion === this.scheduleListRequestVersion) {
|
|
239
|
+
this.setScheduleList(((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) || []);
|
|
240
|
+
}
|
|
241
|
+
case 7:
|
|
242
|
+
case "end":
|
|
243
|
+
return _context3.stop();
|
|
244
|
+
}
|
|
245
|
+
}, _callee3, this);
|
|
246
|
+
}));
|
|
247
|
+
function loadScheduleCatalog(_x3, _x4) {
|
|
248
|
+
return _loadScheduleCatalog.apply(this, arguments);
|
|
249
|
+
}
|
|
250
|
+
return loadScheduleCatalog;
|
|
251
|
+
}()
|
|
154
252
|
}, {
|
|
155
253
|
key: "setScheduleList",
|
|
156
254
|
value: function setScheduleList(list) {
|
|
255
|
+
this.syncScheduleCatalogScope();
|
|
157
256
|
this.store.scheduleList = list;
|
|
158
257
|
this.syncScheduleMap();
|
|
159
258
|
this.hasLoadedScheduleList = true;
|
|
@@ -168,20 +267,22 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
168
267
|
}, {
|
|
169
268
|
key: "getScheduleList",
|
|
170
269
|
value: function getScheduleList() {
|
|
270
|
+
this.syncScheduleCatalogScope();
|
|
171
271
|
return this.store.scheduleList || [];
|
|
172
272
|
}
|
|
173
273
|
}, {
|
|
174
274
|
key: "isScheduleListLoaded",
|
|
175
275
|
value: function isScheduleListLoaded() {
|
|
276
|
+
this.syncScheduleCatalogScope();
|
|
176
277
|
return this.hasLoadedScheduleList;
|
|
177
278
|
}
|
|
178
279
|
}, {
|
|
179
280
|
key: "loadScheduleAvailableDate",
|
|
180
281
|
value: function () {
|
|
181
|
-
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
282
|
+
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref) {
|
|
182
283
|
var startDate, endDate, custom_page_id, channel, dates, res, responseData, dateList, otherProductIds;
|
|
183
|
-
return _regeneratorRuntime().wrap(function
|
|
184
|
-
while (1) switch (
|
|
284
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
285
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
185
286
|
case 0:
|
|
186
287
|
startDate = _ref.startDate, endDate = _ref.endDate, custom_page_id = _ref.custom_page_id, channel = _ref.channel;
|
|
187
288
|
// 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天,需要把 startDate 置为今天
|
|
@@ -193,12 +294,12 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
193
294
|
dates = disableAllDates(dates);
|
|
194
295
|
// 如果 endDate 在今天之前,则不用查接口,直接返回 dates
|
|
195
296
|
if (!dayjs(endDate).isBefore(dayjs(), 'day')) {
|
|
196
|
-
|
|
297
|
+
_context4.next = 6;
|
|
197
298
|
break;
|
|
198
299
|
}
|
|
199
|
-
return
|
|
300
|
+
return _context4.abrupt("return", dates);
|
|
200
301
|
case 6:
|
|
201
|
-
|
|
302
|
+
_context4.next = 8;
|
|
202
303
|
return this.request.get("/schedule/product/availability/v2", {
|
|
203
304
|
start_date: startDate,
|
|
204
305
|
end_date: endDate,
|
|
@@ -206,7 +307,7 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
206
307
|
channel: channel
|
|
207
308
|
});
|
|
208
309
|
case 8:
|
|
209
|
-
res =
|
|
310
|
+
res = _context4.sent;
|
|
210
311
|
responseData = res.data || {};
|
|
211
312
|
dateList = Array.isArray(responseData.date_list) ? responseData.date_list : [];
|
|
212
313
|
otherProductIds = Array.isArray(responseData.other_product_ids) ? responseData.other_product_ids : [];
|
|
@@ -214,10 +315,10 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
214
315
|
this.setOtherProductsIds(otherProductIds);
|
|
215
316
|
// 如果没有schedule或者结束日期在今天之前,则所有日期均不可用
|
|
216
317
|
if (!(!dateList.length && !otherProductIds.length || dayjs(endDate).isBefore(dayjs(), 'day'))) {
|
|
217
|
-
|
|
318
|
+
_context4.next = 16;
|
|
218
319
|
break;
|
|
219
320
|
}
|
|
220
|
-
return
|
|
321
|
+
return _context4.abrupt("return", dates);
|
|
221
322
|
case 16:
|
|
222
323
|
if (otherProductIds.length) {
|
|
223
324
|
// 如果后端有返回 other_product_ids ,意味着有 duration 商品,则今天以及今天以后的日期均可用
|
|
@@ -235,14 +336,14 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
235
336
|
});
|
|
236
337
|
}
|
|
237
338
|
dates = disableDatesBeforeOneDay(dates);
|
|
238
|
-
return
|
|
339
|
+
return _context4.abrupt("return", dates);
|
|
239
340
|
case 19:
|
|
240
341
|
case "end":
|
|
241
|
-
return
|
|
342
|
+
return _context4.stop();
|
|
242
343
|
}
|
|
243
|
-
},
|
|
344
|
+
}, _callee4, this);
|
|
244
345
|
}));
|
|
245
|
-
function loadScheduleAvailableDate(
|
|
346
|
+
function loadScheduleAvailableDate(_x5) {
|
|
246
347
|
return _loadScheduleAvailableDate.apply(this, arguments);
|
|
247
348
|
}
|
|
248
349
|
return loadScheduleAvailableDate;
|
|
@@ -252,6 +353,7 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
252
353
|
value: function getScheduleListByIds(ids) {
|
|
253
354
|
var _this2 = this,
|
|
254
355
|
_this$store$scheduleL;
|
|
356
|
+
this.syncScheduleCatalogScope();
|
|
255
357
|
var idSet = new Set(ids.map(function (id) {
|
|
256
358
|
return String(id);
|
|
257
359
|
}));
|
|
@@ -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;
|