@pisell/pisellos 2.3.24 → 2.3.26

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/modules/Discount/index.d.ts +2 -5
  4. package/dist/modules/Discount/index.js +7 -30
  5. package/dist/modules/Discount/types.d.ts +0 -4
  6. package/dist/modules/Order/index.d.ts +4 -2
  7. package/dist/modules/Order/index.js +725 -647
  8. package/dist/modules/Order/types.d.ts +0 -2
  9. package/dist/modules/Product/types.d.ts +0 -22
  10. package/dist/modules/ProductList/index.d.ts +1 -1
  11. package/dist/modules/ProductList/index.js +2 -4
  12. package/dist/modules/ProductList/types.d.ts +0 -2
  13. package/dist/server/index.d.ts +0 -50
  14. package/dist/server/index.js +749 -995
  15. package/dist/server/modules/products/index.d.ts +7 -26
  16. package/dist/server/modules/products/index.js +76 -167
  17. package/dist/server/modules/products/types.d.ts +0 -14
  18. package/dist/solution/BaseSales/index.d.ts +0 -2
  19. package/dist/solution/BaseSales/index.js +50 -36
  20. package/dist/solution/BookingByStep/index.d.ts +1 -1
  21. package/dist/solution/BookingTicket/index.d.ts +1 -13
  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/modules/Discount/index.d.ts +2 -5
  28. package/lib/modules/Discount/index.js +3 -23
  29. package/lib/modules/Discount/types.d.ts +0 -4
  30. package/lib/modules/Order/index.d.ts +4 -2
  31. package/lib/modules/Order/index.js +80 -34
  32. package/lib/modules/Order/types.d.ts +0 -2
  33. package/lib/modules/Product/types.d.ts +0 -22
  34. package/lib/modules/ProductList/index.d.ts +1 -1
  35. package/lib/modules/ProductList/index.js +2 -4
  36. package/lib/modules/ProductList/types.d.ts +0 -2
  37. package/lib/server/index.d.ts +0 -50
  38. package/lib/server/index.js +29 -206
  39. package/lib/server/modules/products/index.d.ts +7 -26
  40. package/lib/server/modules/products/index.js +35 -114
  41. package/lib/server/modules/products/types.d.ts +0 -14
  42. package/lib/solution/BaseSales/index.d.ts +0 -2
  43. package/lib/solution/BaseSales/index.js +22 -12
  44. package/lib/solution/BookingByStep/index.d.ts +1 -1
  45. package/lib/solution/BookingTicket/index.d.ts +1 -13
  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;
@@ -1312,6 +1346,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1312
1346
  return sum.plus(_this4.calculatePaymentEffectiveAmount(payment));
1313
1347
  }, new Decimal(0));
1314
1348
  }
