@pisell/pisellos 2.3.24 → 2.3.25

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.
Files changed (69) hide show
  1. package/dist/model/strategy/adapter/index.d.ts +0 -4
  2. package/dist/model/strategy/adapter/index.js +1 -5
  3. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  4. package/dist/modules/Discount/index.d.ts +2 -5
  5. package/dist/modules/Discount/index.js +7 -30
  6. package/dist/modules/Discount/types.d.ts +0 -4
  7. package/dist/modules/Order/index.d.ts +1 -1
  8. package/dist/modules/Order/index.js +616 -568
  9. package/dist/modules/Order/types.d.ts +0 -2
  10. package/dist/modules/Product/types.d.ts +0 -22
  11. package/dist/modules/ProductList/index.d.ts +1 -1
  12. package/dist/modules/ProductList/index.js +2 -4
  13. package/dist/modules/ProductList/types.d.ts +0 -2
  14. package/dist/server/index.d.ts +0 -50
  15. package/dist/server/index.js +749 -995
  16. package/dist/server/modules/products/index.d.ts +7 -26
  17. package/dist/server/modules/products/index.js +76 -167
  18. package/dist/server/modules/products/types.d.ts +0 -14
  19. package/dist/solution/BaseSales/index.d.ts +0 -2
  20. package/dist/solution/BaseSales/index.js +50 -36
  21. package/dist/solution/BookingByStep/index.d.ts +1 -1
  22. package/dist/solution/BookingTicket/index.js +21 -5
  23. package/dist/solution/BookingTicket/types.d.ts +0 -2
  24. package/dist/solution/ShopDiscount/index.js +14 -15
  25. package/lib/model/strategy/adapter/index.d.ts +0 -4
  26. package/lib/model/strategy/adapter/index.js +2 -13
  27. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  28. package/lib/modules/Discount/index.d.ts +2 -5
  29. package/lib/modules/Discount/index.js +3 -23
  30. package/lib/modules/Discount/types.d.ts +0 -4
  31. package/lib/modules/Order/index.d.ts +1 -1
  32. package/lib/modules/Order/index.js +36 -20
  33. package/lib/modules/Order/types.d.ts +0 -2
  34. package/lib/modules/Product/types.d.ts +0 -22
  35. package/lib/modules/ProductList/index.d.ts +1 -1
  36. package/lib/modules/ProductList/index.js +2 -4
  37. package/lib/modules/ProductList/types.d.ts +0 -2
  38. package/lib/server/index.d.ts +0 -50
  39. package/lib/server/index.js +29 -206
  40. package/lib/server/modules/products/index.d.ts +7 -26
  41. package/lib/server/modules/products/index.js +35 -114
  42. package/lib/server/modules/products/types.d.ts +0 -14
  43. package/lib/solution/BaseSales/index.d.ts +0 -2
  44. package/lib/solution/BaseSales/index.js +22 -12
  45. package/lib/solution/BookingByStep/index.d.ts +1 -1
  46. package/lib/solution/BookingTicket/index.js +18 -1
  47. package/lib/solution/BookingTicket/types.d.ts +0 -2
  48. package/lib/solution/ShopDiscount/index.js +1 -2
  49. package/package.json +1 -1
  50. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  51. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  52. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  53. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
  54. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  55. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  56. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  57. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  58. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  59. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  60. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  61. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  62. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  63. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
  64. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  65. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  66. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  67. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  68. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  69. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
@@ -295,17 +295,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
295
295
  if (!this.store.summary) {
296
296
  this.store.summary = createEmptySummary();
297
297
  }
298
- if (!Array.isArray(this.store.availableWalletIds)) {
299
- this.store.availableWalletIds = [];
300
- }
301
298
  this.request = this.core.getPlugin('request');
302
299
  appPlugin = this.core.getPlugin('app');
303
300
  if (appPlugin) {
304
- _context.next = 9;
301
+ _context.next = 8;
305
302
  break;
306
303
  }
307
304
  throw new Error('Order 模块需要 app 插件支持');
308
- case 9:
305
+ case 8:
309
306
  app = appPlugin.getApp();
310
307
  this.logger = app.logger;
311
308
  this.window = this.core.getPlugin('window');
@@ -318,7 +315,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
318
315
  this.otherParams = otherParams;
319
316
  this.registerDiscountModules(options);
320
317
  this.logInfo('OrderModule initialized successfully');
321
- case 21:
318
+ case 20:
322
319
  case "end":
323
320
  return _context.stop();
324
321
  }
@@ -495,7 +492,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
495
492
  value: function () {
496
493
  var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
497
494
  var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
498
- var orderId, prepareConfigResult, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentEditDiscounts, currentScanDiscounts, currentScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
495
+ var orderId, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentEditDiscounts, currentScanDiscounts, currentScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, mergedDiscountList;
499
496
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
500
497
  while (1) switch (_context3.prev = _context3.next) {
501
498
  case 0:
@@ -507,18 +504,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
507
504
  with_good_pass: 1,
508
505
  with_discount_card: 1,
509
506
  with_wallet_pass_holder: 1,
510
- with_available_wallet_flag: 1,
511
- with_available_wallet_pass_flag: 1,
512
507
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
513
508
  }, orderId ? {
514
509
  order_id: orderId
515
510
  } : {}));
516
511
  case 3:
517
- prepareConfigResult = _context3.sent;
518
- discountList = prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList;
519
- this.store.availableWalletIds = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.availableWalletIds) || [];
512
+ discountList = _context3.sent;
520
513
  if (!discountList) {
521
- _context3.next = 18;
514
+ _context3.next = 16;
522
515
  break;
523
516
  }
524
517
  currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
@@ -539,17 +532,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
539
532
  return true;
540
533
  });
541
534
  mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(currentScanDiscounts), _toConsumableArray(runtimeDiscounts));
542
- _context3.next = 16;
535
+ _context3.next = 14;
543
536
  return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
544
- case 16:
545
- _context3.next = 18;
537
+ case 14:
538
+ _context3.next = 16;
546
539
  return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
547
- case 18:
540
+ case 16:
548
541
  if (params.apply !== false && (_this$store$tempOrder2 = this.store.tempOrder) !== null && _this$store$tempOrder2 !== void 0 && (_this$store$tempOrder2 = _this$store$tempOrder2.products) !== null && _this$store$tempOrder2 !== void 0 && _this$store$tempOrder2.length) {
549
542
  this.applyDiscount();
550
543
  }
551
544
  return _context3.abrupt("return", this.getDiscountList());
552
- case 20:
545
+ case 18:
553
546
  case "end":
554
547
  return _context3.stop();
555
548
  }
@@ -567,38 +560,71 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
567
560
  return ((_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 ? void 0 : _this$store$discount5.getDiscountList()) || [];
568
561
  }
