@pisell/pisellos 2.3.221 → 2.3.222
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/OpenData/index.d.ts +6 -2
- package/dist/modules/OpenData/index.js +190 -85
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +12 -12
- package/dist/solution/Sales/index.d.ts +0 -4
- package/dist/solution/Sales/index.js +105 -205
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/OpenData/index.d.ts +6 -2
- package/lib/modules/OpenData/index.js +78 -9
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +12 -12
- package/lib/solution/Sales/index.d.ts +0 -4
- package/lib/solution/Sales/index.js +4 -65
- package/package.json +1 -1
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// 导出评估器
|
|
2
|
-
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
-
|
|
4
|
-
// 导出适配器
|
|
5
|
-
export { PromotionAdapter } from "./adapter";
|
|
6
|
-
export { default } from "./adapter";
|
|
7
|
-
|
|
8
|
-
// 导出策略配置示例常量
|
|
9
|
-
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -19,6 +19,8 @@ export declare class OpenDataModule extends BaseModule implements Module {
|
|
|
19
19
|
private otherParams;
|
|
20
20
|
private fetchRevision;
|
|
21
21
|
private invoiceTemplateCacheRevision;
|
|
22
|
+
private printInvoiceTemplates;
|
|
23
|
+
private lastManualPrintKey?;
|
|
22
24
|
private invoiceTemplateDocumentCache;
|
|
23
25
|
private invoiceTemplateDocumentInFlight;
|
|
24
26
|
constructor(name?: string, version?: string);
|
|
@@ -33,15 +35,17 @@ export declare class OpenDataModule extends BaseModule implements Module {
|
|
|
33
35
|
private shouldSkipInvoiceTemplateDocument;
|
|
34
36
|
fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
|
|
35
37
|
private requestOpenData;
|
|
36
|
-
/** Cloud orders must resolve their own channel's template before printing. */
|
|
37
38
|
loadCloudInvoiceTemplate(target: string): Promise<InvoiceTemplateSettings>;
|
|
39
|
+
/** 手动和云单打印共用已成功解析的模板及进行中的请求。每个订单仍单独派单。 */
|
|
40
|
+
loadPrintInvoiceTemplate(target: string, mode: 'manual' | 'cloud'): Promise<InvoiceTemplateSettings>;
|
|
41
|
+
private fetchPrintInvoiceTemplate;
|
|
38
42
|
getOpenData(): OpenDataConfig | null;
|
|
39
43
|
getInvoiceLayoutConfig(): InvoiceLayoutConfig;
|
|
40
44
|
getInvoiceTemplateSettings(): InvoiceTemplateSettings;
|
|
41
45
|
ensureInvoiceTemplateSettings(target: string, openDataConfig?: OpenDataConfig): Promise<InvoiceTemplateSettings>;
|
|
42
46
|
private commitInvoiceTemplateSettings;
|
|
43
47
|
private resolveInvoiceTemplateSettings;
|
|
44
|
-
private
|
|
48
|
+
private buildInvoiceCacheKey;
|
|
45
49
|
private fetchInvoiceTemplateDocument;
|
|
46
50
|
private logInvoiceTemplateDocumentFallback;
|
|
47
51
|
getLastFetchedAt(): number | null;
|
|
@@ -17,6 +17,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
17
17
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
18
18
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
19
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
20
|
+
import { cloneDeep } from 'lodash-es';
|
|
20
21
|
import { BaseModule } from "../BaseModule";
|
|
21
22
|
import { computeAvailability, getDefaultInvoiceTemplateSettings, normalizeInvoiceLayoutFromTemplateSettings, normalizeInvoiceTemplateSettings, normalizeRawInvoiceTemplateSettings } from "./utils";
|
|
22
23
|
export * from "./types";
|
|
@@ -42,6 +43,7 @@ function isLegacyInvoiceTemplate(value) {
|
|
|
42
43
|
var numericLike = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;
|
|
43
44
|
return !numericLike.test(normalized);
|
|
44
45
|
}
|
|
46
|
+
var INVOICE_OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
|
|
45
47
|
export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
46
48
|
_inherits(OpenDataModule, _BaseModule);
|
|
47
49
|
var _super = _createSuper(OpenDataModule);
|
|
@@ -61,6 +63,8 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
61
63
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
62
64
|
_defineProperty(_assertThisInitialized(_this), "fetchRevision", 0);
|
|
63
65
|
_defineProperty(_assertThisInitialized(_this), "invoiceTemplateCacheRevision", 0);
|
|
66
|
+
_defineProperty(_assertThisInitialized(_this), "printInvoiceTemplates", new Map());
|
|
67
|
+
_defineProperty(_assertThisInitialized(_this), "lastManualPrintKey", void 0);
|
|
64
68
|
_defineProperty(_assertThisInitialized(_this), "invoiceTemplateDocumentCache", new Map());
|
|
65
69
|
_defineProperty(_assertThisInitialized(_this), "invoiceTemplateDocumentInFlight", new Map());
|
|
66
70
|
return _this;
|
|
@@ -207,62 +211,161 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
207
211
|
skipErrorHandler: true
|
|
208
212
|
} : {}));
|
|
209
213
|
}
|
|
210
|
-
|
|
211
|
-
/** Cloud orders must resolve their own channel's template before printing. */
|
|
212
214
|
}, {
|
|
213
215
|
key: "loadCloudInvoiceTemplate",
|
|
216
|
+
value: function loadCloudInvoiceTemplate(target) {
|
|
217
|
+
return this.loadPrintInvoiceTemplate(target, 'cloud');
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** 手动和云单打印共用已成功解析的模板及进行中的请求。每个订单仍单独派单。 */
|
|
221
|
+
}, {
|
|
222
|
+
key: "loadPrintInvoiceTemplate",
|
|
214
223
|
value: (function () {
|
|
215
|
-
var
|
|
216
|
-
var
|
|
224
|
+
var _loadPrintInvoiceTemplate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(target, mode) {
|
|
225
|
+
var _this2 = this,
|
|
226
|
+
_entry;
|
|
227
|
+
var skipDocument, key, revision, assertCurrent, manualSwitch, entry, refresh, next, result;
|
|
217
228
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
218
229
|
while (1) switch (_context3.prev = _context3.next) {
|
|
219
230
|
case 0:
|
|
220
|
-
|
|
231
|
+
skipDocument = mode === 'manual' && this.shouldSkipInvoiceTemplateDocument();
|
|
232
|
+
key = this.buildInvoiceCacheKey(target, skipDocument);
|
|
233
|
+
revision = this.invoiceTemplateCacheRevision;
|
|
234
|
+
assertCurrent = function assertCurrent() {
|
|
235
|
+
if (revision !== _this2.invoiceTemplateCacheRevision || key !== _this2.buildInvoiceCacheKey(target, skipDocument)) {
|
|
236
|
+
throw new Error('Invoice 配置已失效');
|
|
237
|
+
}
|
|
238
|
+
}; // 手动切换打印入口时沿用原有行为,重新读取该入口的 Documents 选择。
|
|
239
|
+
manualSwitch = mode === 'manual' && this.lastManualPrintKey !== undefined && this.lastManualPrintKey !== key;
|
|
240
|
+
if (mode === 'manual') this.lastManualPrintKey = key;
|
|
241
|
+
entry = this.printInvoiceTemplates.get(key);
|
|
242
|
+
refresh = ((_entry = entry) === null || _entry === void 0 ? void 0 : _entry.expiresAt) !== undefined && (Date.now() >= entry.expiresAt || manualSwitch || mode === 'cloud' && entry.manualFallback);
|
|
243
|
+
if (!entry || refresh) {
|
|
244
|
+
next = {
|
|
245
|
+
manualFallback: false,
|
|
246
|
+
request: this.fetchPrintInvoiceTemplate(target, skipDocument, assertCurrent).then(function (result) {
|
|
247
|
+
assertCurrent();
|
|
248
|
+
next.expiresAt = Date.now() + INVOICE_OPEN_DATA_CACHE_TTL;
|
|
249
|
+
// 只有手动打印可复用文档读取失败后的 DEFAULT 回退。
|
|
250
|
+
if ('documentError' in result) {
|
|
251
|
+
if (mode === 'cloud') throw result.documentError;
|
|
252
|
+
next.manualFallback = true;
|
|
253
|
+
next.request = Promise.resolve({
|
|
254
|
+
settings: getDefaultInvoiceTemplateSettings()
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
return result;
|
|
258
|
+
}).catch(function (error) {
|
|
259
|
+
if (_this2.printInvoiceTemplates.get(key) === next) _this2.printInvoiceTemplates.delete(key);
|
|
260
|
+
throw error;
|
|
261
|
+
})
|
|
262
|
+
};
|
|
263
|
+
this.printInvoiceTemplates.set(key, next);
|
|
264
|
+
entry = next;
|
|
265
|
+
}
|
|
266
|
+
_context3.next = 11;
|
|
267
|
+
return entry.request;
|
|
268
|
+
case 11:
|
|
269
|
+
result = _context3.sent;
|
|
270
|
+
assertCurrent();
|
|
271
|
+
if (!('documentError' in result)) {
|
|
272
|
+
_context3.next = 15;
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
throw result.documentError;
|
|
276
|
+
case 15:
|
|
277
|
+
return _context3.abrupt("return", cloneDeep(result.settings));
|
|
278
|
+
case 16:
|
|
279
|
+
case "end":
|
|
280
|
+
return _context3.stop();
|
|
281
|
+
}
|
|
282
|
+
}, _callee3, this);
|
|
283
|
+
}));
|
|
284
|
+
function loadPrintInvoiceTemplate(_x4, _x5) {
|
|
285
|
+
return _loadPrintInvoiceTemplate.apply(this, arguments);
|
|
286
|
+
}
|
|
287
|
+
return loadPrintInvoiceTemplate;
|
|
288
|
+
}())
|
|
289
|
+
}, {
|
|
290
|
+
key: "fetchPrintInvoiceTemplate",
|
|
291
|
+
value: function () {
|
|
292
|
+
var _fetchPrintInvoiceTemplate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(target, skipDocument, assertCurrent) {
|
|
293
|
+
var response, raw, documentId;
|
|
294
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
295
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
296
|
+
case 0:
|
|
297
|
+
_context4.next = 2;
|
|
221
298
|
return this.requestOpenData({
|
|
222
299
|
scope: 'board',
|
|
223
300
|
target: target,
|
|
224
301
|
section_code: ['documents']
|
|
225
302
|
}, true);
|
|
226
303
|
case 2:
|
|
227
|
-
response =
|
|
304
|
+
response = _context4.sent;
|
|
305
|
+
assertCurrent();
|
|
228
306
|
if (!((response === null || response === void 0 ? void 0 : response.status) !== true || response.code !== 200 || !isRecord(response.data))) {
|
|
229
|
-
|
|
307
|
+
_context4.next = 6;
|
|
230
308
|
break;
|
|
231
309
|
}
|
|
232
310
|
throw new Error((response === null || response === void 0 ? void 0 : response.message) || 'Cloud Invoice settings unavailable');
|
|
233
|
-
case
|
|
311
|
+
case 6:
|
|
312
|
+
if (!skipDocument) {
|
|
313
|
+
_context4.next = 8;
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
return _context4.abrupt("return", {
|
|
317
|
+
settings: getDefaultInvoiceTemplateSettings()
|
|
318
|
+
});
|
|
319
|
+
case 8:
|
|
234
320
|
raw = response.data['documents.invoice_template'];
|
|
235
321
|
documentId = resolveInvoiceDocumentId(raw);
|
|
236
322
|
if (!documentId) {
|
|
237
|
-
|
|
323
|
+
_context4.next = 21;
|
|
238
324
|
break;
|
|
239
325
|
}
|
|
240
|
-
|
|
241
|
-
|
|
326
|
+
_context4.prev = 11;
|
|
327
|
+
_context4.next = 14;
|
|
328
|
+
return this.fetchInvoiceTemplateDocument(documentId, true);
|
|
329
|
+
case 14:
|
|
330
|
+
_context4.t0 = _context4.sent;
|
|
331
|
+
return _context4.abrupt("return", {
|
|
332
|
+
settings: _context4.t0
|
|
333
|
+
});
|
|
334
|
+
case 18:
|
|
335
|
+
_context4.prev = 18;
|
|
336
|
+
_context4.t1 = _context4["catch"](11);
|
|
337
|
+
return _context4.abrupt("return", {
|
|
338
|
+
documentError: _context4.t1
|
|
339
|
+
});
|
|
340
|
+
case 21:
|
|
242
341
|
if (!(raw == null || typeof raw === 'string' && !raw.trim())) {
|
|
243
|
-
|
|
342
|
+
_context4.next = 23;
|
|
244
343
|
break;
|
|
245
344
|
}
|
|
246
|
-
return
|
|
247
|
-
|
|
345
|
+
return _context4.abrupt("return", {
|
|
346
|
+
settings: getDefaultInvoiceTemplateSettings()
|
|
347
|
+
});
|
|
348
|
+
case 23:
|
|
248
349
|
if (!isLegacyInvoiceTemplate(raw)) {
|
|
249
|
-
|
|
350
|
+
_context4.next = 25;
|
|
250
351
|
break;
|
|
251
352
|
}
|
|
252
|
-
return
|
|
253
|
-
|
|
353
|
+
return _context4.abrupt("return", {
|
|
354
|
+
settings: normalizeInvoiceTemplateSettings(response.data)
|
|
355
|
+
});
|
|
356
|
+
case 25:
|
|
254
357
|
throw new Error('Cloud Invoice template identifier is invalid');
|
|
255
|
-
case
|
|
358
|
+
case 26:
|
|
256
359
|
case "end":
|
|
257
|
-
return
|
|
360
|
+
return _context4.stop();
|
|
258
361
|
}
|
|
259
|
-
},
|
|
362
|
+
}, _callee4, this, [[11, 18]]);
|
|
260
363
|
}));
|
|
261
|
-
function
|
|
262
|
-
return
|
|
364
|
+
function fetchPrintInvoiceTemplate(_x6, _x7, _x8) {
|
|
365
|
+
return _fetchPrintInvoiceTemplate.apply(this, arguments);
|
|
263
366
|
}
|
|
264
|
-
return
|
|
265
|
-
}()
|
|
367
|
+
return fetchPrintInvoiceTemplate;
|
|
368
|
+
}()
|
|
266
369
|
}, {
|
|
267
370
|
key: "getOpenData",
|
|
268
371
|
value: function getOpenData() {
|
|
@@ -285,7 +388,7 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
285
388
|
var documentId = resolveInvoiceDocumentId((_this$store$data = this.store.data) === null || _this$store$data === void 0 ? void 0 : _this$store$data['documents.invoice_template']);
|
|
286
389
|
if (documentId) {
|
|
287
390
|
var target = this.store.invoiceTemplateTarget;
|
|
288
|
-
if (!target || this.store.invoiceTemplateCacheKey !== this.
|
|
391
|
+
if (!target || this.store.invoiceTemplateCacheKey !== this.buildInvoiceCacheKey(target, documentId)) {
|
|
289
392
|
return getDefaultInvoiceTemplateSettings();
|
|
290
393
|
}
|
|
291
394
|
}
|
|
@@ -299,10 +402,10 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
299
402
|
}, {
|
|
300
403
|
key: "ensureInvoiceTemplateSettings",
|
|
301
404
|
value: function () {
|
|
302
|
-
var _ensureInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
405
|
+
var _ensureInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(target, openDataConfig) {
|
|
303
406
|
var normalizedTarget, config, fetchRevision, resolved;
|
|
304
|
-
return _regeneratorRuntime().wrap(function
|
|
305
|
-
while (1) switch (
|
|
407
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
408
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
306
409
|
case 0:
|
|
307
410
|
normalizedTarget = String(target || '').trim();
|
|
308
411
|
if (openDataConfig && openDataConfig !== this.store.data) {
|
|
@@ -315,31 +418,31 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
315
418
|
}
|
|
316
419
|
config = this.store.data;
|
|
317
420
|
if (!(!normalizedTarget || !config)) {
|
|
318
|
-
|
|
421
|
+
_context5.next = 5;
|
|
319
422
|
break;
|
|
320
423
|
}
|
|
321
|
-
return
|
|
424
|
+
return _context5.abrupt("return", getDefaultInvoiceTemplateSettings());
|
|
322
425
|
case 5:
|
|
323
426
|
fetchRevision = this.fetchRevision;
|
|
324
|
-
|
|
427
|
+
_context5.next = 8;
|
|
325
428
|
return this.resolveInvoiceTemplateSettings(config, normalizedTarget);
|
|
326
429
|
case 8:
|
|
327
|
-
resolved =
|
|
430
|
+
resolved = _context5.sent;
|
|
328
431
|
if (!(fetchRevision !== this.fetchRevision || this.store.data !== config)) {
|
|
329
|
-
|
|
432
|
+
_context5.next = 11;
|
|
330
433
|
break;
|
|
331
434
|
}
|
|
332
|
-
return
|
|
435
|
+
return _context5.abrupt("return", getDefaultInvoiceTemplateSettings());
|
|
333
436
|
case 11:
|
|
334
437
|
this.commitInvoiceTemplateSettings(normalizedTarget, resolved);
|
|
335
|
-
return
|
|
438
|
+
return _context5.abrupt("return", normalizeRawInvoiceTemplateSettings(resolved.settings));
|
|
336
439
|
case 13:
|
|
337
440
|
case "end":
|
|
338
|
-
return
|
|
441
|
+
return _context5.stop();
|
|
339
442
|
}
|
|
340
|
-
},
|
|
443
|
+
}, _callee5, this);
|
|
341
444
|
}));
|
|
342
|
-
function ensureInvoiceTemplateSettings(
|
|
445
|
+
function ensureInvoiceTemplateSettings(_x9, _x10) {
|
|
343
446
|
return _ensureInvoiceTemplateSettings.apply(this, arguments);
|
|
344
447
|
}
|
|
345
448
|
return ensureInvoiceTemplateSettings;
|
|
@@ -355,17 +458,17 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
355
458
|
}, {
|
|
356
459
|
key: "resolveInvoiceTemplateSettings",
|
|
357
460
|
value: function () {
|
|
358
|
-
var _resolveInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
359
|
-
var
|
|
461
|
+
var _resolveInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(config, target) {
|
|
462
|
+
var _this3 = this;
|
|
360
463
|
var rawTemplate, documentId, cacheKey, cachedSettings, request, cacheRevision;
|
|
361
|
-
return _regeneratorRuntime().wrap(function
|
|
362
|
-
while (1) switch (
|
|
464
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
465
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
363
466
|
case 0:
|
|
364
467
|
if (!this.shouldSkipInvoiceTemplateDocument()) {
|
|
365
|
-
|
|
468
|
+
_context6.next = 2;
|
|
366
469
|
break;
|
|
367
470
|
}
|
|
368
|
-
return
|
|
471
|
+
return _context6.abrupt("return", {
|
|
369
472
|
settings: getDefaultInvoiceTemplateSettings(),
|
|
370
473
|
documentId: null,
|
|
371
474
|
cacheKey: null
|
|
@@ -374,21 +477,21 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
374
477
|
rawTemplate = config['documents.invoice_template'];
|
|
375
478
|
documentId = resolveInvoiceDocumentId(rawTemplate);
|
|
376
479
|
if (documentId) {
|
|
377
|
-
|
|
480
|
+
_context6.next = 6;
|
|
378
481
|
break;
|
|
379
482
|
}
|
|
380
|
-
return
|
|
483
|
+
return _context6.abrupt("return", {
|
|
381
484
|
settings: isLegacyInvoiceTemplate(rawTemplate) ? normalizeInvoiceTemplateSettings(config) : getDefaultInvoiceTemplateSettings(),
|
|
382
485
|
documentId: null,
|
|
383
486
|
cacheKey: null
|
|
384
487
|
});
|
|
385
488
|
case 6:
|
|
386
|
-
cacheKey = this.
|
|
489
|
+
cacheKey = this.buildInvoiceCacheKey(target, documentId);
|
|
387
490
|
if (!(this.store.invoiceTemplateTarget === target && this.store.invoiceTemplateDocumentId === documentId && this.store.invoiceTemplateCacheKey === cacheKey && isRecord(this.store.invoiceTemplateSettings))) {
|
|
388
|
-
|
|
491
|
+
_context6.next = 9;
|
|
389
492
|
break;
|
|
390
493
|
}
|
|
391
|
-
return
|
|
494
|
+
return _context6.abrupt("return", {
|
|
392
495
|
settings: normalizeRawInvoiceTemplateSettings(this.store.invoiceTemplateSettings),
|
|
393
496
|
documentId: documentId,
|
|
394
497
|
cacheKey: cacheKey
|
|
@@ -396,10 +499,10 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
396
499
|
case 9:
|
|
397
500
|
cachedSettings = this.invoiceTemplateDocumentCache.get(cacheKey);
|
|
398
501
|
if (!cachedSettings) {
|
|
399
|
-
|
|
502
|
+
_context6.next = 12;
|
|
400
503
|
break;
|
|
401
504
|
}
|
|
402
|
-
return
|
|
505
|
+
return _context6.abrupt("return", {
|
|
403
506
|
settings: normalizeRawInvoiceTemplateSettings(cachedSettings),
|
|
404
507
|
documentId: documentId,
|
|
405
508
|
cacheKey: cacheKey
|
|
@@ -409,63 +512,63 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
409
512
|
if (!request) {
|
|
410
513
|
cacheRevision = this.invoiceTemplateCacheRevision;
|
|
411
514
|
request = this.fetchInvoiceTemplateDocument(documentId).catch(function (error) {
|
|
412
|
-
|
|
515
|
+
_this3.logInvoiceTemplateDocumentFallback(error, target, documentId);
|
|
413
516
|
return getDefaultInvoiceTemplateSettings();
|
|
414
517
|
}).then(function (settings) {
|
|
415
518
|
var normalized = normalizeRawInvoiceTemplateSettings(settings);
|
|
416
|
-
if (cacheRevision ===
|
|
417
|
-
|
|
519
|
+
if (cacheRevision === _this3.invoiceTemplateCacheRevision) {
|
|
520
|
+
_this3.invoiceTemplateDocumentCache.set(cacheKey, normalized);
|
|
418
521
|
}
|
|
419
522
|
return normalized;
|
|
420
523
|
}).finally(function () {
|
|
421
|
-
if (
|
|
422
|
-
|
|
524
|
+
if (_this3.invoiceTemplateDocumentInFlight.get(cacheKey) === request) {
|
|
525
|
+
_this3.invoiceTemplateDocumentInFlight.delete(cacheKey);
|
|
423
526
|
}
|
|
424
527
|
});
|
|
425
528
|
this.invoiceTemplateDocumentInFlight.set(cacheKey, request);
|
|
426
529
|
}
|
|
427
|
-
|
|
530
|
+
_context6.next = 16;
|
|
428
531
|
return request;
|
|
429
532
|
case 16:
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
return
|
|
434
|
-
settings:
|
|
435
|
-
documentId:
|
|
436
|
-
cacheKey:
|
|
533
|
+
_context6.t0 = _context6.sent;
|
|
534
|
+
_context6.t1 = documentId;
|
|
535
|
+
_context6.t2 = cacheKey;
|
|
536
|
+
return _context6.abrupt("return", {
|
|
537
|
+
settings: _context6.t0,
|
|
538
|
+
documentId: _context6.t1,
|
|
539
|
+
cacheKey: _context6.t2
|
|
437
540
|
});
|
|
438
541
|
case 20:
|
|
439
542
|
case "end":
|
|
440
|
-
return
|
|
543
|
+
return _context6.stop();
|
|
441
544
|
}
|
|
442
|
-
},
|
|
545
|
+
}, _callee6, this);
|
|
443
546
|
}));
|
|
444
|
-
function resolveInvoiceTemplateSettings(
|
|
547
|
+
function resolveInvoiceTemplateSettings(_x11, _x12) {
|
|
445
548
|
return _resolveInvoiceTemplateSettings.apply(this, arguments);
|
|
446
549
|
}
|
|
447
550
|
return resolveInvoiceTemplateSettings;
|
|
448
551
|
}()
|
|
449
552
|
}, {
|
|
450
|
-
key: "
|
|
451
|
-
value: function
|
|
553
|
+
key: "buildInvoiceCacheKey",
|
|
554
|
+
value: function buildInvoiceCacheKey(target, variant) {
|
|
452
555
|
var _this$appPlugin2, _this$appPlugin2$getD, _getData, _getData2;
|
|
453
556
|
var getData = (_this$appPlugin2 = this.appPlugin) === null || _this$appPlugin2 === void 0 || (_this$appPlugin2$getD = _this$appPlugin2.getData) === null || _this$appPlugin2$getD === void 0 ? void 0 : _this$appPlugin2$getD.call(_this$appPlugin2);
|
|
454
|
-
return JSON.stringify([(_getData = getData === null || getData === void 0 ? void 0 : getData('tenant_id')) !== null && _getData !== void 0 ? _getData : null, (_getData2 = getData === null || getData === void 0 ? void 0 : getData('shop_id')) !== null && _getData2 !== void 0 ? _getData2 : null, target,
|
|
557
|
+
return JSON.stringify([(_getData = getData === null || getData === void 0 ? void 0 : getData('tenant_id')) !== null && _getData !== void 0 ? _getData : null, (_getData2 = getData === null || getData === void 0 ? void 0 : getData('shop_id')) !== null && _getData2 !== void 0 ? _getData2 : null, target, variant]);
|
|
455
558
|
}
|
|
456
559
|
}, {
|
|
457
560
|
key: "fetchInvoiceTemplateDocument",
|
|
458
561
|
value: function () {
|
|
459
|
-
var _fetchInvoiceTemplateDocument = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
562
|
+
var _fetchInvoiceTemplateDocument = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(documentId) {
|
|
460
563
|
var strict,
|
|
461
564
|
response,
|
|
462
565
|
document,
|
|
463
|
-
|
|
464
|
-
return _regeneratorRuntime().wrap(function
|
|
465
|
-
while (1) switch (
|
|
566
|
+
_args7 = arguments;
|
|
567
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
568
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
466
569
|
case 0:
|
|
467
|
-
strict =
|
|
468
|
-
|
|
570
|
+
strict = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : false;
|
|
571
|
+
_context7.next = 3;
|
|
469
572
|
return this.request.get("/document:get?filterByTk=".concat(encodeURIComponent(documentId)), {}, _objectSpread({
|
|
470
573
|
isNocobase: true,
|
|
471
574
|
prefix: false,
|
|
@@ -478,40 +581,40 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
478
581
|
skipErrorHandler: true
|
|
479
582
|
} : {}));
|
|
480
583
|
case 3:
|
|
481
|
-
response =
|
|
584
|
+
response = _context7.sent;
|
|
482
585
|
document = response === null || response === void 0 ? void 0 : response.data;
|
|
483
586
|
if (!(!document || resolveInvoiceDocumentId(document.id) !== documentId)) {
|
|
484
|
-
|
|
587
|
+
_context7.next = 7;
|
|
485
588
|
break;
|
|
486
589
|
}
|
|
487
590
|
throw new Error("Invoice Document ".concat(documentId, " \u8FD4\u56DE\u7684 ID \u4E0D\u5339\u914D"));
|
|
488
591
|
case 7:
|
|
489
592
|
if (!(document.deleted_at !== null && document.deleted_at !== undefined)) {
|
|
490
|
-
|
|
593
|
+
_context7.next = 9;
|
|
491
594
|
break;
|
|
492
595
|
}
|
|
493
596
|
throw new Error("Invoice Document ".concat(documentId, " \u5DF2\u88AB\u5220\u9664"));
|
|
494
597
|
case 9:
|
|
495
598
|
if (!(!isRecord(document.data) || !isRecord(document.data.template_settings))) {
|
|
496
|
-
|
|
599
|
+
_context7.next = 11;
|
|
497
600
|
break;
|
|
498
601
|
}
|
|
499
602
|
throw new Error("Invoice Document ".concat(documentId, " \u7F3A\u5C11 template_settings"));
|
|
500
603
|
case 11:
|
|
501
604
|
if (!(strict && (typeof document.data.template_settings.template !== 'string' || !document.data.template_settings.template.trim()))) {
|
|
502
|
-
|
|
605
|
+
_context7.next = 13;
|
|
503
606
|
break;
|
|
504
607
|
}
|
|
505
608
|
throw new Error("Invoice Document ".concat(documentId, " \u7F3A\u5C11 template"));
|
|
506
609
|
case 13:
|
|
507
|
-
return
|
|
610
|
+
return _context7.abrupt("return", normalizeRawInvoiceTemplateSettings(document.data.template_settings));
|
|
508
611
|
case 14:
|
|
509
612
|
case "end":
|
|
510
|
-
return
|
|
613
|
+
return _context7.stop();
|
|
511
614
|
}
|
|
512
|
-
},
|
|
615
|
+
}, _callee7, this);
|
|
513
616
|
}));
|
|
514
|
-
function fetchInvoiceTemplateDocument(
|
|
617
|
+
function fetchInvoiceTemplateDocument(_x13) {
|
|
515
618
|
return _fetchInvoiceTemplateDocument.apply(this, arguments);
|
|
516
619
|
}
|
|
517
620
|
return fetchInvoiceTemplateDocument;
|
|
@@ -538,6 +641,8 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
538
641
|
value: function clearCache() {
|
|
539
642
|
this.fetchRevision += 1;
|
|
540
643
|
this.invoiceTemplateCacheRevision += 1;
|
|
644
|
+
this.printInvoiceTemplates.clear();
|
|
645
|
+
this.lastManualPrintKey = undefined;
|
|
541
646
|
this.invoiceTemplateDocumentCache.clear();
|
|
542
647
|
this.invoiceTemplateDocumentInFlight.clear();
|
|
543
648
|
this.store.data = null;
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 |
|
|
345
|
+
weekNum: 0 | 5 | 1 | 2 | 4 | 3 | 6;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -373,7 +373,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
373
373
|
* 获取当前的客户搜索条件
|
|
374
374
|
* @returns 当前搜索条件
|
|
375
375
|
*/
|
|
376
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
376
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
377
377
|
/**
|
|
378
378
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
379
379
|
* @returns 客户状态
|
|
@@ -25,17 +25,18 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
25
25
|
notes?: import("../../../modules/Order/types").SalesNote[] | undefined;
|
|
26
26
|
summary?: import("../../../modules/Order/types").OrderSummary | undefined;
|
|
27
27
|
small_ticket_data_flag?: number | undefined;
|
|
28
|
-
|
|
28
|
+
bookings: any[];
|
|
29
|
+
external_sale_number: string;
|
|
30
|
+
payments: any[];
|
|
29
31
|
customer_id: number | null;
|
|
30
|
-
schedule_date: string;
|
|
31
|
-
business_code?: string | undefined;
|
|
32
32
|
order_id: number | null;
|
|
33
33
|
order_number: string | null;
|
|
34
34
|
shop_order_number: string | null;
|
|
35
|
-
shop_full_order_number: string | null;
|
|
36
35
|
type: string;
|
|
36
|
+
business_code?: string | undefined;
|
|
37
37
|
sales_channel: string;
|
|
38
38
|
order_sales_channel: string;
|
|
39
|
+
status: string;
|
|
39
40
|
shipping_status: string;
|
|
40
41
|
customer_name: string;
|
|
41
42
|
country_calling_code: string;
|
|
@@ -52,21 +53,20 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
52
53
|
shop_discount: string;
|
|
53
54
|
surcharge_fee: string;
|
|
54
55
|
note: string;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
table_number?: Record<string, any> | undefined;
|
|
58
|
-
bookings: any[];
|
|
59
|
-
payments: any[];
|
|
56
|
+
schedule_date: string;
|
|
57
|
+
refunds?: any[] | undefined;
|
|
60
58
|
surcharges: any[];
|
|
61
59
|
relation_forms: any[];
|
|
62
60
|
contacts: any[];
|
|
63
61
|
contacts_info: Record<string, any> | null;
|
|
64
62
|
holder: Record<string, any> | null;
|
|
65
|
-
metadata: Record<string, any>;
|
|
66
|
-
external_sale_number: string;
|
|
67
63
|
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
68
|
-
refunds?: any[] | undefined;
|
|
69
64
|
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
65
|
+
metadata: Record<string, any>;
|
|
66
|
+
buzzer?: string | undefined;
|
|
67
|
+
shop_full_order_number: string | null;
|
|
68
|
+
delivery_type?: string | undefined;
|
|
69
|
+
table_number?: Record<string, any> | undefined;
|
|
70
70
|
};
|
|
71
71
|
export declare function describeChangedBookings(before: OrderTempOrder['bookings'], after: OrderTempOrder['bookings']): {
|
|
72
72
|
schedule_event_id: any;
|
|
@@ -27,9 +27,6 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
27
27
|
protected request: RequestPlugin;
|
|
28
28
|
private logger;
|
|
29
29
|
private invoiceOpenDataModule;
|
|
30
|
-
private invoiceOpenDataTarget;
|
|
31
|
-
private invoiceOpenDataInFlight;
|
|
32
|
-
private invoiceOpenDataInFlightTarget;
|
|
33
30
|
constructor(name?: string, version?: string);
|
|
34
31
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
35
32
|
/** 获取当前 store 快照 */
|
|
@@ -51,7 +48,6 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
51
48
|
* Legacy Sales 的系统上下文没有可打印的 system target,因此统一回退 pos。
|
|
52
49
|
*/
|
|
53
50
|
private getInvoiceSalesChannel;
|
|
54
|
-
private loadInvoiceOpenData;
|
|
55
51
|
private logInvoiceOpenDataFallback;
|
|
56
52
|
private resolveInvoiceConfigs;
|
|
57
53
|
printLocalOrderReceipt<T = any>(lookup: string | number, options: SalesPrintLocalOrderReceiptOptions): Promise<T>;
|