1349
+ }, {
1350
+ key: "calculateOrderPaidPaymentTotal",
1351
+ value: function calculateOrderPaidPaymentTotal(payments) {
1352
+ var _this5 = this;
1353
+ return mapPaymentItemsToOrderPayments(payments, {
1354
+ includeVoided: false
1355
+ }).reduce(function (sum, payment) {
1356
+ if (!isPaidPaymentRecord(payment)) return sum;
1357
+ return sum.plus(_this5.calculatePaymentGapAmount(payment));
1358
+ }, new Decimal(0));
1359
+ }
1315
1360
  }, {
1316
1361
  key: "getDepositAmount",
1317
1362
  value: function getDepositAmount(tempOrder, summary) {
@@ -1412,7 +1457,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1412
1457
  var summary = this.store.summary || createEmptySummary();
1413
1458
  var paymentList = payments || tempOrder.payments || [];
1414
1459
  var refundAmount = this.getSummaryRefundAmount(summary);
1415
- var netPaidAmount = Decimal.max(this.calculatePaymentTotal(paymentList).minus(refundAmount), 0);
1460
+ var netPaidAmount = Decimal.max(this.calculateOrderPaidPaymentTotal(paymentList).minus(refundAmount), 0);
1416
1461
  var depositAmount = this.getDepositAmount(tempOrder, summary);
1417
1462
  var orderExpectedAmount = this.getOrderExpectedAmount(summary);
1418
1463
  var isDepositFullyPaid = this.isDepositCovered({
@@ -1434,17 +1479,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1434
1479
  }, {
1435
1480
  key: "calculateDepositPaidAmount",
1436
1481
  value: function calculateDepositPaidAmount(payments) {
1437
- var _this5 = this;
1482
+ var _this6 = this;
1438
1483
  return (payments || []).reduce(function (sum, payment) {
1439
1484
  var paymentRecord = payment;
1440
1485
  if (!isPaidPaymentRecord(paymentRecord)) return sum;
1441
1486
  var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
1442
1487
  if (!isDepositPayment) return sum;
1443
- if (paymentRecord.origin_amount !== undefined && paymentRecord.origin_amount !== null && paymentRecord.origin_amount !== '') {
1444
- return sum.plus(_this5.calculatePaymentGapAmount(paymentRecord));
1445
- }
1446
- var rounding = new Decimal(paymentRecord.rounding_amount || 0);
1447
- return sum.plus(new Decimal(paymentRecord.amount || 0).minus(rounding));
1488
+ return sum.plus(_this6.calculatePaymentGapAmount(paymentRecord));
1448
1489
  }, new Decimal(0));
1449
1490
  }
1450
1491
  }, {
@@ -1481,8 +1522,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1481
1522
  value: function updateTempOrderPaymentStatus(tempOrder, options) {
1482
1523
  var summary = (options === null || options === void 0 ? void 0 : options.summary) || this.store.summary || createEmptySummary();
1483
1524
  var paymentTotal = this.calculatePaymentTotal(tempOrder.payments || []);
1525
+ var orderPaymentTotal = this.calculateOrderPaidPaymentTotal(tempOrder.payments || []);
1484
1526
  var refundAmount = this.getSummaryRefundAmount(summary);
1485
- var netPaymentTotal = Decimal.max(paymentTotal.minus(refundAmount), 0);
1527
+ var netPaymentTotal = Decimal.max(orderPaymentTotal.minus(refundAmount), 0);
1486
1528
  var targetAmount = this.calculatePaymentTargetAmount(tempOrder, summary, netPaymentTotal);
1487
1529
  if (this.shouldKeepPaymentStatusAfterAmountRecalc(tempOrder.payment_status, {
1488
1530
  netPaymentTotal: netPaymentTotal,
@@ -1548,7 +1590,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1548
1590
  key: "capVoucherPaymentsByRemainingAmount",
1549
1591
  value: function capVoucherPaymentsByRemainingAmount(params) {
1550
1592
  var targetAmount = this.getPaymentTargetAmount();
1551
- var nonVoucherTotal = this.calculatePaymentTotal(params.nonVoucherPayments);
1593
+ var nonVoucherTotal = this.calculateOrderPaidPaymentTotal(params.nonVoucherPayments);
1552
1594
  if (targetAmount.lte(0)) return [];
1553
1595
  var remainingAmount = Decimal.max(targetAmount.minus(nonVoucherTotal), 0);
1554
1596
  var cappedVouchers = [];
@@ -1585,16 +1627,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1585
1627
  }, {
1586
1628
  key: "calculatePaidPaymentSummary",
1587
1629
  value: function calculatePaidPaymentSummary(payments) {
1588
- var _this6 = this;
1630
+ var _this7 = this;
1589
1631
  return (payments || []).reduce(function (summary, payment) {
1590
1632
  var paymentRecord = payment;
1591
1633
  if (!isPaidPaymentRecord(paymentRecord)) return summary;
1592
1634
  return {
1593
1635
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
1594
- orderPaidAmount: summary.orderPaidAmount.plus(paymentRecord.origin_amount || 0),
1595
- gapPaidAmount: summary.gapPaidAmount.plus(_this6.calculatePaymentGapAmount(paymentRecord)),
1596
- payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this6.calculatePaymentServiceFee(paymentRecord)),
1597
- roundingAmount: summary.roundingAmount.plus(_this6.calculatePaymentRoundingAmount(paymentRecord))
1636
+ orderPaidAmount: summary.orderPaidAmount.plus(_this7.calculatePaymentOrderAmount(paymentRecord)),
1637
+ gapPaidAmount: summary.gapPaidAmount.plus(_this7.calculatePaymentGapAmount(paymentRecord)),
1638
+ payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this7.calculatePaymentServiceFee(paymentRecord)),
1639
+ roundingAmount: summary.roundingAmount.plus(_this7.calculatePaymentRoundingAmount(paymentRecord))
1598
1640
  };
1599
1641
  }, {
1600
1642
  customerPaidAmount: new Decimal(0),
@@ -1618,11 +1660,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1618
1660
  }, {
1619
1661
  key: "calculatePaymentGapAmount",
1620
1662
  value: function calculatePaymentGapAmount(payment) {
1621
- if (payment.origin_amount === undefined || payment.origin_amount === null || payment.origin_amount === '') {
1622
- return new Decimal(0);
1663
+ if (payment.origin_amount !== undefined && payment.origin_amount !== null && payment.origin_amount !== '') {
1664
+ var _rounding = new Decimal(payment.rounding_amount || 0);
1665
+ return new Decimal(payment.origin_amount || 0).minus(_rounding);
1623
1666
  }
1624
1667
  var rounding = new Decimal(payment.rounding_amount || 0);
1625
- return new Decimal(payment.origin_amount || 0).minus(rounding);
1668
+ var amount = new Decimal(payment.amount || 0);
1669
+ var serviceFee = this.calculatePaymentServiceFee(payment);
1670
+ if (serviceFee.lte(0)) return amount.minus(rounding);
1671
+ if (!hasSyncedOrderPaymentRecord(payment)) return new Decimal(0);
1672
+ return Decimal.max(amount.minus(serviceFee), 0).minus(rounding);
1673
+ }
1674
+ }, {
1675
+ key: "calculatePaymentOrderAmount",
1676
+ value: function calculatePaymentOrderAmount(payment) {
1677
+ if (payment.origin_amount !== undefined && payment.origin_amount !== null && payment.origin_amount !== '') {
1678
+ return new Decimal(payment.origin_amount || 0);
1679
+ }
1680
+ var amount = new Decimal(payment.amount || 0);
1681
+ var serviceFee = this.calculatePaymentServiceFee(payment);
1682
+ if (serviceFee.lte(0)) return amount;
1683
+ if (!hasSyncedOrderPaymentRecord(payment)) return new Decimal(0);
1684
+ return Decimal.max(amount.minus(serviceFee), 0);
1626
1685
  }
1627
1686
  }, {
1628
1687
  key: "calculatePaymentRoundingAmount",
@@ -1779,15 +1838,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1779
1838
  }, {
1780
1839
  key: "normalizeFingerprintValue",
1781
1840
  value: function normalizeFingerprintValue(value) {
1782
- var _this7 = this;
1841
+ var _this8 = this;
1783
1842
  if (Array.isArray(value)) {
1784
1843
  return value.map(function (item) {
1785
- return _this7.normalizeFingerprintValue(item);
1844
+ return _this8.normalizeFingerprintValue(item);
1786
1845
  });
1787
1846
  }
1788
1847
  if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
1789
1848
  return Object.keys(value).sort().reduce(function (result, key) {
1790
- result[key] = _this7.normalizeFingerprintValue(value[key]);
1849
+ result[key] = _this8.normalizeFingerprintValue(value[key]);
1791
1850
  return result;
1792
1851
  }, {});
1793
1852
  }
@@ -1802,7 +1861,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1802
1861
  _sku$barcode,
1803
1862
  _ref20,
1804
1863
  _sku$variant_id,
1805
- _this8 = this;
1864
+ _this9 = this;
1806
1865
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
1807
1866
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
1808
1867
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -1836,7 +1895,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1836
1895
  option_group_id: (_option$option_group_ = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : null,
1837
1896
  option_group_item_id: (_ref22 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref22 !== void 0 ? _ref22 : null,
1838
1897
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
1839
- add_price: _this8.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
1898
+ add_price: _this9.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
1840
1899
  };
1841
1900
  })
1842
1901
  }),
@@ -1846,8 +1905,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1846
1905
  bundle_product_id: (_ref23 = (_ref24 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref24 !== void 0 ? _ref24 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref23 !== void 0 ? _ref23 : null,
1847
1906
  bundle_variant_id: (_ref25 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref25 !== void 0 ? _ref25 : 0,
1848
1907
  num: getSafeProductNum((_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
1849
- price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
1850
- bundle_selling_price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
1908
+ price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
1909
+ bundle_selling_price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
1851
1910
  price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
1852
1911
  price_type_ext: (_bundle$price_type_ex = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : ''
1853
1912
  };
@@ -1857,7 +1916,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1857
1916
  return {
1858
1917
  type: (_ref26 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref26 !== void 0 ? _ref26 : '',
1859
1918
  discount_id: (_ref27 = (_ref28 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref28 !== void 0 ? _ref28 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref27 !== void 0 ? _ref27 : null,
1860
- amount: _this8.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1919
+ amount: _this9.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1861
1920
  };
1862
1921
  }))
1863
1922
  };
@@ -1865,9 +1924,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1865
1924
  }, {
1866
1925
  key: "buildOrderProductsFingerprint",
1867
1926
  value: function buildOrderProductsFingerprint(products) {
1868
- var _this9 = this;
1927
+ var _this10 = this;
1869
1928
  var items = (products || []).map(function (product) {
1870
- return _this9.buildProductFingerprintItem(product);
1929
+ return _this10.buildProductFingerprintItem(product);
1871
1930
  });
1872
1931
  items.sort(function (left, right) {
1873
1932
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -1889,7 +1948,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1889
1948
  _sku$barcode2,
1890
1949
  _ref30,
1891
1950
  _sku$variant_id2,
1892
- _this10 = this;
1951
+ _this11 = this;
1893
1952
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
1894
1953
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
1895
1954
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -1920,7 +1979,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1920
1979
  option_group_id: (_option$option_group_3 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_3 !== void 0 ? _option$option_group_3 : null,
1921
1980
  option_group_item_id: (_ref32 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref32 !== void 0 ? _ref32 : null,
1922
1981
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
1923
- add_price: _this10.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
1982
+ add_price: _this11.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
1924
1983
  };
1925
1984
  })
1926
1985
  }),
@@ -1934,14 +1993,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1934
1993
  num: getSafeProductNum((_bundle$num2 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num2 !== void 0 ? _bundle$num2 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
1935
1994
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
1936
1995
  price_type_ext: (_bundle$price_type_ex2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : '',
1937
- option: _this10.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
1996
+ option: _this11.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
1938
1997
  var _ref38, _option$id3, _option$option_group_5, _ref39, _option$option_group_6, _option$num3, _option$add_price3;
1939
1998
  return {
1940
1999
  id: (_ref38 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref38 !== void 0 ? _ref38 : null,
1941
2000
  option_group_id: (_option$option_group_5 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_5 !== void 0 ? _option$option_group_5 : null,
1942
2001
  option_group_item_id: (_ref39 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref39 !== void 0 ? _ref39 : null,
1943
2002
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
1944
- add_price: _this10.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
2003
+ add_price: _this11.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
1945
2004
  };
1946
2005
  }))
1947
2006
  };
@@ -1951,7 +2010,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1951
2010
  return {
1952
2011
  type: (_ref40 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref40 !== void 0 ? _ref40 : '',
1953
2012
  discount_id: (_ref41 = (_ref42 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref42 !== void 0 ? _ref42 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref41 !== void 0 ? _ref41 : null,
1954
- amount: _this10.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2013
+ amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1955
2014
  };
1956
2015
  }))
1957
2016
  };
@@ -1959,9 +2018,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1959
2018
  }, {
1960
2019
  key: "buildOrderProductsStructuralFingerprint",
1961
2020
  value: function buildOrderProductsStructuralFingerprint(products) {
1962
- var _this11 = this;
2021
+ var _this12 = this;
1963
2022
  var items = (products || []).map(function (product) {
1964
- return _this11.buildProductStructuralFingerprintItem(product);
2023
+ return _this12.buildProductStructuralFingerprintItem(product);
1965
2024
  });
1966
2025
  items.sort(function (left, right) {
1967
2026
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2061,7 +2120,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2061
2120
  tempOrder.surcharge_fee = summary.surcharge_fee || tempOrder.surcharge_fee;
2062
2121
  tempOrder.deposit_amount = summary.deposit_amount || '0.00';
2063
2122
  tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
2123
+ var previousSummary = this.store.summary;
2064
2124
  this.store.summary = summary;
2125
+ this.updateTempOrderPaymentStatus(tempOrder, {
2126
+ previousSummary: previousSummary,
2127
+ summary: summary
2128
+ });
2065
2129
  return summary;
2066
2130
  }
2067
2131
  }, {
@@ -2173,7 +2237,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2173
2237
  }, {
2174
2238
  key: "restoreOrder",
2175
2239
  value: function restoreOrder() {
2176
- var _this$store$discount11, _this$store$discount12;
2240
+ var _this$store$discount15, _this$store$discount16;
2177
2241
  this.logInfo('restoreOrder start', {});
2178
2242
  var freshTempOrder = this.createDefaultTempOrderInstance();
2179
2243
  this.ensureExternalSaleNumber(freshTempOrder);
@@ -2181,8 +2245,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2181
2245
  this.store.summary = createEmptySummary();
2182
2246
  this.store.lastOrderInfo = undefined;
2183
2247
  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([]));
2248
+ void ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.setOriginalDiscountList([]));
2249
+ void ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setDiscountList([]));
2186
2250
  this.persistTempOrder();
2187
2251
  return freshTempOrder;
2188
2252
  }
@@ -2194,13 +2258,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2194
2258
  }, {
2195
2259
  key: "replaceTempOrder",
2196
2260
  value: function () {
2197
- var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(tempOrder, options) {
2261
+ var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(tempOrder, options) {
2198
2262
  var nextTempOrder;
2199
- return _regeneratorRuntime().wrap(function _callee9$(_context11) {
2200
- while (1) switch (_context11.prev = _context11.next) {
2263
+ return _regeneratorRuntime().wrap(function _callee10$(_context12) {
2264
+ while (1) switch (_context12.prev = _context12.next) {
2201
2265
  case 0:
2202
2266
  if (isTempOrder(tempOrder)) {
2203
- _context11.next = 2;
2267
+ _context12.next = 2;
2204
2268
  break;
2205
2269
  }
2206
2270
  throw new Error('无效的 tempOrder 数据');
@@ -2210,15 +2274,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2210
2274
  });
2211
2275
  this.store.tempOrder = nextTempOrder;
2212
2276
  if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
2213
- _context11.next = 9;
2277
+ _context12.next = 9;
2214
2278
  break;
2215
2279
  }
2216
- _context11.next = 7;
2280
+ _context12.next = 7;
2217
2281
  return this.recalculateSummary({
2218
2282
  createIfMissing: false
2219
2283
  });
2220
2284
  case 7:
2221
- _context11.next = 10;
2285
+ _context12.next = 10;
2222
2286
  break;
2223
2287
  case 9:
2224
2288
  this.store.summary = createEmptySummary();
@@ -2227,20 +2291,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2227
2291
  this.persistTempOrder();
2228
2292
  }
2229
2293
  if (!(options !== null && options !== void 0 && options.saveDraft)) {
2230
- _context11.next = 14;
2294
+ _context12.next = 14;
2231
2295
  break;
2232
2296
  }
2233
- _context11.next = 14;
2297
+ _context12.next = 14;
2234
2298
  return this.saveDraft();
2235
2299
  case 14:
2236
- return _context11.abrupt("return", nextTempOrder);
2300
+ return _context12.abrupt("return", nextTempOrder);
2237
2301
  case 15:
2238
2302
  case "end":
2239
- return _context11.stop();
2303
+ return _context12.stop();
2240
2304
  }
2241
- }, _callee9, this);
2305
+ }, _callee10, this);
2242
2306
  }));
2243
- function replaceTempOrder(_x8, _x9) {
2307
+ function replaceTempOrder(_x9, _x10) {
2244
2308
  return _replaceTempOrder.apply(this, arguments);
2245
2309
  }
2246
2310
  return replaceTempOrder;
@@ -2326,32 +2390,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2326
2390
  }, {
2327
2391
  key: "addNewOrder",
2328
2392
  value: function () {
2329
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
2393
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
2330
2394
  var tempOrder;
2331
- return _regeneratorRuntime().wrap(function _callee10$(_context12) {
2332
- while (1) switch (_context12.prev = _context12.next) {
2395
+ return _regeneratorRuntime().wrap(function _callee11$(_context13) {
2396
+ while (1) switch (_context13.prev = _context13.next) {
2333
2397
  case 0:
2334
2398
  tempOrder = this.ensureTempOrder();
2335
2399
  this.ensureExternalSaleNumber(tempOrder);
2336
- _context12.next = 4;
2400
+ _context13.next = 4;
2337
2401
  return this.recalculateSummary({
2338
2402
  createIfMissing: true
2339
2403
  });
2340
2404
  case 4:
2341
2405
  this.persistTempOrder();
2342
2406
  if (!this.draftPersistEnabled) {
2343
- _context12.next = 8;
2407
+ _context13.next = 8;
2344
2408
  break;
2345
2409
  }
2346
- _context12.next = 8;
2410
+ _context13.next = 8;
2347
2411
  return this.saveDraft();
2348
2412
  case 8:
2349
- return _context12.abrupt("return", tempOrder);
2413
+ return _context13.abrupt("return", tempOrder);
2350
2414
  case 9:
2351
2415
  case "end":
2352
- return _context12.stop();
2416
+ return _context13.stop();
2353
2417
  }
2354
- }, _callee10, this);
2418
+ }, _callee11, this);
2355
2419
  }));
2356
2420
  function addNewOrder() {
2357
2421
  return _addNewOrder.apply(this, arguments);
@@ -2384,9 +2448,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2384
2448
  }, {
2385
2449
  key: "sanitizeTempOrderProducts",
2386
2450
  value: function sanitizeTempOrderProducts(tempOrder) {
2387
- var _this12 = this;
2451
+ var _this13 = this;
2388
2452
  tempOrder.products = (tempOrder.products || []).map(function (product) {
2389
- return _this12.sanitizeOrderProductForTempOrder(product);
2453
+ return _this13.sanitizeOrderProductForTempOrder(product);
2390
2454
  });
2391
2455
  }
2392
2456
  }, {
@@ -2489,7 +2553,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2489
2553
  }, {
2490
2554
  key: "syncLinkedBookingHoldersToProducts",
2491
2555
  value: function syncLinkedBookingHoldersToProducts(tempOrder) {
2492
- var _this13 = this;
2556
+ var _this14 = this;
2493
2557
  var bookings = tempOrder.bookings || [];
2494
2558
  var products = tempOrder.products || [];
2495
2559
  if (!bookings.length || !products.length) return;
@@ -2514,7 +2578,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2514
2578
  var bookingUid = product.booking_uid || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
2515
2579
  var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
2516
2580
  if (linkedBooking) {
2517
- _this13.setProductHolderFromBooking(product, linkedBooking);
2581
+ _this14.setProductHolderFromBooking(product, linkedBooking);
2518
2582
  }
2519
2583
  });
2520
2584
  }
@@ -2642,9 +2706,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2642
2706
  }, {
2643
2707
  key: "findBookingIndexByUniqueIdentificationNumber",
2644
2708
  value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
2645
- var _this14 = this;
2709
+ var _this15 = this;
2646
2710
  return (tempOrder.bookings || []).findIndex(function (booking) {
2647
- return _this14.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
2711
+ return _this15.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
2648
2712
  });
2649
2713
  }
2650
2714
  }, {
@@ -2652,12 +2716,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2652
2716
  value: function removeLinkedBookingsForProduct(tempOrder, product) {
2653
2717
  var _product$metadata7,
2654
2718
  _product$metadata8,
2655
- _this15 = this;
2719
+ _this16 = this;
2656
2720
  var productUid = (product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
2657
2721
  var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.booking_uid);
2658
2722
  if (!productUid && !bookingUid) return;
2659
2723
  tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
2660
- var currentBookingUid = _this15.getBookingUniqueIdentificationNumber(booking);
2724
+ var currentBookingUid = _this16.getBookingUniqueIdentificationNumber(booking);
2661
2725
  if (bookingUid && currentBookingUid === String(bookingUid)) return false;
2662
2726
  if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
2663
2727
  return true;
@@ -2703,18 +2767,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2703
2767
  }, {
2704
2768
  key: "recalculateSummary",
2705
2769
  value: function () {
2706
- var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
2770
+ var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(options) {
2707
2771
  var _this$otherParams2, _ref47, _salesSummaryResult$e;
2708
2772
  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) {
2773
+ return _regeneratorRuntime().wrap(function _callee12$(_context14) {
2774
+ while (1) switch (_context14.prev = _context14.next) {
2711
2775
  case 0:
2712
2776
  tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
2713
2777
  if (tempOrder) {
2714
- _context13.next = 3;
2778
+ _context14.next = 3;
2715
2779
  break;
2716
2780
  }
2717
- return _context13.abrupt("return", null);
2781
+ return _context14.abrupt("return", null);
2718
2782
  case 3:
2719
2783
  this.sanitizeTempOrderProducts(tempOrder);
2720
2784
  originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
@@ -2722,10 +2786,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2722
2786
  shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
2723
2787
  snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
2724
2788
  if (!snapshotSummary) {
2725
- _context13.next = 10;
2789
+ _context14.next = 10;
2726
2790
  break;
2727
2791
  }
2728
- return _context13.abrupt("return", snapshotSummary);
2792
+ return _context14.abrupt("return", snapshotSummary);
2729
2793
  case 10:
2730
2794
  shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
2731
2795
  summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
@@ -2737,7 +2801,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2737
2801
  totalRefundAmount = existedSummary.total_refund_amount || '0.00';
2738
2802
  paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
2739
2803
  if (salesSummary) {
2740
- _context13.next = 26;
2804
+ _context14.next = 26;
2741
2805
  break;
2742
2806
  }
2743
2807
  emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
@@ -2763,9 +2827,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2763
2827
  previousSummary: existedSummary,
2764
2828
  summary: emptySummary
2765
2829
  });
2766
- return _context13.abrupt("return", this.store.summary);
2830
+ return _context14.abrupt("return", this.store.summary);
2767
2831
  case 26:
2768
- _context13.next = 28;
2832
+ _context14.next = 28;
2769
2833
  return salesSummary.getSummary(_objectSpread({
2770
2834
  products: summaryProducts,
2771
2835
  isPriceIncludeTax: tempOrder.is_price_include_tax,
@@ -2774,7 +2838,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2774
2838
  channel: this.otherParams.channel
2775
2839
  } : {}));
2776
2840
  case 28:
2777
- salesSummaryResult = _context13.sent;
2841
+ salesSummaryResult = _context14.sent;
2778
2842
  if (shouldFullRecalculateFromSnapshot) {
2779
2843
  tempOrder.products = summaryProducts;
2780
2844
  }
@@ -2819,14 +2883,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2819
2883
  previousSummary: existedSummary,
2820
2884
  summary: summary
2821
2885
  });
2822
- return _context13.abrupt("return", this.store.summary);
2886
+ return _context14.abrupt("return", this.store.summary);
2823
2887
  case 46:
2824
2888
  case "end":
2825
- return _context13.stop();
2889
+ return _context14.stop();
2826
2890
  }
2827
- }, _callee11, this);
2891
+ }, _callee12, this);
2828
2892
  }));
2829
- function recalculateSummary(_x10) {
2893
+ function recalculateSummary(_x11) {
2830
2894
  return _recalculateSummary.apply(this, arguments);
2831
2895
  }
2832
2896
  return recalculateSummary;
@@ -2834,30 +2898,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2834
2898
  }, {
2835
2899
  key: "getOrderSummary",
2836
2900
  value: function () {
2837
- var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
2901
+ var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
2838
2902
  var summary;
2839
- return _regeneratorRuntime().wrap(function _callee12$(_context14) {
2840
- while (1) switch (_context14.prev = _context14.next) {
2903
+ return _regeneratorRuntime().wrap(function _callee13$(_context15) {
2904
+ while (1) switch (_context15.prev = _context15.next) {
2841
2905
  case 0:
2842
- _context14.next = 2;
2906
+ _context15.next = 2;
2843
2907
  return this.recalculateSummary({
2844
2908
  createIfMissing: true
2845
2909
  });
2846
2910
  case 2:
2847
- summary = _context14.sent;
2911
+ summary = _context15.sent;
2848
2912
  if (summary) {
2849
- _context14.next = 5;
2913
+ _context15.next = 5;
2850
2914
  break;
2851
2915
  }
2852
- return _context14.abrupt("return", createEmptySummary());
2916
+ return _context15.abrupt("return", createEmptySummary());
2853
2917
  case 5:
2854
2918
  this.persistTempOrder();
2855
- return _context14.abrupt("return", summary);
2919
+ return _context15.abrupt("return", summary);
2856
2920
  case 7:
2857
2921
  case "end":
2858
- return _context14.stop();
2922
+ return _context15.stop();
2859
2923
  }
2860
- }, _callee12, this);
2924
+ }, _callee13, this);
2861
2925
  }));
2862
2926
  function getOrderSummary() {
2863
2927
  return _getOrderSummary.apply(this, arguments);
@@ -2881,23 +2945,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2881
2945
  }, {
2882
2946
  key: "syncTempOrderNoteToRemote",
2883
2947
  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) {
2948
+ var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderId, note) {
2949
+ return _regeneratorRuntime().wrap(function _callee14$(_context16) {
2950
+ while (1) switch (_context16.prev = _context16.next) {
2887
2951
  case 0:
2888
- _context15.next = 2;
2952
+ _context16.next = 2;
2889
2953
  return this.request.put("/order/order/".concat(orderId, "/note"), {
2890
2954
  note: note
2891
2955
  });
2892
2956
  case 2:
2893
- return _context15.abrupt("return", note);
2957
+ return _context16.abrupt("return", note);
2894
2958
  case 3:
2895
2959
  case "end":
2896
- return _context15.stop();
2960
+ return _context16.stop();
2897
2961
  }
2898
- }, _callee13, this);
2962
+ }, _callee14, this);
2899
2963
  }));