569
562
  }, {
570
- key: "getAvailableWalletIds",
571
- value: function getAvailableWalletIds() {
572
- return Array.isArray(this.store.availableWalletIds) ? _toConsumableArray(this.store.availableWalletIds) : [];
573
- }
563
+ key: "syncScannedDiscountsToOriginalDiscountList",
564
+ value: function () {
565
+ var _syncScannedDiscountsToOriginalDiscountList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(discountList) {
566
+ var _this$store$discount6, _this$store$discount7, _this$store$discount8, _this$store$discount9;
567
+ var scanDiscounts, scanDiscountIds, originalDiscounts, nextOriginalDiscounts;
568
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
569
+ while (1) switch (_context4.prev = _context4.next) {
570
+ case 0:
571
+ scanDiscounts = (discountList || []).filter(function (discount) {
572
+ return discount === null || discount === void 0 ? void 0 : discount.isScan;
573
+ });
574
+ if (scanDiscounts.length) {
575
+ _context4.next = 3;
576
+ break;
577
+ }
578
+ return _context4.abrupt("return");
579
+ case 3:
580
+ scanDiscountIds = new Set(scanDiscounts.map(function (discount) {
581
+ return discount === null || discount === void 0 ? void 0 : discount.id;
582
+ }));
583
+ originalDiscounts = ((_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 || (_this$store$discount7 = _this$store$discount6.getOriginalDiscountList) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.call(_this$store$discount6)) || [];
584
+ nextOriginalDiscounts = [].concat(_toConsumableArray(scanDiscounts), _toConsumableArray(originalDiscounts.filter(function (discount) {
585
+ return !scanDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id);
586
+ })));
587
+ _context4.next = 8;
588
+ return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 || (_this$store$discount9 = _this$store$discount8.setOriginalDiscountList) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.call(_this$store$discount8, nextOriginalDiscounts);
589
+ case 8:
590
+ case "end":
591
+ return _context4.stop();
592
+ }
593
+ }, _callee4, this);
594
+ }));
595
+ function syncScannedDiscountsToOriginalDiscountList(_x4) {
596
+ return _syncScannedDiscountsToOriginalDiscountList.apply(this, arguments);
597
+ }
598
+ return syncScannedDiscountsToOriginalDiscountList;
599
+ }()
574
600
  }, {
575
601
  key: "ensureEditDiscountConfigForProductChange",
576
602
  value: function () {
577
- var _ensureEditDiscountConfigForProductChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(tempOrder) {
578
- var _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _this$store$discount6;
603
+ var _ensureEditDiscountConfigForProductChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(tempOrder) {
604
+ var _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _this$store$discount10;
579
605
  var orderId, customerId, currentDiscountList, hasRuntimeDiscounts;
580
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
581
- while (1) switch (_context4.prev = _context4.next) {
606
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
607
+ while (1) switch (_context5.prev = _context5.next) {
582
608
  case 0:
583
609
  orderId = tempOrder.order_id;
584
610
  customerId = Number(tempOrder.customer_id || ((_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || ((_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.customerSnapshot) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.id) || ((_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.customerSnapshot) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.customer_id) || 0);
585
611
  if (!(!orderId || !customerId || customerId === 1)) {
586
- _context4.next = 4;
612
+ _context5.next = 4;
587
613
  break;
588
614
  }
589
- return _context4.abrupt("return");
615
+ return _context5.abrupt("return");
590
616
  case 4:
591
- currentDiscountList = ((_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 ? void 0 : _this$store$discount6.getDiscountList()) || [];
617
+ currentDiscountList = ((_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 ? void 0 : _this$store$discount10.getDiscountList()) || [];
592
618
  hasRuntimeDiscounts = currentDiscountList.some(function (discount) {
593
619
  return !(discount !== null && discount !== void 0 && discount.isEditMode);
594
620
  });
595
621
  if (!hasRuntimeDiscounts) {
596
- _context4.next = 8;
622
+ _context5.next = 8;
597
623
  break;
598
624
  }
599
- return _context4.abrupt("return");
625
+ return _context5.abrupt("return");
600
626
  case 8:
601
- _context4.next = 10;
627
+ _context5.next = 10;
602
628
  return this.loadDiscountConfig({
603
629
  customerId: customerId,
604
630
  action: 'edit',
@@ -607,11 +633,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
607
633
  });
608
634
  case 10:
609
635
  case "end":
610
- return _context4.stop();
636
+ return _context5.stop();
611
637
  }
612
- }, _callee4, this);
638
+ }, _callee5, this);
613
639
  }));
614
- function ensureEditDiscountConfigForProductChange(_x4) {
640
+ function ensureEditDiscountConfigForProductChange(_x5) {
615
641
  return _ensureEditDiscountConfigForProductChange.apply(this, arguments);
616
642
  }
617
643
  return ensureEditDiscountConfigForProductChange;
@@ -619,35 +645,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
619
645
  }, {
620
646
  key: "scanCode",
621
647
  value: function () {
622
- var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
623
- var _this$store$discount7, _tempOrder$holder, _this$store$summary;
624
- var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$discount8;
625
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
626
- while (1) switch (_context5.prev = _context5.next) {
648
+ var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
649
+ var _this$store$discount11, _tempOrder$holder, _this$store$summary;
650
+ var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$discount12;
651
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
652
+ while (1) switch (_context6.prev = _context6.next) {
627
653
  case 0:
628
- _context5.next = 2;
629
- return (_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.batchSearch(code, {
654
+ _context6.next = 2;
655
+ return (_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.batchSearch(code, {
630
656
  customerId: customerId
631
657
  });
632
658
  case 2:
633
- _context5.t0 = _context5.sent;
634
- if (_context5.t0) {
635
- _context5.next = 5;
659
+ _context6.t0 = _context6.sent;
660
+ if (_context6.t0) {
661
+ _context6.next = 5;
636
662
  break;
637
663
  }
638
- _context5.t0 = {
664
+ _context6.t0 = {
639
665
  discountList: [],
640
666
  unavailableReasonKey: null
641
667
  };
642
668
  case 5:
643
- resultDiscountWithReason = _context5.t0;
669
+ resultDiscountWithReason = _context6.t0;
644
670
  resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
645
671
  rulesModule = this.store.rules;
646
672
  if (rulesModule) {
647
- _context5.next = 10;
673
+ _context6.next = 10;
648
674
  break;
649
675
  }
650
- return _context5.abrupt("return", {
676
+ return _context6.abrupt("return", {
651
677
  type: 'clientCalc',
652
678
  isAvailable: false,
653
679
  discountList: this.getDiscountList(),
@@ -656,10 +682,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
656
682
  });
657
683
  case 10:
658
684
  if (resultDiscountList.length) {
659
- _context5.next = 12;
685
+ _context6.next = 12;
660
686
  break;
661
687
  }
662
- return _context5.abrupt("return", {
688
+ return _context6.abrupt("return", {
663
689
  type: 'server',
664
690
  isAvailable: false,
665
691
  discountList: this.getDiscountList(),
@@ -680,16 +706,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
680
706
  return m.id === n.id;
681
707
  });
682
708
  }))) {
683
- _context5.next = 16;
709
+ _context6.next = 18;
684
710
  break;
685
711
  }
686
- return _context5.abrupt("return", {
712
+ _context6.next = 17;
713
+ return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
714
+ case 17:
715
+ return _context6.abrupt("return", {
687
716
  type: 'clientCalc',
688
717
  isAvailable: true,
689
718
  discountList: this.getDiscountList(),
690
719
  scannedDiscountList: resultDiscountList
691
720
  });
692
- case 16:
721
+ case 18:
693
722
  tempOrder = this.store.tempOrder;
694
723
  holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
695
724
  _ref13 = rulesModule.isDiscountListAvailable({
@@ -705,24 +734,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
705
734
  isAvailable: false,
706
735
  discountList: this.getDiscountList()
707
736
  }, isAvailable = _ref13.isAvailable, newDiscountList = _ref13.discountList, unavailableReason = _ref13.unavailableReason;
708
- if (isAvailable && newDiscountList) {
709
- (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 || _this$store$discount8.setDiscountList(newDiscountList);
710
- this.applyDiscount();
737
+ if (!(isAvailable && newDiscountList)) {
738
+ _context6.next = 26;
739
+ break;
711
740
  }
712
- return _context5.abrupt("return", {
741
+ (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 || _this$store$discount12.setDiscountList(newDiscountList);
742
+ this.applyDiscount();
743
+ _context6.next = 26;
744
+ return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
745
+ case 26:
746
+ return _context6.abrupt("return", {
713
747
  type: 'clientCalc',
714
748
  isAvailable: isAvailable || false,
715
749
  discountList: newDiscountList || this.getDiscountList(),
716
750
  scannedDiscountList: resultDiscountList,
717
751
  unavailableReason: unavailableReason
718
752
  });
719
- case 21:
753
+ case 27:
720
754
  case "end":
721
- return _context5.stop();
755
+ return _context6.stop();
722
756
  }
723
- }, _callee5, this);
757
+ }, _callee6, this);
724
758
  }));
725
- function scanCode(_x5, _x6) {
759
+ function scanCode(_x6, _x7) {
726
760
  return _scanCode.apply(this, arguments);
727
761
  }
728
762
  return scanCode;
@@ -730,7 +764,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
730
764
  }, {
731
765
  key: "applyDiscount",
732
766
  value: function applyDiscount(options) {
733
- var _this$store$discount9,
767
+ var _this$store$discount13,
734
768
  _this$store$summary2,
735
769
  _this2 = this;
736
770
  var tempOrder = this.store.tempOrder;
@@ -740,7 +774,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
740
774
  if (!tempOrder) return;
741
775
  this.syncLinkedBookingHoldersToProducts(tempOrder);
742
776
  delete tempOrder.discount_list;
743
- var discountList = ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.getDiscountList()) || [];
777
+ var discountList = ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.getDiscountList()) || [];
744
778
  var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
745
779
  if (shouldSkipDiscountCalculation) return;
746
780
  var rulesModule = this.store.rules;
@@ -772,9 +806,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
772
806
  }));
773
807
  }
774
808
  if (result !== null && result !== void 0 && result.discountList) {
775
- var _this$store$discount10;
809
+ var _this$store$discount14;
776
810
  OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
777
- (_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 || _this$store$discount10.setDiscountList(result.discountList);
811
+ (_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 || _this$store$discount14.setDiscountList(result.discountList);
778
812
  }
779
813
  this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
780
814
  return _this2.productHasCustomerBoundDiscount(product);
@@ -836,42 +870,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
836
870
  }, {
837
871
  key: "applyPromotion",
838
872
  value: (function () {
839
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
873
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
840
874
  var _this$promotionEvalua,
841
875
  _this$promotionEvalua2,
842
876
  _this3 = this;
843
877
  var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
844
- return _regeneratorRuntime().wrap(function _callee6$(_context8) {
845
- while (1) switch (_context8.prev = _context8.next) {
878
+ return _regeneratorRuntime().wrap(function _callee7$(_context9) {
879
+ while (1) switch (_context9.prev = _context9.next) {
846
880
  case 0:
847
881
  if (!this.isApplyingPromotion) {
848
- _context8.next = 2;
882
+ _context9.next = 2;
849
883
  break;
850
884
  }
851
- return _context8.abrupt("return");
885
+ return _context9.abrupt("return");
852
886
  case 2:
853
887
  if (this.promotionEvaluator) {
854
- _context8.next = 4;
888
+ _context9.next = 4;
855
889
  break;
856
890
  }
857
- return _context8.abrupt("return");
891
+ return _context9.abrupt("return");
858
892
  case 4:
859
893
  tempOrder = this.store.tempOrder;
860
894
  if (tempOrder) {
861
- _context8.next = 7;
895
+ _context9.next = 7;
862
896
  break;
863
897
  }
864
- return _context8.abrupt("return");
898
+ return _context9.abrupt("return");
865
899
  case 7:
866
900
  strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
867
901
  if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
868
- _context8.next = 10;
902
+ _context9.next = 10;
869
903
  break;
870
904
  }
871
- return _context8.abrupt("return");
905
+ return _context9.abrupt("return");
872
906
  case 10:
873
907
  this.isApplyingPromotion = true;
874
- _context8.prev = 11;
908
+ _context9.prev = 11;
875
909
  result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
876
910
  if (result.giftActions.toRemove.length > 0) {
877
911
  removeSet = new Set(result.giftActions.toRemove.map(String));
@@ -883,20 +917,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
883
917
 
884
918
  // step 2: toReduce —— 调整数量
885
919
  _iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
886
- _context8.prev = 15;
920
+ _context9.prev = 15;
887
921
  _iterator3.s();
888
922
  case 17:
889
923
  if ((_step3 = _iterator3.n()).done) {
890
- _context8.next = 37;
924
+ _context9.next = 37;
891
925
  break;
892
926
  }
893
927
  reduce = _step3.value;
894
928
  _iterator6 = _createForOfIteratorHelper(reduce.items);
895
- _context8.prev = 20;
929
+ _context9.prev = 20;
896
930
  _loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
897
931
  var item, product;
898
- return _regeneratorRuntime().wrap(function _loop2$(_context7) {
899
- while (1) switch (_context7.prev = _context7.next) {
932
+ return _regeneratorRuntime().wrap(function _loop2$(_context8) {
933
+ while (1) switch (_context8.prev = _context8.next) {
900
934
  case 0:
901
935
  item = _step6.value;
902
936
  product = result.products.find(function (p) {
@@ -907,52 +941,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
907
941
  }
908
942
  case 3:
909
943
  case "end":
910
- return _context7.stop();
944
+ return _context8.stop();
911
945
  }
912
946
  }, _loop2);
913
947
  });
914
948
  _iterator6.s();
915
949
  case 23:
916
950
  if ((_step6 = _iterator6.n()).done) {
917
- _context8.next = 27;
951
+ _context9.next = 27;
918
952
  break;
919
953
  }
920
- return _context8.delegateYield(_loop2(), "t0", 25);
954
+ return _context9.delegateYield(_loop2(), "t0", 25);
921
955
  case 25:
922
- _context8.next = 23;
956
+ _context9.next = 23;
923
957
  break;
924
958
  case 27:
925
- _context8.next = 32;
959
+ _context9.next = 32;
926
960
  break;
927
961
  case 29:
928
- _context8.prev = 29;
929
- _context8.t1 = _context8["catch"](20);
930
- _iterator6.e(_context8.t1);
962
+ _context9.prev = 29;
963
+ _context9.t1 = _context9["catch"](20);
964
+ _iterator6.e(_context9.t1);
931
965
  case 32:
932
- _context8.prev = 32;
966
+ _context9.prev = 32;
933
967
  _iterator6.f();
934
- return _context8.finish(32);
968
+ return _context9.finish(32);
935
969
  case 35:
936
- _context8.next = 17;
970
+ _context9.next = 17;
937
971
  break;
938
972
  case 37:
939
- _context8.next = 42;
973
+ _context9.next = 42;
940
974
  break;
941
975
  case 39:
942
- _context8.prev = 39;
943
- _context8.t2 = _context8["catch"](15);
944
- _iterator3.e(_context8.t2);
976
+ _context9.prev = 39;
977
+ _context9.t2 = _context9["catch"](15);
978
+ _iterator3.e(_context9.t2);
945
979
  case 42:
946
- _context8.prev = 42;
980
+ _context9.prev = 42;
947
981
  _iterator3.f();
948
- return _context8.finish(42);
982
+ return _context9.finish(42);
949
983
  case 45:
950
984
  if (!(result.giftActions.toAdd.length > 0)) {
951
- _context8.next = 68;
985
+ _context9.next = 68;
952
986
  break;
953
987
  }
954
988
  if (this.giftSelectResolver) {
955
- _context8.next = 50;
989
+ _context9.next = 50;
956
990
  break;
957
991
  }
958
992
  if (result.giftActions.toAdd.some(function (g) {
@@ -963,19 +997,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
963
997
  } else {
964
998
  console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
965
999
  }
966
- _context8.next = 68;
1000
+ _context9.next = 68;
967
1001
  break;
968
1002
  case 50:
969
1003
  _iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
970
- _context8.prev = 51;
1004
+ _context9.prev = 51;
971
1005
  _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
972
1006
  var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
973
- return _regeneratorRuntime().wrap(function _loop$(_context6) {
974
- while (1) switch (_context6.prev = _context6.next) {
1007
+ return _regeneratorRuntime().wrap(function _loop$(_context7) {
1008
+ while (1) switch (_context7.prev = _context7.next) {
975
1009
  case 0:
976
1010
  addAction = _step4.value;
977
1011
  if (!(addAction.giftOptions.length === 1)) {
978
- _context6.next = 6;
1012
+ _context7.next = 6;
979
1013
  break;
980
1014
  }
981
1015
  sameStrategy = result.products.find(function (p) {
@@ -983,14 +1017,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
983
1017
  return ((_p$metadata = p.metadata) === null || _p$metadata === void 0 || (_p$metadata = _p$metadata._giftInfo) === null || _p$metadata === void 0 ? void 0 : _p$metadata.strategyId) === addAction.strategyId;
984
1018
  });
985
1019
  if (!(sameStrategy && !sameStrategy.booking_uid && !((_sameStrategy$metadat = sameStrategy.metadata) !== null && _sameStrategy$metadat !== void 0 && _sameStrategy$metadat.booking_uid))) {
986
- _context6.next = 6;
1020
+ _context7.next = 6;
987
1021
  break;
988
1022
  }
989
1023
  sameStrategy.num = (Number(sameStrategy.num) || 0) + (addAction.giftCount || 1);
990
- return _context6.abrupt("return", 1);
1024
+ return _context7.abrupt("return", 1);
991
1025
  case 6:
992
- _context6.prev = 6;
993
- _context6.next = 9;
1026
+ _context7.prev = 6;
1027
+ _context7.next = 9;
994
1028
  return _this3.giftSelectResolver({
995
1029
  strategyId: addAction.strategyId,
996
1030
  strategyName: addAction.strategyName,
@@ -999,31 +1033,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
999
1033
  sourceProductIds: addAction.sourceProductIds
1000
1034
  });
1001
1035
  case 9:
1002
- giftResult = _context6.sent;
1036
+ giftResult = _context7.sent;
1003
1037
  giftProducts = Array.isArray(giftResult) ? giftResult : giftResult === null || giftResult === void 0 ? void 0 : giftResult.products;
1004
1038
  giftBookings = Array.isArray(giftResult) ? [] : (giftResult === null || giftResult === void 0 ? void 0 : giftResult.bookings) || [];
1005
1039
  if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
1006
- _context6.next = 37;
1040
+ _context7.next = 37;
1007
1041
  break;
1008
1042
  }
1009
1043
  _iterator5 = _createForOfIteratorHelper(giftProducts.entries());
1010
- _context6.prev = 14;
1044
+ _context7.prev = 14;
1011
1045
  _iterator5.s();
1012
1046
  case 16:
1013
1047
  if ((_step5 = _iterator5.n()).done) {
1014
- _context6.next = 29;
1048
+ _context7.next = 29;
1015
1049
  break;
1016
1050
  }
1017
1051
  _step5$value = _slicedToArray(_step5.value, 2), index = _step5$value[0], gp = _step5$value[1];
1018
1052
  if (gp) {
1019
- _context6.next = 20;
1053
+ _context7.next = 20;
1020
1054
  break;
1021
1055
  }
1022
- return _context6.abrupt("continue", 27);
1056
+ return _context7.abrupt("continue", 27);
1023
1057
  case 20:
1024
1058
  booking = giftBookings[index];
1025
1059
  if (!booking) {
1026
- _context6.next = 26;
1060
+ _context7.next = 26;
1027
1061
  break;
1028
1062
  }
1029
1063
  linked = _this3.createLinkedProductAndBooking({
@@ -1032,65 +1066,65 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1032
1066
  });
1033
1067
  result.products.push(linked.product);
1034
1068
  tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
1035
- return _context6.abrupt("continue", 27);
1069
+ return _context7.abrupt("continue", 27);
1036
1070
  case 26:
1037
1071
  // normalize 略过:调用方应保证返回完整 OrderProduct。
1038
1072
  result.products.push(gp);
1039
1073
  case 27:
1040
- _context6.next = 16;
1074
+ _context7.next = 16;
1041
1075
  break;
1042
1076
  case 29:
1043
- _context6.next = 34;
1077
+ _context7.next = 34;
1044
1078
  break;
1045
1079
  case 31:
1046
- _context6.prev = 31;
1047
- _context6.t0 = _context6["catch"](14);
1048
- _iterator5.e(_context6.t0);
1080
+ _context7.prev = 31;
1081
+ _context7.t0 = _context7["catch"](14);
1082
+ _iterator5.e(_context7.t0);
1049
1083
  case 34:
1050
- _context6.prev = 34;
1084
+ _context7.prev = 34;
1051
1085
  _iterator5.f();
1052
- return _context6.finish(34);
1086
+ return _context7.finish(34);
1053
1087
  case 37:
1054
- _context6.next = 42;
1088
+ _context7.next = 42;
1055
1089
  break;
1056
1090
  case 39:
1057
- _context6.prev = 39;
1058
- _context6.t1 = _context6["catch"](6);
1091
+ _context7.prev = 39;
1092
+ _context7.t1 = _context7["catch"](6);
1059
1093
  // 用户取消 / 选择失败 → 视为放弃本次新增
1060
- console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context6.t1);
1094
+ console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context7.t1);
1061
1095
  case 42:
1062
1096
  case "end":
1063
- return _context6.stop();
1097
+ return _context7.stop();
1064
1098
  }
1065
1099
  }, _loop, null, [[6, 39], [14, 31, 34, 37]]);
1066
1100
  });
1067
1101
  _iterator4.s();
1068
1102
  case 54:
1069
1103
  if ((_step4 = _iterator4.n()).done) {
1070
- _context8.next = 60;
1104
+ _context9.next = 60;
1071
1105
  break;
1072
1106
  }
1073
- return _context8.delegateYield(_loop(), "t3", 56);
1107
+ return _context9.delegateYield(_loop(), "t3", 56);
1074
1108
  case 56:
1075
- if (!_context8.t3) {
1076
- _context8.next = 58;
1109
+ if (!_context9.t3) {
1110
+ _context9.next = 58;
1077
1111
  break;
1078
1112
  }
1079
- return _context8.abrupt("continue", 58);
1113
+ return _context9.abrupt("continue", 58);
1080
1114
  case 58:
1081
- _context8.next = 54;
1115
+ _context9.next = 54;
1082
1116
  break;
1083
1117
  case 60:
1084
- _context8.next = 65;
1118
+ _context9.next = 65;
1085
1119
  break;
1086
1120
  case 62:
1087
- _context8.prev = 62;
1088
- _context8.t4 = _context8["catch"](51);
1089
- _iterator4.e(_context8.t4);
1121
+ _context9.prev = 62;
1122
+ _context9.t4 = _context9["catch"](51);
1123
+ _iterator4.e(_context9.t4);
1090
1124
  case 65:
1091
- _context8.prev = 65;
1125
+ _context9.prev = 65;
1092
1126
  _iterator4.f();
1093
- return _context8.finish(65);
1127
+ return _context9.finish(65);
1094
1128
  case 68:
1095
1129
  tempOrder.products = result.products;
1096
1130
  this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
@@ -1109,21 +1143,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1109
1143
  products: tempOrder.products
1110
1144
  };
1111
1145
  this.effectsEmit('onPromotionApplied', payload);
1112
- _context8.next = 78;
1146
+ _context9.next = 78;
1113
1147
  break;
1114
1148
  case 75:
1115
- _context8.prev = 75;
1116
- _context8.t5 = _context8["catch"](11);
1117
- console.error('[OrderModule] applyPromotion failed', _context8.t5);
1149
+ _context9.prev = 75;
1150
+ _context9.t5 = _context9["catch"](11);
1151
+ console.error('[OrderModule] applyPromotion failed', _context9.t5);
1118
1152
  case 78:
1119
- _context8.prev = 78;
1153
+ _context9.prev = 78;
1120
1154
  this.isApplyingPromotion = false;
1121
- return _context8.finish(78);
1155
+ return _context9.finish(78);
1122
1156
  case 81:
1123
1157
  case "end":
1124
- return _context8.stop();
1158
+ return _context9.stop();
1125
1159
  }
1126
- }, _callee6, this, [[11, 75, 78, 81], [15, 39, 42, 45], [20, 29, 32, 35], [51, 62, 65, 68]]);
1160
+ }, _callee7, this, [[11, 75, 78, 81], [15, 39, 42, 45], [20, 29, 32, 35], [51, 62, 65, 68]]);
1127
1161
  }));
1128
1162
  function applyPromotion() {
1129
1163
  return _applyPromotion.apply(this, arguments);
@@ -1245,14 +1279,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1245
1279
  }, {
1246
1280
  key: "saveDraft",
1247
1281
  value: function () {
1248
- var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1249
- return _regeneratorRuntime().wrap(function _callee7$(_context9) {
1250
- while (1) switch (_context9.prev = _context9.next) {
1282
+ var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1283
+ return _regeneratorRuntime().wrap(function _callee8$(_context10) {
1284
+ while (1) switch (_context10.prev = _context10.next) {
1251
1285
  case 0:
1252
1286
  case "end":
1253
- return _context9.stop();
1287
+ return _context10.stop();
1254
1288
  }
1255
- }, _callee7);
1289
+ }, _callee8);
1256
1290
  }));
1257
1291
  function saveDraft() {
1258
1292
  return _saveDraft.apply(this, arguments);
@@ -1267,18 +1301,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1267
1301
  }, {
1268
1302
  key: "hydrateTempOrderFromLocalRecord",
1269
1303
  value: function () {
1270
- var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(record) {
1271
- return _regeneratorRuntime().wrap(function _callee8$(_context10) {
1272
- while (1) switch (_context10.prev = _context10.next) {
1304
+ var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(record) {
1305
+ return _regeneratorRuntime().wrap(function _callee9$(_context11) {
1306
+ while (1) switch (_context11.prev = _context11.next) {
1273
1307
  case 0:
1274
- return _context10.abrupt("return", this.hydrateTempOrderFromRecord(record));
1308
+ return _context11.abrupt("return", this.hydrateTempOrderFromRecord(record));
1275
1309
  case 1:
1276
1310
  case "end":
1277
- return _context10.stop();
1311
+ return _context11.stop();
1278
1312
  }
1279
- }, _callee8, this);
1313
+ }, _callee9, this);
1280
1314
  }));
1281
- function hydrateTempOrderFromLocalRecord(_x7) {
1315
+ function hydrateTempOrderFromLocalRecord(_x8) {
1282
1316
  return _hydrateTempOrderFromLocalRecord.apply(this, arguments);
1283
1317
  }
1284
1318
  return hydrateTempOrderFromLocalRecord;
@@ -2173,7 +2207,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2173
2207
  }, {
2174
2208
  key: "restoreOrder",
2175
2209
  value: function restoreOrder() {
2176
- var _this$store$discount11, _this$store$discount12;
2210
+ var _this$store$discount15, _this$store$discount16;
2177
2211
  this.logInfo('restoreOrder start', {});
2178
2212
  var freshTempOrder = this.createDefaultTempOrderInstance();
2179
2213
  this.ensureExternalSaleNumber(freshTempOrder);
@@ -2181,8 +2215,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2181
2215
  this.store.summary = createEmptySummary();
2182
2216
  this.store.lastOrderInfo = undefined;
2183
2217
  this.store.syncState = undefined;
2184
- void ((_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.setOriginalDiscountList([]));
2185
- void ((_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList([]));
2218
+ void ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.setOriginalDiscountList([]));
2219
+ void ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setDiscountList([]));
2186
2220
  this.persistTempOrder();
2187
2221
  return freshTempOrder;
2188
2222
  }
@@ -2194,13 +2228,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2194
2228
  }, {
2195
2229
  key: "replaceTempOrder",
2196
2230
  value: function () {
2197
- var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(tempOrder, options) {
2231
+ var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(tempOrder, options) {
2198
2232
  var nextTempOrder;
2199
- return _regeneratorRuntime().wrap(function _callee9$(_context11) {
2200
- while (1) switch (_context11.prev = _context11.next) {
2233
+ return _regeneratorRuntime().wrap(function _callee10$(_context12) {
2234
+ while (1) switch (_context12.prev = _context12.next) {
2201
2235
  case 0:
2202
2236
  if (isTempOrder(tempOrder)) {
2203
- _context11.next = 2;
2237
+ _context12.next = 2;
2204
2238
  break;
2205
2239
  }
2206
2240
  throw new Error('无效的 tempOrder 数据');
@@ -2210,15 +2244,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2210
2244
  });
2211
2245
  this.store.tempOrder = nextTempOrder;
2212
2246
  if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
2213
- _context11.next = 9;
2247
+ _context12.next = 9;
2214
2248
  break;
2215
2249
  }
2216
- _context11.next = 7;
2250
+ _context12.next = 7;
2217
2251
  return this.recalculateSummary({
2218
2252
  createIfMissing: false
2219
2253
  });
2220
2254
  case 7:
2221
- _context11.next = 10;
2255
+ _context12.next = 10;
2222
2256
  break;
2223
2257
  case 9:
2224
2258
  this.store.summary = createEmptySummary();
@@ -2227,20 +2261,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2227
2261
  this.persistTempOrder();
2228
2262
  }
2229
2263
  if (!(options !== null && options !== void 0 && options.saveDraft)) {
2230
- _context11.next = 14;
2264
+ _context12.next = 14;
2231
2265
  break;
2232
2266
  }
2233
- _context11.next = 14;
2267
+ _context12.next = 14;
2234
2268
  return this.saveDraft();
2235
2269
  case 14:
2236
- return _context11.abrupt("return", nextTempOrder);
2270
+ return _context12.abrupt("return", nextTempOrder);
2237
2271
  case 15:
2238
2272
  case "end":
2239
- return _context11.stop();
2273
+ return _context12.stop();
2240
2274
  }
2241
- }, _callee9, this);
2275
+ }, _callee10, this);
2242
2276
  }));
2243
- function replaceTempOrder(_x8, _x9) {
2277
+ function replaceTempOrder(_x9, _x10) {
2244
2278
  return _replaceTempOrder.apply(this, arguments);
2245
2279
  }
2246
2280
  return replaceTempOrder;
@@ -2326,32 +2360,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2326
2360
  }, {
2327
2361
  key: "addNewOrder",
2328
2362
  value: function () {
2329
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
2363
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
2330
2364
  var tempOrder;
2331
- return _regeneratorRuntime().wrap(function _callee10$(_context12) {
2332
- while (1) switch (_context12.prev = _context12.next) {
2365
+ return _regeneratorRuntime().wrap(function _callee11$(_context13) {
2366
+ while (1) switch (_context13.prev = _context13.next) {
2333
2367
  case 0:
2334
2368
  tempOrder = this.ensureTempOrder();
2335
2369
  this.ensureExternalSaleNumber(tempOrder);
2336
- _context12.next = 4;
2370
+ _context13.next = 4;
2337
2371
  return this.recalculateSummary({
2338
2372
  createIfMissing: true
2339
2373
  });
2340
2374
  case 4:
2341
2375
  this.persistTempOrder();
2342
2376
  if (!this.draftPersistEnabled) {
2343
- _context12.next = 8;
2377
+ _context13.next = 8;
2344
2378
  break;
2345
2379
  }
2346
- _context12.next = 8;
2380
+ _context13.next = 8;
2347
2381
  return this.saveDraft();
2348
2382
  case 8:
2349
- return _context12.abrupt("return", tempOrder);
2383
+ return _context13.abrupt("return", tempOrder);
2350
2384
  case 9:
2351
2385
  case "end":
2352
- return _context12.stop();
2386
+ return _context13.stop();
2353
2387
  }
2354
- }, _callee10, this);
2388
+ }, _callee11, this);
2355
2389
  }));
2356
2390
  function addNewOrder() {
2357
2391
  return _addNewOrder.apply(this, arguments);
@@ -2703,18 +2737,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2703
2737
  }, {
2704
2738
  key: "recalculateSummary",
2705
2739
  value: function () {
2706
- var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
2740
+ var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(options) {
2707
2741
  var _this$otherParams2, _ref47, _salesSummaryResult$e;
2708
2742
  var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
2709
- return _regeneratorRuntime().wrap(function _callee11$(_context13) {
2710
- while (1) switch (_context13.prev = _context13.next) {
2743
+ return _regeneratorRuntime().wrap(function _callee12$(_context14) {
2744
+ while (1) switch (_context14.prev = _context14.next) {
2711
2745
  case 0:
2712
2746
  tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
2713
2747
  if (tempOrder) {
2714
- _context13.next = 3;
2748
+ _context14.next = 3;
2715
2749
  break;
2716
2750
  }
2717
- return _context13.abrupt("return", null);
2751
+ return _context14.abrupt("return", null);
2718
2752
  case 3:
2719
2753
  this.sanitizeTempOrderProducts(tempOrder);
2720
2754
  originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
@@ -2722,10 +2756,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2722
2756
  shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
2723
2757
  snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
2724
2758
  if (!snapshotSummary) {
2725
- _context13.next = 10;
2759
+ _context14.next = 10;
2726
2760
  break;
2727
2761
  }
2728
- return _context13.abrupt("return", snapshotSummary);
2762
+ return _context14.abrupt("return", snapshotSummary);
2729
2763
  case 10:
2730
2764
  shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
2731
2765
  summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
@@ -2737,7 +2771,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2737
2771
  totalRefundAmount = existedSummary.total_refund_amount || '0.00';
2738
2772
  paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
2739
2773
  if (salesSummary) {
2740
- _context13.next = 26;
2774
+ _context14.next = 26;
2741
2775
  break;
2742
2776
  }
2743
2777
  emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
@@ -2763,9 +2797,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2763
2797
  previousSummary: existedSummary,
2764
2798
  summary: emptySummary
2765
2799
  });
2766
- return _context13.abrupt("return", this.store.summary);
2800
+ return _context14.abrupt("return", this.store.summary);
2767
2801
  case 26:
2768
- _context13.next = 28;
2802
+ _context14.next = 28;
2769
2803
  return salesSummary.getSummary(_objectSpread({
2770
2804
  products: summaryProducts,
2771
2805
  isPriceIncludeTax: tempOrder.is_price_include_tax,
@@ -2774,7 +2808,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2774
2808
  channel: this.otherParams.channel
2775
2809
  } : {}));
2776
2810
  case 28:
2777
- salesSummaryResult = _context13.sent;
2811
+ salesSummaryResult = _context14.sent;
2778
2812
  if (shouldFullRecalculateFromSnapshot) {
2779
2813
  tempOrder.products = summaryProducts;
2780
2814
  }
@@ -2819,14 +2853,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2819
2853
  previousSummary: existedSummary,
2820
2854
  summary: summary
2821
2855
  });
2822
- return _context13.abrupt("return", this.store.summary);
2856
+ return _context14.abrupt("return", this.store.summary);
2823
2857
  case 46:
2824
2858
  case "end":
2825
- return _context13.stop();
2859
+ return _context14.stop();
2826
2860
  }
2827
- }, _callee11, this);
2861
+ }, _callee12, this);
2828
2862
  }));
2829
- function recalculateSummary(_x10) {
2863
+ function recalculateSummary(_x11) {
2830
2864
  return _recalculateSummary.apply(this, arguments);
2831
2865
  }
2832
2866
  return recalculateSummary;
@@ -2834,30 +2868,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2834
2868
  }, {
2835
2869
  key: "getOrderSummary",
2836
2870
  value: function () {
2837
- var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
2871
+ var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
2838
2872
  var summary;
2839
- return _regeneratorRuntime().wrap(function _callee12$(_context14) {
2840
- while (1) switch (_context14.prev = _context14.next) {
2873
+ return _regeneratorRuntime().wrap(function _callee13$(_context15) {
2874
+ while (1) switch (_context15.prev = _context15.next) {
2841
2875
  case 0:
2842
- _context14.next = 2;
2876
+ _context15.next = 2;
2843
2877
  return this.recalculateSummary({
2844
2878
  createIfMissing: true
2845
2879
  });
2846
2880
  case 2:
2847
- summary = _context14.sent;
2881
+ summary = _context15.sent;
2848
2882
  if (summary) {
2849
- _context14.next = 5;
2883
+ _context15.next = 5;
2850
2884
  break;
2851
2885
  }
2852
- return _context14.abrupt("return", createEmptySummary());
2886
+ return _context15.abrupt("return", createEmptySummary());
2853
2887
  case 5:
2854
2888
  this.persistTempOrder();
2855
- return _context14.abrupt("return", summary);
2889
+ return _context15.abrupt("return", summary);
2856
2890
  case 7:
2857
2891
  case "end":
2858
- return _context14.stop();
2892
+ return _context15.stop();
2859
2893
  }
2860
- }, _callee12, this);
2894
+ }, _callee13, this);
2861
2895
  }));
2862
2896
  function getOrderSummary() {
2863
2897
  return _getOrderSummary.apply(this, arguments);
@@ -2881,23 +2915,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2881
2915
  }, {
2882
2916
  key: "syncTempOrderNoteToRemote",
2883
2917
  value: function () {
2884
- var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderId, note) {
2885
- return _regeneratorRuntime().wrap(function _callee13$(_context15) {
2886
- while (1) switch (_context15.prev = _context15.next) {
2918
+ var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderId, note) {
2919
+ return _regeneratorRuntime().wrap(function _callee14$(_context16) {
2920
+ while (1) switch (_context16.prev = _context16.next) {
2887
2921
  case 0:
2888
- _context15.next = 2;
2922
+ _context16.next = 2;
2889
2923
  return this.request.put("/order/order/".concat(orderId, "/note"), {
2890
2924
  note: note
2891
2925
  });
2892
2926
  case 2:
2893
- return _context15.abrupt("return", note);
2927
+ return _context16.abrupt("return", note);
2894
2928
  case 3:
2895
2929
  case "end":
2896
- return _context15.stop();
2930
+ return _context16.stop();
2897
2931
  }
2898
- }, _callee13, this);
2932
+ }, _callee14, this);
2899
2933
  }));
2900
- function syncTempOrderNoteToRemote(_x11, _x12) {
2934
+ function syncTempOrderNoteToRemote(_x12, _x13) {
2901
2935
  return _syncTempOrderNoteToRemote.apply(this, arguments);
2902
2936
  }
2903
2937
  return syncTempOrderNoteToRemote;
@@ -3005,11 +3039,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3005
3039
  }, {
3006
3040
  key: "shouldSkipDiscountCalculation",
3007
3041
  value: function shouldSkipDiscountCalculation(tempOrder) {
3008
- var _this$store$discount13,
3009
- _this$store$discount14,
3042
+ var _this$store$discount17,
3043
+ _this$store$discount18,
3010
3044
  _this17 = this;
3011
3045
  if (this.hasActiveCustomerBoundDiscount) return false;
3012
- var discountList = ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 || (_this$store$discount14 = _this$store$discount13.getDiscountList) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.call(_this$store$discount13)) || [];
3046
+ var discountList = ((_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || (_this$store$discount18 = _this$store$discount17.getDiscountList) === null || _this$store$discount18 === void 0 ? void 0 : _this$store$discount18.call(_this$store$discount17)) || [];
3013
3047
  if (discountList.length > 0) return false;
3014
3048
  return !(tempOrder.products || []).some(function (product) {
3015
3049
  return _this17.productHasCustomerBoundDiscount(product);
@@ -3130,7 +3164,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3130
3164
  }
3131
3165
  var nextCustomerId = (_tempOrder$customer_i5 = tempOrder.customer_id) !== null && _tempOrder$customer_i5 !== void 0 ? _tempOrder$customer_i5 : null;
3132
3166
  if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
3133
- this.store.availableWalletIds = [];
3134
3167
  clearTempOrderHolderAssignments(tempOrder);
3135
3168
  this.clearCustomerBoundDiscounts(tempOrder);
3136
3169
  this.applyDiscount();
@@ -3175,7 +3208,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3175
3208
  tempOrder.email = '';
3176
3209
  tempOrder.customer = null;
3177
3210
  if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
3178
- this.store.availableWalletIds = [];
3179
3211
  this.clearCustomerBoundDiscounts(tempOrder);
3180
3212
  this.persistTempOrder();
3181
3213
  this.saveDraftInBackground();
@@ -3475,45 +3507,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3475
3507
  }, {
3476
3508
  key: "shouldMergeProductToOrder",
3477
3509
  value: function () {
3478
- var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
3510
+ var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
3479
3511
  var _this$orderHooks;
3480
3512
  var onBeforeMergeProductToOrder, result;
3481
- return _regeneratorRuntime().wrap(function _callee14$(_context16) {
3482
- while (1) switch (_context16.prev = _context16.next) {
3513
+ return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3514
+ while (1) switch (_context17.prev = _context17.next) {
3483
3515
  case 0:
3484
3516
  onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
3485
3517
  if (onBeforeMergeProductToOrder) {
3486
- _context16.next = 3;
3518
+ _context17.next = 3;
3487
3519
  break;
3488
3520
  }
3489
- return _context16.abrupt("return", true);
3521
+ return _context17.abrupt("return", true);
3490
3522
  case 3:
3491
- _context16.next = 5;
3523
+ _context17.next = 5;
3492
3524
  return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
3493
3525
  defaultShouldMerge: true
3494
3526
  }));
3495
3527
  case 5:
3496
- result = _context16.sent;
3528
+ result = _context17.sent;
3497
3529
  if (!(typeof result === 'boolean')) {
3498
- _context16.next = 8;
3530
+ _context17.next = 8;
3499
3531
  break;
3500
3532
  }
3501
- return _context16.abrupt("return", result);
3533
+ return _context17.abrupt("return", result);
3502
3534
  case 8:
3503
3535
  if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
3504
- _context16.next = 10;
3536
+ _context17.next = 10;
3505
3537
  break;
3506
3538
  }
3507
- return _context16.abrupt("return", result.shouldMerge);
3539
+ return _context17.abrupt("return", result.shouldMerge);
3508
3540
  case 10:
3509
- return _context16.abrupt("return", true);
3541
+ return _context17.abrupt("return", true);
3510
3542
  case 11:
3511
3543
  case "end":
3512
- return _context16.stop();
3544
+ return _context17.stop();
3513
3545
  }
3514
- }, _callee14, this);
3546
+ }, _callee15, this);
3515
3547
  }));
3516
- function shouldMergeProductToOrder(_x13) {
3548
+ function shouldMergeProductToOrder(_x14) {
3517
3549
  return _shouldMergeProductToOrder.apply(this, arguments);
3518
3550
  }
3519
3551
  return shouldMergeProductToOrder;
@@ -3549,30 +3581,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3549
3581
  }, {
3550
3582
  key: "finalizeProductOrderMutation",
3551
3583
  value: function () {
3552
- var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, options) {
3553
- return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3554
- while (1) switch (_context17.prev = _context17.next) {
3584
+ var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, options) {
3585
+ return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3586
+ while (1) switch (_context18.prev = _context18.next) {
3555
3587
  case 0:
3556
3588
  this.syncTempOrderHolderFromBookings(tempOrder);
3557
3589
  if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
3558
- _context17.next = 4;
3590
+ _context18.next = 4;
3559
3591
  break;
3560
3592
  }
3561
- _context17.next = 4;
3593
+ _context18.next = 4;
3562
3594
  return this.ensureEditDiscountConfigForProductChange(tempOrder);
3563
3595
  case 4:
3564
3596
  if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
3565
- _context17.next = 7;
3597
+ _context18.next = 7;
3566
3598
  break;
3567
3599
  }
3568
- _context17.next = 7;
3600
+ _context18.next = 7;
3569
3601
  return this.applyPromotion();
3570
3602
  case 7:
3571
3603
  if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
3572
3604
  this.applyDiscount();
3573
3605
  }
3574
3606
  this.sanitizeTempOrderProducts(tempOrder);
3575
- _context17.next = 11;
3607
+ _context18.next = 11;
3576
3608
  return this.recalculateSummary({
3577
3609
  createIfMissing: true
3578
3610
  });
@@ -3580,11 +3612,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3580
3612
  this.persistTempOrder();
3581
3613
  case 12:
3582
3614
  case "end":
3583
- return _context17.stop();
3615
+ return _context18.stop();
3584
3616
  }
3585
- }, _callee15, this);
3617
+ }, _callee16, this);
3586
3618
  }));
