@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.
@@ -29,11 +29,9 @@ import dayjs from 'dayjs';
29
29
  import { cloneDeep } from 'lodash-es';
30
30
  import { BaseModule } from "../../modules/BaseModule";
31
31
  import { SalesHooks } from "./types";
32
- import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, OpenDataModule } from "../../modules/OpenData";
32
+ import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, OpenDataModule, normalizeInvoiceLayoutFromTemplateSettings } from "../../modules/OpenData";
33
33
  export * from "./types";
34
34
  var UNPAID_PAYMENT_STATUSES = new Set(['unpaid', 'partially_paid', 'payment_processing']);
35
- var INVOICE_OPEN_DATA_SECTION_CODES = ['documents'];
36
- var INVOICE_OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
37
35
  /**
38
36
  * Sales 解决方案基础骨架
39
37
  *
@@ -63,9 +61,6 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
63
61
  _defineProperty(_assertThisInitialized(_this), "logger", void 0);
64
62
  // LoggerManager 实例
65
63
  _defineProperty(_assertThisInitialized(_this), "invoiceOpenDataModule", null);
66
- _defineProperty(_assertThisInitialized(_this), "invoiceOpenDataTarget", null);
67
- _defineProperty(_assertThisInitialized(_this), "invoiceOpenDataInFlight", null);
68
- _defineProperty(_assertThisInitialized(_this), "invoiceOpenDataInFlightTarget", null);
69
64
  return _this;
70
65
  }
71
66
  _createClass(SalesImpl, [{
@@ -109,9 +104,6 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
109
104
  // 在这里补充从 Server/Order 读取 currentDay 原始数据并转换为预约列表。
110
105
 
111
106
  this.logger = appPlugin === null || appPlugin === void 0 ? void 0 : appPlugin.getApp().logger;
112
- this.invoiceOpenDataTarget = null;
113
- this.invoiceOpenDataInFlight = null;
114
- this.invoiceOpenDataInFlightTarget = null;
115
107
  this.invoiceOpenDataModule = new OpenDataModule("".concat(this.name, "_invoiceOpenData"));
116
108
  this.core.registerModule(this.invoiceOpenDataModule, {
117
109
  initialState: {},
@@ -121,9 +113,9 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
121
113
  platform: (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform
122
114
  }
123
115
  });
124
- _context.next = 18;
116
+ _context.next = 15;
125
117
  return this.core.effects.emit("".concat(this.name, ":onInited"), {});
126
- case 18:
118
+ case 15:
127
119
  case "end":
128
120
  return _context.stop();
129
121
  }
@@ -258,93 +250,6 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
258
250
  var normalized = String((_ref = channel !== null && channel !== void 0 ? channel : contextChannel) !== null && _ref !== void 0 ? _ref : '').trim();
259
251
  return !normalized || normalized === 'system' ? 'pos' : normalized;
260
252
  }
261
- }, {
262
- key: "loadInvoiceOpenData",
263
- value: function () {
264
- var _loadInvoiceOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(businessCode, channel) {
265
- var target, cachedData, lastFetchedAt, request, openData;
266
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
267
- while (1) switch (_context4.prev = _context4.next) {
268
- case 0:
269
- if (this.invoiceOpenDataModule) {
270
- _context4.next = 2;
271
- break;
272
- }
273
- throw new Error('Sales Invoice OpenData 模块未初始化');
274
- case 2:
275
- target = "".concat(businessCode, "+").concat(channel);
276
- cachedData = this.invoiceOpenDataModule.getOpenData();
277
- lastFetchedAt = this.invoiceOpenDataModule.getLastFetchedAt();
278
- if (!(cachedData && this.invoiceOpenDataTarget === target && typeof lastFetchedAt === 'number' && Date.now() - lastFetchedAt < INVOICE_OPEN_DATA_CACHE_TTL)) {
279
- _context4.next = 10;
280
- break;
281
- }
282
- if (!(typeof this.invoiceOpenDataModule.ensureInvoiceTemplateSettings === 'function')) {
283
- _context4.next = 9;
284
- break;
285
- }
286
- _context4.next = 9;
287
- return this.invoiceOpenDataModule.ensureInvoiceTemplateSettings(target);
288
- case 9:
289
- return _context4.abrupt("return", cachedData);
290
- case 10:
291
- if (!this.invoiceOpenDataInFlight) {
292
- _context4.next = 21;
293
- break;
294
- }
295
- if (!(this.invoiceOpenDataInFlightTarget === target)) {
296
- _context4.next = 13;
297
- break;
298
- }
299
- return _context4.abrupt("return", this.invoiceOpenDataInFlight);
300
- case 13:
301
- _context4.prev = 13;
302
- _context4.next = 16;
303
- return this.invoiceOpenDataInFlight;
304
- case 16:
305
- _context4.next = 20;
306
- break;
307
- case 18:
308
- _context4.prev = 18;
309
- _context4.t0 = _context4["catch"](13);
310
- case 20:
311
- return _context4.abrupt("return", this.loadInvoiceOpenData(businessCode, channel));
312
- case 21:
313
- request = this.invoiceOpenDataModule.fetchOpenData({
314
- scope: 'board',
315
- target: target,
316
- section_code: [].concat(INVOICE_OPEN_DATA_SECTION_CODES)
317
- });
318
- this.invoiceOpenDataInFlight = request;
319
- this.invoiceOpenDataInFlightTarget = target;
320
- _context4.prev = 24;
321
- _context4.next = 27;
322
- return request;
323
- case 27:
324
- openData = _context4.sent;
325
- // clearOpenDataCache() 或后续请求接管后,旧响应不得复活 target 归属。
326
- if (this.invoiceOpenDataInFlight === request) {
327
- this.invoiceOpenDataTarget = target;
328
- }
329
- return _context4.abrupt("return", openData);
330
- case 30:
331
- _context4.prev = 30;
332
- if (this.invoiceOpenDataInFlight === request) {
333
- this.invoiceOpenDataInFlight = null;
334
- this.invoiceOpenDataInFlightTarget = null;
335
- }
336
- return _context4.finish(30);
337
- case 33:
338
- case "end":
339
- return _context4.stop();
340
- }
341
- }, _callee4, this, [[13, 18], [24,, 30, 33]]);
342
- }));
343
- function loadInvoiceOpenData(_x4, _x5) {
344
- return _loadInvoiceOpenData.apply(this, arguments);
345
- }
346
- return loadInvoiceOpenData;
347
- }()
348
253
  }, {
349
254
  key: "logInvoiceOpenDataFallback",
350
255
  value: function logInvoiceOpenDataFallback(error) {
@@ -365,43 +270,41 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
365
270
  }, {
366
271
  key: "resolveInvoiceConfigs",
367
272
  value: function () {
368
- var _resolveInvoiceConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(businessCode, channel) {
369
- var _this$invoiceOpenData, _this$invoiceOpenData2, _this$invoiceOpenData3, _this$invoiceOpenData4;
370
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
371
- while (1) switch (_context5.prev = _context5.next) {
273
+ var _resolveInvoiceConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(businessCode, channel) {
274
+ var templateSettings;
275
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
276
+ while (1) switch (_context4.prev = _context4.next) {
372
277
  case 0:
373
- _context5.prev = 0;
374
- _context5.next = 3;
375
- return this.loadInvoiceOpenData(businessCode, channel);
376
- case 3:
377
- if (!(this.invoiceOpenDataTarget !== "".concat(businessCode, "+").concat(channel))) {
378
- _context5.next = 5;
278
+ _context4.prev = 0;
279
+ if (this.invoiceOpenDataModule) {
280
+ _context4.next = 3;
379
281
  break;
380
282
  }
381
- return _context5.abrupt("return", {
382
- invoice: getDefaultInvoiceLayoutConfig(),
383
- templateSettings: getDefaultInvoiceTemplateSettings()
384
- });
283
+ throw new Error('Sales Invoice OpenData 模块未初始化');
284
+ case 3:
285
+ _context4.next = 5;
286
+ return this.invoiceOpenDataModule.loadPrintInvoiceTemplate("".concat(businessCode, "+").concat(channel), 'manual');
385
287
  case 5:
386
- return _context5.abrupt("return", {
387
- invoice: (_this$invoiceOpenData = (_this$invoiceOpenData2 = this.invoiceOpenDataModule) === null || _this$invoiceOpenData2 === void 0 ? void 0 : _this$invoiceOpenData2.getInvoiceLayoutConfig()) !== null && _this$invoiceOpenData !== void 0 ? _this$invoiceOpenData : getDefaultInvoiceLayoutConfig(),
388
- templateSettings: (_this$invoiceOpenData3 = (_this$invoiceOpenData4 = this.invoiceOpenDataModule) === null || _this$invoiceOpenData4 === void 0 ? void 0 : _this$invoiceOpenData4.getInvoiceTemplateSettings()) !== null && _this$invoiceOpenData3 !== void 0 ? _this$invoiceOpenData3 : getDefaultInvoiceTemplateSettings()
288
+ templateSettings = _context4.sent;
289
+ return _context4.abrupt("return", {
290
+ invoice: normalizeInvoiceLayoutFromTemplateSettings(templateSettings),
291
+ templateSettings: templateSettings
389
292
  });
390
- case 8:
391
- _context5.prev = 8;
392
- _context5.t0 = _context5["catch"](0);
393
- this.logInvoiceOpenDataFallback(_context5.t0);
394
- return _context5.abrupt("return", {
293
+ case 9:
294
+ _context4.prev = 9;
295
+ _context4.t0 = _context4["catch"](0);
296
+ this.logInvoiceOpenDataFallback(_context4.t0);
297
+ return _context4.abrupt("return", {
395
298
  invoice: getDefaultInvoiceLayoutConfig(),
396
299
  templateSettings: getDefaultInvoiceTemplateSettings()
397
300
  });
398
- case 12:
301
+ case 13:
399
302
  case "end":
400
- return _context5.stop();
303
+ return _context4.stop();
401
304
  }
402
- }, _callee5, this, [[0, 8]]);
305
+ }, _callee4, this, [[0, 9]]);
403
306
  }));
404
- function resolveInvoiceConfigs(_x6, _x7) {
307
+ function resolveInvoiceConfigs(_x4, _x5) {
405
308
  return _resolveInvoiceConfigs.apply(this, arguments);
406
309
  }
407
310
  return resolveInvoiceConfigs;
@@ -409,31 +312,31 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
409
312
  }, {
410
313
  key: "printLocalOrderReceipt",
411
314
  value: function () {
412
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(lookup, options) {
315
+ var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(lookup, options) {
413
316
  var _options$businessCode;
414
317
  var normalizedLookup, businessCode, channel, _yield$this$resolveIn, invoice, templateSettings, lookupPayload;
415
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
416
- while (1) switch (_context6.prev = _context6.next) {
318
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
319
+ while (1) switch (_context5.prev = _context5.next) {
417
320
  case 0:
418
321
  normalizedLookup = typeof lookup === 'string' ? lookup.trim() : lookup;
419
322
  if (!(normalizedLookup === '' || normalizedLookup === null || normalizedLookup === undefined)) {
420
- _context6.next = 3;
323
+ _context5.next = 3;
421
324
  break;
422
325
  }
423
326
  throw new Error('Sales 本地小票打印需要订单标识');
424
327
  case 3:
425
328
  businessCode = String((_options$businessCode = options === null || options === void 0 ? void 0 : options.businessCode) !== null && _options$businessCode !== void 0 ? _options$businessCode : '').trim();
426
329
  if (businessCode) {
427
- _context6.next = 6;
330
+ _context5.next = 6;
428
331
  break;
429
332
  }
430
333
  throw new Error('Sales 本地小票打印需要 businessCode');
431
334
  case 6:
432
335
  channel = this.getInvoiceSalesChannel(options === null || options === void 0 ? void 0 : options.channel);
433
- _context6.next = 9;
336
+ _context5.next = 9;
434
337
  return this.resolveInvoiceConfigs(businessCode, channel);
435
338
  case 9:
436
- _yield$this$resolveIn = _context6.sent;
339
+ _yield$this$resolveIn = _context5.sent;
437
340
  invoice = _yield$this$resolveIn.invoice;
438
341
  templateSettings = _yield$this$resolveIn.templateSettings;
439
342
  lookupPayload = typeof normalizedLookup === 'number' ? {
@@ -441,7 +344,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
441
344
  } : {
442
345
  external_sale_number: normalizedLookup
443
346
  };
444
- return _context6.abrupt("return", this.request.post('/shop/local/print-order', _objectSpread(_objectSpread({}, lookupPayload), {}, {
347
+ return _context5.abrupt("return", this.request.post('/shop/local/print-order', _objectSpread(_objectSpread({}, lookupPayload), {}, {
445
348
  lookup_order_from_db: 1,
446
349
  small_ticket_data_flag: 1,
447
350
  business_code: businessCode,
@@ -454,11 +357,11 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
454
357
  }));
455
358
  case 14:
456
359
  case "end":
457
- return _context6.stop();
360
+ return _context5.stop();
458
361
  }
459
- }, _callee6, this);
362
+ }, _callee5, this);
460
363
  }));
461
- function printLocalOrderReceipt(_x8, _x9) {
364
+ function printLocalOrderReceipt(_x6, _x7) {
462
365
  return _printLocalOrderReceipt.apply(this, arguments);
463
366
  }
464
367
  return printLocalOrderReceipt;
@@ -466,23 +369,23 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
466
369
  }, {
467
370
  key: "printCloudOrderInvoice",
468
371
  value: function () {
469
- var _printCloudOrderInvoice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(input) {
372
+ var _printCloudOrderInvoice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(input) {
470
373
  var _lookup$data;
471
374
  var orderId, channel, openData, requestOptions, lookup, businessCode, settings, result;
472
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
473
- while (1) switch (_context7.prev = _context7.next) {
375
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
376
+ while (1) switch (_context6.prev = _context6.next) {
474
377
  case 0:
475
378
  orderId = input === null || input === void 0 ? void 0 : input.order_id;
476
379
  channel = typeof (input === null || input === void 0 ? void 0 : input.channel) === 'string' ? input.channel.trim() : '';
477
380
  if (channel) {
478
- _context7.next = 4;
381
+ _context6.next = 4;
479
382
  break;
480
383
  }
481
384
  throw new Error('Cloud Invoice requires a channel');
482
385
  case 4:
483
386
  openData = this.invoiceOpenDataModule;
484
387
  if (openData) {
485
- _context7.next = 7;
388
+ _context6.next = 7;
486
389
  break;
487
390
  }
488
391
  throw new Error('Cloud Invoice is not initialized');
@@ -491,49 +394,49 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
491
394
  osServer: true,
492
395
  customToast: function customToast() {}
493
396
  };
494
- _context7.next = 10;
397
+ _context6.next = 10;
495
398
  return this.request.post('/shop/local/cloud-order-invoice/lookup', {
496
399
  order_id: orderId
497
400
  }, requestOptions);
498
401
  case 10:
499
- lookup = _context7.sent;
402
+ lookup = _context6.sent;
500
403
  if (!((lookup === null || lookup === void 0 ? void 0 : lookup.status) !== true || lookup.code !== 200)) {
501
- _context7.next = 13;
404
+ _context6.next = 13;
502
405
  break;
503
406
  }
504
407
  throw new Error((lookup === null || lookup === void 0 ? void 0 : lookup.message) || 'Cloud Invoice order lookup failed');
505
408
  case 13:
506
409
  businessCode = (_lookup$data = lookup.data) === null || _lookup$data === void 0 || (_lookup$data = _lookup$data.business_code) === null || _lookup$data === void 0 ? void 0 : _lookup$data.trim();
507
410
  if (businessCode) {
508
- _context7.next = 16;
411
+ _context6.next = 16;
509
412
  break;
510
413
  }
511
414
  throw new Error('Cloud Invoice order has no business_code');
512
415
  case 16:
513
- _context7.next = 18;
416
+ _context6.next = 18;
514
417
  return openData.loadCloudInvoiceTemplate("".concat(businessCode, "+").concat(channel));
515
418
  case 18:
516
- settings = _context7.sent;
517
- _context7.next = 21;
419
+ settings = _context6.sent;
420
+ _context6.next = 21;
518
421
  return this.request.post('/shop/local/cloud-order-invoice/submit', {
519
422
  order_id: orderId,
520
423
  business_code: businessCode,
521
424
  template_settings: settings
522
425
  }, requestOptions);
523
426
  case 21:
524
- result = _context7.sent;
427
+ result = _context6.sent;
525
428
  if (!((result === null || result === void 0 ? void 0 : result.status) !== true || result.code !== 200)) {
526
- _context7.next = 24;
429
+ _context6.next = 24;
527
430
  break;
528
431
  }
529
432
  throw new Error((result === null || result === void 0 ? void 0 : result.message) || 'Cloud Invoice dispatch failed');
530
433
  case 24:
531
434
  case "end":
532
- return _context7.stop();
435
+ return _context6.stop();
533
436
  }
534
- }, _callee7, this);
437
+ }, _callee6, this);
535
438
  }));
536
- function printCloudOrderInvoice(_x10) {
439
+ function printCloudOrderInvoice(_x8) {
537
440
  return _printCloudOrderInvoice.apply(this, arguments);
538
441
  }
539
442
  return printCloudOrderInvoice;
@@ -541,11 +444,8 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
541
444
  }, {
542
445
  key: "clearOpenDataCache",
543
446
  value: function clearOpenDataCache() {
544
- var _this$invoiceOpenData5;
545
- this.invoiceOpenDataInFlight = null;
546
- this.invoiceOpenDataInFlightTarget = null;
547
- this.invoiceOpenDataTarget = null;
548
- (_this$invoiceOpenData5 = this.invoiceOpenDataModule) === null || _this$invoiceOpenData5 === void 0 || _this$invoiceOpenData5.clearCache();
447
+ var _this$invoiceOpenData;
448
+ (_this$invoiceOpenData = this.invoiceOpenDataModule) === null || _this$invoiceOpenData === void 0 || _this$invoiceOpenData.clearCache();
549
449
  }
550
450
 
551
451
  // -------------------------------------------------------------------------
@@ -554,38 +454,38 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
554
454
  }, {
555
455
  key: "destroy",
556
456
  value: function () {
557
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
457
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
558
458
  var invoiceOpenDataModule;
559
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
560
- while (1) switch (_context8.prev = _context8.next) {
459
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
460
+ while (1) switch (_context7.prev = _context7.next) {
561
461
  case 0:
562
462
  this.clearOpenDataCache();
563
463
  invoiceOpenDataModule = this.invoiceOpenDataModule;
564
464
  this.invoiceOpenDataModule = null;
565
465
  if (!invoiceOpenDataModule) {
566
- _context8.next = 12;
466
+ _context7.next = 12;
567
467
  break;
568
468
  }
569
- _context8.prev = 4;
570
- _context8.next = 7;
469
+ _context7.prev = 4;
470
+ _context7.next = 7;
571
471
  return invoiceOpenDataModule.destroy();
572
472
  case 7:
573
- _context8.next = 12;
473
+ _context7.next = 12;
574
474
  break;
575
475
  case 9:
576
- _context8.prev = 9;
577
- _context8.t0 = _context8["catch"](4);
578
- console.warn('[Sales] Invoice OpenData 子模块销毁失败', _context8.t0);
476
+ _context7.prev = 9;
477
+ _context7.t0 = _context7["catch"](4);
478
+ console.warn('[Sales] Invoice OpenData 子模块销毁失败', _context7.t0);
579
479
  case 12:
580
- _context8.next = 14;
480
+ _context7.next = 14;
581
481
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
582
482
  case 14:
583
483
  _get(_getPrototypeOf(SalesImpl.prototype), "destroy", this).call(this);
584
484
  case 15:
585
485
  case "end":
586
- return _context8.stop();
486
+ return _context7.stop();
587
487
  }
588
- }, _callee8, this, [[4, 9]]);
488
+ }, _callee7, this, [[4, 9]]);
589
489
  }));
590
490
  function destroy() {
591
491
  return _destroy.apply(this, arguments);
@@ -1177,7 +1077,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1177
1077
  }, {
1178
1078
  key: "getResourceBookingList",
1179
1079
  value: function () {
1180
- var _getResourceBookingList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(currentTime) {
1080
+ var _getResourceBookingList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(currentTime) {
1181
1081
  var _resourceResponse$dat,
1182
1082
  _resourceResponse$dat2,
1183
1083
  _this8 = this;
@@ -1191,28 +1091,28 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1191
1091
  rawBookingMap,
1192
1092
  bookingMap,
1193
1093
  list,
1194
- _args9 = arguments;
1195
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1196
- while (1) switch (_context9.prev = _context9.next) {
1094
+ _args8 = arguments;
1095
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1096
+ while (1) switch (_context8.prev = _context8.next) {
1197
1097
  case 0:
1198
- bookingList = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : [];
1199
- deviceTime = _args9.length > 2 && _args9[2] !== undefined ? _args9[2] : currentTime;
1098
+ bookingList = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : [];
1099
+ deviceTime = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : currentTime;
1200
1100
  // currentTime 约定为完整 datetime;非法值直接返回空,避免误判
1201
1101
  current = dayjs(currentTime);
1202
1102
  if (current.isValid()) {
1203
- _context9.next = 5;
1103
+ _context8.next = 5;
1204
1104
  break;
1205
1105
  }
1206
- return _context9.abrupt("return", []);
1106
+ return _context8.abrupt("return", []);
1207
1107
  case 5:
1208
1108
  deviceCurrent = dayjs(deviceTime);
1209
1109
  if (deviceCurrent.isValid()) {
1210
- _context9.next = 8;
1110
+ _context8.next = 8;
1211
1111
  break;
1212
1112
  }
1213
- return _context9.abrupt("return", []);
1113
+ return _context8.abrupt("return", []);
1214
1114
  case 8:
1215
- _context9.next = 10;
1115
+ _context8.next = 10;
1216
1116
  return this.request.get('/shop/form/resource/page', {
1217
1117
  skip: 1,
1218
1118
  num: 999
@@ -1223,13 +1123,13 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1223
1123
  isShopApi: true
1224
1124
  });
1225
1125
  case 10:
1226
- resourceResponse = _context9.sent;
1126
+ resourceResponse = _context8.sent;
1227
1127
  resourceList = (_resourceResponse$dat = resourceResponse === null || resourceResponse === void 0 || (_resourceResponse$dat2 = resourceResponse.data) === null || _resourceResponse$dat2 === void 0 ? void 0 : _resourceResponse$dat2.list) !== null && _resourceResponse$dat !== void 0 ? _resourceResponse$dat : [];
1228
1128
  if (!(!Array.isArray(resourceList) || resourceList.length === 0)) {
1229
- _context9.next = 14;
1129
+ _context8.next = 14;
1230
1130
  break;
1231
1131
  }
1232
- return _context9.abrupt("return", []);
1132
+ return _context8.abrupt("return", []);
1233
1133
  case 14:
1234
1134
  // 全局先做 booking 标准化 + start_time 升序,后续映射直接复用
1235
1135
  normalizedBookings = this.normalizeResourceBookings(current, deviceCurrent, bookingList); // 建立 resourceId -> bookings[] 倒排索引,加速资源匹配
@@ -1264,14 +1164,14 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1264
1164
  list: list === null || list === void 0 ? void 0 : list.length
1265
1165
  }
1266
1166
  });
1267
- return _context9.abrupt("return", list);
1167
+ return _context8.abrupt("return", list);
1268
1168
  case 20:
1269
1169
  case "end":
1270
- return _context9.stop();
1170
+ return _context8.stop();
1271
1171
  }
1272
- }, _callee9, this);
1172
+ }, _callee8, this);
1273
1173
  }));
1274
- function getResourceBookingList(_x11) {
1174
+ function getResourceBookingList(_x9) {
1275
1175
  return _getResourceBookingList.apply(this, arguments);
1276
1176
  }
1277
1177
  return getResourceBookingList;
@@ -1279,30 +1179,30 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1279
1179
  }, {
1280
1180
  key: "getResourceBookingItem",
1281
1181
  value: function () {
1282
- var _getResourceBookingItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
1182
+ var _getResourceBookingItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
1283
1183
  var _resourceResponse$dat3,
1284
1184
  _resourceResponse$dat4,
1285
1185
  _this9 = this,
1286
1186
  _params$bookingList;
1287
1187
  var current, deviceCurrent, resourceResponse, resourceList, targetResource, resourceId, matchedBookingList, statsBookingList, completedBookingList, unpaidBookingList, bookings, completedBookings, unpaidBookings, orderCount, bookingCount, compeleteBookingCount;
1288
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1289
- while (1) switch (_context10.prev = _context10.next) {
1188
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1189
+ while (1) switch (_context9.prev = _context9.next) {
1290
1190
  case 0:
1291
1191
  current = dayjs(params.currentTime);
1292
1192
  if (current.isValid()) {
1293
- _context10.next = 3;
1193
+ _context9.next = 3;
1294
1194
  break;
1295
1195
  }
1296
- return _context10.abrupt("return", null);
1196
+ return _context9.abrupt("return", null);
1297
1197
  case 3:
1298
1198
  deviceCurrent = dayjs(params.deviceTime || params.currentTime);
1299
1199
  if (deviceCurrent.isValid()) {
1300
- _context10.next = 6;
1200
+ _context9.next = 6;
1301
1201
  break;
1302
1202
  }
1303
- return _context10.abrupt("return", null);
1203
+ return _context9.abrupt("return", null);
1304
1204
  case 6:
1305
- _context10.next = 8;
1205
+ _context9.next = 8;
1306
1206
  return this.request.get('/shop/form/resource/page', {
1307
1207
  skip: 1,
1308
1208
  num: 999
@@ -1313,22 +1213,22 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1313
1213
  isShopApi: true
1314
1214
  });
1315
1215
  case 8:
1316
- resourceResponse = _context10.sent;
1216
+ resourceResponse = _context9.sent;
1317
1217
  resourceList = (_resourceResponse$dat3 = resourceResponse === null || resourceResponse === void 0 || (_resourceResponse$dat4 = resourceResponse.data) === null || _resourceResponse$dat4 === void 0 ? void 0 : _resourceResponse$dat4.list) !== null && _resourceResponse$dat3 !== void 0 ? _resourceResponse$dat3 : [];
1318
1218
  if (!(!Array.isArray(resourceList) || resourceList.length === 0)) {
1319
- _context10.next = 12;
1219
+ _context9.next = 12;
1320
1220
  break;
1321
1221
  }
1322
- return _context10.abrupt("return", null);
1222
+ return _context9.abrupt("return", null);
1323
1223
  case 12:
1324
1224
  targetResource = resourceList.find(function (resource) {
1325
1225
  return String(_this9.getResourceId(resource)) === String(params.resourceId);
1326
1226
  });
1327
1227
  if (targetResource) {
1328
- _context10.next = 15;
1228
+ _context9.next = 15;
1329
1229
  break;
1330
1230
  }
1331
- return _context10.abrupt("return", null);
1231
+ return _context9.abrupt("return", null);
1332
1232
  case 15:
1333
1233
  resourceId = this.getResourceId(targetResource);
1334
1234
  matchedBookingList = params.bookingList.filter(function (booking) {
@@ -1379,7 +1279,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1379
1279
  compeleteBookingCount: compeleteBookingCount
1380
1280
  }
1381
1281
  });
1382
- return _context10.abrupt("return", _objectSpread(_objectSpread({}, targetResource), {}, {
1282
+ return _context9.abrupt("return", _objectSpread(_objectSpread({}, targetResource), {}, {
1383
1283
  resource_id: resourceId,
1384
1284
  orderCount: orderCount,
1385
1285
  bookingCount: bookingCount,
@@ -1390,11 +1290,11 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
1390
1290
  }));
1391
1291
  case 28:
1392
1292
  case "end":
1393
- return _context10.stop();
1293
+ return _context9.stop();
1394
1294
  }
1395
- }, _callee10, this);
1295
+ }, _callee9, this);
1396
1296
  }));
1397
- function getResourceBookingItem(_x12) {
1297
+ function getResourceBookingItem(_x10) {
1398
1298
  return _getResourceBookingItem.apply(this, arguments);
1399
1299
  }
1400
1300
  return getResourceBookingItem;
@@ -1 +1,46 @@
1
- "use strict";
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; }