2900
- function syncTempOrderNoteToRemote(_x11, _x12) {
2964
+ function syncTempOrderNoteToRemote(_x12, _x13) {
2901
2965
  return _syncTempOrderNoteToRemote.apply(this, arguments);
2902
2966
  }
2903
2967
  return syncTempOrderNoteToRemote;
@@ -2990,35 +3054,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2990
3054
  }, {
2991
3055
  key: "productHasCustomerBoundDiscount",
2992
3056
  value: function productHasCustomerBoundDiscount(product) {
2993
- var _this16 = this;
3057
+ var _this17 = this;
2994
3058
  if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
2995
- return _this16.isCustomerBoundDiscount(discount);
3059
+ return _this17.isCustomerBoundDiscount(discount);
2996
3060
  })) {
2997
3061
  return true;
2998
3062
  }
2999
3063
  return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
3000
3064
  return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
3001
- return _this16.isCustomerBoundDiscount(discount);
3065
+ return _this17.isCustomerBoundDiscount(discount);
3002
3066
  });
3003
3067
  });
3004
3068
  }
3005
3069
  }, {
3006
3070
  key: "shouldSkipDiscountCalculation",
3007
3071
  value: function shouldSkipDiscountCalculation(tempOrder) {
3008
- var _this$store$discount13,
3009
- _this$store$discount14,
3010
- _this17 = this;
3072
+ var _this$store$discount17,
3073
+ _this$store$discount18,
3074
+ _this18 = this;
3011
3075
  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)) || [];
3076
+ 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
3077
  if (discountList.length > 0) return false;
3014
3078
  return !(tempOrder.products || []).some(function (product) {
3015
- return _this17.productHasCustomerBoundDiscount(product);
3079
+ return _this18.productHasCustomerBoundDiscount(product);
3016
3080
  });
3017
3081
  }
3018
3082
  }, {
3019
3083
  key: "clearCustomerBoundDiscounts",
3020
3084
  value: function clearCustomerBoundDiscounts(tempOrder) {
3021
- var _this18 = this,
3085
+ var _this19 = this,
3022
3086
  _discountModule$getDi,
3023
3087
  _discountModule$getOr,
3024
3088
  _discountModule$setDi,
@@ -3027,7 +3091,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3027
3091
  var filterDiscountList = function filterDiscountList(discountList) {
3028
3092
  if (!Array.isArray(discountList)) return [];
3029
3093
  return discountList.filter(function (discount) {
3030
- var shouldRemove = _this18.isCustomerBoundDiscount(discount);
3094
+ var shouldRemove = _this19.isCustomerBoundDiscount(discount);
3031
3095
  if (shouldRemove) didRemoveCustomerBoundDiscount = true;
3032
3096
  return !shouldRemove;
3033
3097
  });
@@ -3054,12 +3118,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3054
3118
  var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
3055
3119
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
3056
3120
  var nextDiscounts = currentDiscounts.filter(function (discount) {
3057
- if (_this18.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3058
- return !_this18.isCustomerBoundDiscount(discount);
3121
+ if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3122
+ return !_this19.isCustomerBoundDiscount(discount);
3059
3123
  });
3060
3124
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
3061
- if (_this18.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3062
- return !_this18.isCustomerBoundDiscount(discount);
3125
+ if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3126
+ return !_this19.isCustomerBoundDiscount(discount);
3063
3127
  });
3064
3128
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
3065
3129
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -3130,7 +3194,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3130
3194
  }
3131
3195
  var nextCustomerId = (_tempOrder$customer_i5 = tempOrder.customer_id) !== null && _tempOrder$customer_i5 !== void 0 ? _tempOrder$customer_i5 : null;
3132
3196
  if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
3133
- this.store.availableWalletIds = [];
3134
3197
  clearTempOrderHolderAssignments(tempOrder);
3135
3198
  this.clearCustomerBoundDiscounts(tempOrder);
3136
3199
  this.applyDiscount();
@@ -3175,7 +3238,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3175
3238
  tempOrder.email = '';
3176
3239
  tempOrder.customer = null;
3177
3240
  if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
3178
- this.store.availableWalletIds = [];
3179
3241
  this.clearCustomerBoundDiscounts(tempOrder);
3180
3242
  this.persistTempOrder();
3181
3243
  this.saveDraftInBackground();
@@ -3229,7 +3291,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3229
3291
  }, {
3230
3292
  key: "addOrderPayment",
3231
3293
  value: function addOrderPayment(payment) {
3232
- var _this19 = this;
3294
+ var _this20 = this;
3233
3295
  this.logInfo('addOrderPayment', {
3234
3296
  payment: payment
3235
3297
  });
@@ -3246,7 +3308,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3246
3308
  void this.recalculateSummary({
3247
3309
  createIfMissing: true
3248
3310
  }).catch(function (error) {
3249
- _this19.logError('recalculate summary after addOrderPayment failed', {
3311
+ _this20.logError('recalculate summary after addOrderPayment failed', {
3250
3312
  error: error instanceof Error ? error.message : String(error)
3251
3313
  });
3252
3314
  });
@@ -3328,7 +3390,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3328
3390
  }, {
3329
3391
  key: "applyPaymentLifecycleChange",
3330
3392
  value: function applyPaymentLifecycleChange(tempOrder, options) {
3331
- var _this20 = this;
3393
+ var _this21 = this;
3332
3394
  this.updateTempOrderPaymentStatus(tempOrder);
3333
3395
  if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
3334
3396
  this.persistTempOrder();
@@ -3338,7 +3400,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3338
3400
  void this.recalculateSummary({
3339
3401
  createIfMissing: true
3340
3402
  }).catch(function (error) {
3341
- _this20.logError("recalculate summary after ".concat(logContext, " failed"), {
3403
+ _this21.logError("recalculate summary after ".concat(logContext, " failed"), {
3342
3404
  error: error instanceof Error ? error.message : String(error)
3343
3405
  });
3344
3406
  });
@@ -3382,7 +3444,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3382
3444
  }, {
3383
3445
  key: "updateVoucherOrderPayments",
3384
3446
  value: function updateVoucherOrderPayments(payments, options) {
3385
- var _this21 = this;
3447
+ var _this22 = this;
3386
3448
  var tempOrder = this.ensureTempOrder();
3387
3449
  var isOrderPaymentType = function isOrderPaymentType(value) {
3388
3450
  return value === 'normal' || value === 'deposit';
@@ -3417,7 +3479,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3417
3479
  });
3418
3480
  };
3419
3481
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
3420
- return _this21.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
3482
+ return _this22.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
3421
3483
  defaultPaid: false
3422
3484
  });
3423
3485
  })).filter(function (payment) {
@@ -3466,7 +3528,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3466
3528
  void this.recalculateSummary({
3467
3529
  createIfMissing: true
3468
3530
  }).catch(function (error) {
3469
- _this21.logError('recalculate summary after updateVoucherOrderPayments failed', {
3531
+ _this22.logError('recalculate summary after updateVoucherOrderPayments failed', {
3470
3532
  error: error instanceof Error ? error.message : String(error)
3471
3533
  });
3472
3534
  });
@@ -3475,45 +3537,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3475
3537
  }, {
3476
3538
  key: "shouldMergeProductToOrder",
3477
3539
  value: function () {
3478
- var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
3540
+ var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
3479
3541
  var _this$orderHooks;
3480
3542
  var onBeforeMergeProductToOrder, result;
3481
- return _regeneratorRuntime().wrap(function _callee14$(_context16) {
3482
- while (1) switch (_context16.prev = _context16.next) {
3543
+ return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3544
+ while (1) switch (_context17.prev = _context17.next) {
3483
3545
  case 0:
3484
3546
  onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
3485
3547
  if (onBeforeMergeProductToOrder) {
3486
- _context16.next = 3;
3548
+ _context17.next = 3;
3487
3549
  break;
3488
3550
  }
3489
- return _context16.abrupt("return", true);
3551
+ return _context17.abrupt("return", true);
3490
3552
  case 3:
3491
- _context16.next = 5;
3553
+ _context17.next = 5;
3492
3554
  return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
3493
3555
  defaultShouldMerge: true
3494
3556
  }));
3495
3557
  case 5:
3496
- result = _context16.sent;
3558
+ result = _context17.sent;
3497
3559
  if (!(typeof result === 'boolean')) {
3498
- _context16.next = 8;
3560
+ _context17.next = 8;
3499
3561
  break;
3500
3562
  }
3501
- return _context16.abrupt("return", result);
3563
+ return _context17.abrupt("return", result);
3502
3564
  case 8:
3503
3565
  if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
3504
- _context16.next = 10;
3566
+ _context17.next = 10;
3505
3567
  break;
3506
3568
  }
3507
- return _context16.abrupt("return", result.shouldMerge);
3569
+ return _context17.abrupt("return", result.shouldMerge);
3508
3570
  case 10:
3509
- return _context16.abrupt("return", true);
3571
+ return _context17.abrupt("return", true);
3510
3572
  case 11:
3511
3573
  case "end":
3512
- return _context16.stop();
3574
+ return _context17.stop();
3513
3575
  }
3514
- }, _callee14, this);
3576
+ }, _callee15, this);
3515
3577
  }));