3587
- function finalizeProductOrderMutation(_x14, _x15) {
3619
+ function finalizeProductOrderMutation(_x15, _x16) {
3588
3620
  return _finalizeProductOrderMutation.apply(this, arguments);
3589
3621
  }
3590
3622
  return finalizeProductOrderMutation;
@@ -3599,13 +3631,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3599
3631
  }, {
3600
3632
  key: "appendProductLineToTempOrder",
3601
3633
  value: (function () {
3602
- var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, product, booking) {
3634
+ var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(tempOrder, product, booking) {
3603
3635
  var _booking_uid,
3604
3636
  _metadata,
3605
3637
  _this22 = this;
3606
3638
  var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
3607
- return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3608
- while (1) switch (_context18.prev = _context18.next) {
3639
+ return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3640
+ while (1) switch (_context19.prev = _context19.next) {
3609
3641
  case 0:
3610
3642
  linked = booking ? this.createLinkedProductAndBooking({
3611
3643
  product: product,
@@ -3638,10 +3670,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3638
3670
  matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
3639
3671
  existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
3640
3672
  if (!matchedProduct) {
3641
- _context18.next = 20;
3673
+ _context19.next = 20;
3642
3674
  break;
3643
3675
  }
3644
- _context18.next = 17;
3676
+ _context19.next = 17;
3645
3677
  return this.shouldMergeProductToOrder({
3646
3678
  incomingProduct: productToAdd,
3647
3679
  normalizedIncoming: normalizedIncoming,
@@ -3653,13 +3685,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3653
3685
  booking: booking
3654
3686
  });
3655
3687
  case 17:
3656
- _context18.t0 = _context18.sent;
3657
- _context18.next = 21;
3688
+ _context19.t0 = _context19.sent;
3689
+ _context19.next = 21;
3658
3690
  break;
3659
3691
  case 20:
3660
- _context18.t0 = false;
3692
+ _context19.t0 = false;
3661
3693
  case 21:
3662
- shouldMerge = _context18.t0;
3694
+ shouldMerge = _context19.t0;
3663
3695
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
3664
3696
  this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
3665
3697
  if (linked) {
@@ -3713,11 +3745,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3713
3745
  }
3714
3746
  case 24:
3715
3747
  case "end":
3716
- return _context18.stop();
3748
+ return _context19.stop();
3717
3749
  }
3718
- }, _callee16, this);
3750
+ }, _callee17, this);
3719
3751
  }));
3720
- function appendProductLineToTempOrder(_x16, _x17, _x18) {
3752
+ function appendProductLineToTempOrder(_x17, _x18, _x19) {
3721
3753
  return _appendProductLineToTempOrder.apply(this, arguments);
3722
3754
  }
3723
3755
  return appendProductLineToTempOrder;
@@ -3733,61 +3765,61 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3733
3765
  }, {
3734
3766
  key: "addProductToOrder",
3735
3767
  value: (function () {
3736
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(product, booking) {
3768
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(product, booking) {
3737
3769
  var tempOrder, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
3738
- return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3739
- while (1) switch (_context19.prev = _context19.next) {
3770
+ return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3771
+ while (1) switch (_context20.prev = _context20.next) {
3740
3772
  case 0:
3741
3773
  tempOrder = this.ensureTempOrder();
3742
3774
  if (!booking) {
3743
- _context19.next = 18;
3775
+ _context20.next = 18;
3744
3776
  break;
3745
3777
  }
3746
3778
  productRecord = product;
3747
3779
  splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
3748
3780
  if (!(splitCount > 1)) {
3749
- _context19.next = 18;
3781
+ _context20.next = 18;
3750
3782
  break;
3751
3783
  }
3752
3784
  i = 0;
3753
3785
  case 6:
3754
3786
  if (!(i < splitCount)) {
3755
- _context19.next = 15;
3787
+ _context20.next = 15;
3756
3788
  break;
3757
3789
  }
3758
3790
  singleLine = cloneDeep(productRecord);
3759
3791
  singleLine.num = 1;
3760
3792
  delete singleLine.product_quantity;
3761
- _context19.next = 12;
3793
+ _context20.next = 12;
3762
3794
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
3763
3795
  case 12:
3764
3796
  i += 1;
3765
- _context19.next = 6;
3797
+ _context20.next = 6;
3766
3798
  break;
3767
3799
  case 15:
3768
- _context19.next = 17;
3800
+ _context20.next = 17;
3769
3801
  return this.finalizeProductOrderMutation(tempOrder);
3770
3802
  case 17:
3771
- return _context19.abrupt("return", tempOrder.products);
3803
+ return _context20.abrupt("return", tempOrder.products);
3772
3804
  case 18:
3773
- _context19.next = 20;
3805
+ _context20.next = 20;
3774
3806
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
3775
3807
  case 20:
3776
- _context19.next = 22;
3808
+ _context20.next = 22;
3777
3809
  return this.finalizeProductOrderMutation(tempOrder);
3778
3810
  case 22:
3779
3811
  this.logInfo('addProductToOrder success', {
3780
3812
  product_id: product.product_id,
3781
3813
  with_booking: !!booking
3782
3814
  });
3783
- return _context19.abrupt("return", tempOrder.products);
3815
+ return _context20.abrupt("return", tempOrder.products);
3784
3816
  case 24:
3785
3817
  case "end":
3786
- return _context19.stop();
3818
+ return _context20.stop();
3787
3819
  }
3788
- }, _callee17, this);
3820
+ }, _callee18, this);
3789
3821
  }));