3516
- function shouldMergeProductToOrder(_x13) {
3578
+ function shouldMergeProductToOrder(_x14) {
3517
3579
  return _shouldMergeProductToOrder.apply(this, arguments);
3518
3580
  }
3519
3581
  return shouldMergeProductToOrder;
@@ -3549,30 +3611,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3549
3611
  }, {
3550
3612
  key: "finalizeProductOrderMutation",
3551
3613
  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) {
3614
+ var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, options) {
3615
+ return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3616
+ while (1) switch (_context18.prev = _context18.next) {
3555
3617
  case 0:
3556
3618
  this.syncTempOrderHolderFromBookings(tempOrder);
3557
3619
  if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
3558
- _context17.next = 4;
3620
+ _context18.next = 4;
3559
3621
  break;
3560
3622
  }
3561
- _context17.next = 4;
3623
+ _context18.next = 4;
3562
3624
  return this.ensureEditDiscountConfigForProductChange(tempOrder);
3563
3625
  case 4:
3564
3626
  if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
3565
- _context17.next = 7;
3627
+ _context18.next = 7;
3566
3628
  break;
3567
3629
  }
3568
- _context17.next = 7;
3630
+ _context18.next = 7;
3569
3631
  return this.applyPromotion();
3570
3632
  case 7:
3571
3633
  if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
3572
3634
  this.applyDiscount();
3573
3635
  }
3574
3636
  this.sanitizeTempOrderProducts(tempOrder);
3575
- _context17.next = 11;
3637
+ _context18.next = 11;
3576
3638
  return this.recalculateSummary({
3577
3639
  createIfMissing: true
3578
3640
  });
@@ -3580,11 +3642,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3580
3642
  this.persistTempOrder();
3581
3643
  case 12:
3582
3644
  case "end":
3583
- return _context17.stop();
3645
+ return _context18.stop();
3584
3646
  }
3585
- }, _callee15, this);
3647
+ }, _callee16, this);
3586
3648
  }));
3587
- function finalizeProductOrderMutation(_x14, _x15) {
3649
+ function finalizeProductOrderMutation(_x15, _x16) {
3588
3650
  return _finalizeProductOrderMutation.apply(this, arguments);
3589
3651
  }
3590
3652
  return finalizeProductOrderMutation;
@@ -3599,13 +3661,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3599
3661
  }, {
3600
3662
  key: "appendProductLineToTempOrder",
3601
3663
  value: (function () {
3602
- var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, product, booking) {
3664
+ var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(tempOrder, product, booking) {
3603
3665
  var _booking_uid,
3604
3666
  _metadata,
3605
- _this22 = this;
3667
+ _this23 = this;
3606
3668
  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) {
3669
+ return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3670
+ while (1) switch (_context19.prev = _context19.next) {
3609
3671
  case 0:
3610
3672
  linked = booking ? this.createLinkedProductAndBooking({
3611
3673
  product: product,
@@ -3627,8 +3689,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3627
3689
  hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
3628
3690
  shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
3629
3691
  matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
3630
- if (_this22.hasGoodPassDiscount(item)) return false;
3631
- if (_this22.hasOrderProductLineNote(item)) return false;
3692
+ if (_this23.hasGoodPassDiscount(item)) return false;
3693
+ if (_this23.hasOrderProductLineNote(item)) return false;
3632
3694
  if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
3633
3695
  if (item.product_id !== productToAdd.product_id) return false;
3634
3696
  if (item.product_variant_id !== productToAdd.product_variant_id) return false;
@@ -3638,10 +3700,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3638
3700
  matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
3639
3701
  existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
3640
3702
  if (!matchedProduct) {
3641
- _context18.next = 20;
3703
+ _context19.next = 20;
3642
3704
  break;
3643
3705
  }
3644
- _context18.next = 17;
3706
+ _context19.next = 17;
3645
3707
  return this.shouldMergeProductToOrder({
3646
3708
  incomingProduct: productToAdd,
3647
3709
  normalizedIncoming: normalizedIncoming,
@@ -3653,13 +3715,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3653
3715
  booking: booking
3654
3716
  });
3655
3717
  case 17:
3656
- _context18.t0 = _context18.sent;
3657
- _context18.next = 21;
3718
+ _context19.t0 = _context19.sent;
3719
+ _context19.next = 21;
3658
3720
  break;
3659
3721
  case 20:
3660
- _context18.t0 = false;
3722
+ _context19.t0 = false;
3661
3723
  case 21:
3662
- shouldMerge = _context18.t0;
3724
+ shouldMerge = _context19.t0;
3663
3725
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
3664
3726
  this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
3665
3727
  if (linked) {
@@ -3713,11 +3775,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3713
3775
  }
3714
3776
  case 24:
3715
3777
  case "end":
3716
- return _context18.stop();
3778
+ return _context19.stop();
3717
3779
  }
3718
- }, _callee16, this);
3780
+ }, _callee17, this);
3719
3781
  }));
3720
- function appendProductLineToTempOrder(_x16, _x17, _x18) {
3782
+ function appendProductLineToTempOrder(_x17, _x18, _x19) {
3721
3783
  return _appendProductLineToTempOrder.apply(this, arguments);
3722
3784
  }
3723
3785
  return appendProductLineToTempOrder;
@@ -3733,61 +3795,61 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3733
3795
  }, {
3734
3796
  key: "addProductToOrder",
3735
3797
  value: (function () {
3736
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(product, booking) {
3798
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(product, booking) {
3737
3799
  var tempOrder, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
3738
- return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3739
- while (1) switch (_context19.prev = _context19.next) {
3800
+ return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3801
+ while (1) switch (_context20.prev = _context20.next) {
3740
3802
  case 0:
3741
3803
  tempOrder = this.ensureTempOrder();
3742
3804
  if (!booking) {
3743
- _context19.next = 18;
3805
+ _context20.next = 18;
3744
3806
  break;
3745
3807
  }
3746
3808
  productRecord = product;
3747
3809
  splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
3748
3810
  if (!(splitCount > 1)) {
3749
- _context19.next = 18;
3811
+ _context20.next = 18;
3750
3812
  break;
3751
3813
  }
3752
3814
  i = 0;
3753
3815
  case 6:
3754
3816
  if (!(i < splitCount)) {
3755
- _context19.next = 15;
3817
+ _context20.next = 15;
3756
3818
  break;
3757
3819
  }
3758
3820
  singleLine = cloneDeep(productRecord);
3759
3821
  singleLine.num = 1;
3760
3822
  delete singleLine.product_quantity;
3761
- _context19.next = 12;
3823
+ _context20.next = 12;
3762
3824
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
3763
3825
  case 12:
3764
3826
  i += 1;
3765
- _context19.next = 6;
3827
+ _context20.next = 6;
3766
3828
  break;
3767
3829
  case 15:
3768
- _context19.next = 17;
3830
+ _context20.next = 17;
3769
3831
  return this.finalizeProductOrderMutation(tempOrder);
3770
3832
  case 17:
3771
- return _context19.abrupt("return", tempOrder.products);
3833
+ return _context20.abrupt("return", tempOrder.products);
3772
3834
  case 18:
3773
- _context19.next = 20;
3835
+ _context20.next = 20;
3774
3836
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
3775
3837
  case 20:
3776
- _context19.next = 22;
3838
+ _context20.next = 22;
3777
3839
  return this.finalizeProductOrderMutation(tempOrder);
3778
3840
  case 22:
3779
3841
  this.logInfo('addProductToOrder success', {
3780
3842
  product_id: product.product_id,
3781
3843
  with_booking: !!booking
3782
3844
  });
3783
- return _context19.abrupt("return", tempOrder.products);
3845
+ return _context20.abrupt("return", tempOrder.products);
3784
3846
  case 24:
3785
3847
  case "end":
3786
- return _context19.stop();
3848
+ return _context20.stop();
3787
3849
  }
3788
- }, _callee17, this);
3850
+ }, _callee18, this);
3789
3851
  }));
3790
- function addProductToOrder(_x19, _x20) {
3852
+ function addProductToOrder(_x20, _x21) {
3791
3853
  return _addProductToOrder.apply(this, arguments);
3792
3854
  }
3793
3855
  return addProductToOrder;
@@ -3805,93 +3867,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3805
3867
  }, {
3806
3868
  key: "addProductsToOrder",
3807
3869
  value: (function () {
3808
- var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(items, options) {
3870
+ var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(items, options) {
3809
3871
  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) {
3872
+ return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3873
+ while (1) switch (_context21.prev = _context21.next) {
3812
3874
  case 0:
3813
3875
  tempOrder = this.ensureTempOrder();
3814
3876
  if (!(!Array.isArray(items) || items.length === 0)) {
3815
- _context20.next = 3;
3877
+ _context21.next = 3;
3816
3878
  break;
3817
3879
  }
3818
- return _context20.abrupt("return", tempOrder.products);
3880
+ return _context21.abrupt("return", tempOrder.products);
3819
3881
  case 3:
3820
3882
  _iterator20 = _createForOfIteratorHelper(items || []);
3821
- _context20.prev = 4;
3883
+ _context21.prev = 4;
3822
3884
  _iterator20.s();
3823
3885
  case 6:
3824
3886
  if ((_step20 = _iterator20.n()).done) {
3825
- _context20.next = 30;
3887
+ _context21.next = 30;
3826
3888
  break;
3827
3889
  }
3828
3890
  item = _step20.value;
3829
3891
  product = item.product, booking = item.booking;
3830
3892
  if (product) {
3831
- _context20.next = 11;
3893
+ _context21.next = 11;
3832
3894
  break;
3833
3895
  }
3834
- return _context20.abrupt("continue", 28);
3896
+ return _context21.abrupt("continue", 28);
3835
3897
  case 11:
3836
3898
  if (!booking) {
3837
- _context20.next = 26;
3899
+ _context21.next = 26;
3838
3900
  break;
3839
3901
  }
3840
3902
  productRecord = product;
3841
3903
  splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
3842
3904
  if (!(splitCount > 1)) {
3843
- _context20.next = 26;
3905
+ _context21.next = 26;
3844
3906
  break;
3845
3907
  }
3846
3908
  i = 0;
3847
3909
  case 16:
3848
3910
  if (!(i < splitCount)) {
3849
- _context20.next = 25;
3911
+ _context21.next = 25;
3850
3912
  break;
3851
3913
  }
3852
3914
  singleLine = cloneDeep(productRecord);
3853
3915
  singleLine.num = 1;
3854
3916
  delete singleLine.product_quantity;
3855
- _context20.next = 22;
3917
+ _context21.next = 22;
3856
3918
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
3857
3919
  case 22:
3858
3920
  i += 1;
3859
- _context20.next = 16;
3921
+ _context21.next = 16;
3860
3922
  break;
3861
3923
  case 25:
3862
- return _context20.abrupt("continue", 28);
3924
+ return _context21.abrupt("continue", 28);
3863
3925
  case 26:
3864
- _context20.next = 28;
3926
+ _context21.next = 28;
3865
3927
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
3866
3928
  case 28:
3867
- _context20.next = 6;
3929
+ _context21.next = 6;
3868
3930
  break;
3869
3931
  case 30:
3870
- _context20.next = 35;
3932
+ _context21.next = 35;
3871
3933
  break;
3872
3934
  case 32:
3873
- _context20.prev = 32;
3874
- _context20.t0 = _context20["catch"](4);
3875
- _iterator20.e(_context20.t0);
3935
+ _context21.prev = 32;
3936
+ _context21.t0 = _context21["catch"](4);
3937
+ _iterator20.e(_context21.t0);
3876
3938
  case 35:
3877
- _context20.prev = 35;
3939
+ _context21.prev = 35;
3878
3940
  _iterator20.f();
3879
- return _context20.finish(35);
3941
+ return _context21.finish(35);
3880
3942
  case 38:
3881
- _context20.next = 40;
3943
+ _context21.next = 40;
3882
3944
  return this.finalizeProductOrderMutation(tempOrder, options);
3883
3945
  case 40:
3884
3946
  this.logInfo('addProductsToOrder success', {
3885
3947
  itemsCount: items.length
3886
3948
  });
3887
- return _context20.abrupt("return", tempOrder.products);
3949
+ return _context21.abrupt("return", tempOrder.products);
3888
3950
  case 42:
3889
3951
  case "end":
3890
- return _context20.stop();
3952
+ return _context21.stop();
3891
3953
  }
3892
- }, _callee18, this, [[4, 32, 35, 38]]);
3954
+ }, _callee19, this, [[4, 32, 35, 38]]);
3893
3955
  }));