3790
- function addProductToOrder(_x19, _x20) {
3822
+ function addProductToOrder(_x20, _x21) {
3791
3823
  return _addProductToOrder.apply(this, arguments);
3792
3824
  }
3793
3825
  return addProductToOrder;
@@ -3805,93 +3837,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3805
3837
  }, {
3806
3838
  key: "addProductsToOrder",
3807
3839
  value: (function () {
3808
- var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(items, options) {
3840
+ var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(items, options) {
3809
3841
  var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
3810
- return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3811
- while (1) switch (_context20.prev = _context20.next) {
3842
+ return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3843
+ while (1) switch (_context21.prev = _context21.next) {
3812
3844
  case 0:
3813
3845
  tempOrder = this.ensureTempOrder();
3814
3846
  if (!(!Array.isArray(items) || items.length === 0)) {
3815
- _context20.next = 3;
3847
+ _context21.next = 3;
3816
3848
  break;
3817
3849
  }
3818
- return _context20.abrupt("return", tempOrder.products);
3850
+ return _context21.abrupt("return", tempOrder.products);
3819
3851
  case 3:
3820
3852
  _iterator20 = _createForOfIteratorHelper(items || []);
3821
- _context20.prev = 4;
3853
+ _context21.prev = 4;
3822
3854
  _iterator20.s();
3823
3855
  case 6:
3824
3856
  if ((_step20 = _iterator20.n()).done) {
3825
- _context20.next = 30;
3857
+ _context21.next = 30;
3826
3858
  break;
3827
3859
  }
3828
3860
  item = _step20.value;
3829
3861
  product = item.product, booking = item.booking;
3830
3862
  if (product) {
3831
- _context20.next = 11;
3863
+ _context21.next = 11;
3832
3864
  break;
3833
3865
  }
3834
- return _context20.abrupt("continue", 28);
3866
+ return _context21.abrupt("continue", 28);
3835
3867
  case 11:
3836
3868
  if (!booking) {
3837
- _context20.next = 26;
3869
+ _context21.next = 26;
3838
3870
  break;
3839
3871
  }
3840
3872
  productRecord = product;
3841
3873
  splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
3842
3874
  if (!(splitCount > 1)) {
3843
- _context20.next = 26;
3875
+ _context21.next = 26;
3844
3876
  break;
3845
3877
  }
3846
3878
  i = 0;
3847
3879
  case 16:
3848
3880
  if (!(i < splitCount)) {
3849
- _context20.next = 25;
3881
+ _context21.next = 25;
3850
3882
  break;
3851
3883
  }
3852
3884
  singleLine = cloneDeep(productRecord);
3853
3885
  singleLine.num = 1;
3854
3886
  delete singleLine.product_quantity;
3855
- _context20.next = 22;
3887
+ _context21.next = 22;
3856
3888
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
3857
3889
  case 22:
3858
3890
  i += 1;
3859
- _context20.next = 16;
3891
+ _context21.next = 16;
3860
3892
  break;
3861
3893
  case 25:
3862
- return _context20.abrupt("continue", 28);
3894
+ return _context21.abrupt("continue", 28);
3863
3895
  case 26:
3864
- _context20.next = 28;
3896
+ _context21.next = 28;
3865
3897
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
3866
3898
  case 28:
3867
- _context20.next = 6;
3899
+ _context21.next = 6;
3868
3900
  break;
3869
3901
  case 30:
3870
- _context20.next = 35;
3902
+ _context21.next = 35;
3871
3903
  break;
3872
3904
  case 32:
3873
- _context20.prev = 32;
3874
- _context20.t0 = _context20["catch"](4);
3875
- _iterator20.e(_context20.t0);
3905
+ _context21.prev = 32;
3906
+ _context21.t0 = _context21["catch"](4);
3907
+ _iterator20.e(_context21.t0);
3876
3908
  case 35:
3877
- _context20.prev = 35;
3909
+ _context21.prev = 35;
3878
3910
  _iterator20.f();
3879
- return _context20.finish(35);
3911
+ return _context21.finish(35);
3880
3912
  case 38:
3881
- _context20.next = 40;
3913
+ _context21.next = 40;
3882
3914
  return this.finalizeProductOrderMutation(tempOrder, options);
3883
3915
  case 40:
3884
3916
  this.logInfo('addProductsToOrder success', {
3885
3917
  itemsCount: items.length
3886
3918
  });
3887
- return _context20.abrupt("return", tempOrder.products);
3919
+ return _context21.abrupt("return", tempOrder.products);
3888
3920
  case 42:
3889
3921
  case "end":
3890
- return _context20.stop();
3922
+ return _context21.stop();
3891
3923
  }
3892
- }, _callee18, this, [[4, 32, 35, 38]]);
3924
+ }, _callee19, this, [[4, 32, 35, 38]]);
3893
3925
  }));
3894
- function addProductsToOrder(_x21, _x22) {
3926
+ function addProductsToOrder(_x22, _x23) {
3895
3927
  return _addProductsToOrder.apply(this, arguments);
3896
3928
  }
3897
3929
  return addProductsToOrder;
@@ -4088,21 +4120,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4088
4120
  }, {
4089
4121
  key: "updateOrderProduct",
4090
4122
  value: function () {
4091
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
4123
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
4092
4124
  var tempOrder, updatedProductUid;
4093
- return _regeneratorRuntime().wrap(function _callee19$(_context21) {
4094
- while (1) switch (_context21.prev = _context21.next) {
4125
+ return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4126
+ while (1) switch (_context22.prev = _context22.next) {
4095
4127
  case 0:
4096
4128
  tempOrder = this.ensureTempOrder();
4097
4129
  updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
4098
- _context21.next = 4;
4130
+ _context22.next = 4;
4099
4131
  return this.applyPromotion();
4100
4132
  case 4:
4101
4133
  this.applyDiscount({
4102
4134
  reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
4103
4135
  });
4104
4136
  this.sanitizeTempOrderProducts(tempOrder);
4105
- _context21.next = 8;
4137
+ _context22.next = 8;
4106
4138
  return this.recalculateSummary({
4107
4139
  createIfMissing: true
4108
4140
  });
@@ -4111,14 +4143,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4111
4143
  this.logInfo('updateOrderProduct success', {
4112
4144
  params: params
4113
4145
  });
4114
- return _context21.abrupt("return", tempOrder.products);
4146
+ return _context22.abrupt("return", tempOrder.products);
4115
4147
  case 11:
4116
4148
  case "end":
4117
- return _context21.stop();
4149
+ return _context22.stop();
4118
4150
  }
4119
- }, _callee19, this);
4151
+ }, _callee20, this);
4120
4152
  }));
4121
- function updateOrderProduct(_x23) {
4153
+ function updateOrderProduct(_x24) {
4122
4154
  return _updateOrderProduct.apply(this, arguments);
4123
4155
  }
4124
4156
  return updateOrderProduct;
@@ -4126,18 +4158,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4126
4158
  }, {
4127
4159
  key: "updateOrderProducts",
4128
4160
  value: function () {
4129
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(paramsList) {
4161
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(paramsList) {
4130
4162
  var _this24 = this;
4131
4163
  var tempOrder, reapplyBookingDiscountProductUids;
4132
- return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4133
- while (1) switch (_context22.prev = _context22.next) {
4164
+ return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4165
+ while (1) switch (_context23.prev = _context23.next) {
4134
4166
  case 0:
4135
4167
  tempOrder = this.ensureTempOrder();
4136
4168
  if (paramsList.length) {
4137
- _context22.next = 3;
4169
+ _context23.next = 3;
4138
4170
  break;
4139
4171
  }
4140
- return _context22.abrupt("return", tempOrder.products);
4172
+ return _context23.abrupt("return", tempOrder.products);
4141
4173
  case 3:
4142
4174
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
4143
4175
  var updatedProductUid = _this24.applyOrderProductUpdateToTempOrder(tempOrder, params);
@@ -4147,7 +4179,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4147
4179
  }
4148
4180
  return acc;
4149
4181
  }, []);
4150
- _context22.next = 6;
4182
+ _context23.next = 6;
4151
4183
  return this.finalizeAfterProductsMutation(tempOrder, {
4152
4184
  reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
4153
4185
  });
@@ -4155,14 +4187,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4155
4187
  this.logInfo('updateOrderProduct success', {
4156
4188
  paramsList: paramsList
4157
4189
  });
4158
- return _context22.abrupt("return", tempOrder.products);
4190
+ return _context23.abrupt("return", tempOrder.products);
4159
4191
  case 8:
4160
4192
  case "end":
4161
- return _context22.stop();
4193
+ return _context23.stop();
4162
4194
  }
4163
- }, _callee20, this);
4195
+ }, _callee21, this);
4164
4196
  }));
4165
- function updateOrderProducts(_x24) {
4197
+ function updateOrderProducts(_x25) {
4166
4198
  return _updateOrderProducts.apply(this, arguments);
4167
4199
  }
4168
4200
  return updateOrderProducts;
@@ -4170,11 +4202,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4170
4202
  }, {
4171
4203
  key: "updateOrderProductQuantity",
4172
4204
  value: function () {
4173
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
4205
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
4174
4206
  var _targetProduct$metada10;
4175
4207
  var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
4176
- return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4177
- while (1) switch (_context23.prev = _context23.next) {
4208
+ return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4209
+ while (1) switch (_context24.prev = _context24.next) {
4178
4210
  case 0:
4179
4211
  product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
4180
4212
  tempOrder = this.ensureTempOrder();
@@ -4203,7 +4235,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4203
4235
  productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
4204
4236
  }
4205
4237
  if (!(productIndex === -1)) {
4206
- _context23.next = 12;
4238
+ _context24.next = 12;
4207
4239
  break;
4208
4240
  }
4209
4241
  throw new Error('[Order] 目标商品不存在,无法更新数量');
@@ -4217,12 +4249,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4217
4249
  }));
4218
4250
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
4219
4251
  tempOrder.products[productIndex] = normalizedProduct;
4220
- _context23.next = 18;
4252
+ _context24.next = 18;
4221
4253
  return this.applyPromotion();
4222
4254
  case 18:
4223
4255
  this.applyDiscount();
4224
4256
  this.sanitizeTempOrderProducts(tempOrder);
4225
- _context23.next = 22;
4257
+ _context24.next = 22;
4226
4258
  return this.recalculateSummary({
4227
4259
  createIfMissing: true
4228
4260
  });
@@ -4231,14 +4263,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4231
4263
  this.logInfo('updateOrderProductQuantity success', {
4232
4264
  params: params
4233
4265
  });
4234
- return _context23.abrupt("return", tempOrder.products);
4266
+ return _context24.abrupt("return", tempOrder.products);
4235
4267
  case 25:
4236
4268
  case "end":
4237
- return _context23.stop();
4269
+ return _context24.stop();
4238
4270
  }
4239
- }, _callee21, this);
4271
+ }, _callee22, this);
4240
4272
  }));
4241
- function updateOrderProductQuantity(_x25) {
4273
+ function updateOrderProductQuantity(_x26) {
4242
4274
  return _updateOrderProductQuantity.apply(this, arguments);
4243
4275
  }
4244
4276
  return updateOrderProductQuantity;
@@ -4279,19 +4311,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4279
4311
  }, {
4280
4312
  key: "finalizeAfterProductsMutation",
4281
4313
  value: (function () {
4282
- var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(tempOrder, options) {
4283
- return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4284
- while (1) switch (_context24.prev = _context24.next) {
4314
+ var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(tempOrder, options) {
4315
+ return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4316
+ while (1) switch (_context25.prev = _context25.next) {
4285
4317
  case 0:
4286
4318
  this.syncTempOrderHolderFromBookings(tempOrder);
4287
- _context24.next = 3;
4319
+ _context25.next = 3;
4288
4320
  return this.applyPromotion();
4289
4321
  case 3:
4290
4322
  this.applyDiscount({
4291
4323
  reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
4292
4324
  });
4293
4325
  this.sanitizeTempOrderProducts(tempOrder);
4294
- _context24.next = 7;
4326
+ _context25.next = 7;
4295
4327
  return this.recalculateSummary({
4296
4328
  createIfMissing: true
4297
4329
  });
@@ -4299,11 +4331,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4299
4331
  this.persistTempOrder();
4300
4332
  case 8:
4301
4333
  case "end":
4302
- return _context24.stop();
4334
+ return _context25.stop();
4303
4335
  }
4304
- }, _callee22, this);
4336
+ }, _callee23, this);
4305
4337
  }));
4306
- function finalizeAfterProductsMutation(_x26, _x27) {
4338
+ function finalizeAfterProductsMutation(_x27, _x28) {
4307
4339
  return _finalizeAfterProductsMutation.apply(this, arguments);
4308
4340
  }
4309
4341
  return finalizeAfterProductsMutation;
@@ -4318,18 +4350,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4318
4350
  }, {
4319
4351
  key: "removeProductsFromOrder",
4320
4352
  value: (function () {
4321
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(identities) {
4353
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identities) {
4322
4354
  var _this25 = this;
4323
4355
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
4324
- return _regeneratorRuntime().wrap(function _callee23$(_context26) {
4325
- while (1) switch (_context26.prev = _context26.next) {
4356
+ return _regeneratorRuntime().wrap(function _callee24$(_context27) {
4357
+ while (1) switch (_context27.prev = _context27.next) {
4326
4358
  case 0:
4327
4359
  tempOrder = this.ensureTempOrder();
4328
4360
  if (identities.length) {
4329
- _context26.next = 3;
4361
+ _context27.next = 3;
4330
4362
  break;
4331
4363
  }
4332
- return _context26.abrupt("return", tempOrder.products);
4364
+ return _context27.abrupt("return", tempOrder.products);
4333
4365
  case 3:
4334
4366
  productsBeforeRemove = tempOrder.products || [];
4335
4367
  bookingsBeforeRemove = tempOrder.bookings || [];
@@ -4352,22 +4384,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4352
4384
  }
4353
4385
  linkedBookingUidsToRemove = new Set();
4354
4386
  _iterator21 = _createForOfIteratorHelper(matchedProducts);
4355
- _context26.prev = 11;
4387
+ _context27.prev = 11;
4356
4388
  _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
4357
4389
  var _metadata8, _metadata9, _metadata10, _metadata11;
4358
4390
  var product, productUid, productBookingUid, isAddTimeProduct;
4359
- return _regeneratorRuntime().wrap(function _loop3$(_context25) {
4360
- while (1) switch (_context25.prev = _context25.next) {
4391
+ return _regeneratorRuntime().wrap(function _loop3$(_context26) {
4392
+ while (1) switch (_context26.prev = _context26.next) {
4361
4393
  case 0:
4362
4394
  product = _step21.value;
4363
4395
  productUid = (product === null || product === void 0 || (_metadata8 = product.metadata) === null || _metadata8 === void 0 ? void 0 : _metadata8.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
4364
4396
  productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata9 = product.metadata) === null || _metadata9 === void 0 ? void 0 : _metadata9.booking_uid);
4365
4397
  isAddTimeProduct = (product === null || product === void 0 || (_metadata10 = product.metadata) === null || _metadata10 === void 0 ? void 0 : _metadata10.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.product_add_schedule_time) !== null;
4366
4398
  if (!isAddTimeProduct) {
4367
- _context25.next = 6;
4399
+ _context26.next = 6;
4368
4400
  break;
4369
4401
  }
4370
- return _context25.abrupt("return", 1);
4402
+ return _context26.abrupt("return", 1);
4371
4403
  case 6:
4372
4404
  if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
4373
4405
  linkedBookingUidsToRemove.add(String(productBookingUid));
@@ -4382,37 +4414,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4382
4414
  }
4383
4415
  case 8:
4384
4416
  case "end":
4385
- return _context25.stop();
4417
+ return _context26.stop();
4386
4418
  }
4387
4419
  }, _loop3);
4388
4420
  });
4389
4421
  _iterator21.s();
4390
4422
  case 14:
4391
4423
  if ((_step21 = _iterator21.n()).done) {
4392
- _context26.next = 20;
4424
+ _context27.next = 20;
4393
4425
  break;
4394
4426
  }
4395
- return _context26.delegateYield(_loop3(), "t0", 16);
4427
+ return _context27.delegateYield(_loop3(), "t0", 16);
4396
4428
  case 16:
4397
- if (!_context26.t0) {
4398
- _context26.next = 18;
4429
+ if (!_context27.t0) {
4430
+ _context27.next = 18;
4399
4431
  break;
4400
4432
  }
4401
- return _context26.abrupt("continue", 18);
4433
+ return _context27.abrupt("continue", 18);
4402
4434
  case 18:
4403
- _context26.next = 14;
4435
+ _context27.next = 14;
4404
4436
  break;
4405
4437
  case 20:
4406
- _context26.next = 25;
4438
+ _context27.next = 25;
4407
4439
  break;
4408
4440
  case 22:
4409
- _context26.prev = 22;
4410
- _context26.t1 = _context26["catch"](11);
4411
- _iterator21.e(_context26.t1);
4441
+ _context27.prev = 22;
4442
+ _context27.t1 = _context27["catch"](11);
4443
+ _iterator21.e(_context27.t1);
4412
4444
  case 25:
4413
- _context26.prev = 25;
4445
+ _context27.prev = 25;
4414
4446
  _iterator21.f();
4415
- return _context26.finish(25);
4447
+ return _context27.finish(25);
4416
4448
  case 28:
4417
4449
  if (linkedBookingUidsToRemove.size > 0) {
4418
4450
  // 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
@@ -4423,20 +4455,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4423
4455
  return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
4424
4456
  });
4425
4457
  }
4426
- _context26.next = 31;
4458
+ _context27.next = 31;
4427
4459
  return this.finalizeAfterProductsMutation(tempOrder);
4428
4460
  case 31:
4429
4461
  this.logInfo('removeProductsFromOrder success', {
4430
4462
  identities: identities
4431
4463
  });
4432
- return _context26.abrupt("return", tempOrder.products);
4464
+ return _context27.abrupt("return", tempOrder.products);
4433
4465
  case 33:
4434
4466
  case "end":
4435
- return _context26.stop();
4467
+ return _context27.stop();
4436
4468
  }
4437
- }, _callee23, this, [[11, 22, 25, 28]]);
4469
+ }, _callee24, this, [[11, 22, 25, 28]]);
4438
4470
  }));
4439
- function removeProductsFromOrder(_x28) {
4471
+ function removeProductsFromOrder(_x29) {
4440
4472
  return _removeProductsFromOrder.apply(this, arguments);
4441
4473
  }
4442
4474
  return removeProductsFromOrder;
@@ -4444,18 +4476,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4444
4476
  }, {
4445
4477
  key: "removeProductFromOrder",
4446
4478
  value: function () {
4447
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identity) {
4448
- return _regeneratorRuntime().wrap(function _callee24$(_context27) {
4449
- while (1) switch (_context27.prev = _context27.next) {
4479
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(identity) {
4480
+ return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4481
+ while (1) switch (_context28.prev = _context28.next) {
4450
4482
  case 0:
4451
- return _context27.abrupt("return", this.removeProductsFromOrder([identity]));
4483
+ return _context28.abrupt("return", this.removeProductsFromOrder([identity]));
4452
4484
  case 1:
4453
4485
  case "end":
4454
- return _context27.stop();
4486
+ return _context28.stop();
4455
4487
  }
4456
- }, _callee24, this);
4488
+ }, _callee25, this);
4457
4489
  }));
4458
- function removeProductFromOrder(_x29) {
4490
+ function removeProductFromOrder(_x30) {
4459
4491
  return _removeProductFromOrder.apply(this, arguments);
4460
4492
  }
4461
4493
  return removeProductFromOrder;
@@ -4467,10 +4499,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4467
4499
  }, {
4468
4500
  key: "clearOrderCartLines",
4469
4501
  value: (function () {
4470
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
4502
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
4471
4503
  var tempOrder;
4472
- return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4473
- while (1) switch (_context28.prev = _context28.next) {
4504
+ return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4505
+ while (1) switch (_context29.prev = _context29.next) {
4474
4506
  case 0:
4475
4507
  tempOrder = this.ensureTempOrder();
4476
4508
  tempOrder.products = [];
@@ -4481,24 +4513,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4481
4513
  productsByUid: {}
4482
4514
  });
4483
4515
  }
4484
- _context28.next = 7;
4516
+ _context29.next = 7;
4485
4517
  return this.applyPromotion();
4486
4518
  case 7:
4487
4519
  this.applyDiscount();
4488
4520
  this.sanitizeTempOrderProducts(tempOrder);
4489
- _context28.next = 11;
4521
+ _context29.next = 11;
4490
4522
  return this.recalculateSummary({
4491
4523
  createIfMissing: true
4492
4524
  });
4493
4525
  case 11:
4494
4526
  this.persistTempOrder();
4495
4527
  this.logInfo('clearOrderCartLines success', {});
4496
- return _context28.abrupt("return", tempOrder);
4528
+ return _context29.abrupt("return", tempOrder);
4497
4529
  case 14:
4498
4530
  case "end":
4499
- return _context28.stop();
4531
+ return _context29.stop();
4500
4532
  }
4501
- }, _callee25, this);
4533
+ }, _callee26, this);
4502
4534
  }));
4503
4535
  function clearOrderCartLines() {
4504
4536
  return _clearOrderCartLines.apply(this, arguments);
@@ -4536,17 +4568,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4536
4568
  }, {
4537
4569
  key: "applyLocalPrintOrderNumbers",
4538
4570
  value: function () {
4539
- var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(order) {
4571
+ var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(order) {
4540
4572
  var tempOrder, shopOrderNumber, shopFullOrderNumber;
4541
- return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4542
- while (1) switch (_context29.prev = _context29.next) {
4573
+ return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4574
+ while (1) switch (_context30.prev = _context30.next) {
4543
4575
  case 0:
4544
4576
  tempOrder = this.ensureTempOrder();
4545
4577
  if (!(!order || _typeof(order) !== 'object')) {
4546
- _context29.next = 3;
4578
+ _context30.next = 3;
4547
4579
  break;
4548
4580
  }
4549
- return _context29.abrupt("return", tempOrder);
4581
+ return _context30.abrupt("return", tempOrder);
4550
4582
  case 3:
4551
4583
  shopOrderNumber = order.shop_order_number;
4552
4584
  shopFullOrderNumber = order.shop_full_order_number;
@@ -4557,17 +4589,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4557
4589
  tempOrder.shop_full_order_number = String(shopFullOrderNumber);
4558
4590
  }
4559
4591
  this.persistTempOrder();
4560
- _context29.next = 10;
4592
+ _context30.next = 10;
4561
4593
  return this.saveDraft();
4562
4594
  case 10:
4563
- return _context29.abrupt("return", tempOrder);
4595
+ return _context30.abrupt("return", tempOrder);
4564
4596
  case 11:
4565
4597
  case "end":
4566
- return _context29.stop();
4598
+ return _context30.stop();
4567
4599
  }
4568
- }, _callee26, this);
4600
+ }, _callee27, this);
4569
4601
  }));
4570
- function applyLocalPrintOrderNumbers(_x30) {
4602
+ function applyLocalPrintOrderNumbers(_x31) {
4571
4603
  return _applyLocalPrintOrderNumbers.apply(this, arguments);
4572
4604
  }
4573
4605
  return applyLocalPrintOrderNumbers;
@@ -4581,18 +4613,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4581
4613
  }, {
4582
4614
  key: "submitTempOrder",
4583
4615
  value: (function () {
4584
- var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
4585
- return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4586
- while (1) switch (_context30.prev = _context30.next) {
4616
+ var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4617
+ return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4618
+ while (1) switch (_context31.prev = _context31.next) {
4587
4619
  case 0:
4588
- return _context30.abrupt("return", this.runSubmitTempOrder(params));
4620
+ return _context31.abrupt("return", this.runSubmitTempOrder(params));
4589
4621
  case 1:
4590
4622
  case "end":
4591
- return _context30.stop();
4623
+ return _context31.stop();
4592
4624
  }
4593
- }, _callee27, this);
4625
+ }, _callee28, this);
4594
4626
  }));
4595
- function submitTempOrder(_x31) {
4627
+ function submitTempOrder(_x32) {
4596
4628
  return _submitTempOrder.apply(this, arguments);
4597
4629
  }
4598
4630
  return submitTempOrder;
@@ -4600,20 +4632,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4600
4632
  }, {
4601
4633
  key: "submitTempOrderAsync",
4602
4634
  value: function () {
4603
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4604
- return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4605
- while (1) switch (_context31.prev = _context31.next) {
4635
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4636
+ return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4637
+ while (1) switch (_context32.prev = _context32.next) {
4606
4638
  case 0:
4607
- return _context31.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4639
+ return _context32.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4608
4640
  syncMode: true
4609
4641
  })));
4610
4642
  case 1:
4611
4643
  case "end":
4612
- return _context31.stop();
4644
+ return _context32.stop();
4613
4645
  }
4614
- }, _callee28, this);
4646
+ }, _callee29, this);
4615
4647
  }));