3894
- function addProductsToOrder(_x21, _x22) {
3956
+ function addProductsToOrder(_x22, _x23) {
3895
3957
  return _addProductsToOrder.apply(this, arguments);
3896
3958
  }
3897
3959
  return addProductsToOrder;
@@ -3925,17 +3987,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3925
3987
  }, {
3926
3988
  key: "preservePersistedBundlePriceFields",
3927
3989
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
3928
- var _this23 = this;
3990
+ var _this24 = this;
3929
3991
  if (!Array.isArray(nextBundles)) return nextBundles;
3930
3992
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
3931
3993
  var previousByIdentity = new Map();
3932
3994
  previousBundles.forEach(function (bundle) {
3933
- var identity = _this23.getBundleRuntimeIdentity(bundle);
3995
+ var identity = _this24.getBundleRuntimeIdentity(bundle);
3934
3996
  if (identity) previousByIdentity.set(identity, bundle);
3935
3997
  });
3936
3998
  return nextBundles.map(function (bundle, index) {
3937
3999
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
3938
- var previous = previousByIdentity.get(_this23.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
4000
+ var previous = previousByIdentity.get(_this24.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
3939
4001
  if (!previous || _typeof(previous) !== 'object') return bundle;
3940
4002
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
3941
4003
  cover: previous.cover
@@ -4088,21 +4150,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4088
4150
  }, {
4089
4151
  key: "updateOrderProduct",
4090
4152
  value: function () {
4091
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
4153
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
4092
4154
  var tempOrder, updatedProductUid;
4093
- return _regeneratorRuntime().wrap(function _callee19$(_context21) {
4094
- while (1) switch (_context21.prev = _context21.next) {
4155
+ return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4156
+ while (1) switch (_context22.prev = _context22.next) {
4095
4157
  case 0:
4096
4158
  tempOrder = this.ensureTempOrder();
4097
4159
  updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
4098
- _context21.next = 4;
4160
+ _context22.next = 4;
4099
4161
  return this.applyPromotion();
4100
4162
  case 4:
4101
4163
  this.applyDiscount({
4102
4164
  reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
4103
4165
  });
4104
4166
  this.sanitizeTempOrderProducts(tempOrder);
4105
- _context21.next = 8;
4167
+ _context22.next = 8;
4106
4168
  return this.recalculateSummary({
4107
4169
  createIfMissing: true
4108
4170
  });
@@ -4111,14 +4173,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4111
4173
  this.logInfo('updateOrderProduct success', {
4112
4174
  params: params
4113
4175
  });
4114
- return _context21.abrupt("return", tempOrder.products);
4176
+ return _context22.abrupt("return", tempOrder.products);
4115
4177
  case 11:
4116
4178
  case "end":
4117
- return _context21.stop();
4179
+ return _context22.stop();
4118
4180
  }
4119
- }, _callee19, this);
4181
+ }, _callee20, this);
4120
4182
  }));
4121
- function updateOrderProduct(_x23) {
4183
+ function updateOrderProduct(_x24) {
4122
4184
  return _updateOrderProduct.apply(this, arguments);
4123
4185
  }
4124
4186
  return updateOrderProduct;
@@ -4126,28 +4188,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4126
4188
  }, {
4127
4189
  key: "updateOrderProducts",
4128
4190
  value: function () {
4129
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(paramsList) {
4130
- var _this24 = this;
4191
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(paramsList) {
4192
+ var _this25 = this;
4131
4193
  var tempOrder, reapplyBookingDiscountProductUids;
4132
- return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4133
- while (1) switch (_context22.prev = _context22.next) {
4194
+ return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4195
+ while (1) switch (_context23.prev = _context23.next) {
4134
4196
  case 0:
4135
4197
  tempOrder = this.ensureTempOrder();
4136
4198
  if (paramsList.length) {
4137
- _context22.next = 3;
4199
+ _context23.next = 3;
4138
4200
  break;
4139
4201
  }
4140
- return _context22.abrupt("return", tempOrder.products);
4202
+ return _context23.abrupt("return", tempOrder.products);
4141
4203
  case 3:
4142
4204
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
4143
- var updatedProductUid = _this24.applyOrderProductUpdateToTempOrder(tempOrder, params);
4205
+ var updatedProductUid = _this25.applyOrderProductUpdateToTempOrder(tempOrder, params);
4144
4206
  // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
4145
4207
  if (params.allow_booking_discount_reapply && updatedProductUid) {
4146
4208
  acc.push(String(updatedProductUid));
4147
4209
  }
4148
4210
  return acc;
4149
4211
  }, []);
4150
- _context22.next = 6;
4212
+ _context23.next = 6;
4151
4213
  return this.finalizeAfterProductsMutation(tempOrder, {
4152
4214
  reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
4153
4215
  });
@@ -4155,14 +4217,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4155
4217
  this.logInfo('updateOrderProduct success', {
4156
4218
  paramsList: paramsList
4157
4219
  });
4158
- return _context22.abrupt("return", tempOrder.products);
4220
+ return _context23.abrupt("return", tempOrder.products);
4159
4221
  case 8:
4160
4222
  case "end":
4161
- return _context22.stop();
4223
+ return _context23.stop();
4162
4224
  }
4163
- }, _callee20, this);
4225
+ }, _callee21, this);
4164
4226
  }));
4165
- function updateOrderProducts(_x24) {
4227
+ function updateOrderProducts(_x25) {
4166
4228
  return _updateOrderProducts.apply(this, arguments);
4167
4229
  }
4168
4230
  return updateOrderProducts;
@@ -4170,11 +4232,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4170
4232
  }, {
4171
4233
  key: "updateOrderProductQuantity",
4172
4234
  value: function () {
4173
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
4235
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
4174
4236
  var _targetProduct$metada10;
4175
4237
  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) {
4238
+ return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4239
+ while (1) switch (_context24.prev = _context24.next) {
4178
4240
  case 0:
4179
4241
  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
4242
  tempOrder = this.ensureTempOrder();
@@ -4203,7 +4265,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4203
4265
  productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
4204
4266
  }
4205
4267
  if (!(productIndex === -1)) {
4206
- _context23.next = 12;
4268
+ _context24.next = 12;
4207
4269
  break;
4208
4270
  }
4209
4271
  throw new Error('[Order] 目标商品不存在,无法更新数量');
@@ -4217,12 +4279,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4217
4279
  }));
4218
4280
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
4219
4281
  tempOrder.products[productIndex] = normalizedProduct;
4220
- _context23.next = 18;
4282
+ _context24.next = 18;
4221
4283
  return this.applyPromotion();
4222
4284
  case 18:
4223
4285
  this.applyDiscount();
4224
4286
  this.sanitizeTempOrderProducts(tempOrder);
4225
- _context23.next = 22;
4287
+ _context24.next = 22;
4226
4288
  return this.recalculateSummary({
4227
4289
  createIfMissing: true
4228
4290
  });
@@ -4231,14 +4293,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4231
4293
  this.logInfo('updateOrderProductQuantity success', {
4232
4294
  params: params
4233
4295
  });
4234
- return _context23.abrupt("return", tempOrder.products);
4296
+ return _context24.abrupt("return", tempOrder.products);
4235
4297
  case 25:
4236
4298
  case "end":
4237
- return _context23.stop();
4299
+ return _context24.stop();
4238
4300
  }
4239
- }, _callee21, this);
4301
+ }, _callee22, this);
4240
4302
  }));
4241
- function updateOrderProductQuantity(_x25) {
4303
+ function updateOrderProductQuantity(_x26) {
4242
4304
  return _updateOrderProductQuantity.apply(this, arguments);
4243
4305
  }
4244
4306
  return updateOrderProductQuantity;
@@ -4279,19 +4341,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4279
4341
  }, {
4280
4342
  key: "finalizeAfterProductsMutation",
4281
4343
  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) {
4344
+ var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(tempOrder, options) {
4345
+ return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4346
+ while (1) switch (_context25.prev = _context25.next) {
4285
4347
  case 0:
4286
4348
  this.syncTempOrderHolderFromBookings(tempOrder);
4287
- _context24.next = 3;
4349
+ _context25.next = 3;
4288
4350
  return this.applyPromotion();
4289
4351
  case 3:
4290
4352
  this.applyDiscount({
4291
4353
  reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
4292
4354
  });
4293
4355
  this.sanitizeTempOrderProducts(tempOrder);
4294
- _context24.next = 7;
4356
+ _context25.next = 7;
4295
4357
  return this.recalculateSummary({
4296
4358
  createIfMissing: true
4297
4359
  });
@@ -4299,11 +4361,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4299
4361
  this.persistTempOrder();
4300
4362
  case 8:
4301
4363
  case "end":
4302
- return _context24.stop();
4364
+ return _context25.stop();
4303
4365
  }
4304
- }, _callee22, this);
4366
+ }, _callee23, this);
4305
4367
  }));
4306
- function finalizeAfterProductsMutation(_x26, _x27) {
4368
+ function finalizeAfterProductsMutation(_x27, _x28) {
4307
4369
  return _finalizeAfterProductsMutation.apply(this, arguments);
4308
4370
  }
4309
4371
  return finalizeAfterProductsMutation;
@@ -4318,18 +4380,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4318
4380
  }, {
4319
4381
  key: "removeProductsFromOrder",
4320
4382
  value: (function () {
4321
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(identities) {
4322
- var _this25 = this;
4383
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identities) {
4384
+ var _this26 = this;
4323
4385
  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) {
4386
+ return _regeneratorRuntime().wrap(function _callee24$(_context27) {
4387
+ while (1) switch (_context27.prev = _context27.next) {
4326
4388
  case 0:
4327
4389
  tempOrder = this.ensureTempOrder();
4328
4390
  if (identities.length) {
4329
- _context26.next = 3;
4391
+ _context27.next = 3;
4330
4392
  break;
4331
4393
  }
4332
- return _context26.abrupt("return", tempOrder.products);
4394
+ return _context27.abrupt("return", tempOrder.products);
4333
4395
  case 3:
4334
4396
  productsBeforeRemove = tempOrder.products || [];
4335
4397
  bookingsBeforeRemove = tempOrder.bookings || [];
@@ -4352,29 +4414,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4352
4414
  }
4353
4415
  linkedBookingUidsToRemove = new Set();
4354
4416
  _iterator21 = _createForOfIteratorHelper(matchedProducts);
4355
- _context26.prev = 11;
4417
+ _context27.prev = 11;
4356
4418
  _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
4357
4419
  var _metadata8, _metadata9, _metadata10, _metadata11;
4358
4420
  var product, productUid, productBookingUid, isAddTimeProduct;
4359
- return _regeneratorRuntime().wrap(function _loop3$(_context25) {
4360
- while (1) switch (_context25.prev = _context25.next) {
4421
+ return _regeneratorRuntime().wrap(function _loop3$(_context26) {
4422
+ while (1) switch (_context26.prev = _context26.next) {
4361
4423
  case 0:
4362
4424
  product = _step21.value;
4363
4425
  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
4426
  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
4427
  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
4428
  if (!isAddTimeProduct) {
4367
- _context25.next = 6;
4429
+ _context26.next = 6;
4368
4430
  break;
4369
4431
  }
4370
- return _context25.abrupt("return", 1);
4432
+ return _context26.abrupt("return", 1);
4371
4433
  case 6:
4372
4434
  if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
4373
4435
  linkedBookingUidsToRemove.add(String(productBookingUid));
4374
4436
  }
4375
4437
  if (productUid !== undefined && productUid !== null && productUid !== '') {
4376
4438
  bookingsBeforeRemove.forEach(function (booking) {
4377
- var bookingUid = _this25.getBookingUniqueIdentificationNumber(booking);
4439
+ var bookingUid = _this26.getBookingUniqueIdentificationNumber(booking);
4378
4440
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
4379
4441
  linkedBookingUidsToRemove.add(bookingUid);
4380
4442
  }
@@ -4382,37 +4444,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4382
4444
  }
4383
4445
  case 8:
4384
4446
  case "end":
4385
- return _context25.stop();
4447
+ return _context26.stop();
4386
4448
  }
4387
4449
  }, _loop3);
4388
4450
  });
4389
4451
  _iterator21.s();
4390
4452
  case 14:
4391
4453
  if ((_step21 = _iterator21.n()).done) {
4392
- _context26.next = 20;
4454
+ _context27.next = 20;
4393
4455
  break;
4394
4456
  }
4395
- return _context26.delegateYield(_loop3(), "t0", 16);
4457
+ return _context27.delegateYield(_loop3(), "t0", 16);
4396
4458
  case 16:
4397
- if (!_context26.t0) {
4398
- _context26.next = 18;
4459
+ if (!_context27.t0) {
4460
+ _context27.next = 18;
4399
4461
  break;
4400
4462
  }
4401
- return _context26.abrupt("continue", 18);
4463
+ return _context27.abrupt("continue", 18);
4402
4464
  case 18:
4403
- _context26.next = 14;
4465
+ _context27.next = 14;
4404
4466
  break;
4405
4467
  case 20:
4406
- _context26.next = 25;
4468
+ _context27.next = 25;
4407
4469
  break;
4408
4470
  case 22:
4409
- _context26.prev = 22;
4410
- _context26.t1 = _context26["catch"](11);
4411
- _iterator21.e(_context26.t1);
4471
+ _context27.prev = 22;
4472
+ _context27.t1 = _context27["catch"](11);
4473
+ _iterator21.e(_context27.t1);
4412
4474
  case 25:
4413
- _context26.prev = 25;
4475
+ _context27.prev = 25;
4414
4476
  _iterator21.f();
4415
- return _context26.finish(25);
4477
+ return _context27.finish(25);
4416
4478
  case 28:
4417
4479
  if (linkedBookingUidsToRemove.size > 0) {
4418
4480
  // 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
@@ -4423,20 +4485,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4423
4485
  return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
4424
4486
  });
4425
4487
  }
4426
- _context26.next = 31;
4488
+ _context27.next = 31;
4427
4489
  return this.finalizeAfterProductsMutation(tempOrder);
4428
4490
  case 31:
4429
4491
  this.logInfo('removeProductsFromOrder success', {
4430
4492
  identities: identities
4431
4493
  });
4432
- return _context26.abrupt("return", tempOrder.products);
4494
+ return _context27.abrupt("return", tempOrder.products);
4433
4495
  case 33:
4434
4496
  case "end":
4435
- return _context26.stop();
4497
+ return _context27.stop();
4436
4498
  }
4437
- }, _callee23, this, [[11, 22, 25, 28]]);
4499
+ }, _callee24, this, [[11, 22, 25, 28]]);
4438
4500
  }));