4616
- function submitTempOrderAsync(_x32) {
4648
+ function submitTempOrderAsync(_x33) {
4617
4649
  return _submitTempOrderAsync.apply(this, arguments);
4618
4650
  }
4619
4651
  return submitTempOrderAsync;
@@ -4621,11 +4653,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4621
4653
  }, {
4622
4654
  key: "runSubmitTempOrder",
4623
4655
  value: function () {
4624
- var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4656
+ var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
4625
4657
  var _params$cacheId2, _this$otherParams6, _ref72, _ref73, _submitSnapshot$busin, _this$otherParams7, _this$otherParams8, _submitSnapshot$type;
4626
4658
  var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
4627
- return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4628
- while (1) switch (_context32.prev = _context32.next) {
4659
+ return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4660
+ while (1) switch (_context33.prev = _context33.next) {
4629
4661
  case 0:
4630
4662
  tempOrder = this.ensureTempOrder();
4631
4663
  shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
@@ -4645,26 +4677,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4645
4677
  }
4646
4678
  }
4647
4679
  this.persistTempOrder();
4648
- _context32.next = 8;
4680
+ _context33.next = 8;
4649
4681
  return this.recalculateSummary({
4650
4682
  createIfMissing: true
4651
4683
  });
4652
4684
  case 8:
4653
- _context32.t1 = _context32.sent;
4654
- if (_context32.t1) {
4655
- _context32.next = 11;
4685
+ _context33.t1 = _context33.sent;
4686
+ if (_context33.t1) {
4687
+ _context33.next = 11;
4656
4688
  break;
4657
4689
  }
4658
- _context32.t1 = this.store.summary;
4690
+ _context33.t1 = this.store.summary;
4659
4691
  case 11:
4660
- _context32.t0 = _context32.t1;
4661
- if (_context32.t0) {
4662
- _context32.next = 14;
4692
+ _context33.t0 = _context33.t1;
4693
+ if (_context33.t0) {
4694
+ _context33.next = 14;
4663
4695
  break;
4664
4696
  }
4665
- _context32.t0 = createEmptySummary();
4697
+ _context33.t0 = createEmptySummary();
4666
4698
  case 14:
4667
- latestSummary = _context32.t0;
4699
+ latestSummary = _context33.t0;
4668
4700
  effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
4669
4701
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
4670
4702
  hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
@@ -4699,10 +4731,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4699
4731
  if (!payload.created_at) {
4700
4732
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
4701
4733
  }
4702
- _context32.next = 26;
4734
+ _context33.next = 26;
4703
4735
  return this.saveDraft();
4704
4736
  case 26:
4705
- _context32.prev = 26;
4737
+ _context33.prev = 26;
4706
4738
  this.logInfo('submitTempOrder calling sales checkout', {
4707
4739
  orderId: payload.order_id,
4708
4740
  externalSaleNumber: payload.external_sale_number,
@@ -4712,43 +4744,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4712
4744
  smallTicketDataFlag: payload.small_ticket_data_flag,
4713
4745
  syncMode: payload.sync_mode
4714
4746
  });
4715
- _context32.next = 30;
4747
+ _context33.next = 30;
4716
4748
  return this.submitSalesOrder({
4717
4749
  query: payload
4718
4750
  });
4719
4751
  case 30:
4720
- result = _context32.sent;
4721
- _context32.next = 43;
4752
+ result = _context33.sent;
4753
+ _context33.next = 43;
4722
4754
  break;
4723
4755
  case 33:
4724
- _context32.prev = 33;
4725
- _context32.t2 = _context32["catch"](26);
4726
- backendErrorResponse = this.extractSubmitErrorResponse(_context32.t2);
4756
+ _context33.prev = 33;
4757
+ _context33.t2 = _context33["catch"](26);
4758
+ backendErrorResponse = this.extractSubmitErrorResponse(_context33.t2);
4727
4759
  if (!backendErrorResponse) {
4728
- _context32.next = 40;
4760
+ _context33.next = 40;
4729
4761
  break;
4730
4762
  }
4731
4763
  this.store.syncState = 'failed';
4732
4764
  this.logSubmitBackendRejected(backendErrorResponse, payload);
4733
- return _context32.abrupt("return", backendErrorResponse);
4765
+ return _context33.abrupt("return", backendErrorResponse);
4734
4766
  case 40:
4735
4767
  this.store.syncState = 'failed';
4736
4768
  this.logError('submitTempOrder failed', {
4737
- error: _context32.t2 instanceof Error ? _context32.t2.message : String(_context32.t2),
4769
+ error: _context33.t2 instanceof Error ? _context33.t2.message : String(_context33.t2),
4738
4770
  orderId: payload.order_id,
4739
4771
  externalSaleNumber: payload.external_sale_number,
4740
4772
  paymentStatus: payload.payment_status,
4741
4773
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
4742
4774
  });
4743
- throw _context32.t2;
4775
+ throw _context33.t2;
4744
4776
  case 43:
4745
4777
  if (!this.isSubmitResponseRejected(result)) {
4746
- _context32.next = 47;
4778
+ _context33.next = 47;
4747
4779
  break;
4748
4780
  }
4749
4781
  this.store.syncState = 'failed';
4750
4782
  this.logSubmitBackendRejected(result, payload);
4751
- return _context32.abrupt("return", result);
4783
+ return _context33.abrupt("return", result);
4752
4784
  case 47:
4753
4785
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
4754
4786
  this.logInfo('runSubmitTempOrder: 提交成功', {
@@ -4759,15 +4791,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4759
4791
  })
4760
4792
  });
4761
4793
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
4762
- _context32.next = 56;
4794
+ _context33.next = 56;
4763
4795
  break;
4764
4796
  }
4765
4797
  tempOrder.order_id = submittedOrderId;
4766
4798
  resultRecord = result;
4767
- _context32.next = 54;
4799
+ _context33.next = 54;
4768
4800
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
4769
4801
  case 54:
4770
- _context32.next = 57;
4802
+ _context33.next = 57;
4771
4803
  break;
4772
4804
  case 56:
4773
4805
  if (this.isLocalPendingSubmitResult(result)) {
@@ -4776,14 +4808,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4776
4808
  this.store.syncState = 'submitted';
4777
4809
  }
4778
4810
  case 57:
4779
- return _context32.abrupt("return", result);
4811
+ return _context33.abrupt("return", result);
4780
4812
  case 58:
4781
4813
  case "end":
4782
- return _context32.stop();
4814
+ return _context33.stop();
4783
4815
  }
4784
- }, _callee29, this, [[26, 33]]);
4816
+ }, _callee30, this, [[26, 33]]);
4785
4817
  }));
4786
- function runSubmitTempOrder(_x33) {
4818
+ function runSubmitTempOrder(_x34) {
4787
4819
  return _runSubmitTempOrder.apply(this, arguments);
4788
4820
  }
4789
4821
  return runSubmitTempOrder;
@@ -4791,10 +4823,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4791
4823
  }, {
4792
4824
  key: "markLocalOrderSynced",
4793
4825
  value: function () {
4794
- var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(orderId, remoteOrder) {
4826
+ var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(orderId, remoteOrder) {
4795
4827
  var tempOrder;
4796
- return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4797
- while (1) switch (_context33.prev = _context33.next) {
4828
+ return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4829
+ while (1) switch (_context34.prev = _context34.next) {
4798
4830
  case 0:
4799
4831
  tempOrder = this.ensureTempOrder();
4800
4832
  tempOrder.order_id = orderId;
@@ -4802,15 +4834,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4802
4834
  this.store.lastOrderInfo = remoteOrder;
4803
4835
  this.store.syncState = 'submitted';
4804
4836
  this.persistTempOrder();
4805
- _context33.next = 8;
4837
+ _context34.next = 8;
4806
4838
  return this.saveDraft();
4807
4839
  case 8:
4808
4840
  case "end":
4809
- return _context33.stop();
4841
+ return _context34.stop();
4810
4842
  }
4811
- }, _callee30, this);
4843
+ }, _callee31, this);
4812
4844
  }));
4813
- function markLocalOrderSynced(_x34, _x35) {
4845
+ function markLocalOrderSynced(_x35, _x36) {
4814
4846
  return _markLocalOrderSynced.apply(this, arguments);
4815
4847
  }
4816
4848
  return markLocalOrderSynced;
@@ -4883,11 +4915,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4883
4915
  }, {
4884
4916
  key: "syncPaymentsToOrder",
4885
4917
  value: function () {
4886
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
4918
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
4887
4919
  var _params$confirmPendin;
4888
4920
  var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, paidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
4889
- return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4890
- while (1) switch (_context34.prev = _context34.next) {
4921
+ return _regeneratorRuntime().wrap(function _callee32$(_context35) {
4922
+ while (1) switch (_context35.prev = _context35.next) {
4891
4923
  case 0:
4892
4924
  tempOrder = this.ensureTempOrder();
4893
4925
  mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
@@ -4899,24 +4931,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4899
4931
  tempOrder.payments = effectivePayments;
4900
4932
  tempOrder.payment_status = paymentStatus;
4901
4933
  this.persistTempOrder();
4902
- _context34.next = 12;
4934
+ _context35.next = 12;
4903
4935
  return this.saveDraft();
4904
4936
  case 12:
4905
4937
  if (params.submitWhenPaid) {
4906
- _context34.next = 14;
4938
+ _context35.next = 14;
4907
4939
  break;
4908
4940
  }
4909
- return _context34.abrupt("return", completion);
4941
+ return _context35.abrupt("return", completion);
4910
4942
  case 14:
4911
4943
  if (!(this.store.syncState === 'submitting')) {
4912
- _context34.next = 16;
4944
+ _context35.next = 16;
4913
4945
  break;
4914
4946
  }
4915
- return _context34.abrupt("return", completion);
4947
+ return _context35.abrupt("return", completion);
4916
4948
  case 16:
4917
4949
  this.store.syncState = 'submitting';
4918
4950
  paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
4919
- _context34.next = 20;
4951
+ _context35.next = 20;
4920
4952
  return this.submitTempOrder({
4921
4953
  payments: effectivePayments,
4922
4954
  paymentStatus: paymentStatus,
@@ -4932,17 +4964,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4932
4964
  }
4933
4965
  });
4934
4966
  case 20:
4935
- submitResult = _context34.sent;
4936
- return _context34.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
4967
+ submitResult = _context35.sent;
4968
+ return _context35.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
4937
4969
  submitResult: submitResult
4938
4970
  }));
4939
4971
  case 22:
4940
4972
  case "end":
4941
- return _context34.stop();
4973
+ return _context35.stop();
4942
4974
  }
4943
- }, _callee31, this);
4975
+ }, _callee32, this);
4944
4976
  }));
4945
- function syncPaymentsToOrder(_x36) {
4977
+ function syncPaymentsToOrder(_x37) {
4946
4978
  return _syncPaymentsToOrder.apply(this, arguments);
4947
4979
  }
4948
4980
  return syncPaymentsToOrder;
@@ -5031,11 +5063,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5031
5063
  }, {
5032
5064
  key: "submitOrder",
5033
5065
  value: function () {
5034
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(order) {
5066
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(order) {
5035
5067
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
5036
5068
  var url, query, fetchUrl, params;
5037
- return _regeneratorRuntime().wrap(function _callee32$(_context35) {
5038
- while (1) switch (_context35.prev = _context35.next) {
5069
+ return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5070
+ while (1) switch (_context36.prev = _context36.next) {
5039
5071
  case 0:
5040
5072
  this.logInfo('submitOrder called', {
5041
5073
  url: order.url,
@@ -5055,14 +5087,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5055
5087
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
5056
5088
  scheduleDate: params.schedule_date
5057
5089
  });
5058
- return _context35.abrupt("return", this.request.post(fetchUrl, params));
5090
+ return _context36.abrupt("return", this.request.post(fetchUrl, params));
5059
5091
  case 6:
5060
5092
  case "end":
5061
- return _context35.stop();
5093
+ return _context36.stop();
5062
5094
  }
5063
- }, _callee32, this);
5095
+ }, _callee33, this);
5064
5096
  }));
5065
- function submitOrder(_x37) {
5097
+ function submitOrder(_x38) {
5066
5098
  return _submitOrder.apply(this, arguments);
5067
5099
  }
5068
5100
  return submitOrder;
@@ -5070,13 +5102,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5070
5102
  }, {
5071
5103
  key: "cancelOrder",
5072
5104
  value: function () {
5073
- var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
5105
+ var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5074
5106
  var payload;
5075
- return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5076
- while (1) switch (_context36.prev = _context36.next) {
5107
+ return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5108
+ while (1) switch (_context37.prev = _context37.next) {
5077
5109
  case 0:
5078
5110
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
5079
- _context36.next = 2;
5111
+ _context37.next = 2;
5080
5112
  break;
5081
5113
  }
5082
5114
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -5092,16 +5124,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5092
5124
  method: 'PUT',
5093
5125
  orderIdsCount: params.order_ids.length
5094
5126
  });
5095
- return _context36.abrupt("return", this.request.put('/order/update-status', payload, {
5127
+ return _context37.abrupt("return", this.request.put('/order/update-status', payload, {
5096
5128
  isShopApi: true
5097
5129
  }));
5098
5130
  case 5:
5099
5131
  case "end":
5100
- return _context36.stop();
5132
+ return _context37.stop();
5101
5133
  }
5102
- }, _callee33, this);
5134
+ }, _callee34, this);
5103
5135
  }));
5104
- function cancelOrder(_x38) {
5136
+ function cancelOrder(_x39) {
5105
5137
  return _cancelOrder.apply(this, arguments);
5106
5138
  }
5107
5139
  return cancelOrder;
@@ -5109,19 +5141,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5109
5141
  }, {
5110
5142
  key: "changeBookingStatus",
5111
5143
  value: function () {
5112
- var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5144
+ var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
5113
5145
  var url, payload;
5114
- return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5115
- while (1) switch (_context37.prev = _context37.next) {
5146
+ return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5147
+ while (1) switch (_context38.prev = _context38.next) {
5116
5148
  case 0:
5117
5149
  if (params.booking_id) {
5118
- _context37.next = 2;
5150
+ _context38.next = 2;
5119
5151
  break;
5120
5152
  }
5121
5153
  throw new Error('变更预约状态失败:booking_id 不能为空');
5122
5154
  case 2:
5123
5155
  if (params.appointment_status) {
5124
- _context37.next = 4;
5156
+ _context38.next = 4;
5125
5157
  break;
5126
5158
  }
5127
5159
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -5136,16 +5168,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5136
5168
  bookingId: params.booking_id,
5137
5169
  appointmentStatus: params.appointment_status
5138
5170
  });
5139
- return _context37.abrupt("return", this.request.put(url, payload, {
5171
+ return _context38.abrupt("return", this.request.put(url, payload, {
5140
5172
  isShopApi: true
5141
5173
  }));
5142
5174
  case 8:
5143
5175
  case "end":
5144
- return _context37.stop();
5176
+ return _context38.stop();
5145
5177
  }
5146
- }, _callee34, this);
5178
+ }, _callee35, this);
5147
5179
  }));