4439
- function removeProductsFromOrder(_x28) {
4501
+ function removeProductsFromOrder(_x29) {
4440
4502
  return _removeProductsFromOrder.apply(this, arguments);
4441
4503
  }
4442
4504
  return removeProductsFromOrder;
@@ -4444,18 +4506,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4444
4506
  }, {
4445
4507
  key: "removeProductFromOrder",
4446
4508
  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) {
4509
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(identity) {
4510
+ return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4511
+ while (1) switch (_context28.prev = _context28.next) {
4450
4512
  case 0:
4451
- return _context27.abrupt("return", this.removeProductsFromOrder([identity]));
4513
+ return _context28.abrupt("return", this.removeProductsFromOrder([identity]));
4452
4514
  case 1:
4453
4515
  case "end":
4454
- return _context27.stop();
4516
+ return _context28.stop();
4455
4517
  }
4456
- }, _callee24, this);
4518
+ }, _callee25, this);
4457
4519
  }));
4458
- function removeProductFromOrder(_x29) {
4520
+ function removeProductFromOrder(_x30) {
4459
4521
  return _removeProductFromOrder.apply(this, arguments);
4460
4522
  }
4461
4523
  return removeProductFromOrder;
@@ -4467,10 +4529,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4467
4529
  }, {
4468
4530
  key: "clearOrderCartLines",
4469
4531
  value: (function () {
4470
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
4532
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
4471
4533
  var tempOrder;
4472
- return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4473
- while (1) switch (_context28.prev = _context28.next) {
4534
+ return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4535
+ while (1) switch (_context29.prev = _context29.next) {
4474
4536
  case 0:
4475
4537
  tempOrder = this.ensureTempOrder();
4476
4538
  tempOrder.products = [];
@@ -4481,24 +4543,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4481
4543
  productsByUid: {}
4482
4544
  });
4483
4545
  }
4484
- _context28.next = 7;
4546
+ _context29.next = 7;
4485
4547
  return this.applyPromotion();
4486
4548
  case 7:
4487
4549
  this.applyDiscount();
4488
4550
  this.sanitizeTempOrderProducts(tempOrder);
4489
- _context28.next = 11;
4551
+ _context29.next = 11;
4490
4552
  return this.recalculateSummary({
4491
4553
  createIfMissing: true
4492
4554
  });
4493
4555
  case 11:
4494
4556
  this.persistTempOrder();
4495
4557
  this.logInfo('clearOrderCartLines success', {});
4496
- return _context28.abrupt("return", tempOrder);
4558
+ return _context29.abrupt("return", tempOrder);
4497
4559
  case 14:
4498
4560
  case "end":
4499
- return _context28.stop();
4561
+ return _context29.stop();
4500
4562
  }
4501
- }, _callee25, this);
4563
+ }, _callee26, this);
4502
4564
  }));
4503
4565
  function clearOrderCartLines() {
4504
4566
  return _clearOrderCartLines.apply(this, arguments);
@@ -4536,17 +4598,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4536
4598
  }, {
4537
4599
  key: "applyLocalPrintOrderNumbers",
4538
4600
  value: function () {
4539
- var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(order) {
4601
+ var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(order) {
4540
4602
  var tempOrder, shopOrderNumber, shopFullOrderNumber;
4541
- return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4542
- while (1) switch (_context29.prev = _context29.next) {
4603
+ return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4604
+ while (1) switch (_context30.prev = _context30.next) {
4543
4605
  case 0:
4544
4606
  tempOrder = this.ensureTempOrder();
4545
4607
  if (!(!order || _typeof(order) !== 'object')) {
4546
- _context29.next = 3;
4608
+ _context30.next = 3;
4547
4609
  break;
4548
4610
  }
4549
- return _context29.abrupt("return", tempOrder);
4611
+ return _context30.abrupt("return", tempOrder);
4550
4612
  case 3:
4551
4613
  shopOrderNumber = order.shop_order_number;
4552
4614
  shopFullOrderNumber = order.shop_full_order_number;
@@ -4557,17 +4619,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4557
4619
  tempOrder.shop_full_order_number = String(shopFullOrderNumber);
4558
4620
  }
4559
4621
  this.persistTempOrder();
4560
- _context29.next = 10;
4622
+ _context30.next = 10;
4561
4623
  return this.saveDraft();
4562
4624
  case 10:
4563
- return _context29.abrupt("return", tempOrder);
4625
+ return _context30.abrupt("return", tempOrder);
4564
4626
  case 11:
4565
4627
  case "end":
4566
- return _context29.stop();
4628
+ return _context30.stop();
4567
4629
  }
4568
- }, _callee26, this);
4630
+ }, _callee27, this);
4569
4631
  }));
4570
- function applyLocalPrintOrderNumbers(_x30) {
4632
+ function applyLocalPrintOrderNumbers(_x31) {
4571
4633
  return _applyLocalPrintOrderNumbers.apply(this, arguments);
4572
4634
  }
4573
4635
  return applyLocalPrintOrderNumbers;
@@ -4581,18 +4643,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4581
4643
  }, {
4582
4644
  key: "submitTempOrder",
4583
4645
  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) {
4646
+ var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4647
+ return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4648
+ while (1) switch (_context31.prev = _context31.next) {
4587
4649
  case 0:
4588
- return _context30.abrupt("return", this.runSubmitTempOrder(params));
4650
+ return _context31.abrupt("return", this.runSubmitTempOrder(params));
4589
4651
  case 1:
4590
4652
  case "end":
4591
- return _context30.stop();
4653
+ return _context31.stop();
4592
4654
  }
4593
- }, _callee27, this);
4655
+ }, _callee28, this);
4594
4656
  }));
4595
- function submitTempOrder(_x31) {
4657
+ function submitTempOrder(_x32) {
4596
4658
  return _submitTempOrder.apply(this, arguments);
4597
4659
  }
4598
4660
  return submitTempOrder;
@@ -4600,20 +4662,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4600
4662
  }, {
4601
4663
  key: "submitTempOrderAsync",
4602
4664
  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) {
4665
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4666
+ return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4667
+ while (1) switch (_context32.prev = _context32.next) {
4606
4668
  case 0:
4607
- return _context31.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4669
+ return _context32.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4608
4670
  syncMode: true
4609
4671
  })));
4610
4672
  case 1:
4611
4673
  case "end":
4612
- return _context31.stop();
4674
+ return _context32.stop();
4613
4675
  }
4614
- }, _callee28, this);
4676
+ }, _callee29, this);
4615
4677
  }));
4616
- function submitTempOrderAsync(_x32) {
4678
+ function submitTempOrderAsync(_x33) {
4617
4679
  return _submitTempOrderAsync.apply(this, arguments);
4618
4680
  }
4619
4681
  return submitTempOrderAsync;
@@ -4621,11 +4683,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4621
4683
  }, {
4622
4684
  key: "runSubmitTempOrder",
4623
4685
  value: function () {
4624
- var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4686
+ var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
4625
4687
  var _params$cacheId2, _this$otherParams6, _ref72, _ref73, _submitSnapshot$busin, _this$otherParams7, _this$otherParams8, _submitSnapshot$type;
4626
4688
  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) {
4689
+ return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4690
+ while (1) switch (_context33.prev = _context33.next) {
4629
4691
  case 0:
4630
4692
  tempOrder = this.ensureTempOrder();
4631
4693
  shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
@@ -4645,26 +4707,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4645
4707
  }
4646
4708
  }
4647
4709
  this.persistTempOrder();
4648
- _context32.next = 8;
4710
+ _context33.next = 8;
4649
4711
  return this.recalculateSummary({
4650
4712
  createIfMissing: true
4651
4713
  });
4652
4714
  case 8:
4653
- _context32.t1 = _context32.sent;
4654
- if (_context32.t1) {
4655
- _context32.next = 11;
4715
+ _context33.t1 = _context33.sent;
4716
+ if (_context33.t1) {
4717
+ _context33.next = 11;
4656
4718
  break;
4657
4719
  }
4658
- _context32.t1 = this.store.summary;
4720
+ _context33.t1 = this.store.summary;
4659
4721
  case 11:
4660
- _context32.t0 = _context32.t1;
4661
- if (_context32.t0) {
4662
- _context32.next = 14;
4722
+ _context33.t0 = _context33.t1;
4723
+ if (_context33.t0) {
4724
+ _context33.next = 14;
4663
4725
  break;
4664
4726
  }
4665
- _context32.t0 = createEmptySummary();
4727
+ _context33.t0 = createEmptySummary();
4666
4728
  case 14:
4667
- latestSummary = _context32.t0;
4729
+ latestSummary = _context33.t0;
4668
4730
  effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
4669
4731
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
4670
4732
  hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
@@ -4699,10 +4761,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4699
4761
  if (!payload.created_at) {
4700
4762
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
4701
4763
  }
4702
- _context32.next = 26;
4764
+ _context33.next = 26;
4703
4765
  return this.saveDraft();
4704
4766
  case 26:
4705
- _context32.prev = 26;
4767
+ _context33.prev = 26;
4706
4768
  this.logInfo('submitTempOrder calling sales checkout', {
4707
4769
  orderId: payload.order_id,
4708
4770
  externalSaleNumber: payload.external_sale_number,
@@ -4712,43 +4774,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4712
4774
  smallTicketDataFlag: payload.small_ticket_data_flag,
4713
4775
  syncMode: payload.sync_mode
4714
4776
  });
4715
- _context32.next = 30;
4777
+ _context33.next = 30;
4716
4778
  return this.submitSalesOrder({
4717
4779
  query: payload
4718
4780
  });
4719
4781
  case 30:
4720
- result = _context32.sent;
4721
- _context32.next = 43;
4782
+ result = _context33.sent;
4783
+ _context33.next = 43;
4722
4784
  break;
4723
4785
  case 33:
4724
- _context32.prev = 33;
4725
- _context32.t2 = _context32["catch"](26);
4726
- backendErrorResponse = this.extractSubmitErrorResponse(_context32.t2);
4786
+ _context33.prev = 33;
4787
+ _context33.t2 = _context33["catch"](26);
4788
+ backendErrorResponse = this.extractSubmitErrorResponse(_context33.t2);
4727
4789
  if (!backendErrorResponse) {
4728
- _context32.next = 40;
4790
+ _context33.next = 40;
4729
4791
  break;
4730
4792
  }
4731
4793
  this.store.syncState = 'failed';
4732
4794
  this.logSubmitBackendRejected(backendErrorResponse, payload);
4733
- return _context32.abrupt("return", backendErrorResponse);
4795
+ return _context33.abrupt("return", backendErrorResponse);
4734
4796
  case 40:
4735
4797
  this.store.syncState = 'failed';
4736
4798
  this.logError('submitTempOrder failed', {
4737
- error: _context32.t2 instanceof Error ? _context32.t2.message : String(_context32.t2),
4799
+ error: _context33.t2 instanceof Error ? _context33.t2.message : String(_context33.t2),
4738
4800
  orderId: payload.order_id,
4739
4801
  externalSaleNumber: payload.external_sale_number,
4740
4802
  paymentStatus: payload.payment_status,
4741
4803
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
4742
4804
  });
4743
- throw _context32.t2;
4805
+ throw _context33.t2;
4744
4806
  case 43:
4745
4807
  if (!this.isSubmitResponseRejected(result)) {
4746
- _context32.next = 47;
4808
+ _context33.next = 47;
4747
4809
  break;
4748
4810
  }
4749
4811
  this.store.syncState = 'failed';
4750
4812
  this.logSubmitBackendRejected(result, payload);
4751
- return _context32.abrupt("return", result);
4813
+ return _context33.abrupt("return", result);
4752
4814
  case 47:
4753
4815
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
4754
4816
  this.logInfo('runSubmitTempOrder: 提交成功', {
@@ -4759,15 +4821,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4759
4821
  })
4760
4822
  });
4761
4823
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
4762
- _context32.next = 56;
4824
+ _context33.next = 56;
4763
4825
  break;
4764
4826
  }
4765
4827
  tempOrder.order_id = submittedOrderId;
4766
4828
  resultRecord = result;
4767
- _context32.next = 54;
4829
+ _context33.next = 54;
4768
4830
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
4769
4831
  case 54:
4770
- _context32.next = 57;
4832
+ _context33.next = 57;
4771
4833
  break;
4772
4834
  case 56:
4773
4835
  if (this.isLocalPendingSubmitResult(result)) {
@@ -4776,14 +4838,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4776
4838
  this.store.syncState = 'submitted';
4777
4839
  }
4778
4840
  case 57:
4779
- return _context32.abrupt("return", result);
4841
+ return _context33.abrupt("return", result);
4780
4842
  case 58:
4781
4843
  case "end":
4782
- return _context32.stop();
4844
+ return _context33.stop();
4783
4845
  }
4784
- }, _callee29, this, [[26, 33]]);
4846
+ }, _callee30, this, [[26, 33]]);
4785
4847
  }));
4786
- function runSubmitTempOrder(_x33) {
4848
+ function runSubmitTempOrder(_x34) {
4787
4849
  return _runSubmitTempOrder.apply(this, arguments);
4788
4850
  }
4789
4851
  return runSubmitTempOrder;
@@ -4791,10 +4853,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4791
4853
  }, {
4792
4854
  key: "markLocalOrderSynced",
4793
4855
  value: function () {
4794
- var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(orderId, remoteOrder) {
4856
+ var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(orderId, remoteOrder) {
4795
4857
  var tempOrder;
4796
- return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4797
- while (1) switch (_context33.prev = _context33.next) {
4858
+ return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4859
+ while (1) switch (_context34.prev = _context34.next) {
4798
4860
  case 0:
4799
4861
  tempOrder = this.ensureTempOrder();
4800
4862
  tempOrder.order_id = orderId;
@@ -4802,15 +4864,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4802
4864
  this.store.lastOrderInfo = remoteOrder;
4803
4865
  this.store.syncState = 'submitted';
4804
4866
  this.persistTempOrder();
4805
- _context33.next = 8;
4867
+ _context34.next = 8;
4806
4868
  return this.saveDraft();
4807
4869
  case 8:
4808
4870
  case "end":
4809
- return _context33.stop();
4871
+ return _context34.stop();
4810
4872
  }
4811
- }, _callee30, this);
4873
+ }, _callee31, this);
4812
4874
  }));
4813
- function markLocalOrderSynced(_x34, _x35) {
4875
+ function markLocalOrderSynced(_x35, _x36) {
4814
4876
  return _markLocalOrderSynced.apply(this, arguments);
4815
4877
  }
4816
4878
  return markLocalOrderSynced;
@@ -4853,10 +4915,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4853
4915
  value: function extractSubmitErrorResponse(error) {
4854
4916
  var _error$response,
4855
4917
  _error$response2,
4856
- _this26 = this;
4918
+ _this27 = this;
4857
4919
  var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
4858
4920
  return candidates.find(function (candidate) {
4859
- return _this26.isSubmitErrorResponse(candidate);
4921
+ return _this27.isSubmitErrorResponse(candidate);
4860
4922
  }) || null;
4861
4923
  }
4862
4924
  }, {
@@ -4883,40 +4945,40 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4883
4945
  }, {
4884
4946
  key: "syncPaymentsToOrder",
4885
4947
  value: function () {
4886
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
4948
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
4887
4949
  var _params$confirmPendin;
4888
- 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) {
4950
+ var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
4951
+ return _regeneratorRuntime().wrap(function _callee32$(_context35) {
4952
+ while (1) switch (_context35.prev = _context35.next) {
4891
4953
  case 0:
4892
4954
  tempOrder = this.ensureTempOrder();
4893
4955
  mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
4894
4956
  shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
4895
4957
  effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
4896
4958
  completion = this.getPaymentCompletion(effectivePayments);
4897
- paidPaymentTotal = this.calculatePaymentTotal(effectivePayments);
4898
- paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || 'paid' : paidPaymentTotal.gt(0) ? 'partially_paid' : 'payment_processing';
4959
+ orderPaidPaymentTotal = this.calculateOrderPaidPaymentTotal(effectivePayments);
4960
+ paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || 'paid' : orderPaidPaymentTotal.gt(0) ? 'partially_paid' : 'payment_processing';
4899
4961
  tempOrder.payments = effectivePayments;
4900
4962
  tempOrder.payment_status = paymentStatus;
4901
4963
  this.persistTempOrder();
4902
- _context34.next = 12;
4964
+ _context35.next = 12;
4903
4965
  return this.saveDraft();
4904
4966
  case 12:
4905
4967
  if (params.submitWhenPaid) {
4906
- _context34.next = 14;
4968
+ _context35.next = 14;
4907
4969
  break;
4908
4970
  }
4909
- return _context34.abrupt("return", completion);
4971
+ return _context35.abrupt("return", completion);
4910
4972
  case 14:
4911
4973
  if (!(this.store.syncState === 'submitting')) {
4912
- _context34.next = 16;
4974
+ _context35.next = 16;
4913
4975
  break;
4914
4976
  }
4915
- return _context34.abrupt("return", completion);
4977
+ return _context35.abrupt("return", completion);
4916
4978
  case 16:
4917
4979
  this.store.syncState = 'submitting';
4918
4980
  paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
4919
- _context34.next = 20;
4981
+ _context35.next = 20;
4920
4982
  return this.submitTempOrder({
4921
4983
  payments: effectivePayments,
4922
4984
  paymentStatus: paymentStatus,
@@ -4932,17 +4994,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4932
4994
  }
4933
4995
  });
4934
4996
  case 20:
4935
- submitResult = _context34.sent;
4936
- return _context34.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
4997
+ submitResult = _context35.sent;
4998
+ return _context35.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
4937
4999
  submitResult: submitResult
4938
5000
  }));
4939
5001
  case 22:
4940
5002
  case "end":
4941
- return _context34.stop();
5003
+ return _context35.stop();
4942
5004
  }
4943
- }, _callee31, this);
5005
+ }, _callee32, this);
4944
5006
  }));
4945
- function syncPaymentsToOrder(_x36) {
5007
+ function syncPaymentsToOrder(_x37) {
4946
5008
  return _syncPaymentsToOrder.apply(this, arguments);
4947
5009
  }
4948
5010
  return syncPaymentsToOrder;
@@ -5031,11 +5093,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5031
5093
  }, {
5032
5094
  key: "submitOrder",
5033
5095
  value: function () {
5034
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(order) {
5096
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(order) {
5035
5097
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
5036
5098
  var url, query, fetchUrl, params;
5037
- return _regeneratorRuntime().wrap(function _callee32$(_context35) {
5038
- while (1) switch (_context35.prev = _context35.next) {
5099
+ return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5100
+ while (1) switch (_context36.prev = _context36.next) {
5039
5101
  case 0:
5040
5102
  this.logInfo('submitOrder called', {
5041
5103
  url: order.url,
@@ -5055,14 +5117,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5055
5117
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
5056
5118
  scheduleDate: params.schedule_date
5057
5119
  });
5058
- return _context35.abrupt("return", this.request.post(fetchUrl, params));
5120
+ return _context36.abrupt("return", this.request.post(fetchUrl, params));
5059
5121
  case 6:
5060
5122
  case "end":
5061
- return _context35.stop();
5123
+ return _context36.stop();
5062
5124
  }
5063
- }, _callee32, this);
5125
+ }, _callee33, this);
5064
5126
  }));
5065
- function submitOrder(_x37) {
5127
+ function submitOrder(_x38) {
5066
5128
  return _submitOrder.apply(this, arguments);
5067
5129
  }
5068
5130
  return submitOrder;
@@ -5070,13 +5132,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5070
5132
  }, {
5071
5133
  key: "cancelOrder",
5072
5134
  value: function () {
5073
- var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
5135
+ var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5074
5136
  var payload;
5075
- return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5076
- while (1) switch (_context36.prev = _context36.next) {
5137
+ return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5138
+ while (1) switch (_context37.prev = _context37.next) {
5077
5139
  case 0:
5078
5140
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
5079
- _context36.next = 2;
5141
+ _context37.next = 2;
5080
5142
  break;
5081
5143
  }
5082
5144
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -5092,16 +5154,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5092
5154
  method: 'PUT',
5093
5155
  orderIdsCount: params.order_ids.length
5094
5156
  });
5095
- return _context36.abrupt("return", this.request.put('/order/update-status', payload, {
5157
+ return _context37.abrupt("return", this.request.put('/order/update-status', payload, {
5096
5158
  isShopApi: true
5097
5159
  }));
5098
5160
  case 5:
5099
5161
  case "end":
5100
- return _context36.stop();
5162
+ return _context37.stop();
5101
5163
  }
5102
- }, _callee33, this);
5164
+ }, _callee34, this);
5103
5165
  }));
5104
- function cancelOrder(_x38) {
5166
+ function cancelOrder(_x39) {
5105
5167
  return _cancelOrder.apply(this, arguments);
5106
5168
  }
5107
5169
  return cancelOrder;
@@ -5109,19 +5171,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5109
5171
  }, {
5110
5172
  key: "changeBookingStatus",
5111
5173
  value: function () {
5112
- var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5174
+ var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
5113
5175
  var url, payload;
5114
- return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5115
- while (1) switch (_context37.prev = _context37.next) {
5176
+ return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5177
+ while (1) switch (_context38.prev = _context38.next) {
5116
5178
  case 0:
5117
5179
  if (params.booking_id) {
5118
- _context37.next = 2;
5180
+ _context38.next = 2;
5119
5181
  break;
5120
5182
  }
5121
5183
  throw new Error('变更预约状态失败:booking_id 不能为空');
5122
5184
  case 2:
5123
5185
  if (params.appointment_status) {
5124
- _context37.next = 4;
5186
+ _context38.next = 4;
5125
5187
  break;
5126
5188
  }
5127
5189
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -5136,16 +5198,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5136
5198
  bookingId: params.booking_id,
5137
5199
  appointmentStatus: params.appointment_status
5138
5200
  });
5139
- return _context37.abrupt("return", this.request.put(url, payload, {
5201
+ return _context38.abrupt("return", this.request.put(url, payload, {
5140
5202
  isShopApi: true
5141
5203
  }));
5142
5204
  case 8:
5143
5205
  case "end":
5144
- return _context37.stop();
5206
+ return _context38.stop();
5145
5207
  }
5146
- }, _callee34, this);
5208
+ }, _callee35, this);
5147
5209
  }));
5148
- function changeBookingStatus(_x39) {
5210
+ function changeBookingStatus(_x40) {
5149
5211
  return _changeBookingStatus.apply(this, arguments);
5150
5212
  }
5151
5213
  return changeBookingStatus;
@@ -5163,11 +5225,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5163
5225
  }, {
5164
5226
  key: "createOrderByCheckout",
5165
5227
  value: (function () {
5166
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
5228
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5167
5229
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
5168
5230
  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) {
5231
+ return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5232
+ while (1) switch (_context39.prev = _context39.next) {
5171
5233
  case 0:
5172
5234
  // 过滤掉由在线店铺下单的 payment 支付数据
5173
5235
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -5201,7 +5263,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5201
5263
  relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
5202
5264
  paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
5203
5265
  });
5204
- _context38.prev = 4;
5266
+ _context39.prev = 4;
5205
5267
  // 构建订单数据,设置默认值并允许 params 覆盖
5206
5268
  orderData = _objectSpread({
5207
5269
  sales_channel: 'my_pisel',
@@ -5263,13 +5325,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5263
5325
  hasOrderId: !!orderData.order_id,
5264
5326
  smallTicketDataFlag: orderData.small_ticket_data_flag
5265
5327
  });
5266
- _context38.next = 12;
5328
+ _context39.next = 12;
5267
5329
  return this.request.post('/order/checkout', orderData, {
5268
5330
  osServer: true,
5269
5331
  customToast: function customToast() {}
5270
5332
  });
5271
5333
  case 12:
5272
- response = _context38.sent;
5334
+ response = _context39.sent;
5273
5335
  this.logInfo('Order API called successfully', {
5274
5336
  response: response
5275
5337
  });
@@ -5277,22 +5339,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5277
5339
  success: !!response,
5278
5340
  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
5341
  });
5280
- return _context38.abrupt("return", response);
5342
+ return _context39.abrupt("return", response);
5281
5343
  case 18:
5282
- _context38.prev = 18;
5283
- _context38.t0 = _context38["catch"](4);
5284
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context38.t0);
5344
+ _context39.prev = 18;
5345
+ _context39.t0 = _context39["catch"](4);
5346
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context39.t0);
5285
5347
  this.logInfo('Order API called failed', {
5286
- error: _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0)
5348
+ error: _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0)
5287
5349
  });
5288
- throw _context38.t0;
5350
+ throw _context39.t0;
5289
5351
  case 23:
5290
5352
  case "end":
5291
- return _context38.stop();
5353
+ return _context39.stop();
5292
5354
  }
5293
- }, _callee35, this, [[4, 18]]);
5355
+ }, _callee36, this, [[4, 18]]);
5294
5356
  }));
5295
- function createOrderByCheckout(_x40) {
5357
+ function createOrderByCheckout(_x41) {
5296
5358
  return _createOrderByCheckout.apply(this, arguments);
5297
5359
  }
5298
5360
  return createOrderByCheckout;
@@ -5300,24 +5362,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5300
5362
  }, {
5301
5363
  key: "submitSalesOrder",
5302
5364
  value: function () {
5303
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5365
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
5304
5366
  var url, query, fetchUrl;
5305
- return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5306
- while (1) switch (_context39.prev = _context39.next) {
5367
+ return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5368
+ while (1) switch (_context40.prev = _context40.next) {
5307
5369
  case 0:
5308
5370
  url = params.url, query = params.query;
5309
5371
  fetchUrl = url || '/order/sales/checkout';
5310
- return _context39.abrupt("return", this.request.post(fetchUrl, query, {
5372
+ return _context40.abrupt("return", this.request.post(fetchUrl, query, {
5311
5373
  osServer: true,
5312
5374
  customToast: function customToast() {}
5313
5375
  }));
5314
5376
  case 3:
5315
5377
  case "end":
5316
- return _context39.stop();
5378
+ return _context40.stop();
5317
5379
  }
5318
- }, _callee36, this);
5380
+ }, _callee37, this);
5319
5381
  }));
5320
- function submitSalesOrder(_x41) {
5382
+ function submitSalesOrder(_x42) {
5321
5383
  return _submitSalesOrder.apply(this, arguments);
5322
5384
  }
5323
5385
  return submitSalesOrder;
@@ -5331,37 +5393,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5331
5393
  }, {
5332
5394
  key: "sendCustomerPayLink",
5333
5395
  value: (function () {
5334
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
5396
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5335
5397
  var _params$emails;
5336
5398
  var orderIds;
5337
- return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5338
- while (1) switch (_context40.prev = _context40.next) {
5399
+ return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5400
+ while (1) switch (_context41.prev = _context41.next) {
5339
5401
  case 0:
5340
5402
  orderIds = params.order_ids || params.orderIds || [];
5341
5403
  if (orderIds.length) {
5342
- _context40.next = 3;
5404
+ _context41.next = 3;
5343
5405
  break;
5344
5406
  }
5345
5407
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
5346
5408
  case 3:
5347
5409
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
5348
- _context40.next = 5;
5410
+ _context41.next = 5;
5349
5411
  break;
5350
5412
  }
5351
5413
  throw new Error('发送支付链接需要至少一个邮箱');
5352
5414
  case 5:
5353
- return _context40.abrupt("return", this.request.post('/order/batch-email', {
5415
+ return _context41.abrupt("return", this.request.post('/order/batch-email', {
5354
5416
  order_ids: orderIds,
5355
5417
  notify_action: params.notify_action || 'order_payment_reminder',
5356
5418
  emails: params.emails
5357
5419
  }));
5358
5420
  case 6:
5359
5421
  case "end":
5360
- return _context40.stop();
5422
+ return _context41.stop();
5361
5423
  }
5362
- }, _callee37, this);
5424
+ }, _callee38, this);
5363
5425
  }));
5364
- function sendCustomerPayLink(_x42) {
5426
+ function sendCustomerPayLink(_x43) {
5365
5427
  return _sendCustomerPayLink.apply(this, arguments);
5366
5428
  }
5367
5429
  return sendCustomerPayLink;
@@ -5369,14 +5431,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5369
5431
  }, {
5370
5432
  key: "getSalesOrderByLookup",
5371
5433
  value: function () {
5372
- var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5434
+ var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
5373
5435
  var lookup, res;
5374
- return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5375
- while (1) switch (_context41.prev = _context41.next) {
5436
+ return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5437
+ while (1) switch (_context42.prev = _context42.next) {
5376
5438
  case 0:
5377
5439
  lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
5378
5440
  if (lookup) {
5379
- _context41.next = 3;
5441
+ _context42.next = 3;
5380
5442
  break;
5381
5443
  }
5382
5444
  throw new Error('加载销售详情需要 lookup');
@@ -5385,7 +5447,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5385
5447
  if (lookup.startsWith('LOCAL_')) {
5386
5448
  params.forceRemote = false;
5387
5449
  }
5388
- _context41.next = 6;
5450
+ _context42.next = 6;
5389
5451
  return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
5390
5452
  with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
5391
5453
  }, params.forceRemote ? {
@@ -5394,18 +5456,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5394
5456
  osServer: true
5395
5457
  });
5396
5458
  case 6:
5397
- res = _context41.sent;
5459
+ res = _context42.sent;
5398
5460
  if (res.code === 200) {
5399
5461
  this.store.lastOrderInfo = res.data;
5400
5462
  }
5401
- return _context41.abrupt("return", res);
5463
+ return _context42.abrupt("return", res);
5402
5464
  case 9:
5403
5465
  case "end":
5404
- return _context41.stop();
5466
+ return _context42.stop();
5405
5467
  }
5406
- }, _callee38, this);
5468
+ }, _callee39, this);
5407
5469
  }));
5408
- function getSalesOrderByLookup(_x43) {
5470
+ function getSalesOrderByLookup(_x44) {
5409
5471
  return _getSalesOrderByLookup.apply(this, arguments);
5410
5472
  }
5411
5473
  return getSalesOrderByLookup;
@@ -5419,14 +5481,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5419
5481
  }, {
5420
5482
  key: "hydrateTempOrderFromRecord",
5421
5483
  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) {
5484
+ var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(record, options) {
5485
+ var _this$store$discount19;
5486
+ var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
5487
+ return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5488
+ while (1) switch (_context43.prev = _context43.next) {
5427
5489
  case 0:
5428
5490
  raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
5429
- nextTempOrder = this.normalizeTempOrderForRuntime(raw);
5491
+ nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
5492
+ makeEditMark: true
5493
+ });
5430
5494
  rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
5431
5495
  summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
5432
5496
  return _objectSpread({}, s || {});
@@ -5447,37 +5511,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5447
5511
  });
5448
5512
  this.store.lastOrderInfo = raw.lastOrderInfo || raw;
5449
5513
  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;
5514
+ 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() || [] : [];
5515
+ currentScanDiscounts = currentDiscounts.filter(function (discount) {
5516
+ return discount === null || discount === void 0 ? void 0 : discount.isScan;
5517
+ });
5518
+ hydratedDiscountIds = new Set(hydratedEditDiscounts.map(function (discount) {
5519
+ return discount === null || discount === void 0 ? void 0 : discount.id;
5520
+ }));
5521
+ retainedScanDiscounts = currentScanDiscounts.filter(function (discount) {
5522
+ return !hydratedDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id);
5523
+ });
5524
+ nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
5525
+ shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
5452
5526
  if (shouldSkipEmptyDiscountSync) {
5453
- _context42.next = 17;
5527
+ _context43.next = 21;
5454
5528
  break;
5455
5529
  }
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:
5530
+ OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
5531
+ _context43.next = 19;
5532
+ return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(nextDiscounts);
5533
+ case 19:
5534
+ _context43.next = 21;
5535
+ return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(nextDiscounts);
5536
+ case 21:
5463
5537
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
5464
- _context42.next = 20;
5538
+ _context43.next = 24;
5465
5539
  break;
5466
5540
  }
5467
- _context42.next = 20;
5541
+ _context43.next = 24;
5468
5542
  return this.recalculateSummary({
5469
5543
  createIfMissing: false
5470
5544
  });
5471
- case 20:
5545
+ case 24:
5472
5546
  this.persistTempOrder();
5473
- return _context42.abrupt("return", nextTempOrder);
5474
- case 22:
5547
+ return _context43.abrupt("return", nextTempOrder);
5548
+ case 26:
5475
5549
  case "end":
5476
- return _context42.stop();
5550
+ return _context43.stop();
5477
5551
  }
5478
- }, _callee39, this);
5552
+ }, _callee40, this);
5479
5553
  }));
5480
- function hydrateTempOrderFromRecord(_x44, _x45) {
5554
+ function hydrateTempOrderFromRecord(_x45, _x46) {
5481
5555
  return _hydrateTempOrderFromRecord.apply(this, arguments);
5482
5556
  }
5483
5557
  return hydrateTempOrderFromRecord;
@@ -5518,7 +5592,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5518
5592
  }, {
5519
5593
  key: "normalizeTempOrderForRuntime",
5520
5594
  value: function normalizeTempOrderForRuntime(raw, options) {
5521
- var _this27 = this;
5595
+ var _this28 = this;
5522
5596
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
5523
5597
  // ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
5524
5598
  if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (raw === null || raw === void 0 ? void 0 : raw.id) !== undefined && (raw === null || raw === void 0 ? void 0 : raw.id) !== null) {
@@ -5541,10 +5615,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5541
5615
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
5542
5616
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
5543
5617
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
5544
- return _this27.normalizeHydratedOrderProduct(p);
5618
+ return _this28.normalizeHydratedOrderProduct(p, {
5619
+ makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
5620
+ });
5545
5621
  }) : [];
5546
5622
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
5547
- var booking = _this27.normalizeHydratedBookingHolder(b || {});
5623
+ var booking = _this28.normalizeHydratedBookingHolder(b || {});
5548
5624
  return _objectSpread(_objectSpread({}, booking), {}, {
5549
5625
  is_all: normalizeBookingIsAll(booking),
5550
5626
  sub_type: normalizeBookingSubType(booking)
@@ -5712,8 +5788,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5712
5788
  }
5713
5789
  }, {
5714
5790
  key: "normalizeHydratedOrderProduct",
5715
- value: function normalizeHydratedOrderProduct(product) {
5716
- var _this28 = this;
5791
+ value: function normalizeHydratedOrderProduct(product, options) {
5792
+ var _this29 = this;
5717
5793
  var row = _objectSpread({}, product || {});
5718
5794
  if (row.num === undefined && row.product_quantity !== undefined) {
5719
5795
  row.num = row.product_quantity;
@@ -5721,7 +5797,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5721
5797
  var productSku = ensureProductSku(row);
5722
5798
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
5723
5799
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
5724
- return _this28.normalizeHydratedProductOptionItem(optionItem || {});
5800
+ return _this29.normalizeHydratedProductOptionItem(optionItem || {});
5725
5801
  }))
5726
5802
  });
5727
5803
  delete row["product_".concat('option', "_item")];
@@ -5736,7 +5812,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5736
5812
  row.metadata.unique_identification_number = createUuidV4();
5737
5813
  }
5738
5814
  // 从云端、本地数据库中获取到的商品数据,先打上 runtime 标记,提供给 UI 做 saved items.
5739
- row.metadata.is_edit_for_runtime = true;
5815
+ if (options !== null && options !== void 0 && options.makeEditMark) {
5816
+ row.metadata.is_edit_for_runtime = true;
5817
+ }
5740
5818
  var normalized = normalizeOrderProduct(row);
5741
5819
  normalized.discount_list = normalizeOrderProductDiscountList(normalized.discount_list);
5742
5820
  var result = _objectSpread(_objectSpread(_objectSpread({}, row), normalized), {}, {
@@ -5756,27 +5834,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5756
5834
  }, {
5757
5835
  key: "getOrderInfo",
5758
5836
  value: function () {
5759
- var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(order_id) {
5837
+ var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(order_id) {
5760
5838
  var res;
5761
- return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5762
- while (1) switch (_context43.prev = _context43.next) {
5839
+ return _regeneratorRuntime().wrap(function _callee41$(_context44) {
5840
+ while (1) switch (_context44.prev = _context44.next) {
5763
5841
  case 0:
5764
- _context43.next = 2;
5842
+ _context44.next = 2;
5765
5843
  return this.request.get("/order/sales/".concat(order_id), {
5766
5844
  with: ['products', 'bookings']
5767
5845
  }, {
5768
5846
  osServer: true
5769
5847
  });
5770
5848
  case 2:
5771
- res = _context43.sent;
5772
- return _context43.abrupt("return", res);
5849
+ res = _context44.sent;
5850
+ return _context44.abrupt("return", res);
5773
5851
  case 4:
5774
5852
  case "end":
5775
- return _context43.stop();
5853
+ return _context44.stop();
5776
5854
  }
5777
- }, _callee40, this);
5855
+ }, _callee41, this);
5778
5856
  }));
5779
- function getOrderInfo(_x46) {
5857
+ function getOrderInfo(_x47) {
5780
5858
  return _getOrderInfo.apply(this, arguments);
5781
5859
  }
5782
5860
  return getOrderInfo;