5148
- function changeBookingStatus(_x39) {
5180
+ function changeBookingStatus(_x40) {
5149
5181
  return _changeBookingStatus.apply(this, arguments);
5150
5182
  }
5151
5183
  return changeBookingStatus;
@@ -5163,11 +5195,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5163
5195
  }, {
5164
5196
  key: "createOrderByCheckout",
5165
5197
  value: (function () {
5166
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
5198
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5167
5199
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
5168
5200
  var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
5169
- return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5170
- while (1) switch (_context38.prev = _context38.next) {
5201
+ return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5202
+ while (1) switch (_context39.prev = _context39.next) {
5171
5203
  case 0:
5172
5204
  // 过滤掉由在线店铺下单的 payment 支付数据
5173
5205
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -5201,7 +5233,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5201
5233
  relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
5202
5234
  paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
5203
5235
  });
5204
- _context38.prev = 4;
5236
+ _context39.prev = 4;
5205
5237
  // 构建订单数据,设置默认值并允许 params 覆盖
5206
5238
  orderData = _objectSpread({
5207
5239
  sales_channel: 'my_pisel',
@@ -5263,13 +5295,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5263
5295
  hasOrderId: !!orderData.order_id,
5264
5296
  smallTicketDataFlag: orderData.small_ticket_data_flag
5265
5297
  });
5266
- _context38.next = 12;
5298
+ _context39.next = 12;
5267
5299
  return this.request.post('/order/checkout', orderData, {
5268
5300
  osServer: true,
5269
5301
  customToast: function customToast() {}
5270
5302
  });
5271
5303
  case 12:
5272
- response = _context38.sent;
5304
+ response = _context39.sent;
5273
5305
  this.logInfo('Order API called successfully', {
5274
5306
  response: response
5275
5307
  });
@@ -5277,22 +5309,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5277
5309
  success: !!response,
5278
5310
  hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
5279
5311
  });
5280
- return _context38.abrupt("return", response);
5312
+ return _context39.abrupt("return", response);
5281
5313
  case 18:
5282
- _context38.prev = 18;
5283
- _context38.t0 = _context38["catch"](4);
5284
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context38.t0);
5314
+ _context39.prev = 18;
5315
+ _context39.t0 = _context39["catch"](4);
5316
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context39.t0);
5285
5317
  this.logInfo('Order API called failed', {
5286
- error: _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0)
5318
+ error: _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0)
5287
5319
  });
5288
- throw _context38.t0;
5320
+ throw _context39.t0;
5289
5321
  case 23:
5290
5322
  case "end":
5291
- return _context38.stop();
5323
+ return _context39.stop();
5292
5324
  }
5293
- }, _callee35, this, [[4, 18]]);
5325
+ }, _callee36, this, [[4, 18]]);
5294
5326
  }));
5295
- function createOrderByCheckout(_x40) {
5327
+ function createOrderByCheckout(_x41) {
5296
5328
  return _createOrderByCheckout.apply(this, arguments);
5297
5329
  }
5298
5330
  return createOrderByCheckout;
@@ -5300,24 +5332,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5300
5332
  }, {
5301
5333
  key: "submitSalesOrder",
5302
5334
  value: function () {
5303
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5335
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
5304
5336
  var url, query, fetchUrl;
5305
- return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5306
- while (1) switch (_context39.prev = _context39.next) {
5337
+ return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5338
+ while (1) switch (_context40.prev = _context40.next) {
5307
5339
  case 0:
5308
5340
  url = params.url, query = params.query;
5309
5341
  fetchUrl = url || '/order/sales/checkout';
5310
- return _context39.abrupt("return", this.request.post(fetchUrl, query, {
5342
+ return _context40.abrupt("return", this.request.post(fetchUrl, query, {
5311
5343
  osServer: true,
5312
5344
  customToast: function customToast() {}
5313
5345
  }));
5314
5346
  case 3:
5315
5347
  case "end":
5316
- return _context39.stop();
5348
+ return _context40.stop();
5317
5349
  }
5318
- }, _callee36, this);
5350
+ }, _callee37, this);
5319
5351
  }));
5320
- function submitSalesOrder(_x41) {
5352
+ function submitSalesOrder(_x42) {
5321
5353
  return _submitSalesOrder.apply(this, arguments);
5322
5354
  }
5323
5355
  return submitSalesOrder;
@@ -5331,37 +5363,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5331
5363
  }, {
5332
5364
  key: "sendCustomerPayLink",
5333
5365
  value: (function () {
5334
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
5366
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5335
5367
  var _params$emails;
5336
5368
  var orderIds;
5337
- return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5338
- while (1) switch (_context40.prev = _context40.next) {
5369
+ return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5370
+ while (1) switch (_context41.prev = _context41.next) {
5339
5371
  case 0:
5340
5372
  orderIds = params.order_ids || params.orderIds || [];
5341
5373
  if (orderIds.length) {
5342
- _context40.next = 3;
5374
+ _context41.next = 3;
5343
5375
  break;
5344
5376
  }
5345
5377
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
5346
5378
  case 3:
5347
5379
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
5348
- _context40.next = 5;
5380
+ _context41.next = 5;
5349
5381
  break;
5350
5382
  }
5351
5383
  throw new Error('发送支付链接需要至少一个邮箱');
5352
5384
  case 5:
5353
- return _context40.abrupt("return", this.request.post('/order/batch-email', {
5385
+ return _context41.abrupt("return", this.request.post('/order/batch-email', {
5354
5386
  order_ids: orderIds,
5355
5387
  notify_action: params.notify_action || 'order_payment_reminder',
5356
5388
  emails: params.emails
5357
5389
  }));
5358
5390
  case 6:
5359
5391
  case "end":
5360
- return _context40.stop();
5392
+ return _context41.stop();
5361
5393
  }
5362
- }, _callee37, this);
5394
+ }, _callee38, this);
5363
5395
  }));
5364
- function sendCustomerPayLink(_x42) {
5396
+ function sendCustomerPayLink(_x43) {
5365
5397
  return _sendCustomerPayLink.apply(this, arguments);
5366
5398
  }
5367
5399
  return sendCustomerPayLink;
@@ -5369,14 +5401,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5369
5401
  }, {
5370
5402
  key: "getSalesOrderByLookup",
5371
5403
  value: function () {
5372
- var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5404
+ var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
5373
5405
  var lookup, res;
5374
- return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5375
- while (1) switch (_context41.prev = _context41.next) {
5406
+ return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5407
+ while (1) switch (_context42.prev = _context42.next) {
5376
5408
  case 0:
5377
5409
  lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
5378
5410
  if (lookup) {
5379
- _context41.next = 3;
5411
+ _context42.next = 3;
5380
5412
  break;
5381
5413
  }
5382
5414
  throw new Error('加载销售详情需要 lookup');
@@ -5385,7 +5417,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5385
5417
  if (lookup.startsWith('LOCAL_')) {
5386
5418
  params.forceRemote = false;
5387
5419
  }
5388
- _context41.next = 6;
5420
+ _context42.next = 6;
5389
5421
  return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
5390
5422
  with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
5391
5423
  }, params.forceRemote ? {
@@ -5394,18 +5426,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5394
5426
  osServer: true
5395
5427
  });
5396
5428
  case 6:
5397
- res = _context41.sent;
5429
+ res = _context42.sent;
5398
5430
  if (res.code === 200) {
5399
5431
  this.store.lastOrderInfo = res.data;
5400
5432
  }
5401
- return _context41.abrupt("return", res);
5433
+ return _context42.abrupt("return", res);
5402
5434
  case 9:
5403
5435
  case "end":
5404
- return _context41.stop();
5436
+ return _context42.stop();
5405
5437
  }
5406
- }, _callee38, this);
5438
+ }, _callee39, this);
5407
5439
  }));
5408
- function getSalesOrderByLookup(_x43) {
5440
+ function getSalesOrderByLookup(_x44) {
5409
5441
  return _getSalesOrderByLookup.apply(this, arguments);
5410
5442
  }
5411
5443
  return getSalesOrderByLookup;
@@ -5419,14 +5451,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5419
5451
  }, {
5420
5452
  key: "hydrateTempOrderFromRecord",
5421
5453
  value: (function () {
5422
- var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(record, options) {
5423
- var _this$store$discount15;
5424
- var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount16, _this$store$discount17;
5425
- return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5426
- while (1) switch (_context42.prev = _context42.next) {
5454
+ var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(record, options) {
5455
+ var _this$store$discount19;
5456
+ var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
5457
+ return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5458
+ while (1) switch (_context43.prev = _context43.next) {
5427
5459
  case 0:
5428
5460
  raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
5429
- nextTempOrder = this.normalizeTempOrderForRuntime(raw);
5461
+ nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
5462
+ makeEditMark: true
5463
+ });
5430
5464
  rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
5431
5465
  summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
5432
5466
  return _objectSpread({}, s || {});
@@ -5447,37 +5481,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5447
5481
  });
5448
5482
  this.store.lastOrderInfo = raw.lastOrderInfo || raw;
5449
5483
  hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
5450
- currentDiscounts = typeof ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
5451
- shouldSkipEmptyDiscountSync = hydratedEditDiscounts.length === 0 && currentDiscounts.length === 0;
5484
+ currentDiscounts = typeof ((_this$store$discount19 = this.store.discount) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
5485
+ currentScanDiscounts = currentDiscounts.filter(function (discount) {
5486
+ return discount === null || discount === void 0 ? void 0 : discount.isScan;
5487
+ });
5488
+ hydratedDiscountIds = new Set(hydratedEditDiscounts.map(function (discount) {
5489
+ return discount === null || discount === void 0 ? void 0 : discount.id;
5490
+ }));
5491
+ retainedScanDiscounts = currentScanDiscounts.filter(function (discount) {
5492
+ return !hydratedDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id);
5493
+ });
5494
+ nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
5495
+ shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
5452
5496
  if (shouldSkipEmptyDiscountSync) {
5453
- _context42.next = 17;
5497
+ _context43.next = 21;
5454
5498
  break;
5455
5499
  }
5456
- OrderModule.populateSavedAmounts(nextTempOrder.products, hydratedEditDiscounts);
5457
- _context42.next = 15;
5458
- return (_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setOriginalDiscountList(hydratedEditDiscounts);
5459
- case 15:
5460
- _context42.next = 17;
5461
- return (_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 ? void 0 : _this$store$discount17.setDiscountList(hydratedEditDiscounts);
5462
- case 17:
5500
+ OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
5501
+ _context43.next = 19;
5502
+ return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(nextDiscounts);
5503
+ case 19:
5504
+ _context43.next = 21;
5505
+ return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(nextDiscounts);
5506
+ case 21:
5463
5507
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
5464
- _context42.next = 20;
5508
+ _context43.next = 24;
5465
5509
  break;
5466
5510
  }
5467
- _context42.next = 20;
5511
+ _context43.next = 24;
5468
5512
  return this.recalculateSummary({
5469
5513
  createIfMissing: false
5470
5514
  });
5471
- case 20:
5515
+ case 24:
5472
5516
  this.persistTempOrder();
5473
- return _context42.abrupt("return", nextTempOrder);
5474
- case 22:
5517
+ return _context43.abrupt("return", nextTempOrder);
5518
+ case 26:
5475
5519
  case "end":
5476
- return _context42.stop();
5520
+ return _context43.stop();
5477
5521
  }
5478
- }, _callee39, this);
5522
+ }, _callee40, this);
5479
5523
  }));
5480
- function hydrateTempOrderFromRecord(_x44, _x45) {
5524
+ function hydrateTempOrderFromRecord(_x45, _x46) {
5481
5525
  return _hydrateTempOrderFromRecord.apply(this, arguments);
5482
5526
  }
5483
5527
  return hydrateTempOrderFromRecord;
@@ -5541,7 +5585,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5541
5585
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
5542
5586
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
5543
5587
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
5544
- return _this27.normalizeHydratedOrderProduct(p);
5588
+ return _this27.normalizeHydratedOrderProduct(p, {
5589
+ makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
5590
+ });
5545
5591
  }) : [];
5546
5592
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
5547
5593
  var booking = _this27.normalizeHydratedBookingHolder(b || {});
@@ -5712,7 +5758,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5712
5758
  }
5713
5759
  }, {
5714
5760
  key: "normalizeHydratedOrderProduct",
5715
- value: function normalizeHydratedOrderProduct(product) {
5761
+ value: function normalizeHydratedOrderProduct(product, options) {
5716
5762
  var _this28 = this;
5717
5763
  var row = _objectSpread({}, product || {});
5718
5764
  if (row.num === undefined && row.product_quantity !== undefined) {
@@ -5736,7 +5782,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5736
5782
  row.metadata.unique_identification_number = createUuidV4();
5737
5783
  }
5738
5784
  // 从云端、本地数据库中获取到的商品数据,先打上 runtime 标记,提供给 UI 做 saved items.
5739
- row.metadata.is_edit_for_runtime = true;
5785
+ if (options !== null && options !== void 0 && options.makeEditMark) {
5786
+ row.metadata.is_edit_for_runtime = true;
5787
+ }
5740
5788
  var normalized = normalizeOrderProduct(row);
5741
5789
  normalized.discount_list = normalizeOrderProductDiscountList(normalized.discount_list);
5742
5790
  var result = _objectSpread(_objectSpread(_objectSpread({}, row), normalized), {}, {
@@ -5756,27 +5804,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5756
5804
  }, {
5757
5805
  key: "getOrderInfo",
5758
5806
  value: function () {
5759
- var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(order_id) {
5807
+ var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(order_id) {
5760
5808
  var res;
5761
- return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5762
- while (1) switch (_context43.prev = _context43.next) {
5809
+ return _regeneratorRuntime().wrap(function _callee41$(_context44) {
5810
+ while (1) switch (_context44.prev = _context44.next) {
5763
5811
  case 0:
5764
- _context43.next = 2;
5812
+ _context44.next = 2;
5765
5813
  return this.request.get("/order/sales/".concat(order_id), {
5766
5814
  with: ['products', 'bookings']
5767
5815
  }, {
5768
5816
  osServer: true
5769
5817
  });
5770
5818
  case 2:
5771
- res = _context43.sent;
5772
- return _context43.abrupt("return", res);
5819
+ res = _context44.sent;
5820
+ return _context44.abrupt("return", res);
5773
5821
  case 4:
5774
5822
  case "end":
5775
- return _context43.stop();
5823
+ return _context44.stop();
5776
5824
  }
5777
- }, _callee40, this);
5825
+ }, _callee41, this);
5778
5826
  }));
5779
- function getOrderInfo(_x46) {
5827
+ function getOrderInfo(_x47) {
5780
5828
  return _getOrderInfo.apply(this, arguments);
5781
5829
  }
5782
5830
  return getOrderInfo;