@pisell/pisellos 2.3.155 → 2.3.157

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.
@@ -34,6 +34,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
34
34
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
35
35
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
36
36
  import { BaseModule } from "../../modules/BaseModule";
37
+ import { isLocalFinalizedPayment, PAYMENT_REFRESH_MESSAGE, requiresLocalPaymentRefresh } from "../../modules/Order/localEftposState";
37
38
  import { BaseSalesHookNames } from "./types";
38
39
  import { OrderModule } from "../../modules/Order";
39
40
  import { isFulfillmentTimingBooking } from "../../modules/Order/pickupTiming";
@@ -563,6 +564,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
563
564
  _defineProperty(_assertThisInitialized(_this), "pickupTimingEnabled", false);
564
565
  _defineProperty(_assertThisInitialized(_this), "pickupTimingController", void 0);
565
566
  _defineProperty(_assertThisInitialized(_this), "fulfillmentItemRulesController", void 0);
567
+ _defineProperty(_assertThisInitialized(_this), "pendingLocalEftposFinalizations", new Map());
566
568
  return _this;
567
569
  }
568
570
 
@@ -671,6 +673,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
671
673
  }
672
674
  this.queuedServerOrderChanges.push(snapshot);
673
675
  }
676
+ }, {
677
+ key: "shouldSyncServerOrderChanges",
678
+ value: function shouldSyncServerOrderChanges() {
679
+ var _this$store$order2;
680
+ var payments = ((_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || (_this$store$order2 = _this$store$order2.getTempOrder()) === null || _this$store$order2 === void 0 ? void 0 : _this$store$order2.payments) || [];
681
+ return this.serverOrderChangeSyncEnabled || payments.some(isLocalFinalizedPayment) && !payments.some(isPendingOrderPayment);
682
+ }
674
683
  }, {
675
684
  key: "drainQueuedServerOrderChanges",
676
685
  value: function () {
@@ -679,7 +688,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
679
688
  return _regeneratorRuntime().wrap(function _callee$(_context) {
680
689
  while (1) switch (_context.prev = _context.next) {
681
690
  case 0:
682
- if (!(!this.serverOrderChangeSyncEnabled || this.salesDetailLoadInFlightCount > 0 || this.serverOrderChangeHydrateInFlight || this.queuedServerOrderChanges.length === 0)) {
691
+ if (!(!this.shouldSyncServerOrderChanges() || this.salesDetailLoadInFlightCount > 0 || this.serverOrderChangeHydrateInFlight || this.queuedServerOrderChanges.length === 0)) {
683
692
  _context.next = 2;
684
693
  break;
685
694
  }
@@ -706,49 +715,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
706
715
  key: "syncCurrentSalesDetailFromServerOrderChange",
707
716
  value: function () {
708
717
  var _syncCurrentSalesDetailFromServerOrderChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payload) {
709
- var _this2 = this;
710
- var changedOrders, changedOrder;
718
+ var _this$store$order3,
719
+ _this2 = this;
720
+ var fullSnapshotAfterFinalization, changedOrders, changedOrder;
711
721
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
712
722
  while (1) switch (_context3.prev = _context3.next) {
713
723
  case 0:
714
- changedOrders = Array.isArray(payload) ? payload : Array.isArray(payload === null || payload === void 0 ? void 0 : payload.changedOrders) ? payload.changedOrders : payload !== null && payload !== void 0 && payload.data && _typeof(payload.data) === 'object' ? [payload.data] : [];
715
- if (this.serverOrderChangeSyncEnabled) {
716
- _context3.next = 3;
724
+ fullSnapshotAfterFinalization = Array.isArray(payload === null || payload === void 0 ? void 0 : payload.list) && ((_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || (_this$store$order3 = _this$store$order3.getTempOrder()) === null || _this$store$order3 === void 0 || (_this$store$order3 = _this$store$order3.payments) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.some(isLocalFinalizedPayment));
725
+ changedOrders = Array.isArray(payload) ? payload : Array.isArray(payload === null || payload === void 0 ? void 0 : payload.changedOrders) && payload.changedOrders.length > 0 ? payload.changedOrders : fullSnapshotAfterFinalization ? payload.list : payload !== null && payload !== void 0 && payload.data && _typeof(payload.data) === 'object' ? [payload.data] : [];
726
+ if (this.shouldSyncServerOrderChanges()) {
727
+ _context3.next = 4;
717
728
  break;
718
729
  }
719
730
  return _context3.abrupt("return");
720
- case 3:
731
+ case 4:
721
732
  if (!(this.salesDetailLoadInFlightCount > 0)) {
722
- _context3.next = 6;
733
+ _context3.next = 7;
723
734
  break;
724
735
  }
725
736
  changedOrders.forEach(function (order) {
726
737
  return _this2.queueLatestServerOrderChange(order);
727
738
  });
728
739
  return _context3.abrupt("return");
729
- case 6:
740
+ case 7:
730
741
  changedOrder = changedOrders.find(function (order) {
731
742
  return _this2.isCurrentSalesOrderRecord(order);
732
743
  });
733
744
  if (changedOrder) {
734
- _context3.next = 9;
745
+ _context3.next = 10;
735
746
  break;
736
747
  }
737
748
  return _context3.abrupt("return");
738
- case 9:
749
+ case 10:
739
750
  if (!this.serverOrderChangeHydrateInFlight) {
740
- _context3.next = 12;
751
+ _context3.next = 13;
741
752
  break;
742
753
  }
743
754
  this.queueLatestServerOrderChange(changedOrder);
744
755
  return _context3.abrupt("return");
745
- case 12:
756
+ case 13:
746
757
  if (this.store.order) {
747
- _context3.next = 14;
758
+ _context3.next = 15;
748
759
  break;
749
760
  }
750
761
  return _context3.abrupt("return");
751
- case 14:
762
+ case 15:
752
763
  this.serverOrderChangeHydrateInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
753
764
  var _getTempOrder, _ref9;
754
765
  var currentTempOrder, record, sales;
@@ -774,21 +785,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
774
785
  }
775
786
  }, _callee2);
776
787
  }))();
777
- _context3.prev = 15;
778
- _context3.next = 18;
788
+ _context3.prev = 16;
789
+ _context3.next = 19;
779
790
  return this.serverOrderChangeHydrateInFlight;
780
- case 18:
781
- _context3.prev = 18;
791
+ case 19:
792
+ _context3.prev = 19;
782
793
  this.serverOrderChangeHydrateInFlight = null;
783
- _context3.next = 22;
794
+ _context3.next = 23;
784
795
  return this.drainQueuedServerOrderChanges();
785
- case 22:
786
- return _context3.finish(18);
787
796
  case 23:
797
+ return _context3.finish(19);
798
+ case 24:
788
799
  case "end":
789
800
  return _context3.stop();
790
801
  }
791
- }, _callee3, this, [[15,, 18, 23]]);
802
+ }, _callee3, this, [[16,, 19, 24]]);
792
803
  }));
793
804
  function syncCurrentSalesDetailFromServerOrderChange(_x) {
794
805
  return _syncCurrentSalesDetailFromServerOrderChange.apply(this, arguments);
@@ -981,8 +992,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
981
992
  }, {
982
993
  key: "getCurrentOrderCustomerId",
983
994
  value: function getCurrentOrderCustomerId() {
984
- var _this$store$order2, _this$store$order2$ge;
985
- var tempOrder = (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || (_this$store$order2$ge = _this$store$order2.getTempOrder) === null || _this$store$order2$ge === void 0 ? void 0 : _this$store$order2$ge.call(_this$store$order2);
995
+ var _this$store$order4, _this$store$order4$ge;
996
+ var tempOrder = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || (_this$store$order4$ge = _this$store$order4.getTempOrder) === null || _this$store$order4$ge === void 0 ? void 0 : _this$store$order4$ge.call(_this$store$order4);
986
997
  var customerId = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id;
987
998
  if (customerId === null || customerId === undefined) return undefined;
988
999
  return customerId;
@@ -2172,8 +2183,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2172
2183
  }
2173
2184
  }
2174
2185
  try {
2175
- var _this$store$order3, _this$store$order3$ge, _this$logger, _this$logger$addLog, _orderIdentity$orderI, _orderIdentity$extern, _orderIdentity$shopOr;
2176
- var orderIdentity = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || (_this$store$order3$ge = _this$store$order3.getOrderIdentity) === null || _this$store$order3$ge === void 0 ? void 0 : _this$store$order3$ge.call(_this$store$order3);
2186
+ var _this$store$order5, _this$store$order5$ge, _this$logger, _this$logger$addLog, _orderIdentity$orderI, _orderIdentity$extern, _orderIdentity$shopOr;
2187
+ var orderIdentity = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || (_this$store$order5$ge = _this$store$order5.getOrderIdentity) === null || _this$store$order5$ge === void 0 ? void 0 : _this$store$order5$ge.call(_this$store$order5);
2177
2188
  (_this$logger = this.logger) === null || _this$logger === void 0 || (_this$logger$addLog = _this$logger.addLog) === null || _this$logger$addLog === void 0 || _this$logger$addLog.call(_this$logger, {
2178
2189
  type: 'info',
2179
2190
  title: 'syncAppDataToTempOrder',
@@ -2513,8 +2524,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2513
2524
  }, {
2514
2525
  key: "getTempOrder",
2515
2526
  value: function getTempOrder() {
2516
- var _this$store$order4;
2517
- var result = ((_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getTempOrder()) || null;
2527
+ var _this$store$order6;
2528
+ var result = ((_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getTempOrder()) || null;
2518
2529
  return result;
2519
2530
  }
2520
2531
  }, {
@@ -2765,8 +2776,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2765
2776
  }, {
2766
2777
  key: "getPickupTimingBooking",
2767
2778
  value: function getPickupTimingBooking() {
2768
- var _this$store$order5;
2769
- return ((_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getPickupTimingBooking()) || null;
2779
+ var _this$store$order7;
2780
+ return ((_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getPickupTimingBooking()) || null;
2770
2781
  }
2771
2782
  }, {
2772
2783
  key: "setPickupTimingBooking",
@@ -2777,8 +2788,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2777
2788
  }, {
2778
2789
  key: "clearPickupTimingBooking",
2779
2790
  value: function clearPickupTimingBooking() {
2780
- var _this$store$order6;
2781
- (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || _this$store$order6.clearPickupTimingBooking();
2791
+ var _this$store$order8;
2792
+ (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 || _this$store$order8.clearPickupTimingBooking();
2782
2793
  }
2783
2794
  }, {
2784
2795
  key: "updateTempOrderContactsInfo",
@@ -3217,8 +3228,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3217
3228
  }, {
3218
3229
  key: "getDiscountConfigOrderIdentityKey",
3219
3230
  value: function getDiscountConfigOrderIdentityKey(tempOrder) {
3220
- var _this$store$order7, _this$store$order7$ge, _ref43, _identity$orderId, _tempOrder$request_un, _ref44, _identity$externalSal, _ref45, _ref46, _identity$localId, _tempOrder$_extend3;
3221
- var identity = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 || (_this$store$order7$ge = _this$store$order7.getOrderIdentity) === null || _this$store$order7$ge === void 0 ? void 0 : _this$store$order7$ge.call(_this$store$order7);
3231
+ var _this$store$order9, _this$store$order9$ge, _ref43, _identity$orderId, _tempOrder$request_un, _ref44, _identity$externalSal, _ref45, _ref46, _identity$localId, _tempOrder$_extend3;
3232
+ var identity = (_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 || (_this$store$order9$ge = _this$store$order9.getOrderIdentity) === null || _this$store$order9$ge === void 0 ? void 0 : _this$store$order9$ge.call(_this$store$order9);
3222
3233
  return JSON.stringify([(_ref43 = (_identity$orderId = identity === null || identity === void 0 ? void 0 : identity.orderId) !== null && _identity$orderId !== void 0 ? _identity$orderId : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) !== null && _ref43 !== void 0 ? _ref43 : '', (_tempOrder$request_un = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.request_unique_idempotency_token) !== null && _tempOrder$request_un !== void 0 ? _tempOrder$request_un : '', (_ref44 = (_identity$externalSal = identity === null || identity === void 0 ? void 0 : identity.externalSaleNumber) !== null && _identity$externalSal !== void 0 ? _identity$externalSal : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number) !== null && _ref44 !== void 0 ? _ref44 : '', (_ref45 = (_ref46 = (_identity$localId = identity === null || identity === void 0 ? void 0 : identity.localId) !== null && _identity$localId !== void 0 ? _identity$localId : tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.localId) !== null && _ref46 !== void 0 ? _ref46 : this.cacheId) !== null && _ref45 !== void 0 ? _ref45 : '']);
3223
3234
  }
3224
3235
  }, {
@@ -3226,17 +3237,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3226
3237
  value: function () {
3227
3238
  var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
3228
3239
  var _this$store$order$get2,
3229
- _this$store$order8,
3240
+ _this$store$order10,
3230
3241
  _tempOrder$customer2,
3231
3242
  _tempOrder$_extend4,
3232
3243
  _tempOrder$_extend5,
3233
3244
  _discountModule$getDi,
3234
3245
  _discountModule$getOr,
3235
3246
  _this$store$order$get3,
3236
- _this$store$order9,
3247
+ _this$store$order11,
3237
3248
  _this18 = this,
3238
3249
  _discountModule$getDi3;
3239
- var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, requestOrderIdentityKey, discountConfigCacheKey, requestEpoch, isCurrentRequest, getCurrentResult, searchedDiscountList, searchedDiscountIds, preparedDiscountList, _this$store$order$get4, _this$store$order10, _discountModule$setOr, prepareConfigPromise, _discountModule$setOr2, _discountModule$setDi, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _orderStore$summary, orderTotalAmount, result, _iterator3, _step3, _product$metadata5, _tempOrder$_extend6, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
3250
+ var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, requestOrderIdentityKey, discountConfigCacheKey, requestEpoch, isCurrentRequest, getCurrentResult, searchedDiscountList, searchedDiscountIds, preparedDiscountList, _this$store$order$get4, _this$store$order12, _discountModule$setOr, prepareConfigPromise, _discountModule$setOr2, _discountModule$setDi, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _orderStore$summary, orderTotalAmount, result, _iterator3, _step3, _product$metadata5, _tempOrder$_extend6, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
3240
3251
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3241
3252
  while (1) switch (_context29.prev = _context29.next) {
3242
3253
  case 0:
@@ -3250,7 +3261,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3250
3261
  orderStore = this.store.order.store || {};
3251
3262
  discountModule = orderStore.discount;
3252
3263
  rulesModule = orderStore.rules;
3253
- orderId = tempOrder.order_id || ((_this$store$order$get2 = (_this$store$order8 = this.store.order).getOrderIdentity) === null || _this$store$order$get2 === void 0 || (_this$store$order$get2 = _this$store$order$get2.call(_this$store$order8)) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.orderId);
3264
+ orderId = tempOrder.order_id || ((_this$store$order$get2 = (_this$store$order10 = this.store.order).getOrderIdentity) === null || _this$store$order$get2 === void 0 || (_this$store$order$get2 = _this$store$order$get2.call(_this$store$order10)) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.orderId);
3254
3265
  customerId = Number((params === null || params === void 0 ? void 0 : params.customerId) || tempOrder.customer_id || ((_tempOrder$customer2 = tempOrder.customer) === null || _tempOrder$customer2 === void 0 ? void 0 : _tempOrder$customer2.id) || ((_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.customerSnapshot) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.id) || ((_tempOrder$_extend5 = tempOrder._extend) === null || _tempOrder$_extend5 === void 0 || (_tempOrder$_extend5 = _tempOrder$_extend5.customerSnapshot) === null || _tempOrder$_extend5 === void 0 ? void 0 : _tempOrder$_extend5.customer_id) || 0);
3255
3266
  currentDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
3256
3267
  originalDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
@@ -3260,7 +3271,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3260
3271
  discountAction = (params === null || params === void 0 ? void 0 : params.action) || (orderId ? 'edit' : 'create');
3261
3272
  requestOrderIdentityKey = this.getDiscountConfigOrderIdentityKey(tempOrder);
3262
3273
  discountConfigCacheKey = JSON.stringify([customerId, discountAction, Number(orderId) || 0, requestOrderIdentityKey]);
3263
- requestEpoch = (_this$store$order$get3 = (_this$store$order9 = this.store.order).getCustomerWalletPrepareConfigEpoch) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order9);
3274
+ requestEpoch = (_this$store$order$get3 = (_this$store$order11 = this.store.order).getCustomerWalletPrepareConfigEpoch) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order11);
3264
3275
  isCurrentRequest = function isCurrentRequest() {
3265
3276
  var _this18$store$order, _this18$store$order$g, _this18$store$order2, _this18$store$order2$;
3266
3277
  var currentTempOrder = (_this18$store$order = _this18.store.order) === null || _this18$store$order === void 0 || (_this18$store$order$g = _this18$store$order.getTempOrder) === null || _this18$store$order$g === void 0 ? void 0 : _this18$store$order$g.call(_this18$store$order);
@@ -3304,7 +3315,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3304
3315
  orderId: Number(orderId) || undefined,
3305
3316
  apply: false
3306
3317
  }); // OrderModule increments this epoch synchronously before its first await.
3307
- requestEpoch = (_this$store$order$get4 = (_this$store$order10 = this.store.order).getCustomerWalletPrepareConfigEpoch) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.call(_this$store$order10);
3318
+ requestEpoch = (_this$store$order$get4 = (_this$store$order12 = this.store.order).getCustomerWalletPrepareConfigEpoch) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.call(_this$store$order12);
3308
3319
  _context29.next = 29;
3309
3320
  return prepareConfigPromise;
3310
3321
  case 29:
@@ -3596,15 +3607,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3596
3607
  }, {
3597
3608
  key: "getAvailableWalletIds",
3598
3609
  value: function getAvailableWalletIds() {
3599
- var _this$store$order11;
3600
- if (!((_this$store$order11 = this.store.order) !== null && _this$store$order11 !== void 0 && _this$store$order11.getAvailableWalletIds)) return [];
3610
+ var _this$store$order13;
3611
+ if (!((_this$store$order13 = this.store.order) !== null && _this$store$order13 !== void 0 && _this$store$order13.getAvailableWalletIds)) return [];
3601
3612
  return this.store.order.getAvailableWalletIds();
3602
3613
  }
3603
3614
  }, {
3604
3615
  key: "getVirtualCurrencyList",
3605
3616
  value: function getVirtualCurrencyList() {
3606
- var _this$store$order12;
3607
- if (!((_this$store$order12 = this.store.order) !== null && _this$store$order12 !== void 0 && _this$store$order12.getVirtualCurrencyList)) return [];
3617
+ var _this$store$order14;
3618
+ if (!((_this$store$order14 = this.store.order) !== null && _this$store$order14 !== void 0 && _this$store$order14.getVirtualCurrencyList)) return [];
3608
3619
  return this.store.order.getVirtualCurrencyList();
3609
3620
  }
3610
3621
  }, {
@@ -4412,29 +4423,240 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4412
4423
  return submitSalesOrder;
4413
4424
  }())
4414
4425
  }, {
4415
- key: "saveSalesOrderDraft",
4426
+ key: "finalizeLocalEftposPayment",
4416
4427
  value: function () {
4417
- var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
4418
- var _params$platform, _this$otherParams24, _this$otherParams25, _this$otherParams26, _params$channel, _params$type, _this$otherParams27;
4428
+ var _finalizeLocalEftposPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
4429
+ var _response$data2;
4430
+ var key, response, _response$data3, order, payment, temp, isCurrentOrder, _temp$payments, currentTemp, _this$store$order15, refreshed;
4419
4431
  return _regeneratorRuntime().wrap(function _callee38$(_context38) {
4420
4432
  while (1) switch (_context38.prev = _context38.next) {
4433
+ case 0:
4434
+ key = "".concat(params.saleId, ":").concat(params.paymentNumber); // If SQLite rejects the write, retry this known result before another payment can start.
4435
+ this.pendingLocalEftposFinalizations.set(key, params);
4436
+ _context38.next = 4;
4437
+ return this.request.post('/local/finalizeLocalEftposPayment', {
4438
+ sale_id: params.saleId,
4439
+ payment_number: params.paymentNumber,
4440
+ result: params.result,
4441
+ failed_transaction_numbers: params.failedTransactionNumbers
4442
+ }, {
4443
+ osServer: true,
4444
+ customToast: function customToast() {}
4445
+ });
4446
+ case 4:
4447
+ response = _context38.sent;
4448
+ if (!((response === null || response === void 0 ? void 0 : response.code) !== 200 || !(response !== null && response !== void 0 && (_response$data2 = response.data) !== null && _response$data2 !== void 0 && _response$data2.order))) {
4449
+ _context38.next = 7;
4450
+ break;
4451
+ }
4452
+ throw new Error((response === null || response === void 0 ? void 0 : response.message) || '本地支付收尾失败,请刷新订单后重试');
4453
+ case 7:
4454
+ this.pendingLocalEftposFinalizations.delete(key);
4455
+ _response$data3 = response.data, order = _response$data3.order, payment = _response$data3.payment;
4456
+ temp = this.getTempOrder();
4457
+ isCurrentOrder = String((temp === null || temp === void 0 ? void 0 : temp.external_sale_number) || (temp === null || temp === void 0 ? void 0 : temp.order_id)) === String(params.saleId) || (temp === null || temp === void 0 ? void 0 : temp.order_id) && String(temp.order_id) === String(order.order_id);
4458
+ if (!isCurrentOrder) {
4459
+ _context38.next = 28;
4460
+ break;
4461
+ }
4462
+ if (!(temp !== null && temp !== void 0 && (_temp$payments = temp.payments) !== null && _temp$payments !== void 0 && _temp$payments.some(function (item) {
4463
+ return String(item.payment_number) === params.paymentNumber;
4464
+ }))) {
4465
+ _context38.next = 15;
4466
+ break;
4467
+ }
4468
+ _context38.next = 15;
4469
+ return this.updateOrderPayment(params.paymentNumber, payment, {
4470
+ persistDraft: false,
4471
+ submitWhenPaid: false
4472
+ });
4473
+ case 15:
4474
+ if (!requiresLocalPaymentRefresh(order)) {
4475
+ _context38.next = 26;
4476
+ break;
4477
+ }
4478
+ // Set the in-memory gate before the GET so a failed refresh also blocks this page.
4479
+ currentTemp = this.getTempOrder();
4480
+ if (currentTemp) currentTemp.metadata = _objectSpread(_objectSpread({}, currentTemp.metadata), order.metadata);
4481
+ _context38.prev = 18;
4482
+ _context38.next = 21;
4483
+ return this.loadSalesDetail({
4484
+ orderId: order.order_id,
4485
+ forceRemote: true,
4486
+ merge: false
4487
+ });
4488
+ case 21:
4489
+ _context38.next = 26;
4490
+ break;
4491
+ case 23:
4492
+ _context38.prev = 23;
4493
+ _context38.t0 = _context38["catch"](18);
4494
+ throw new Error(PAYMENT_REFRESH_MESSAGE);
4495
+ case 26:
4496
+ _context38.next = 34;
4497
+ break;
4498
+ case 28:
4499
+ if (!requiresLocalPaymentRefresh(order)) {
4500
+ _context38.next = 34;
4501
+ break;
4502
+ }
4503
+ _context38.next = 31;
4504
+ return (_this$store$order15 = this.store.order) === null || _this$store$order15 === void 0 ? void 0 : _this$store$order15.getSalesOrderByLookup({
4505
+ lookup: order.order_id,
4506
+ forceRemote: true
4507
+ });
4508
+ case 31:
4509
+ refreshed = _context38.sent;
4510
+ if (!((refreshed === null || refreshed === void 0 ? void 0 : refreshed.code) !== 200)) {
4511
+ _context38.next = 34;
4512
+ break;
4513
+ }
4514
+ throw new Error(PAYMENT_REFRESH_MESSAGE);
4515
+ case 34:
4516
+ return _context38.abrupt("return", response.data);
4517
+ case 35:
4518
+ case "end":
4519
+ return _context38.stop();
4520
+ }
4521
+ }, _callee38, this, [[18, 23]]);
4522
+ }));
4523
+ function finalizeLocalEftposPayment(_x29) {
4524
+ return _finalizeLocalEftposPayment.apply(this, arguments);
4525
+ }
4526
+ return finalizeLocalEftposPayment;
4527
+ }() /** Entry gate also reads SQLite state, so stale sessions/restarts cannot bypass it. */
4528
+ }, {
4529
+ key: "ensureSalesOrderReadyForPayment",
4530
+ value: (function () {
4531
+ var _ensureSalesOrderReadyForPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
4532
+ var _this$core6, _this$core6$hasRoute, _localOrder;
4533
+ var temp, unfinished, _iterator6, _step6, params, lookup, localOrder, response, orderId;
4534
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
4535
+ while (1) switch (_context39.prev = _context39.next) {
4536
+ case 0:
4537
+ temp = this.getTempOrder();
4538
+ unfinished = _toConsumableArray(this.pendingLocalEftposFinalizations.values()).filter(function (params) {
4539
+ return String(params.saleId) === String(temp === null || temp === void 0 ? void 0 : temp.external_sale_number) || String(params.saleId) === String(temp === null || temp === void 0 ? void 0 : temp.order_id);
4540
+ });
4541
+ if (!(unfinished.length > 0)) {
4542
+ _context39.next = 21;
4543
+ break;
4544
+ }
4545
+ _iterator6 = _createForOfIteratorHelper(unfinished);
4546
+ _context39.prev = 4;
4547
+ _iterator6.s();
4548
+ case 6:
4549
+ if ((_step6 = _iterator6.n()).done) {
4550
+ _context39.next = 12;
4551
+ break;
4552
+ }
4553
+ params = _step6.value;
4554
+ _context39.next = 10;
4555
+ return this.finalizeLocalEftposPayment(params);
4556
+ case 10:
4557
+ _context39.next = 6;
4558
+ break;
4559
+ case 12:
4560
+ _context39.next = 17;
4561
+ break;
4562
+ case 14:
4563
+ _context39.prev = 14;
4564
+ _context39.t0 = _context39["catch"](4);
4565
+ _iterator6.e(_context39.t0);
4566
+ case 17:
4567
+ _context39.prev = 17;
4568
+ _iterator6.f();
4569
+ return _context39.finish(17);
4570
+ case 20:
4571
+ throw new Error('订单已更新,请确认商品和金额后重新付款');
4572
+ case 21:
4573
+ lookup = (temp === null || temp === void 0 ? void 0 : temp.order_id) || (temp === null || temp === void 0 ? void 0 : temp.external_sale_number);
4574
+ localOrder = null;
4575
+ if (!(lookup && (_this$core6 = this.core) !== null && _this$core6 !== void 0 && (_this$core6 = _this$core6.server) !== null && _this$core6 !== void 0 && (_this$core6$hasRoute = _this$core6.hasRoute) !== null && _this$core6$hasRoute !== void 0 && _this$core6$hasRoute.call(_this$core6, 'post', '/shop/local/orderPaymentReadiness'))) {
4576
+ _context39.next = 30;
4577
+ break;
4578
+ }
4579
+ _context39.next = 26;
4580
+ return this.request.post('/local/orderPaymentReadiness', {
4581
+ sale_id: lookup
4582
+ }, {
4583
+ osServer: true,
4584
+ customToast: function customToast() {}
4585
+ });
4586
+ case 26:
4587
+ response = _context39.sent;
4588
+ if (!((response === null || response === void 0 ? void 0 : response.code) !== 200)) {
4589
+ _context39.next = 29;
4590
+ break;
4591
+ }
4592
+ throw new Error(PAYMENT_REFRESH_MESSAGE);
4593
+ case 29:
4594
+ localOrder = response.data;
4595
+ case 30:
4596
+ if (!(!requiresLocalPaymentRefresh(temp) && !requiresLocalPaymentRefresh(localOrder))) {
4597
+ _context39.next = 32;
4598
+ break;
4599
+ }
4600
+ return _context39.abrupt("return");
4601
+ case 32:
4602
+ orderId = ((_localOrder = localOrder) === null || _localOrder === void 0 ? void 0 : _localOrder.order_id) || (temp === null || temp === void 0 ? void 0 : temp.order_id);
4603
+ if (!(!orderId || String(orderId) === String(temp === null || temp === void 0 ? void 0 : temp.external_sale_number))) {
4604
+ _context39.next = 35;
4605
+ break;
4606
+ }
4607
+ throw new Error(PAYMENT_REFRESH_MESSAGE);
4608
+ case 35:
4609
+ _context39.prev = 35;
4610
+ _context39.next = 38;
4611
+ return this.loadSalesDetail({
4612
+ orderId: orderId,
4613
+ forceRemote: true,
4614
+ merge: false
4615
+ });
4616
+ case 38:
4617
+ _context39.next = 43;
4618
+ break;
4619
+ case 40:
4620
+ _context39.prev = 40;
4621
+ _context39.t1 = _context39["catch"](35);
4622
+ throw new Error(PAYMENT_REFRESH_MESSAGE);
4623
+ case 43:
4624
+ throw new Error('订单已刷新,请确认商品和金额后重新付款');
4625
+ case 44:
4626
+ case "end":
4627
+ return _context39.stop();
4628
+ }
4629
+ }, _callee39, this, [[4, 14, 17, 20], [35, 40]]);
4630
+ }));
4631
+ function ensureSalesOrderReadyForPayment() {
4632
+ return _ensureSalesOrderReadyForPayment.apply(this, arguments);
4633
+ }
4634
+ return ensureSalesOrderReadyForPayment;
4635
+ }())
4636
+ }, {
4637
+ key: "saveSalesOrderDraft",
4638
+ value: function () {
4639
+ var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
4640
+ var _params$platform, _this$otherParams24, _this$otherParams25, _this$otherParams26, _params$channel, _params$type, _this$otherParams27;
4641
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
4642
+ while (1) switch (_context40.prev = _context40.next) {
4421
4643
  case 0:
4422
4644
  if (this.store.order) {
4423
- _context38.next = 2;
4645
+ _context40.next = 2;
4424
4646
  break;
4425
4647
  }
4426
4648
  throw new Error('BaseSales 解决方案需要 order 模块支持');
4427
4649
  case 2:
4428
4650
  if (!this.isPickupTimingEnabled()) {
4429
- _context38.next = 5;
4651
+ _context40.next = 5;
4430
4652
  break;
4431
4653
  }
4432
- _context38.next = 5;
4654
+ _context40.next = 5;
4433
4655
  return this.preparePickupTimingForCheckout({
4434
4656
  freeze: false
4435
4657
  });
4436
4658
  case 5:
4437
- return _context38.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
4659
+ return _context40.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
4438
4660
  cacheId: this.cacheId,
4439
4661
  platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.platform,
4440
4662
  businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.businessCode) || ((_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.business_code),
@@ -4445,11 +4667,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4445
4667
  } : {})));
4446
4668
  case 6:
4447
4669
  case "end":
4448
- return _context38.stop();
4670
+ return _context40.stop();
4449
4671
  }
4450
- }, _callee38, this);
4672
+ }, _callee40, this);
4451
4673
  }));
4452
- function saveSalesOrderDraft(_x29) {
4674
+ function saveSalesOrderDraft(_x30) {
4453
4675
  return _saveSalesOrderDraft.apply(this, arguments);
4454
4676
  }
4455
4677
  return saveSalesOrderDraft;
@@ -4457,23 +4679,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4457
4679
  }, {
4458
4680
  key: "submitTempOrderAsync",
4459
4681
  value: function () {
4460
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
4682
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
4461
4683
  var _params$smallTicketDa2, _this$otherParams28, _this$otherParams29, _this$otherParams30, _this$otherParams31;
4462
4684
  var inferredPaymentStatus, smallTicketDataFlag, enhancePayload, submitParams;
4463
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
4464
- while (1) switch (_context39.prev = _context39.next) {
4685
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
4686
+ while (1) switch (_context41.prev = _context41.next) {
4465
4687
  case 0:
4466
4688
  if (this.store.order) {
4467
- _context39.next = 2;
4689
+ _context41.next = 2;
4468
4690
  break;
4469
4691
  }
4470
4692
  throw new Error('BaseSales 解决方案需要 order 模块支持');
4471
4693
  case 2:
4472
4694
  if (!this.isPickupTimingEnabled()) {
4473
- _context39.next = 5;
4695
+ _context41.next = 5;
4474
4696
  break;
4475
4697
  }
4476
- _context39.next = 5;
4698
+ _context41.next = 5;
4477
4699
  return this.preparePickupTimingForCheckout({
4478
4700
  freeze: true
4479
4701
  });
@@ -4499,14 +4721,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4499
4721
  } : {}), enhancePayload !== undefined ? {
4500
4722
  enhancePayload: enhancePayload
4501
4723
  } : {});
4502
- return _context39.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
4724
+ return _context41.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
4503
4725
  case 10:
4504
4726
  case "end":
4505
- return _context39.stop();
4727
+ return _context41.stop();
4506
4728
  }
4507
- }, _callee39, this);
4729
+ }, _callee41, this);
4508
4730
  }));
4509
- function submitTempOrderAsync(_x30) {
4731
+ function submitTempOrderAsync(_x31) {
4510
4732
  return _submitTempOrderAsync.apply(this, arguments);
4511
4733
  }
4512
4734
  return submitTempOrderAsync;
@@ -4532,14 +4754,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4532
4754
  }, {
4533
4755
  key: "printLocalOrderReceipt",
4534
4756
  value: function () {
4535
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(lookup) {
4757
+ var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(lookup) {
4536
4758
  var _this$otherParams33, _this$otherParams34, _this$otherParams35, _this$otherParams36;
4537
- var hasLookup, lookupPayload, context, payload, invoiceLayoutConfig, invoiceTemplateSettings, printPayload, response, _this$store$order$app, _this$store$order13, _data;
4538
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
4539
- while (1) switch (_context40.prev = _context40.next) {
4759
+ var hasLookup, lookupPayload, context, payload, invoiceLayoutConfig, invoiceTemplateSettings, printPayload, response, _this$store$order$app, _this$store$order16, _data;
4760
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4761
+ while (1) switch (_context42.prev = _context42.next) {
4540
4762
  case 0:
4541
4763
  if (this.store.order) {
4542
- _context40.next = 2;
4764
+ _context42.next = 2;
4543
4765
  break;
4544
4766
  }
4545
4767
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -4577,28 +4799,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4577
4799
  } : {}), invoiceTemplateSettings ? {
4578
4800
  template_settings: cloneDeep(invoiceTemplateSettings)
4579
4801
  } : {});
4580
- _context40.next = 11;
4802
+ _context42.next = 11;
4581
4803
  return this.request.post('/local/print-order', printPayload, {
4582
4804
  osServer: true,
4583
4805
  customToast: function customToast() {}
4584
4806
  });
4585
4807
  case 11:
4586
- response = _context40.sent;
4808
+ response = _context42.sent;
4587
4809
  if (hasLookup) {
4588
- _context40.next = 15;
4810
+ _context42.next = 15;
4589
4811
  break;
4590
4812
  }
4591
- _context40.next = 15;
4592
- return (_this$store$order$app = (_this$store$order13 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order13, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
4813
+ _context42.next = 15;
4814
+ return (_this$store$order$app = (_this$store$order16 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order16, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
4593
4815
  case 15:
4594
- return _context40.abrupt("return", response);
4816
+ return _context42.abrupt("return", response);
4595
4817
  case 16:
4596
4818
  case "end":
4597
- return _context40.stop();
4819
+ return _context42.stop();
4598
4820
  }
4599
- }, _callee40, this);
4821
+ }, _callee42, this);
4600
4822
  }));
4601
- function printLocalOrderReceipt(_x31) {
4823
+ function printLocalOrderReceipt(_x32) {
4602
4824
  return _printLocalOrderReceipt.apply(this, arguments);
4603
4825
  }
4604
4826
  return printLocalOrderReceipt;
@@ -4606,27 +4828,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4606
4828
  }, {
4607
4829
  key: "getSubmitPaymentStatus",
4608
4830
  value: function getSubmitPaymentStatus(paymentStatus) {
4609
- var _this$store$order14, _this$store$order14$g;
4831
+ var _this$store$order17, _this$store$order17$g;
4610
4832
  if (paymentStatus !== undefined) return paymentStatus;
4611
- var amountSnapshot = (_this$store$order14 = this.store.order) === null || _this$store$order14 === void 0 || (_this$store$order14$g = _this$store$order14.getOrderAmountSnapshot) === null || _this$store$order14$g === void 0 ? void 0 : _this$store$order14$g.call(_this$store$order14);
4833
+ var amountSnapshot = (_this$store$order17 = this.store.order) === null || _this$store$order17 === void 0 || (_this$store$order17$g = _this$store$order17.getOrderAmountSnapshot) === null || _this$store$order17$g === void 0 ? void 0 : _this$store$order17$g.call(_this$store$order17);
4612
4834
  if (!amountSnapshot) return undefined;
4613
4835
  try {
4614
4836
  return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
4615
- } catch (_unused5) {
4837
+ } catch (_unused7) {
4616
4838
  return undefined;
4617
4839
  }
4618
4840
  }
4619
4841
  }, {
4620
4842
  key: "syncPaymentsToOrder",
4621
4843
  value: function () {
4622
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
4844
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
4623
4845
  var _ref48, _params$businessCode, _this$otherParams37, _this$otherParams38, _params$channel2;
4624
4846
  var businessCode, channel, enhancePayload, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
4625
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
4626
- while (1) switch (_context41.prev = _context41.next) {
4847
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4848
+ while (1) switch (_context43.prev = _context43.next) {
4627
4849
  case 0:
4628
4850
  if (this.store.order) {
4629
- _context41.next = 2;
4851
+ _context43.next = 2;
4630
4852
  break;
4631
4853
  }
4632
4854
  throw new Error('order 模块未初始化');
@@ -4645,14 +4867,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4645
4867
  } : {});
4646
4868
  syncState = this.store.order.getOrderSyncState();
4647
4869
  if (!(params.submitWhenPaid && syncState === 'submitting')) {
4648
- _context41.next = 10;
4870
+ _context43.next = 10;
4649
4871
  break;
4650
4872
  }
4651
4873
  this.queueLatestAutoPaymentSync();
4652
- return _context41.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
4874
+ return _context43.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
4653
4875
  case 10:
4654
4876
  payments = params.payments || [];
4655
- _context41.next = 13;
4877
+ _context43.next = 13;
4656
4878
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
4657
4879
  payments: payments,
4658
4880
  params: syncParams,
@@ -4660,11 +4882,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4660
4882
  orderSnapshot: this.store.order.getOrderSnapshot()
4661
4883
  });
4662
4884
  case 13:
4663
- _context41.prev = 13;
4664
- _context41.next = 16;
4885
+ _context43.prev = 13;
4886
+ _context43.next = 16;
4665
4887
  return this.store.order.syncPaymentsToOrder(syncParams);
4666
4888
  case 16:
4667
- syncResult = _context41.sent;
4889
+ syncResult = _context43.sent;
4668
4890
  latestPayments = this.store.order.getOrderPayments();
4669
4891
  amountSnapshot = this.store.order.getOrderAmountSnapshot();
4670
4892
  orderSnapshot = this.store.order.getOrderSnapshot();
@@ -4682,25 +4904,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4682
4904
  depositAmount: syncResult.depositAmount,
4683
4905
  orderExpectedAmount: syncResult.orderExpectedAmount
4684
4906
  };
4685
- _context41.next = 23;
4907
+ _context43.next = 23;
4686
4908
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
4687
4909
  case 23:
4688
4910
  if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
4689
- _context41.next = 26;
4911
+ _context43.next = 26;
4690
4912
  break;
4691
4913
  }
4692
- _context41.next = 26;
4914
+ _context43.next = 26;
4693
4915
  return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
4694
4916
  case 26:
4695
4917
  this.scheduleQueuedAutoPaymentSyncFlush(0);
4696
- return _context41.abrupt("return", syncResult);
4918
+ return _context43.abrupt("return", syncResult);
4697
4919
  case 30:
4698
- _context41.prev = 30;
4699
- _context41.t0 = _context41["catch"](13);
4700
- _context41.next = 34;
4920
+ _context43.prev = 30;
4921
+ _context43.t0 = _context43["catch"](13);
4922
+ _context43.next = 34;
4701
4923
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
4702
4924
  ok: false,
4703
- error: _context41.t0,
4925
+ error: _context43.t0,
4704
4926
  payments: this.store.order.getOrderPayments(),
4705
4927
  params: syncParams,
4706
4928
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
@@ -4708,14 +4930,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4708
4930
  });
4709
4931
  case 34:
4710
4932
  this.scheduleQueuedAutoPaymentSyncFlush(0);
4711
- throw _context41.t0;
4933
+ throw _context43.t0;
4712
4934
  case 36:
4713
4935
  case "end":
4714
- return _context41.stop();
4936
+ return _context43.stop();
4715
4937
  }
4716
- }, _callee41, this, [[13, 30]]);
4938
+ }, _callee43, this, [[13, 30]]);
4717
4939
  }));
4718
- function syncPaymentsToOrder(_x32) {
4940
+ function syncPaymentsToOrder(_x33) {
4719
4941
  return _syncPaymentsToOrder.apply(this, arguments);
4720
4942
  }
4721
4943
  return syncPaymentsToOrder;
@@ -4764,46 +4986,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4764
4986
  }, {
4765
4987
  key: "flushQueuedAutoPaymentSync",
4766
4988
  value: function () {
4767
- var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
4989
+ var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
4768
4990
  var payments;
4769
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4770
- while (1) switch (_context42.prev = _context42.next) {
4991
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4992
+ while (1) switch (_context44.prev = _context44.next) {
4771
4993
  case 0:
4772
4994
  if (this.store.order) {
4773
- _context42.next = 2;
4995
+ _context44.next = 2;
4774
4996
  break;
4775
4997
  }
4776
- return _context42.abrupt("return");
4998
+ return _context44.abrupt("return");
4777
4999
  case 2:
4778
5000
  if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
4779
- _context42.next = 4;
5001
+ _context44.next = 4;
4780
5002
  break;
4781
5003
  }
4782
- return _context42.abrupt("return");
5004
+ return _context44.abrupt("return");
4783
5005
  case 4:
4784
5006
  if (!(this.store.order.getOrderSyncState() === 'submitting')) {
4785
- _context42.next = 7;
5007
+ _context44.next = 7;
4786
5008
  break;
4787
5009
  }
4788
5010
  this.scheduleQueuedAutoPaymentSyncFlush();
4789
- return _context42.abrupt("return");
5011
+ return _context44.abrupt("return");
4790
5012
  case 7:
4791
5013
  this.autoPaymentSyncFlushing = true;
4792
- _context42.prev = 8;
5014
+ _context44.prev = 8;
4793
5015
  case 9:
4794
5016
  if (!this.queuedAutoPaymentSync) {
4795
- _context42.next = 18;
5017
+ _context44.next = 18;
4796
5018
  break;
4797
5019
  }
4798
5020
  this.queuedAutoPaymentSync = false;
4799
5021
  payments = this.store.order.getOrderPayments();
4800
5022
  if (payments.length) {
4801
- _context42.next = 14;
5023
+ _context44.next = 14;
4802
5024
  break;
4803
5025
  }
4804
- return _context42.abrupt("continue", 9);
5026
+ return _context44.abrupt("continue", 9);
4805
5027
  case 14:
4806
- _context42.next = 16;
5028
+ _context44.next = 16;
4807
5029
  return this.syncPaymentsToOrder({
4808
5030
  payments: payments,
4809
5031
  paymentStatus: this.getPaymentStatusForSync(payments),
@@ -4811,29 +5033,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4811
5033
  smallTicketDataFlag: 1
4812
5034
  });
4813
5035
  case 16:
4814
- _context42.next = 9;
5036
+ _context44.next = 9;
4815
5037
  break;
4816
5038
  case 18:
4817
- _context42.next = 23;
5039
+ _context44.next = 23;
4818
5040
  break;
4819
5041
  case 20:
4820
- _context42.prev = 20;
4821
- _context42.t0 = _context42["catch"](8);
5042
+ _context44.prev = 20;
5043
+ _context44.t0 = _context44["catch"](8);
4822
5044
  this.logError('queued auto sync payments failed', {
4823
- error: _context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0)
5045
+ error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
4824
5046
  });
4825
5047
  case 23:
4826
- _context42.prev = 23;
5048
+ _context44.prev = 23;
4827
5049
  this.autoPaymentSyncFlushing = false;
4828
5050
  if (this.queuedAutoPaymentSync) {
4829
5051
  this.scheduleQueuedAutoPaymentSyncFlush(0);
4830
5052
  }
4831
- return _context42.finish(23);
5053
+ return _context44.finish(23);
4832
5054
  case 27:
4833
5055
  case "end":
4834
- return _context42.stop();
5056
+ return _context44.stop();
4835
5057
  }
4836
- }, _callee42, this, [[8, 20, 23, 27]]);
5058
+ }, _callee44, this, [[8, 20, 23, 27]]);
4837
5059
  }));
4838
5060
  function flushQueuedAutoPaymentSync() {
4839
5061
  return _flushQueuedAutoPaymentSync.apply(this, arguments);
@@ -4857,35 +5079,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4857
5079
  }, {
4858
5080
  key: "addOrderPaymentAsync",
4859
5081
  value: (function () {
4860
- var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(payment) {
5082
+ var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(payment) {
4861
5083
  var paymentRecord, hasPaymentNumber, devicePrefix;
4862
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4863
- while (1) switch (_context43.prev = _context43.next) {
5084
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
5085
+ while (1) switch (_context45.prev = _context45.next) {
4864
5086
  case 0:
4865
5087
  paymentRecord = payment;
4866
5088
  hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
4867
5089
  if (!hasPaymentNumber) {
4868
- _context43.next = 6;
5090
+ _context45.next = 6;
4869
5091
  break;
4870
5092
  }
4871
- _context43.t0 = 'LOCAL';
4872
- _context43.next = 9;
5093
+ _context45.t0 = 'LOCAL';
5094
+ _context45.next = 9;
4873
5095
  break;
4874
5096
  case 6:
4875
- _context43.next = 8;
5097
+ _context45.next = 8;
4876
5098
  return this.getPaymentNumberDevicePrefixAsync();
4877
5099
  case 8:
4878
- _context43.t0 = _context43.sent;
5100
+ _context45.t0 = _context45.sent;
4879
5101
  case 9:
4880
- devicePrefix = _context43.t0;
4881
- return _context43.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
5102
+ devicePrefix = _context45.t0;
5103
+ return _context45.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
4882
5104
  case 11:
4883
5105
  case "end":
4884
- return _context43.stop();
5106
+ return _context45.stop();
4885
5107
  }
4886
- }, _callee43, this);
5108
+ }, _callee45, this);
4887
5109
  }));
4888
- function addOrderPaymentAsync(_x33) {
5110
+ function addOrderPaymentAsync(_x34) {
4889
5111
  return _addOrderPaymentAsync.apply(this, arguments);
4890
5112
  }
4891
5113
  return addOrderPaymentAsync;
@@ -4954,7 +5176,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4954
5176
  }, {
4955
5177
  key: "updateOrderPayment",
4956
5178
  value: (function () {
4957
- var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(paymentIdentity, updates) {
5179
+ var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(paymentIdentity, updates) {
4958
5180
  var _result$payment, _result$payment2;
4959
5181
  var options,
4960
5182
  matchMode,
@@ -4971,13 +5193,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4971
5193
  shouldSubmit,
4972
5194
  syncResult,
4973
5195
  _options$smallTicketD2,
4974
- _args44 = arguments;
4975
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4976
- while (1) switch (_context44.prev = _context44.next) {
5196
+ _args46 = arguments;
5197
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
5198
+ while (1) switch (_context46.prev = _context46.next) {
4977
5199
  case 0:
4978
- options = _args44.length > 2 && _args44[2] !== undefined ? _args44[2] : {};
5200
+ options = _args46.length > 2 && _args46[2] !== undefined ? _args46[2] : {};
4979
5201
  if (this.store.order) {
4980
- _context44.next = 3;
5202
+ _context46.next = 3;
4981
5203
  break;
4982
5204
  }
4983
5205
  throw new Error('order 模块未初始化');
@@ -4986,15 +5208,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4986
5208
  previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
4987
5209
  previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
4988
5210
  if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
4989
- _context44.next = 13;
5211
+ _context46.next = 13;
4990
5212
  break;
4991
5213
  }
4992
5214
  currentPayments = this.store.order.getOrderPayments();
4993
5215
  if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
4994
- _context44.next = 12;
5216
+ _context46.next = 12;
4995
5217
  break;
4996
5218
  }
4997
- _context44.next = 11;
5219
+ _context46.next = 11;
4998
5220
  return this.syncPaymentsToOrder({
4999
5221
  payments: currentPayments,
5000
5222
  paymentStatus: this.getPaymentStatusForSync(currentPayments),
@@ -5002,9 +5224,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5002
5224
  smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
5003
5225
  });
5004
5226
  case 11:
5005
- _syncResult = _context44.sent;
5227
+ _syncResult = _context46.sent;
5006
5228
  case 12:
5007
- return _context44.abrupt("return", _objectSpread({
5229
+ return _context46.abrupt("return", _objectSpread({
5008
5230
  updated: false,
5009
5231
  payment: previousPayment,
5010
5232
  payments: currentPayments,
@@ -5013,44 +5235,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5013
5235
  syncResult: _syncResult
5014
5236
  } : {}));
5015
5237
  case 13:
5016
- _context44.next = 15;
5238
+ _context46.next = 15;
5017
5239
  return this.store.order.updateOrderPayment(paymentIdentity, updates, {
5018
5240
  matchBy: matchMode
5019
5241
  });
5020
5242
  case 15:
5021
- result = _context44.sent;
5243
+ result = _context46.sent;
5022
5244
  if (!(options.persistDraft !== false)) {
5023
- _context44.next = 29;
5245
+ _context46.next = 29;
5024
5246
  break;
5025
5247
  }
5026
- _context44.prev = 17;
5027
- _context44.next = 20;
5248
+ _context46.prev = 17;
5249
+ _context46.next = 20;
5028
5250
  return this.saveSalesOrderDraft();
5029
5251
  case 20:
5030
- draftResult = _context44.sent;
5031
- _context44.next = 29;
5252
+ draftResult = _context46.sent;
5253
+ _context46.next = 29;
5032
5254
  break;
5033
5255
  case 23:
5034
- _context44.prev = 23;
5035
- _context44.t0 = _context44["catch"](17);
5036
- draftError = _context44.t0;
5256
+ _context46.prev = 23;
5257
+ _context46.t0 = _context46["catch"](17);
5258
+ draftError = _context46.t0;
5037
5259
  this.logError('updateOrderPayment: 保存支付草稿失败', {
5038
5260
  paymentIdentity: paymentIdentity,
5039
- error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
5261
+ error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
5040
5262
  });
5041
5263
  if (options.submitWhenPaid) {
5042
- _context44.next = 29;
5264
+ _context46.next = 29;
5043
5265
  break;
5044
5266
  }
5045
- throw _context44.t0;
5267
+ throw _context46.t0;
5046
5268
  case 29:
5047
5269
  becamePaid = (previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) !== 'paid' && ((_result$payment = result.payment) === null || _result$payment === void 0 ? void 0 : _result$payment.status) === 'paid';
5048
5270
  shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
5049
5271
  if (!shouldSubmit) {
5050
- _context44.next = 35;
5272
+ _context46.next = 35;
5051
5273
  break;
5052
5274
  }
5053
- _context44.next = 34;
5275
+ _context46.next = 34;
5054
5276
  return this.syncPaymentsToOrder({
5055
5277
  payments: result.payments,
5056
5278
  paymentStatus: this.getPaymentStatusForSync(result.payments),
@@ -5058,9 +5280,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5058
5280
  smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
5059
5281
  });
5060
5282
  case 34:
5061
- syncResult = _context44.sent;
5283
+ syncResult = _context46.sent;
5062
5284
  case 35:
5063
- return _context44.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
5285
+ return _context46.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
5064
5286
  draftResult: draftResult
5065
5287
  } : {}), draftError !== undefined ? {
5066
5288
  draftError: draftError
@@ -5069,11 +5291,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5069
5291
  } : {}));
5070
5292
  case 36:
5071
5293
  case "end":
5072
- return _context44.stop();
5294
+ return _context46.stop();
5073
5295
  }
5074
- }, _callee44, this, [[17, 23]]);
5296
+ }, _callee46, this, [[17, 23]]);
5075
5297
  }));
5076
- function updateOrderPayment(_x34, _x35) {
5298
+ function updateOrderPayment(_x35, _x36) {
5077
5299
  return _updateOrderPayment.apply(this, arguments);
5078
5300
  }
5079
5301
  return updateOrderPayment;
@@ -5095,24 +5317,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5095
5317
  }, {
5096
5318
  key: "updateVoucherOrderPaymentsAsync",
5097
5319
  value: function () {
5098
- var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(payments, options) {
5099
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
5100
- while (1) switch (_context45.prev = _context45.next) {
5320
+ var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(payments, options) {
5321
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
5322
+ while (1) switch (_context47.prev = _context47.next) {
5101
5323
  case 0:
5102
5324
  if (this.store.order) {
5103
- _context45.next = 2;
5325
+ _context47.next = 2;
5104
5326
  break;
5105
5327
  }
5106
5328
  throw new Error('order 模块未初始化');
5107
5329
  case 2:
5108
- return _context45.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
5330
+ return _context47.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
5109
5331
  case 3:
5110
5332
  case "end":
5111
- return _context45.stop();
5333
+ return _context47.stop();
5112
5334
  }
5113
- }, _callee45, this);
5335
+ }, _callee47, this);
5114
5336
  }));
5115
- function updateVoucherOrderPaymentsAsync(_x36, _x37) {
5337
+ function updateVoucherOrderPaymentsAsync(_x37, _x38) {
5116
5338
  return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
5117
5339
  }
5118
5340
  return updateVoucherOrderPaymentsAsync;
@@ -5138,8 +5360,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5138
5360
  }, {
5139
5361
  key: "getWalletProductList",
5140
5362
  value: function getWalletProductList() {
5141
- var _this$store$order15, _tempOrder$products;
5142
- var tempOrder = (_this$store$order15 = this.store.order) === null || _this$store$order15 === void 0 ? void 0 : _this$store$order15.getTempOrder();
5363
+ var _this$store$order18, _tempOrder$products;
5364
+ var tempOrder = (_this$store$order18 = this.store.order) === null || _this$store$order18 === void 0 ? void 0 : _this$store$order18.getTempOrder();
5143
5365
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
5144
5366
  // 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
5145
5367
  // debugger
@@ -5199,8 +5421,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5199
5421
  }, {
5200
5422
  key: "buildWalletInitBusinessData",
5201
5423
  value: function buildWalletInitBusinessData(params) {
5202
- var _this$store$order16, _params$order_wait_pa, _ref50, _tempOrder$is_price_i;
5203
- var snapshot = (_this$store$order16 = this.store.order) === null || _this$store$order16 === void 0 ? void 0 : _this$store$order16.getOrderSnapshot();
5424
+ var _this$store$order19, _params$order_wait_pa, _ref50, _tempOrder$is_price_i;
5425
+ var snapshot = (_this$store$order19 = this.store.order) === null || _this$store$order19 === void 0 ? void 0 : _this$store$order19.getOrderSnapshot();
5204
5426
  var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
5205
5427
  var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
5206
5428
  if (!tempOrder || !amount) return null;
@@ -5223,20 +5445,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5223
5445
  }, {
5224
5446
  key: "initWalletData",
5225
5447
  value: function () {
5226
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
5227
- var _this$store$order$mer, _this$store$order17, _snapshot$identity;
5448
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
5449
+ var _this$store$order$mer, _this$store$order20, _snapshot$identity;
5228
5450
  var snapshot, walletBusinessData, result;
5229
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
5230
- while (1) switch (_context46.prev = _context46.next) {
5451
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
5452
+ while (1) switch (_context48.prev = _context48.next) {
5231
5453
  case 0:
5232
5454
  if (this.store.order) {
5233
- _context46.next = 2;
5455
+ _context48.next = 2;
5234
5456
  break;
5235
5457
  }
5236
5458
  throw new Error('order 模块未初始化');
5237
5459
  case 2:
5238
5460
  if (this.store.payment) {
5239
- _context46.next = 4;
5461
+ _context48.next = 4;
5240
5462
  break;
5241
5463
  }
5242
5464
  throw new Error('payment 模块未初始化');
@@ -5244,10 +5466,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5244
5466
  snapshot = this.store.order.getOrderSnapshot();
5245
5467
  walletBusinessData = this.buildWalletInitBusinessData(params);
5246
5468
  if (walletBusinessData) {
5247
- _context46.next = 8;
5469
+ _context48.next = 8;
5248
5470
  break;
5249
5471
  }
5250
- return _context46.abrupt("return", {
5472
+ return _context48.abrupt("return", {
5251
5473
  walletRecommendList: [],
5252
5474
  userIdentificationCodes: [],
5253
5475
  transformList: [],
@@ -5255,15 +5477,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5255
5477
  products: []
5256
5478
  });
5257
5479
  case 8:
5258
- _context46.next = 10;
5480
+ _context48.next = 10;
5259
5481
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
5260
5482
  case 10:
5261
- result = _context46.sent;
5262
- (_this$store$order$mer = (_this$store$order17 = this.store.order).mergePointCardSnapshotCodes) === null || _this$store$order$mer === void 0 || _this$store$order$mer.call(_this$store$order17, result.userIdentificationCodes, {
5483
+ result = _context48.sent;
5484
+ (_this$store$order$mer = (_this$store$order20 = this.store.order).mergePointCardSnapshotCodes) === null || _this$store$order$mer === void 0 || _this$store$order$mer.call(_this$store$order20, result.userIdentificationCodes, {
5263
5485
  customerId: walletBusinessData.customer_id,
5264
5486
  orderIdentity: snapshot === null || snapshot === void 0 ? void 0 : snapshot.identity
5265
5487
  });
5266
- _context46.next = 14;
5488
+ _context48.next = 14;
5267
5489
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
5268
5490
  orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
5269
5491
  customerId: walletBusinessData.customer_id,
@@ -5275,14 +5497,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5275
5497
  timestamp: Date.now()
5276
5498
  });
5277
5499
  case 14:
5278
- return _context46.abrupt("return", result);
5500
+ return _context48.abrupt("return", result);
5279
5501
  case 15:
5280
5502
  case "end":
5281
- return _context46.stop();
5503
+ return _context48.stop();
5282
5504
  }
5283
- }, _callee46, this);
5505
+ }, _callee48, this);
5284
5506
  }));
5285
- function initWalletData(_x38) {
5507
+ function initWalletData(_x39) {
5286
5508
  return _initWalletData.apply(this, arguments);
5287
5509
  }
5288
5510
  return initWalletData;
@@ -5290,8 +5512,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5290
5512
  }, {
5291
5513
  key: "getCommittedWalletAssets",
5292
5514
  value: function getCommittedWalletAssets() {
5293
- var _this$store$order18, _this$store$order18$g;
5294
- var payments = ((_this$store$order18 = this.store.order) === null || _this$store$order18 === void 0 || (_this$store$order18$g = _this$store$order18.getOrderPayments) === null || _this$store$order18$g === void 0 ? void 0 : _this$store$order18$g.call(_this$store$order18)) || [];
5515
+ var _this$store$order21, _this$store$order21$g;
5516
+ var payments = ((_this$store$order21 = this.store.order) === null || _this$store$order21 === void 0 || (_this$store$order21$g = _this$store$order21.getOrderPayments) === null || _this$store$order21$g === void 0 ? void 0 : _this$store$order21$g.call(_this$store$order21)) || [];
5295
5517
  var committed = payments.filter(function (payment) {
5296
5518
  var voucherId = payment === null || payment === void 0 ? void 0 : payment.voucher_id;
5297
5519
  if (voucherId === undefined || voucherId === null || voucherId === 0) {
@@ -5333,27 +5555,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5333
5555
  }, {
5334
5556
  key: "publishWalletAssetsState",
5335
5557
  value: function () {
5336
- var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(state) {
5558
+ var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(state) {
5337
5559
  var changeSource,
5338
- _args47 = arguments;
5339
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
5340
- while (1) switch (_context47.prev = _context47.next) {
5560
+ _args49 = arguments;
5561
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
5562
+ while (1) switch (_context49.prev = _context49.next) {
5341
5563
  case 0:
5342
- changeSource = _args47.length > 1 && _args47[1] !== undefined ? _args47[1] : 'derived';
5343
- _context47.next = 3;
5564
+ changeSource = _args49.length > 1 && _args49[1] !== undefined ? _args49[1] : 'derived';
5565
+ _context49.next = 3;
5344
5566
  return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
5345
5567
  state: state,
5346
5568
  changeSource: changeSource
5347
5569
  });
5348
5570
  case 3:
5349
- return _context47.abrupt("return", state);
5571
+ return _context49.abrupt("return", state);
5350
5572
  case 4:
5351
5573
  case "end":
5352
- return _context47.stop();
5574
+ return _context49.stop();
5353
5575
  }
5354
- }, _callee47, this);
5576
+ }, _callee49, this);
5355
5577
  }));
5356
- function publishWalletAssetsState(_x39) {
5578
+ function publishWalletAssetsState(_x40) {
5357
5579
  return _publishWalletAssetsState.apply(this, arguments);
5358
5580
  }
5359
5581
  return publishWalletAssetsState;
@@ -5361,26 +5583,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5361
5583
  }, {
5362
5584
  key: "syncSelectedWalletAssets",
5363
5585
  value: function () {
5364
- var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(state) {
5586
+ var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(state) {
5365
5587
  var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
5366
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
5367
- while (1) switch (_context48.prev = _context48.next) {
5588
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
5589
+ while (1) switch (_context50.prev = _context50.next) {
5368
5590
  case 0:
5369
5591
  if (!(!this.store.order || !this.store.payment)) {
5370
- _context48.next = 2;
5592
+ _context50.next = 2;
5371
5593
  break;
5372
5594
  }
5373
5595
  throw new Error('订单或支付模块未初始化');
5374
5596
  case 2:
5375
5597
  paymentMethods = this.getPaymentMethods();
5376
5598
  if (!(!paymentMethods.length && state.selectedItems.length)) {
5377
- _context48.next = 7;
5599
+ _context50.next = 7;
5378
5600
  break;
5379
5601
  }
5380
- _context48.next = 6;
5602
+ _context50.next = 6;
5381
5603
  return this.getPaymentMethodsAsync();
5382
5604
  case 6:
5383
- paymentMethods = _context48.sent;
5605
+ paymentMethods = _context50.sent;
5384
5606
  case 7:
5385
5607
  methodByCode = new Map(paymentMethods.map(function (method) {
5386
5608
  return [String(method.code || '').toUpperCase(), method];
@@ -5422,19 +5644,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5422
5644
  payments = this.updateVoucherOrderPayments(voucherPayments, {
5423
5645
  status: 'payment_pending'
5424
5646
  });
5425
- _context48.next = 14;
5647
+ _context50.next = 14;
5426
5648
  return this.store.order.recalculateSummary({
5427
5649
  createIfMissing: true
5428
5650
  });
5429
5651
  case 14:
5430
- return _context48.abrupt("return", payments);
5652
+ return _context50.abrupt("return", payments);
5431
5653
  case 15:
5432
5654
  case "end":
5433
- return _context48.stop();
5655
+ return _context50.stop();
5434
5656
  }
5435
- }, _callee48, this);
5657
+ }, _callee50, this);
5436
5658
  }));
5437
- function syncSelectedWalletAssets(_x40) {
5659
+ function syncSelectedWalletAssets(_x41) {
5438
5660
  return _syncSelectedWalletAssets.apply(this, arguments);
5439
5661
  }
5440
5662
  return syncSelectedWalletAssets;
@@ -5468,31 +5690,31 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5468
5690
  }, {
5469
5691
  key: "importWalletAssetsSnapshot",
5470
5692
  value: (function () {
5471
- var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(snapshot) {
5472
- var _this$store$order19, _this$store$order19$m;
5693
+ var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(snapshot) {
5694
+ var _this$store$order22, _this$store$order22$m;
5473
5695
  var state;
5474
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
5475
- while (1) switch (_context49.prev = _context49.next) {
5696
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5697
+ while (1) switch (_context51.prev = _context51.next) {
5476
5698
  case 0:
5477
5699
  if (this.store.payment) {
5478
- _context49.next = 2;
5700
+ _context51.next = 2;
5479
5701
  break;
5480
5702
  }
5481
5703
  throw new Error('payment 模块未初始化');
5482
5704
  case 2:
5483
5705
  state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
5484
- (_this$store$order19 = this.store.order) === null || _this$store$order19 === void 0 || (_this$store$order19$m = _this$store$order19.mergePointCardSnapshotCodes) === null || _this$store$order19$m === void 0 || _this$store$order19$m.call(_this$store$order19, state.items);
5485
- _context49.next = 6;
5706
+ (_this$store$order22 = this.store.order) === null || _this$store$order22 === void 0 || (_this$store$order22$m = _this$store$order22.mergePointCardSnapshotCodes) === null || _this$store$order22$m === void 0 || _this$store$order22$m.call(_this$store$order22, state.items);
5707
+ _context51.next = 6;
5486
5708
  return this.syncSelectedWalletAssets(state);
5487
5709
  case 6:
5488
- return _context49.abrupt("return", this.publishWalletAssetsState(state));
5710
+ return _context51.abrupt("return", this.publishWalletAssetsState(state));
5489
5711
  case 7:
5490
5712
  case "end":
5491
- return _context49.stop();
5713
+ return _context51.stop();
5492
5714
  }
5493
- }, _callee49, this);
5715
+ }, _callee51, this);
5494
5716
  }));
5495
- function importWalletAssetsSnapshot(_x41) {
5717
+ function importWalletAssetsSnapshot(_x42) {
5496
5718
  return _importWalletAssetsSnapshot.apply(this, arguments);
5497
5719
  }
5498
5720
  return importWalletAssetsSnapshot;
@@ -5504,20 +5726,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5504
5726
  }, {
5505
5727
  key: "refreshWalletAssets",
5506
5728
  value: (function () {
5507
- var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
5729
+ var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
5508
5730
  var _this$store$order$get6, _previousState$custom, _businessData$custome;
5509
- var refreshSequence, wallet, businessData, emptyState, pointCardSnapshotMergeContext, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, _this$store$order$mer2, _this$store$order20, _wallet$getUserIdenti, committed;
5510
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
5511
- while (1) switch (_context50.prev = _context50.next) {
5731
+ var refreshSequence, wallet, businessData, emptyState, pointCardSnapshotMergeContext, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, _this$store$order$mer2, _this$store$order23, _wallet$getUserIdenti, committed;
5732
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5733
+ while (1) switch (_context52.prev = _context52.next) {
5512
5734
  case 0:
5513
5735
  if (this.store.order) {
5514
- _context50.next = 2;
5736
+ _context52.next = 2;
5515
5737
  break;
5516
5738
  }
5517
5739
  throw new Error('order 模块未初始化');
5518
5740
  case 2:
5519
5741
  if (this.store.payment) {
5520
- _context50.next = 4;
5742
+ _context52.next = 4;
5521
5743
  break;
5522
5744
  }
5523
5745
  throw new Error('payment 模块未初始化');
@@ -5526,7 +5748,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5526
5748
  wallet = this.store.payment.wallet;
5527
5749
  businessData = this.buildWalletInitBusinessData(params);
5528
5750
  if (businessData) {
5529
- _context50.next = 12;
5751
+ _context52.next = 12;
5530
5752
  break;
5531
5753
  }
5532
5754
  wallet.clearAllCache();
@@ -5534,7 +5756,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5534
5756
  this.updateVoucherOrderPayments([], {
5535
5757
  status: 'payment_pending'
5536
5758
  });
5537
- return _context50.abrupt("return", this.publishWalletAssetsState(emptyState));
5759
+ return _context52.abrupt("return", this.publishWalletAssetsState(emptyState));
5538
5760
  case 12:
5539
5761
  pointCardSnapshotMergeContext = {
5540
5762
  customerId: businessData.customer_id,
@@ -5544,49 +5766,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5544
5766
  hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
5545
5767
  customerChanged = hasPreviousWalletContext && String((_previousState$custom = previousState.customerId) !== null && _previousState$custom !== void 0 ? _previousState$custom : '') !== String((_businessData$custome = businessData.customer_id) !== null && _businessData$custome !== void 0 ? _businessData$custome : '');
5546
5768
  if (!customerChanged) {
5547
- _context50.next = 21;
5769
+ _context52.next = 21;
5548
5770
  break;
5549
5771
  }
5550
5772
  clearedState = wallet.clearWalletAssetSelection();
5551
5773
  this.updateVoucherOrderPayments([], {
5552
5774
  status: 'payment_pending'
5553
5775
  });
5554
- _context50.next = 21;
5776
+ _context52.next = 21;
5555
5777
  return this.publishWalletAssetsState(clearedState);
5556
5778
  case 21:
5557
5779
  refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
5558
5780
  preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged,
5559
5781
  retainSearchResultCodes: params === null || params === void 0 ? void 0 : params.retainSearchResultCodes
5560
5782
  });
5561
- _context50.next = 24;
5783
+ _context52.next = 24;
5562
5784
  return this.publishWalletAssetsState(wallet.getWalletAssetsState());
5563
5785
  case 24:
5564
- _context50.next = 26;
5786
+ _context52.next = 26;
5565
5787
  return refreshTask;
5566
5788
  case 26:
5567
- state = _context50.sent;
5789
+ state = _context52.sent;
5568
5790
  if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
5569
- _context50.next = 29;
5791
+ _context52.next = 29;
5570
5792
  break;
5571
5793
  }
5572
- return _context50.abrupt("return", wallet.getWalletAssetsState());
5794
+ return _context52.abrupt("return", wallet.getWalletAssetsState());
5573
5795
  case 29:
5574
5796
  if (state.status !== 'error') {
5575
5797
  committed = this.getCommittedWalletAssets();
5576
5798
  state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
5577
- (_this$store$order$mer2 = (_this$store$order20 = this.store.order).mergePointCardSnapshotCodes) === null || _this$store$order$mer2 === void 0 || _this$store$order$mer2.call(_this$store$order20, ((_wallet$getUserIdenti = wallet.getUserIdentificationCodes) === null || _wallet$getUserIdenti === void 0 ? void 0 : _wallet$getUserIdenti.call(wallet)) || [], pointCardSnapshotMergeContext);
5799
+ (_this$store$order$mer2 = (_this$store$order23 = this.store.order).mergePointCardSnapshotCodes) === null || _this$store$order$mer2 === void 0 || _this$store$order$mer2.call(_this$store$order23, ((_wallet$getUserIdenti = wallet.getUserIdentificationCodes) === null || _wallet$getUserIdenti === void 0 ? void 0 : _wallet$getUserIdenti.call(wallet)) || [], pointCardSnapshotMergeContext);
5578
5800
  }
5579
- _context50.next = 32;
5801
+ _context52.next = 32;
5580
5802
  return this.syncSelectedWalletAssets(state);
5581
5803
  case 32:
5582
- return _context50.abrupt("return", this.publishWalletAssetsState(state));
5804
+ return _context52.abrupt("return", this.publishWalletAssetsState(state));
5583
5805
  case 33:
5584
5806
  case "end":
5585
- return _context50.stop();
5807
+ return _context52.stop();
5586
5808
  }
5587
- }, _callee50, this);
5809
+ }, _callee52, this);
5588
5810
  }));
5589
- function refreshWalletAssets(_x42) {
5811
+ function refreshWalletAssets(_x43) {
5590
5812
  return _refreshWalletAssets.apply(this, arguments);
5591
5813
  }
5592
5814
  return refreshWalletAssets;
@@ -5594,13 +5816,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5594
5816
  }, {
5595
5817
  key: "selectWalletAsset",
5596
5818
  value: (function () {
5597
- var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
5819
+ var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
5598
5820
  var state;
5599
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5600
- while (1) switch (_context51.prev = _context51.next) {
5821
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5822
+ while (1) switch (_context53.prev = _context53.next) {
5601
5823
  case 0:
5602
5824
  if (this.store.payment) {
5603
- _context51.next = 2;
5825
+ _context53.next = 2;
5604
5826
  break;
5605
5827
  }
5606
5828
  throw new Error('payment 模块未初始化');
@@ -5609,17 +5831,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5609
5831
  selected: params.selected,
5610
5832
  source: params.source
5611
5833
  });
5612
- _context51.next = 5;
5834
+ _context53.next = 5;
5613
5835
  return this.syncSelectedWalletAssets(state);
5614
5836
  case 5:
5615
- return _context51.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5837
+ return _context53.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5616
5838
  case 6:
5617
5839
  case "end":
5618
- return _context51.stop();
5840
+ return _context53.stop();
5619
5841
  }
5620
- }, _callee51, this);
5842
+ }, _callee53, this);
5621
5843
  }));
5622
- function selectWalletAsset(_x43) {
5844
+ function selectWalletAsset(_x44) {
5623
5845
  return _selectWalletAsset.apply(this, arguments);
5624
5846
  }
5625
5847
  return selectWalletAsset;
@@ -5627,29 +5849,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5627
5849
  }, {
5628
5850
  key: "updateWalletAssetAmount",
5629
5851
  value: (function () {
5630
- var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
5852
+ var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
5631
5853
  var state;
5632
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5633
- while (1) switch (_context52.prev = _context52.next) {
5854
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5855
+ while (1) switch (_context54.prev = _context54.next) {
5634
5856
  case 0:
5635
5857
  if (this.store.payment) {
5636
- _context52.next = 2;
5858
+ _context54.next = 2;
5637
5859
  break;
5638
5860
  }
5639
5861
  throw new Error('payment 模块未初始化');
5640
5862
  case 2:
5641
5863
  state = this.store.payment.wallet.updateWalletAssetAmount(params.assetId, params.amount);
5642
- _context52.next = 5;
5864
+ _context54.next = 5;
5643
5865
  return this.syncSelectedWalletAssets(state);
5644
5866
  case 5:
5645
- return _context52.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5867
+ return _context54.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5646
5868
  case 6:
5647
5869
  case "end":
5648
- return _context52.stop();
5870
+ return _context54.stop();
5649
5871
  }
5650
- }, _callee52, this);
5872
+ }, _callee54, this);
5651
5873
  }));
5652
- function updateWalletAssetAmount(_x44) {
5874
+ function updateWalletAssetAmount(_x45) {
5653
5875
  return _updateWalletAssetAmount.apply(this, arguments);
5654
5876
  }
5655
5877
  return updateWalletAssetAmount;
@@ -5657,13 +5879,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5657
5879
  }, {
5658
5880
  key: "scanWalletAsset",
5659
5881
  value: (function () {
5660
- var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(code) {
5882
+ var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(code) {
5661
5883
  var wallet, businessData, result;
5662
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5663
- while (1) switch (_context53.prev = _context53.next) {
5884
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5885
+ while (1) switch (_context55.prev = _context55.next) {
5664
5886
  case 0:
5665
5887
  if (this.store.payment) {
5666
- _context53.next = 2;
5888
+ _context55.next = 2;
5667
5889
  break;
5668
5890
  }
5669
5891
  throw new Error('payment 模块未初始化');
@@ -5673,28 +5895,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5673
5895
  if (businessData) {
5674
5896
  wallet.generateWalletParams(businessData);
5675
5897
  }
5676
- _context53.next = 7;
5898
+ _context55.next = 7;
5677
5899
  return wallet.scanWalletAssetAsync(code);
5678
5900
  case 7:
5679
- result = _context53.sent;
5901
+ result = _context55.sent;
5680
5902
  if (!(result.type === 'normalCode')) {
5681
- _context53.next = 13;
5903
+ _context55.next = 13;
5682
5904
  break;
5683
5905
  }
5684
- _context53.next = 11;
5906
+ _context55.next = 11;
5685
5907
  return this.syncSelectedWalletAssets(result.state);
5686
5908
  case 11:
5687
- _context53.next = 13;
5909
+ _context55.next = 13;
5688
5910
  return this.publishWalletAssetsState(result.state, 'local');
5689
5911
  case 13:
5690
- return _context53.abrupt("return", result);
5912
+ return _context55.abrupt("return", result);
5691
5913
  case 14:
5692
5914
  case "end":
5693
- return _context53.stop();
5915
+ return _context55.stop();
5694
5916
  }
5695
- }, _callee53, this);
5917
+ }, _callee55, this);
5696
5918
  }));
5697
- function scanWalletAsset(_x45) {
5919
+ function scanWalletAsset(_x46) {
5698
5920
  return _scanWalletAsset.apply(this, arguments);
5699
5921
  }
5700
5922
  return scanWalletAsset;
@@ -5702,27 +5924,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5702
5924
  }, {
5703
5925
  key: "clearWalletAssetSelection",
5704
5926
  value: (function () {
5705
- var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
5927
+ var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56() {
5706
5928
  var state;
5707
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5708
- while (1) switch (_context54.prev = _context54.next) {
5929
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5930
+ while (1) switch (_context56.prev = _context56.next) {
5709
5931
  case 0:
5710
5932
  if (this.store.payment) {
5711
- _context54.next = 2;
5933
+ _context56.next = 2;
5712
5934
  break;
5713
5935
  }
5714
5936
  throw new Error('payment 模块未初始化');
5715
5937
  case 2:
5716
5938
  state = this.store.payment.wallet.clearWalletAssetSelection();
5717
- _context54.next = 5;
5939
+ _context56.next = 5;
5718
5940
  return this.syncSelectedWalletAssets(state);
5719
5941
  case 5:
5720
- return _context54.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5942
+ return _context56.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5721
5943
  case 6:
5722
5944
  case "end":
5723
- return _context54.stop();
5945
+ return _context56.stop();
5724
5946
  }
5725
- }, _callee54, this);
5947
+ }, _callee56, this);
5726
5948
  }));
5727
5949
  function clearWalletAssetSelection() {
5728
5950
  return _clearWalletAssetSelection.apply(this, arguments);
@@ -5739,11 +5961,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5739
5961
  }, {
5740
5962
  key: "updateOrderCustomer",
5741
5963
  value: function updateOrderCustomer(customer) {
5742
- var _this$store$order$get7, _this$store$order21, _this$store$order$get8, _this$store$order22;
5964
+ var _this$store$order$get7, _this$store$order24, _this$store$order$get8, _this$store$order25;
5743
5965
  if (!this.store.order) throw new Error('order 模块未初始化');
5744
- var previousCustomerId = this.resolveDiscountConfigCustomerId((_this$store$order$get7 = (_this$store$order21 = this.store.order).getTempOrder) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.call(_this$store$order21));
5966
+ var previousCustomerId = this.resolveDiscountConfigCustomerId((_this$store$order$get7 = (_this$store$order24 = this.store.order).getTempOrder) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.call(_this$store$order24));
5745
5967
  var result = this.store.order.updateTempOrderCustomer(customer);
5746
- var nextCustomerId = this.resolveDiscountConfigCustomerId((_this$store$order$get8 = (_this$store$order22 = this.store.order).getTempOrder) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.call(_this$store$order22));
5968
+ var nextCustomerId = this.resolveDiscountConfigCustomerId((_this$store$order$get8 = (_this$store$order25 = this.store.order).getTempOrder) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.call(_this$store$order25));
5747
5969
  if (String(previousCustomerId) !== String(nextCustomerId)) {
5748
5970
  this.discountConfigCacheKey = null;
5749
5971
  this.hasManualDiscountSelection = false;
@@ -5759,35 +5981,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5759
5981
  }, {
5760
5982
  key: "getPaymentMethodsAsync",
5761
5983
  value: (function () {
5762
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
5984
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57() {
5763
5985
  var response, paymentMethods;
5764
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5765
- while (1) switch (_context55.prev = _context55.next) {
5986
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5987
+ while (1) switch (_context57.prev = _context57.next) {
5766
5988
  case 0:
5767
- _context55.prev = 0;
5768
- _context55.next = 3;
5989
+ _context57.prev = 0;
5990
+ _context57.next = 3;
5769
5991
  return this.request.get('/pay/custom-payment/all', {
5770
5992
  filterPaymentMethods: true
5771
5993
  }, {
5772
5994
  osServer: true
5773
5995
  });
5774
5996
  case 3:
5775
- response = _context55.sent;
5997
+ response = _context57.sent;
5776
5998
  paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
5777
5999
  this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
5778
- return _context55.abrupt("return", this.getPaymentMethods());
6000
+ return _context57.abrupt("return", this.getPaymentMethods());
5779
6001
  case 9:
5780
- _context55.prev = 9;
5781
- _context55.t0 = _context55["catch"](0);
6002
+ _context57.prev = 9;
6003
+ _context57.t0 = _context57["catch"](0);
5782
6004
  this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
5783
- error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
6005
+ error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0)
5784
6006
  });
5785
- return _context55.abrupt("return", this.getPaymentMethods());
6007
+ return _context57.abrupt("return", this.getPaymentMethods());
5786
6008
  case 13:
5787
6009
  case "end":
5788
- return _context55.stop();
6010
+ return _context57.stop();
5789
6011
  }
5790
- }, _callee55, this, [[0, 9]]);
6012
+ }, _callee57, this, [[0, 9]]);
5791
6013
  }));
5792
6014
  function getPaymentMethodsAsync() {
5793
6015
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -5818,15 +6040,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5818
6040
  }, {
5819
6041
  key: "getPendingWalletPaymentAmount",
5820
6042
  value: function getPendingWalletPaymentAmount() {
5821
- var _this$store$order23, _this$store$order23$g;
5822
- var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_this$store$order23 = this.store.order) === null || _this$store$order23 === void 0 || (_this$store$order23$g = _this$store$order23.getOrderPayments) === null || _this$store$order23$g === void 0 ? void 0 : _this$store$order23$g.call(_this$store$order23)) || [];
6043
+ var _this$store$order26, _this$store$order26$g;
6044
+ var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_this$store$order26 = this.store.order) === null || _this$store$order26 === void 0 || (_this$store$order26$g = _this$store$order26.getOrderPayments) === null || _this$store$order26$g === void 0 ? void 0 : _this$store$order26$g.call(_this$store$order26)) || [];
5823
6045
  return payments.reduce(function (total, payment) {
5824
6046
  if ((payment === null || payment === void 0 ? void 0 : payment.status) !== 'payment_pending' || (payment === null || payment === void 0 ? void 0 : payment.voucher_id) === undefined || Number(payment.voucher_id) === 0) {
5825
6047
  return total;
5826
6048
  }
5827
6049
  try {
5828
6050
  return total.plus(payment.amount || 0).plus(payment.rounding_amount || 0);
5829
- } catch (_unused6) {
6051
+ } catch (_unused8) {
5830
6052
  return total;
5831
6053
  }
5832
6054
  }, new Decimal(0));
@@ -5836,8 +6058,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5836
6058
  }, {
5837
6059
  key: "getCashPaymentConfig",
5838
6060
  value: (function () {
5839
- var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56() {
5840
- var _this$store$order24, _this$store$order24$g, _this$store$order25, _this$store$order25$g, _this$otherParams40;
6061
+ var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58() {
6062
+ var _this$store$order27, _this$store$order27$g, _this$store$order28, _this$store$order28$g, _this$otherParams40;
5841
6063
  var options,
5842
6064
  paymentMethods,
5843
6065
  paymentMethod,
@@ -5846,13 +6068,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5846
6068
  amountDue,
5847
6069
  currency,
5848
6070
  recommendedAmounts,
5849
- _args56 = arguments;
5850
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5851
- while (1) switch (_context56.prev = _context56.next) {
6071
+ _args58 = arguments;
6072
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
6073
+ while (1) switch (_context58.prev = _context58.next) {
5852
6074
  case 0:
5853
- options = _args56.length > 0 && _args56[0] !== undefined ? _args56[0] : {};
6075
+ options = _args58.length > 0 && _args58[0] !== undefined ? _args58[0] : {};
5854
6076
  if (this.store.payment) {
5855
- _context56.next = 3;
6077
+ _context58.next = 3;
5856
6078
  break;
5857
6079
  }
5858
6080
  throw new Error('payment 模块未初始化');
@@ -5860,27 +6082,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5860
6082
  paymentMethods = this.getPaymentMethods();
5861
6083
  paymentMethod = this.findCashPaymentMethod(paymentMethods, options.paymentMethodId);
5862
6084
  if (paymentMethod) {
5863
- _context56.next = 10;
6085
+ _context58.next = 10;
5864
6086
  break;
5865
6087
  }
5866
- _context56.next = 8;
6088
+ _context58.next = 8;
5867
6089
  return this.getPaymentMethodsAsync();
5868
6090
  case 8:
5869
- paymentMethods = _context56.sent;
6091
+ paymentMethods = _context58.sent;
5870
6092
  paymentMethod = this.findCashPaymentMethod(paymentMethods, options.paymentMethodId);
5871
6093
  case 10:
5872
6094
  if (!(!paymentMethod && options.paymentMethodId !== undefined)) {
5873
- _context56.next = 12;
6095
+ _context58.next = 12;
5874
6096
  break;
5875
6097
  }
5876
6098
  throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u73B0\u91D1\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(options.paymentMethodId));
5877
6099
  case 12:
5878
- amountSnapshot = (_this$store$order24 = this.store.order) === null || _this$store$order24 === void 0 || (_this$store$order24$g = _this$store$order24.getOrderAmountSnapshot) === null || _this$store$order24$g === void 0 ? void 0 : _this$store$order24$g.call(_this$store$order24);
6100
+ amountSnapshot = (_this$store$order27 = this.store.order) === null || _this$store$order27 === void 0 || (_this$store$order27$g = _this$store$order27.getOrderAmountSnapshot) === null || _this$store$order27$g === void 0 ? void 0 : _this$store$order27$g.call(_this$store$order27);
5879
6101
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
5880
6102
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
5881
- currency = ((_this$store$order25 = this.store.order) === null || _this$store$order25 === void 0 || (_this$store$order25$g = _this$store$order25.getTempOrder) === null || _this$store$order25$g === void 0 || (_this$store$order25$g = _this$store$order25$g.call(_this$store$order25)) === null || _this$store$order25$g === void 0 ? void 0 : _this$store$order25$g.currency_code) || ((_this$otherParams40 = this.otherParams) === null || _this$otherParams40 === void 0 ? void 0 : _this$otherParams40.currency) || 'USD';
6103
+ currency = ((_this$store$order28 = this.store.order) === null || _this$store$order28 === void 0 || (_this$store$order28$g = _this$store$order28.getTempOrder) === null || _this$store$order28$g === void 0 || (_this$store$order28$g = _this$store$order28$g.call(_this$store$order28)) === null || _this$store$order28$g === void 0 ? void 0 : _this$store$order28$g.currency_code) || ((_this$otherParams40 = this.otherParams) === null || _this$otherParams40 === void 0 ? void 0 : _this$otherParams40.currency) || 'USD';
5882
6104
  recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
5883
- return _context56.abrupt("return", {
6105
+ return _context58.abrupt("return", {
5884
6106
  available: Boolean(paymentMethod && amountDue > 0),
5885
6107
  paymentMethod: paymentMethod,
5886
6108
  amountDue: amountDue,
@@ -5888,9 +6110,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5888
6110
  });
5889
6111
  case 18:
5890
6112
  case "end":
5891
- return _context56.stop();
6113
+ return _context58.stop();
5892
6114
  }
5893
- }, _callee56, this);
6115
+ }, _callee58, this);
5894
6116
  }));
5895
6117
  function getCashPaymentConfig() {
5896
6118
  return _getCashPaymentConfig.apply(this, arguments);
@@ -5907,42 +6129,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5907
6129
  }, {
5908
6130
  key: "confirmWalletPayment",
5909
6131
  value: (function () {
5910
- var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57() {
5911
- var _this$store$order$get9, _this$store$order26, _this$store$order$get11, _this$store$order$get12, _this$store$order28;
5912
- var beforePayments, pendingWalletAmount, amountSnapshot, _this$store$order$get10, _this$store$order27, _submitResult, _latestAmountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
5913
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5914
- while (1) switch (_context57.prev = _context57.next) {
6132
+ var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59() {
6133
+ var _this$store$order$get9, _this$store$order29, _this$store$order$get11, _this$store$order$get12, _this$store$order31;
6134
+ var beforePayments, pendingWalletAmount, amountSnapshot, _this$store$order$get10, _this$store$order30, _submitResult, _latestAmountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
6135
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
6136
+ while (1) switch (_context59.prev = _context59.next) {
5915
6137
  case 0:
5916
6138
  if (this.store.order) {
5917
- _context57.next = 2;
6139
+ _context59.next = 2;
5918
6140
  break;
5919
6141
  }
5920
6142
  throw new Error('order 模块未初始化');
5921
6143
  case 2:
5922
6144
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
5923
6145
  pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
5924
- amountSnapshot = (_this$store$order$get9 = (_this$store$order26 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get9 === void 0 ? void 0 : _this$store$order$get9.call(_this$store$order26);
6146
+ amountSnapshot = (_this$store$order$get9 = (_this$store$order29 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get9 === void 0 ? void 0 : _this$store$order$get9.call(_this$store$order29);
5925
6147
  if (!pendingWalletAmount.lte(0)) {
5926
- _context57.next = 14;
6148
+ _context59.next = 14;
5927
6149
  break;
5928
6150
  }
5929
6151
  this.logWarning('confirmWalletPayment: 未发现待确认 Wallet 支付,跳过 Wallet 确认并按普通订单提交', {
5930
6152
  amountGap: amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap
5931
6153
  });
5932
- _context57.next = 9;
6154
+ _context59.next = 9;
5933
6155
  return this.submitSalesOrder({
5934
6156
  smallTicketDataFlag: 1
5935
6157
  });
5936
6158
  case 9:
5937
- _submitResult = _context57.sent;
6159
+ _submitResult = _context59.sent;
5938
6160
  if (!isRejectedSalesSubmitResult(_submitResult)) {
5939
- _context57.next = 12;
6161
+ _context59.next = 12;
5940
6162
  break;
5941
6163
  }
5942
6164
  throw new Error(getSalesSubmitErrorMessage(_submitResult, '订单提交失败'));
5943
6165
  case 12:
5944
- _latestAmountSnapshot = (_this$store$order$get10 = (_this$store$order27 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get10 === void 0 ? void 0 : _this$store$order$get10.call(_this$store$order27);
5945
- return _context57.abrupt("return", {
6166
+ _latestAmountSnapshot = (_this$store$order$get10 = (_this$store$order30 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get10 === void 0 ? void 0 : _this$store$order$get10.call(_this$store$order30);
6167
+ return _context59.abrupt("return", {
5946
6168
  submitResult: _submitResult,
5947
6169
  payments: this.store.order.getOrderPayments(),
5948
6170
  isOrderFullyPaid: new Decimal((_latestAmountSnapshot === null || _latestAmountSnapshot === void 0 ? void 0 : _latestAmountSnapshot.amountGap) || 0).lte(0)
@@ -5950,74 +6172,74 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5950
6172
  case 14:
5951
6173
  effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
5952
6174
  if (!effectiveAmountDue.gt(0.01)) {
5953
- _context57.next = 17;
6175
+ _context59.next = 17;
5954
6176
  break;
5955
6177
  }
5956
6178
  throw new Error('Wallet 支付尚未覆盖全部待支付金额');
5957
6179
  case 17:
5958
6180
  beforePaymentStatus = (_this$store$order$get11 = this.store.order.getTempOrder()) === null || _this$store$order$get11 === void 0 ? void 0 : _this$store$order$get11.payment_status;
5959
- _context57.prev = 18;
5960
- _context57.next = 21;
6181
+ _context59.prev = 18;
6182
+ _context59.next = 21;
5961
6183
  return this.submitSalesOrder({
5962
6184
  smallTicketDataFlag: 1,
5963
6185
  confirmPendingVoucherPayments: true
5964
6186
  });
5965
6187
  case 21:
5966
- submitResult = _context57.sent;
6188
+ submitResult = _context59.sent;
5967
6189
  if (!isRejectedSalesSubmitResult(submitResult)) {
5968
- _context57.next = 24;
6190
+ _context59.next = 24;
5969
6191
  break;
5970
6192
  }
5971
6193
  throw new Error(getSalesSubmitErrorMessage(submitResult, 'Wallet 支付确认失败'));
5972
6194
  case 24:
5973
- _context57.next = 34;
6195
+ _context59.next = 34;
5974
6196
  break;
5975
6197
  case 26:
5976
- _context57.prev = 26;
5977
- _context57.t0 = _context57["catch"](18);
6198
+ _context59.prev = 26;
6199
+ _context59.t0 = _context59["catch"](18);
5978
6200
  this.store.order.setOrderPayments(beforePayments);
5979
6201
  restoredTempOrder = this.store.order.getTempOrder();
5980
6202
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
5981
6203
  restoredTempOrder.payment_status = beforePaymentStatus;
5982
6204
  this.store.order.persistTempOrder();
5983
6205
  }
5984
- _context57.next = 33;
6206
+ _context59.next = 33;
5985
6207
  return this.store.order.recalculateSummary({
5986
6208
  createIfMissing: true
5987
6209
  });
5988
6210
  case 33:
5989
- throw _context57.t0;
6211
+ throw _context59.t0;
5990
6212
  case 34:
5991
6213
  if (!this.store.payment) {
5992
- _context57.next = 45;
6214
+ _context59.next = 45;
5993
6215
  break;
5994
6216
  }
5995
- _context57.prev = 35;
6217
+ _context59.prev = 35;
5996
6218
  committed = this.getCommittedWalletAssets();
5997
6219
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
5998
- _context57.next = 40;
6220
+ _context59.next = 40;
5999
6221
  return this.publishWalletAssetsState(walletState, 'local');
6000
6222
  case 40:
6001
- _context57.next = 45;
6223
+ _context59.next = 45;
6002
6224
  break;
6003
6225
  case 42:
6004
- _context57.prev = 42;
6005
- _context57.t1 = _context57["catch"](35);
6226
+ _context59.prev = 42;
6227
+ _context59.t1 = _context59["catch"](35);
6006
6228
  this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
6007
- error: _context57.t1 instanceof Error ? _context57.t1.message : String(_context57.t1)
6229
+ error: _context59.t1 instanceof Error ? _context59.t1.message : String(_context59.t1)
6008
6230
  });
6009
6231
  case 45:
6010
- latestAmountSnapshot = (_this$store$order$get12 = (_this$store$order28 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get12 === void 0 ? void 0 : _this$store$order$get12.call(_this$store$order28);
6011
- return _context57.abrupt("return", {
6232
+ latestAmountSnapshot = (_this$store$order$get12 = (_this$store$order31 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get12 === void 0 ? void 0 : _this$store$order$get12.call(_this$store$order31);
6233
+ return _context59.abrupt("return", {
6012
6234
  submitResult: submitResult,
6013
6235
  payments: this.store.order.getOrderPayments(),
6014
6236
  isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
6015
6237
  });
6016
6238
  case 47:
6017
6239
  case "end":
6018
- return _context57.stop();
6240
+ return _context59.stop();
6019
6241
  }
6020
- }, _callee57, this, [[18, 26], [35, 42]]);
6242
+ }, _callee59, this, [[18, 26], [35, 42]]);
6021
6243
  }));
6022
6244
  function confirmWalletPayment() {
6023
6245
  return _confirmWalletPayment.apply(this, arguments);
@@ -6032,53 +6254,53 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6032
6254
  }, {
6033
6255
  key: "payCash",
6034
6256
  value: (function () {
6035
- var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
6257
+ var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
6036
6258
  var _this$store$order$get13, _params$actualPaidAmo, _this$otherParams41, _this$window, _this$window$postMess;
6037
6259
  var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
6038
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
6039
- while (1) switch (_context58.prev = _context58.next) {
6260
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
6261
+ while (1) switch (_context60.prev = _context60.next) {
6040
6262
  case 0:
6041
6263
  if (this.store.order) {
6042
- _context58.next = 2;
6264
+ _context60.next = 2;
6043
6265
  break;
6044
6266
  }
6045
6267
  throw new Error('order 模块未初始化');
6046
6268
  case 2:
6047
6269
  amount = Number(params.amount || 0);
6048
6270
  if (!(!Number.isFinite(amount) || amount <= 0)) {
6049
- _context58.next = 5;
6271
+ _context60.next = 5;
6050
6272
  break;
6051
6273
  }
6052
6274
  throw new Error('现金支付金额必须大于 0');
6053
6275
  case 5:
6054
6276
  if (!(params.paymentMethodId === undefined)) {
6055
- _context58.next = 11;
6277
+ _context60.next = 11;
6056
6278
  break;
6057
6279
  }
6058
- _context58.next = 8;
6280
+ _context60.next = 8;
6059
6281
  return this.getCashPaymentConfig();
6060
6282
  case 8:
6061
- _context58.t0 = _context58.sent;
6062
- _context58.next = 14;
6283
+ _context60.t0 = _context60.sent;
6284
+ _context60.next = 14;
6063
6285
  break;
6064
6286
  case 11:
6065
- _context58.next = 13;
6287
+ _context60.next = 13;
6066
6288
  return this.getCashPaymentConfig({
6067
6289
  paymentMethodId: params.paymentMethodId
6068
6290
  });
6069
6291
  case 13:
6070
- _context58.t0 = _context58.sent;
6292
+ _context60.t0 = _context60.sent;
6071
6293
  case 14:
6072
- config = _context58.t0;
6294
+ config = _context60.t0;
6073
6295
  paymentMethod = config.paymentMethod;
6074
6296
  if (paymentMethod) {
6075
- _context58.next = 18;
6297
+ _context60.next = 18;
6076
6298
  break;
6077
6299
  }
6078
6300
  throw new Error('未找到可用的 CASHMANUAL 支付方式');
6079
6301
  case 18:
6080
6302
  if (!(config.amountDue <= 0)) {
6081
- _context58.next = 20;
6303
+ _context60.next = 20;
6082
6304
  break;
6083
6305
  }
6084
6306
  throw new Error('当前订单没有待支付金额');
@@ -6086,7 +6308,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6086
6308
  roundingAmount = Number(params.roundingAmount || 0);
6087
6309
  effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
6088
6310
  if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
6089
- _context58.next = 24;
6311
+ _context60.next = 24;
6090
6312
  break;
6091
6313
  }
6092
6314
  throw new Error('现金支付金额超过当前待支付金额');
@@ -6099,16 +6321,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6099
6321
  changeAmount = Number(params.changeAmount || 0);
6100
6322
  shopWalletPassId = (_this$otherParams41 = this.otherParams) === null || _this$otherParams41 === void 0 ? void 0 : _this$otherParams41.shop_wallet_pass_id;
6101
6323
  if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
6102
- _context58.next = 33;
6324
+ _context60.next = 33;
6103
6325
  break;
6104
6326
  }
6105
6327
  throw new Error('顾客实收现金不能小于支付金额');
6106
6328
  case 33:
6107
6329
  if (!this.isPickupTimingEnabled()) {
6108
- _context58.next = 36;
6330
+ _context60.next = 36;
6109
6331
  break;
6110
6332
  }
6111
- _context58.next = 36;
6333
+ _context60.next = 36;
6112
6334
  return this.preparePickupTimingForCheckout({
6113
6335
  freeze: true
6114
6336
  });
@@ -6143,8 +6365,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6143
6365
  var _item$metadata2;
6144
6366
  return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
6145
6367
  });
6146
- _context58.prev = 39;
6147
- _context58.next = 42;
6368
+ _context60.prev = 39;
6369
+ _context60.next = 42;
6148
6370
  return this.syncPaymentsToOrder({
6149
6371
  payments: payments,
6150
6372
  submitWhenPaid: true,
@@ -6152,50 +6374,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6152
6374
  confirmPendingVoucherPayments: true
6153
6375
  });
6154
6376
  case 42:
6155
- syncResult = _context58.sent;
6377
+ syncResult = _context60.sent;
6156
6378
  if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
6157
- _context58.next = 45;
6379
+ _context60.next = 45;
6158
6380
  break;
6159
6381
  }
6160
6382
  throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
6161
6383
  case 45:
6162
6384
  if (!this.store.payment) {
6163
- _context58.next = 50;
6385
+ _context60.next = 50;
6164
6386
  break;
6165
6387
  }
6166
6388
  committed = this.getCommittedWalletAssets();
6167
6389
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
6168
- _context58.next = 50;
6390
+ _context60.next = 50;
6169
6391
  return this.publishWalletAssetsState(walletState, 'local');
6170
6392
  case 50:
6171
- return _context58.abrupt("return", {
6393
+ return _context60.abrupt("return", {
6172
6394
  payment: payment || {},
6173
6395
  payments: this.store.order.getOrderPayments(),
6174
6396
  syncResult: syncResult,
6175
6397
  isOrderFullyPaid: syncResult.isOrderFullyPaid
6176
6398
  });
6177
6399
  case 53:
6178
- _context58.prev = 53;
6179
- _context58.t1 = _context58["catch"](39);
6400
+ _context60.prev = 53;
6401
+ _context60.t1 = _context60["catch"](39);
6180
6402
  this.store.order.setOrderPayments(beforePayments);
6181
6403
  restoredTempOrder = this.store.order.getTempOrder();
6182
6404
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
6183
6405
  restoredTempOrder.payment_status = beforePaymentStatus;
6184
6406
  this.store.order.persistTempOrder();
6185
6407
  }
6186
- _context58.next = 60;
6408
+ _context60.next = 60;
6187
6409
  return this.store.order.recalculateSummary({
6188
6410
  createIfMissing: true
6189
6411
  });
6190
6412
  case 60:
6191
- throw _context58.t1;
6413
+ throw _context60.t1;
6192
6414
  case 61:
6193
6415
  case "end":
6194
- return _context58.stop();
6416
+ return _context60.stop();
6195
6417
  }
6196
- }, _callee58, this, [[39, 53]]);
6418
+ }, _callee60, this, [[39, 53]]);
6197
6419
  }));
6198
- function payCash(_x46) {
6420
+ function payCash(_x47) {
6199
6421
  return _payCash.apply(this, arguments);
6200
6422
  }
6201
6423
  return payCash;
@@ -6211,21 +6433,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6211
6433
  }, {
6212
6434
  key: "commitPaymentMethodPayment",
6213
6435
  value: (function () {
6214
- var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
6215
- var _this$store$order$get14, _this$store$order29, _this$store$order$get15, _params$metadata, _params$originAmount;
6436
+ var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
6437
+ var _this$store$order$get14, _this$store$order32, _this$store$order$get15, _params$metadata, _params$originAmount;
6216
6438
  var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
6217
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
6218
- while (1) switch (_context59.prev = _context59.next) {
6439
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6440
+ while (1) switch (_context61.prev = _context61.next) {
6219
6441
  case 0:
6220
6442
  if (this.store.order) {
6221
- _context59.next = 2;
6443
+ _context61.next = 2;
6222
6444
  break;
6223
6445
  }
6224
6446
  throw new Error('order 模块未初始化');
6225
6447
  case 2:
6226
6448
  amount = Number(params.amount || 0);
6227
6449
  if (!(!Number.isFinite(amount) || amount <= 0)) {
6228
- _context59.next = 5;
6450
+ _context61.next = 5;
6229
6451
  break;
6230
6452
  }
6231
6453
  throw new Error('支付金额必须大于 0');
@@ -6241,32 +6463,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6241
6463
  };
6242
6464
  paymentMethod = findPaymentMethod();
6243
6465
  if (paymentMethod) {
6244
- _context59.next = 13;
6466
+ _context61.next = 13;
6245
6467
  break;
6246
6468
  }
6247
- _context59.next = 11;
6469
+ _context61.next = 11;
6248
6470
  return this.getPaymentMethodsAsync();
6249
6471
  case 11:
6250
- paymentMethods = _context59.sent;
6472
+ paymentMethods = _context61.sent;
6251
6473
  paymentMethod = findPaymentMethod();
6252
6474
  case 13:
6253
6475
  if (paymentMethod) {
6254
- _context59.next = 15;
6476
+ _context61.next = 15;
6255
6477
  break;
6256
6478
  }
6257
6479
  throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
6258
6480
  case 15:
6259
- amountSnapshot = (_this$store$order$get14 = (_this$store$order29 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get14 === void 0 ? void 0 : _this$store$order$get14.call(_this$store$order29);
6481
+ amountSnapshot = (_this$store$order$get14 = (_this$store$order32 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get14 === void 0 ? void 0 : _this$store$order$get14.call(_this$store$order32);
6260
6482
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
6261
6483
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
6262
6484
  if (!amountDue.lte(0)) {
6263
- _context59.next = 20;
6485
+ _context61.next = 20;
6264
6486
  break;
6265
6487
  }
6266
6488
  throw new Error('当前订单没有待支付金额');
6267
6489
  case 20:
6268
6490
  if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
6269
- _context59.next = 22;
6491
+ _context61.next = 22;
6270
6492
  break;
6271
6493
  }
6272
6494
  throw new Error('支付金额超过当前待支付金额');
@@ -6305,8 +6527,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6305
6527
  var _item$metadata3;
6306
6528
  return (item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.unique_payment_number) === metadata.unique_payment_number;
6307
6529
  });
6308
- _context59.prev = 30;
6309
- _context59.next = 33;
6530
+ _context61.prev = 30;
6531
+ _context61.next = 33;
6310
6532
  return this.syncPaymentsToOrder({
6311
6533
  payments: payments,
6312
6534
  submitWhenPaid: true,
@@ -6314,50 +6536,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6314
6536
  confirmPendingVoucherPayments: true
6315
6537
  });
6316
6538
  case 33:
6317
- syncResult = _context59.sent;
6539
+ syncResult = _context61.sent;
6318
6540
  if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
6319
- _context59.next = 36;
6541
+ _context61.next = 36;
6320
6542
  break;
6321
6543
  }
6322
6544
  throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
6323
6545
  case 36:
6324
6546
  if (!this.store.payment) {
6325
- _context59.next = 41;
6547
+ _context61.next = 41;
6326
6548
  break;
6327
6549
  }
6328
6550
  committed = this.getCommittedWalletAssets();
6329
6551
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
6330
- _context59.next = 41;
6552
+ _context61.next = 41;
6331
6553
  return this.publishWalletAssetsState(walletState, 'local');
6332
6554
  case 41:
6333
- return _context59.abrupt("return", {
6555
+ return _context61.abrupt("return", {
6334
6556
  payment: payment || {},
6335
6557
  payments: this.store.order.getOrderPayments(),
6336
6558
  syncResult: syncResult,
6337
6559
  isOrderFullyPaid: syncResult.isOrderFullyPaid
6338
6560
  });
6339
6561
  case 44:
6340
- _context59.prev = 44;
6341
- _context59.t0 = _context59["catch"](30);
6562
+ _context61.prev = 44;
6563
+ _context61.t0 = _context61["catch"](30);
6342
6564
  this.store.order.setOrderPayments(beforePayments);
6343
6565
  restoredTempOrder = this.store.order.getTempOrder();
6344
6566
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
6345
6567
  restoredTempOrder.payment_status = beforePaymentStatus;
6346
6568
  this.store.order.persistTempOrder();
6347
6569
  }
6348
- _context59.next = 51;
6570
+ _context61.next = 51;
6349
6571
  return this.store.order.recalculateSummary({
6350
6572
  createIfMissing: true
6351
6573
  });
6352
6574
  case 51:
6353
- throw _context59.t0;
6575
+ throw _context61.t0;
6354
6576
  case 52:
6355
6577
  case "end":
6356
- return _context59.stop();
6578
+ return _context61.stop();
6357
6579
  }
6358
- }, _callee59, this, [[30, 44]]);
6580
+ }, _callee61, this, [[30, 44]]);
6359
6581
  }));
6360
- function commitPaymentMethodPayment(_x47) {
6582
+ function commitPaymentMethodPayment(_x48) {
6361
6583
  return _commitPaymentMethodPayment.apply(this, arguments);
6362
6584
  }
6363
6585
  return commitPaymentMethodPayment;
@@ -6372,40 +6594,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6372
6594
  }, {
6373
6595
  key: "roundAmount",
6374
6596
  value: (function () {
6375
- var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
6597
+ var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
6376
6598
  var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
6377
6599
  var amount, cashManualPayment;
6378
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
6379
- while (1) switch (_context60.prev = _context60.next) {
6600
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6601
+ while (1) switch (_context62.prev = _context62.next) {
6380
6602
  case 0:
6381
6603
  amount = params.amount;
6382
6604
  cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
6383
6605
  return paymentMethod.code === 'CASHMANUAL';
6384
6606
  });
6385
6607
  if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
6386
- _context60.next = 4;
6608
+ _context62.next = 4;
6387
6609
  break;
6388
6610
  }
6389
- return _context60.abrupt("return", {
6611
+ return _context62.abrupt("return", {
6390
6612
  originalAmount: amount.toString(),
6391
6613
  roundedAmount: amount.toString(),
6392
6614
  roundingDifference: '0.00'
6393
6615
  });
6394
6616
  case 4:
6395
6617
  if (this.payment) {
6396
- _context60.next = 6;
6618
+ _context62.next = 6;
6397
6619
  break;
6398
6620
  }
6399
6621
  throw new Error('payment 模块未初始化');
6400
6622
  case 6:
6401
- return _context60.abrupt("return", this.payment.roundAmountAsync(amount, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.interval, (_this$otherParams$ord3 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord3 === void 0 ? void 0 : _this$otherParams$ord3.type));
6623
+ return _context62.abrupt("return", this.payment.roundAmountAsync(amount, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.interval, (_this$otherParams$ord3 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord3 === void 0 ? void 0 : _this$otherParams$ord3.type));
6402
6624
  case 7:
6403
6625
  case "end":
6404
- return _context60.stop();
6626
+ return _context62.stop();
6405
6627
  }
6406
- }, _callee60, this);
6628
+ }, _callee62, this);
6407
6629
  }));
6408
- function roundAmount(_x48) {
6630
+ function roundAmount(_x49) {
6409
6631
  return _roundAmount.apply(this, arguments);
6410
6632
  }
6411
6633
  return roundAmount;
@@ -6420,49 +6642,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6420
6642
  }, {
6421
6643
  key: "sendCustomerPayLink",
6422
6644
  value: (function () {
6423
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
6645
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
6424
6646
  var orderIds, _ref53, _ref54, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
6425
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6426
- while (1) switch (_context61.prev = _context61.next) {
6647
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6648
+ while (1) switch (_context63.prev = _context63.next) {
6427
6649
  case 0:
6428
6650
  if (this.store.order) {
6429
- _context61.next = 2;
6651
+ _context63.next = 2;
6430
6652
  break;
6431
6653
  }
6432
6654
  throw new Error('order 模块未初始化');
6433
6655
  case 2:
6434
6656
  orderIds = params.order_ids || params.orderIds || [];
6435
6657
  if (!(!orderIds.length || params.submitBeforeSend)) {
6436
- _context61.next = 11;
6658
+ _context63.next = 11;
6437
6659
  break;
6438
6660
  }
6439
- _context61.next = 6;
6661
+ _context63.next = 6;
6440
6662
  return this.submitSalesOrder({
6441
6663
  smallTicketDataFlag: 1
6442
6664
  });
6443
6665
  case 6:
6444
- submitResult = _context61.sent;
6666
+ submitResult = _context63.sent;
6445
6667
  orderId = (_ref53 = (_ref54 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref54 !== void 0 ? _ref54 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref53 !== void 0 ? _ref53 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
6446
6668
  if (orderId) {
6447
- _context61.next = 10;
6669
+ _context63.next = 10;
6448
6670
  break;
6449
6671
  }
6450
6672
  throw new Error('本地订单提交云端失败,无法发送支付链接');
6451
6673
  case 10:
6452
6674
  orderIds = [orderId];
6453
6675
  case 11:
6454
- return _context61.abrupt("return", this.store.order.sendCustomerPayLink({
6676
+ return _context63.abrupt("return", this.store.order.sendCustomerPayLink({
6455
6677
  emails: params.emails,
6456
6678
  notify_action: params.notify_action,
6457
6679
  order_ids: orderIds
6458
6680
  }));
6459
6681
  case 12:
6460
6682
  case "end":
6461
- return _context61.stop();
6683
+ return _context63.stop();
6462
6684
  }
6463
- }, _callee61, this);
6685
+ }, _callee63, this);
6464
6686
  }));
6465
- function sendCustomerPayLink(_x49) {
6687
+ function sendCustomerPayLink(_x50) {
6466
6688
  return _sendCustomerPayLink.apply(this, arguments);
6467
6689
  }
6468
6690
  return sendCustomerPayLink;
@@ -6475,20 +6697,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6475
6697
  }, {
6476
6698
  key: "calculateProductBookingPrice",
6477
6699
  value: function () {
6478
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
6700
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
6479
6701
  var _params$customer_id;
6480
6702
  var useCustomerUserPricing, quotation, customerId, channel, _yield$this$resolvePr, _yield$this$resolvePr2, authoritativeProduct, product;
6481
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6482
- while (1) switch (_context62.prev = _context62.next) {
6703
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6704
+ while (1) switch (_context64.prev = _context64.next) {
6483
6705
  case 0:
6484
6706
  useCustomerUserPricing = this.isCustomerUserPriceQuery();
6485
6707
  quotation = useCustomerUserPricing ? undefined : this.store.quotation;
6486
6708
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
6487
- _context62.next = 5;
6709
+ _context64.next = 5;
6488
6710
  return this.prepareProductPriceQueryContext(customerId);
6489
6711
  case 5:
6490
6712
  channel = this.getPriceQueryChannel(params.channel);
6491
- _context62.next = 8;
6713
+ _context64.next = 8;
6492
6714
  return this.resolveProductsForPriceQuery({
6493
6715
  priceQueries: [params],
6494
6716
  schedule: this.getPriceQuerySchedule(params),
@@ -6496,22 +6718,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6496
6718
  channel: channel
6497
6719
  });
6498
6720
  case 8:
6499
- _yield$this$resolvePr = _context62.sent;
6721
+ _yield$this$resolvePr = _context64.sent;
6500
6722
  _yield$this$resolvePr2 = _slicedToArray(_yield$this$resolvePr, 1);
6501
6723
  authoritativeProduct = _yield$this$resolvePr2[0];
6502
6724
  product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
6503
6725
  if (useCustomerUserPricing) {
6504
- _context62.next = 15;
6726
+ _context64.next = 15;
6505
6727
  break;
6506
6728
  }
6507
- _context62.next = 15;
6729
+ _context64.next = 15;
6508
6730
  return this.loadQuotationForPriceQuery({
6509
6731
  quotation: quotation,
6510
6732
  customer_id: customerId,
6511
6733
  channel: channel
6512
6734
  });
6513
6735
  case 15:
6514
- return _context62.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
6736
+ return _context64.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
6515
6737
  channel: channel,
6516
6738
  product: product,
6517
6739
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
@@ -6520,11 +6742,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6520
6742
  })));
6521
6743
  case 16:
6522
6744
  case "end":
6523
- return _context62.stop();
6745
+ return _context64.stop();
6524
6746
  }
6525
- }, _callee62, this);
6747
+ }, _callee64, this);
6526
6748
  }));
6527
- function calculateProductBookingPrice(_x50) {
6749
+ function calculateProductBookingPrice(_x51) {
6528
6750
  return _calculateProductBookingPrice.apply(this, arguments);
6529
6751
  }
6530
6752
  return calculateProductBookingPrice;
@@ -6571,8 +6793,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6571
6793
  }, {
6572
6794
  key: "hasSmartPricingStrategies",
6573
6795
  value: function hasSmartPricingStrategies() {
6574
- var _this$core6;
6575
- var evaluator = (_this$core6 = this.core) === null || _this$core6 === void 0 || (_this$core6 = _this$core6.context) === null || _this$core6 === void 0 ? void 0 : _this$core6.dataVariantEvaluator;
6796
+ var _this$core7;
6797
+ var evaluator = (_this$core7 = this.core) === null || _this$core7 === void 0 || (_this$core7 = _this$core7.context) === null || _this$core7 === void 0 ? void 0 : _this$core7.dataVariantEvaluator;
6576
6798
  if (!evaluator || typeof evaluator.getStrategyConfigs !== 'function') {
6577
6799
  return false;
6578
6800
  }
@@ -6608,17 +6830,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6608
6830
  }, {
6609
6831
  key: "calculateProductBookingPrices",
6610
6832
  value: function () {
6611
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(paramsList) {
6833
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(paramsList) {
6612
6834
  var _this22 = this;
6613
6835
  var useCustomerUserPricing, quotation, currentOrderCustomerId, resolvedChannels, authoritativeProducts, groups, quotationContexts;
6614
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6615
- while (1) switch (_context64.prev = _context64.next) {
6836
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6837
+ while (1) switch (_context66.prev = _context66.next) {
6616
6838
  case 0:
6617
6839
  if (paramsList.length) {
6618
- _context64.next = 2;
6840
+ _context66.next = 2;
6619
6841
  break;
6620
6842
  }
6621
- return _context64.abrupt("return", []);
6843
+ return _context66.abrupt("return", []);
6622
6844
  case 2:
6623
6845
  useCustomerUserPricing = this.isCustomerUserPriceQuery();
6624
6846
  quotation = useCustomerUserPricing ? undefined : this.store.quotation;
@@ -6645,20 +6867,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6645
6867
  group.indices.push(index);
6646
6868
  groups.set(groupKey, group);
6647
6869
  });
6648
- _context64.next = 11;
6870
+ _context66.next = 11;
6649
6871
  return Promise.all(Array.from(groups.values()).map( /*#__PURE__*/function () {
6650
- var _ref55 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(group) {
6872
+ var _ref55 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(group) {
6651
6873
  var priceQueries, resolvedProducts;
6652
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6653
- while (1) switch (_context63.prev = _context63.next) {
6874
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6875
+ while (1) switch (_context65.prev = _context65.next) {
6654
6876
  case 0:
6655
- _context63.next = 2;
6877
+ _context65.next = 2;
6656
6878
  return _this22.prepareProductPriceQueryContext(group.customerId);
6657
6879
  case 2:
6658
6880
  priceQueries = group.indices.map(function (index) {
6659
6881
  return paramsList[index];
6660
6882
  });
6661
- _context63.next = 5;
6883
+ _context65.next = 5;
6662
6884
  return _this22.resolveProductsForPriceQuery({
6663
6885
  priceQueries: priceQueries,
6664
6886
  schedule: group.schedule,
@@ -6666,23 +6888,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6666
6888
  channel: group.channel
6667
6889
  });
6668
6890
  case 5:
6669
- resolvedProducts = _context63.sent;
6891
+ resolvedProducts = _context65.sent;
6670
6892
  group.indices.forEach(function (originalIndex, groupIndex) {
6671
6893
  authoritativeProducts[originalIndex] = resolvedProducts[groupIndex] || null;
6672
6894
  });
6673
6895
  case 7:
6674
6896
  case "end":
6675
- return _context63.stop();
6897
+ return _context65.stop();
6676
6898
  }
6677
- }, _callee63);
6899
+ }, _callee65);
6678
6900
  }));
6679
- return function (_x52) {
6901
+ return function (_x53) {
6680
6902
  return _ref55.apply(this, arguments);
6681
6903
  };
6682
6904
  }()));
6683
6905
  case 11:
6684
6906
  if (useCustomerUserPricing) {
6685
- _context64.next = 16;
6907
+ _context66.next = 16;
6686
6908
  break;
6687
6909
  }
6688
6910
  quotationContexts = new Map();
@@ -6696,14 +6918,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6696
6918
  customer_id: (_params$customer_id3 = params.customer_id) !== null && _params$customer_id3 !== void 0 ? _params$customer_id3 : currentOrderCustomerId
6697
6919
  });
6698
6920
  });
6699
- _context64.next = 16;
6921
+ _context66.next = 16;
6700
6922
  return Promise.all(Array.from(quotationContexts.values()).map(function (context) {
6701
6923
  return _this22.loadQuotationForPriceQuery(_objectSpread({
6702
6924
  quotation: quotation
6703
6925
  }, context));
6704
6926
  }));
6705
6927
  case 16:
6706
- return _context64.abrupt("return", paramsList.map(function (params, index) {
6928
+ return _context66.abrupt("return", paramsList.map(function (params, index) {
6707
6929
  var _params$customer_id4;
6708
6930
  var productInput = params.product || {};
6709
6931
  var authoritativeProduct = authoritativeProducts[index];
@@ -6720,11 +6942,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6720
6942
  }));
6721
6943
  case 17:
6722
6944
  case "end":
6723
- return _context64.stop();
6945
+ return _context66.stop();
6724
6946
  }
6725
- }, _callee64, this);
6947
+ }, _callee66, this);
6726
6948
  }));
6727
- function calculateProductBookingPrices(_x51) {
6949
+ function calculateProductBookingPrices(_x52) {
6728
6950
  return _calculateProductBookingPrices.apply(this, arguments);
6729
6951
  }
6730
6952
  return calculateProductBookingPrices;
@@ -6732,47 +6954,47 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6732
6954
  }, {
6733
6955
  key: "addProductToOrder",
6734
6956
  value: function () {
6735
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(product, booking, options) {
6957
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(product, booking, options) {
6736
6958
  var products;
6737
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6738
- while (1) switch (_context65.prev = _context65.next) {
6959
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6960
+ while (1) switch (_context67.prev = _context67.next) {
6739
6961
  case 0:
6740
- _context65.prev = 0;
6962
+ _context67.prev = 0;
6741
6963
  if (this.store.order) {
6742
- _context65.next = 3;
6964
+ _context67.next = 3;
6743
6965
  break;
6744
6966
  }
6745
6967
  throw new Error('order 模块未初始化');
6746
6968
  case 3:
6747
6969
  if (!(options === undefined)) {
6748
- _context65.next = 9;
6970
+ _context67.next = 9;
6749
6971
  break;
6750
6972
  }
6751
- _context65.next = 6;
6973
+ _context67.next = 6;
6752
6974
  return this.store.order.addProductToOrder(product, booking);
6753
6975
  case 6:
6754
- _context65.t0 = _context65.sent;
6755
- _context65.next = 12;
6976
+ _context67.t0 = _context67.sent;
6977
+ _context67.next = 12;
6756
6978
  break;
6757
6979
  case 9:
6758
- _context65.next = 11;
6980
+ _context67.next = 11;
6759
6981
  return this.store.order.addProductToOrder(product, booking, options);
6760
6982
  case 11:
6761
- _context65.t0 = _context65.sent;
6983
+ _context67.t0 = _context67.sent;
6762
6984
  case 12:
6763
- products = _context65.t0;
6764
- return _context65.abrupt("return", products);
6985
+ products = _context67.t0;
6986
+ return _context67.abrupt("return", products);
6765
6987
  case 16:
6766
- _context65.prev = 16;
6767
- _context65.t1 = _context65["catch"](0);
6768
- throw _context65.t1;
6988
+ _context67.prev = 16;
6989
+ _context67.t1 = _context67["catch"](0);
6990
+ throw _context67.t1;
6769
6991
  case 19:
6770
6992
  case "end":
6771
- return _context65.stop();
6993
+ return _context67.stop();
6772
6994
  }
6773
- }, _callee65, this, [[0, 16]]);
6995
+ }, _callee67, this, [[0, 16]]);
6774
6996
  }));
6775
- function addProductToOrder(_x53, _x54, _x55) {
6997
+ function addProductToOrder(_x54, _x55, _x56) {
6776
6998
  return _addProductToOrder.apply(this, arguments);
6777
6999
  }
6778
7000
  return addProductToOrder;
@@ -6780,34 +7002,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6780
7002
  }, {
6781
7003
  key: "updateOrderProduct",
6782
7004
  value: function () {
6783
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(params) {
7005
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(params) {
6784
7006
  var products;
6785
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6786
- while (1) switch (_context66.prev = _context66.next) {
7007
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
7008
+ while (1) switch (_context68.prev = _context68.next) {
6787
7009
  case 0:
6788
- _context66.prev = 0;
7010
+ _context68.prev = 0;
6789
7011
  if (this.store.order) {
6790
- _context66.next = 3;
7012
+ _context68.next = 3;
6791
7013
  break;
6792
7014
  }
6793
7015
  throw new Error('order 模块未初始化');
6794
7016
  case 3:
6795
- _context66.next = 5;
7017
+ _context68.next = 5;
6796
7018
  return this.store.order.updateOrderProduct(params);
6797
7019
  case 5:
6798
- products = _context66.sent;
6799
- return _context66.abrupt("return", products);
7020
+ products = _context68.sent;
7021
+ return _context68.abrupt("return", products);
6800
7022
  case 9:
6801
- _context66.prev = 9;
6802
- _context66.t0 = _context66["catch"](0);
6803
- throw _context66.t0;
7023
+ _context68.prev = 9;
7024
+ _context68.t0 = _context68["catch"](0);
7025
+ throw _context68.t0;
6804
7026
  case 12:
6805
7027
  case "end":
6806
- return _context66.stop();
7028
+ return _context68.stop();
6807
7029
  }
6808
- }, _callee66, this, [[0, 9]]);
7030
+ }, _callee68, this, [[0, 9]]);
6809
7031
  }));
6810
- function updateOrderProduct(_x56) {
7032
+ function updateOrderProduct(_x57) {
6811
7033
  return _updateOrderProduct.apply(this, arguments);
6812
7034
  }
6813
7035
  return updateOrderProduct;
@@ -6815,34 +7037,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6815
7037
  }, {
6816
7038
  key: "updateOrderProducts",
6817
7039
  value: function () {
6818
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(paramsList) {
7040
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(paramsList) {
6819
7041
  var products;
6820
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6821
- while (1) switch (_context67.prev = _context67.next) {
7042
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
7043
+ while (1) switch (_context69.prev = _context69.next) {
6822
7044
  case 0:
6823
- _context67.prev = 0;
7045
+ _context69.prev = 0;
6824
7046
  if (this.store.order) {
6825
- _context67.next = 3;
7047
+ _context69.next = 3;
6826
7048
  break;
6827
7049
  }
6828
7050
  throw new Error('order 模块未初始化');
6829
7051
  case 3:
6830
- _context67.next = 5;
7052
+ _context69.next = 5;
6831
7053
  return this.store.order.updateOrderProducts(paramsList);
6832
7054
  case 5:
6833
- products = _context67.sent;
6834
- return _context67.abrupt("return", products);
7055
+ products = _context69.sent;
7056
+ return _context69.abrupt("return", products);
6835
7057
  case 9:
6836
- _context67.prev = 9;
6837
- _context67.t0 = _context67["catch"](0);
6838
- throw _context67.t0;
7058
+ _context69.prev = 9;
7059
+ _context69.t0 = _context69["catch"](0);
7060
+ throw _context69.t0;
6839
7061
  case 12:
6840
7062
  case "end":
6841
- return _context67.stop();
7063
+ return _context69.stop();
6842
7064
  }
6843
- }, _callee67, this, [[0, 9]]);
7065
+ }, _callee69, this, [[0, 9]]);
6844
7066
  }));
6845
- function updateOrderProducts(_x57) {
7067
+ function updateOrderProducts(_x58) {
6846
7068
  return _updateOrderProducts.apply(this, arguments);
6847
7069
  }
6848
7070
  return updateOrderProducts;
@@ -6850,34 +7072,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6850
7072
  }, {
6851
7073
  key: "updateOrderProductQuantity",
6852
7074
  value: function () {
6853
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(params) {
7075
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
6854
7076
  var products;
6855
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6856
- while (1) switch (_context68.prev = _context68.next) {
7077
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
7078
+ while (1) switch (_context70.prev = _context70.next) {
6857
7079
  case 0:
6858
- _context68.prev = 0;
7080
+ _context70.prev = 0;
6859
7081
  if (this.store.order) {
6860
- _context68.next = 3;
7082
+ _context70.next = 3;
6861
7083
  break;
6862
7084
  }
6863
7085
  throw new Error('order 模块未初始化');
6864
7086
  case 3:
6865
- _context68.next = 5;
7087
+ _context70.next = 5;
6866
7088
  return this.store.order.updateOrderProductQuantity(params);
6867
7089
  case 5:
6868
- products = _context68.sent;
6869
- return _context68.abrupt("return", products);
7090
+ products = _context70.sent;
7091
+ return _context70.abrupt("return", products);
6870
7092
  case 9:
6871
- _context68.prev = 9;
6872
- _context68.t0 = _context68["catch"](0);
6873
- throw _context68.t0;
7093
+ _context70.prev = 9;
7094
+ _context70.t0 = _context70["catch"](0);
7095
+ throw _context70.t0;
6874
7096
  case 12:
6875
7097
  case "end":
6876
- return _context68.stop();
7098
+ return _context70.stop();
6877
7099
  }
6878
- }, _callee68, this, [[0, 9]]);
7100
+ }, _callee70, this, [[0, 9]]);
6879
7101
  }));
6880
- function updateOrderProductQuantity(_x58) {
7102
+ function updateOrderProductQuantity(_x59) {
6881
7103
  return _updateOrderProductQuantity.apply(this, arguments);
6882
7104
  }
6883
7105
  return updateOrderProductQuantity;
@@ -6900,12 +7122,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6900
7122
  }, {
6901
7123
  key: "setOrderProductLineNote",
6902
7124
  value: (function () {
6903
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(identity, note) {
7125
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(identity, note) {
6904
7126
  var params, products;
6905
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6906
- while (1) switch (_context69.prev = _context69.next) {
7127
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7128
+ while (1) switch (_context71.prev = _context71.next) {
6907
7129
  case 0:
6908
- _context69.prev = 0;
7130
+ _context71.prev = 0;
6909
7131
  params = {
6910
7132
  product_id: identity.product_id,
6911
7133
  product_variant_id: identity.product_variant_id,
@@ -6920,22 +7142,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6920
7142
  params.product_sku = identity.product_sku;
6921
7143
  }
6922
7144
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
6923
- _context69.next = 7;
7145
+ _context71.next = 7;
6924
7146
  return this.updateOrderProduct(params);
6925
7147
  case 7:
6926
- products = _context69.sent;
6927
- return _context69.abrupt("return", products);
7148
+ products = _context71.sent;
7149
+ return _context71.abrupt("return", products);
6928
7150
  case 11:
6929
- _context69.prev = 11;
6930
- _context69.t0 = _context69["catch"](0);
6931
- throw _context69.t0;
7151
+ _context71.prev = 11;
7152
+ _context71.t0 = _context71["catch"](0);
7153
+ throw _context71.t0;
6932
7154
  case 14:
6933
7155
  case "end":
6934
- return _context69.stop();
7156
+ return _context71.stop();
6935
7157
  }
6936
- }, _callee69, this, [[0, 11]]);
7158
+ }, _callee71, this, [[0, 11]]);
6937
7159
  }));
6938
- function setOrderProductLineNote(_x59, _x60) {
7160
+ function setOrderProductLineNote(_x60, _x61) {
6939
7161
  return _setOrderProductLineNote.apply(this, arguments);
6940
7162
  }
6941
7163
  return setOrderProductLineNote;
@@ -6950,45 +7172,45 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6950
7172
  }, {
6951
7173
  key: "removeProductsFromOrder",
6952
7174
  value: (function () {
6953
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(identities, options) {
6954
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
6955
- while (1) switch (_context70.prev = _context70.next) {
7175
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(identities, options) {
7176
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7177
+ while (1) switch (_context72.prev = _context72.next) {
6956
7178
  case 0:
6957
- _context70.prev = 0;
7179
+ _context72.prev = 0;
6958
7180
  if (this.store.order) {
6959
- _context70.next = 3;
7181
+ _context72.next = 3;
6960
7182
  break;
6961
7183
  }
6962
7184
  throw new Error('order 模块未初始化');
6963
7185
  case 3:
6964
7186
  if (!(options === undefined)) {
6965
- _context70.next = 9;
7187
+ _context72.next = 9;
6966
7188
  break;
6967
7189
  }
6968
- _context70.next = 6;
7190
+ _context72.next = 6;
6969
7191
  return this.store.order.removeProductsFromOrder(identities);
6970
7192
  case 6:
6971
- _context70.t0 = _context70.sent;
6972
- _context70.next = 12;
7193
+ _context72.t0 = _context72.sent;
7194
+ _context72.next = 12;
6973
7195
  break;
6974
7196
  case 9:
6975
- _context70.next = 11;
7197
+ _context72.next = 11;
6976
7198
  return this.store.order.removeProductsFromOrder(identities, options);
6977
7199
  case 11:
6978
- _context70.t0 = _context70.sent;
7200
+ _context72.t0 = _context72.sent;
6979
7201
  case 12:
6980
- return _context70.abrupt("return", _context70.t0);
7202
+ return _context72.abrupt("return", _context72.t0);
6981
7203
  case 15:
6982
- _context70.prev = 15;
6983
- _context70.t1 = _context70["catch"](0);
6984
- throw _context70.t1;
7204
+ _context72.prev = 15;
7205
+ _context72.t1 = _context72["catch"](0);
7206
+ throw _context72.t1;
6985
7207
  case 18:
6986
7208
  case "end":
6987
- return _context70.stop();
7209
+ return _context72.stop();
6988
7210
  }
6989
- }, _callee70, this, [[0, 15]]);
7211
+ }, _callee72, this, [[0, 15]]);
6990
7212
  }));
6991
- function removeProductsFromOrder(_x61, _x62) {
7213
+ function removeProductsFromOrder(_x62, _x63) {
6992
7214
  return _removeProductsFromOrder.apply(this, arguments);
6993
7215
  }
6994
7216
  return removeProductsFromOrder;
@@ -6996,18 +7218,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6996
7218
  }, {
6997
7219
  key: "removeProductFromOrder",
6998
7220
  value: function () {
6999
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(identity, options) {
7000
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7001
- while (1) switch (_context71.prev = _context71.next) {
7221
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(identity, options) {
7222
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7223
+ while (1) switch (_context73.prev = _context73.next) {
7002
7224
  case 0:
7003
- return _context71.abrupt("return", this.removeProductsFromOrder([identity], options));
7225
+ return _context73.abrupt("return", this.removeProductsFromOrder([identity], options));
7004
7226
  case 1:
7005
7227
  case "end":
7006
- return _context71.stop();
7228
+ return _context73.stop();
7007
7229
  }
7008
- }, _callee71, this);
7230
+ }, _callee73, this);
7009
7231
  }));
7010
- function removeProductFromOrder(_x63, _x64) {
7232
+ function removeProductFromOrder(_x64, _x65) {
7011
7233
  return _removeProductFromOrder.apply(this, arguments);
7012
7234
  }
7013
7235
  return removeProductFromOrder;
@@ -7057,23 +7279,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7057
7279
  }, {
7058
7280
  key: "applyPromotion",
7059
7281
  value: (function () {
7060
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72() {
7061
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7062
- while (1) switch (_context72.prev = _context72.next) {
7282
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74() {
7283
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7284
+ while (1) switch (_context74.prev = _context74.next) {
7063
7285
  case 0:
7064
7286
  if (this.store.order) {
7065
- _context72.next = 2;
7287
+ _context74.next = 2;
7066
7288
  break;
7067
7289
  }
7068
7290
  throw new Error('order 模块未初始化');
7069
7291
  case 2:
7070
- _context72.next = 4;
7292
+ _context74.next = 4;
7071
7293
  return this.store.order.applyPromotion();
7072
7294
  case 4:
7073
7295
  case "end":
7074
- return _context72.stop();
7296
+ return _context74.stop();
7075
7297
  }
7076
- }, _callee72, this);
7298
+ }, _callee74, this);
7077
7299
  }));
7078
7300
  function applyPromotion() {
7079
7301
  return _applyPromotion.apply(this, arguments);
@@ -7083,16 +7305,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7083
7305
  }, {
7084
7306
  key: "getUnfulfilledPromotions",
7085
7307
  value: function getUnfulfilledPromotions() {
7086
- var _this$store$order30;
7087
- return ((_this$store$order30 = this.store.order) === null || _this$store$order30 === void 0 ? void 0 : _this$store$order30.getUnfulfilledPromotions()) || [];
7308
+ var _this$store$order33;
7309
+ return ((_this$store$order33 = this.store.order) === null || _this$store$order33 === void 0 ? void 0 : _this$store$order33.getUnfulfilledPromotions()) || [];
7088
7310
  }
7089
7311
 
7090
7312
  /** 最近一次促销计算输出的赠品操作 diff。 */
7091
7313
  }, {
7092
7314
  key: "getLastGiftActions",
7093
7315
  value: function getLastGiftActions() {
7094
- var _this$store$order31;
7095
- return ((_this$store$order31 = this.store.order) === null || _this$store$order31 === void 0 ? void 0 : _this$store$order31.getLastGiftActions()) || null;
7316
+ var _this$store$order34;
7317
+ return ((_this$store$order34 = this.store.order) === null || _this$store$order34 === void 0 ? void 0 : _this$store$order34.getLastGiftActions()) || null;
7096
7318
  }
7097
7319
 
7098
7320
  // 获取商品列表
@@ -7100,18 +7322,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7100
7322
  }, {
7101
7323
  key: "getProductList",
7102
7324
  value: function () {
7103
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73() {
7325
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75() {
7104
7326
  var _this$otherParams42;
7105
7327
  var menu_list_ids, _this$store$products, res;
7106
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7107
- while (1) switch (_context73.prev = _context73.next) {
7328
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7329
+ while (1) switch (_context75.prev = _context75.next) {
7108
7330
  case 0:
7109
7331
  // 可以直接通过配置里的 menu 读取
7110
7332
  menu_list_ids = ((_this$otherParams42 = this.otherParams) === null || _this$otherParams42 === void 0 || (_this$otherParams42 = _this$otherParams42.dineInConfig) === null || _this$otherParams42 === void 0 ? void 0 : _this$otherParams42['menu.associated_menus'].map(function (n) {
7111
7333
  return Number(n.value);
7112
7334
  })) || [];
7113
- _context73.prev = 1;
7114
- _context73.next = 4;
7335
+ _context75.prev = 1;
7336
+ _context75.next = 4;
7115
7337
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
7116
7338
  menu_list_ids: menu_list_ids,
7117
7339
  cacheId: this.cacheId,
@@ -7119,17 +7341,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7119
7341
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
7120
7342
  });
7121
7343
  case 4:
7122
- res = _context73.sent;
7123
- return _context73.abrupt("return", res);
7344
+ res = _context75.sent;
7345
+ return _context75.abrupt("return", res);
7124
7346
  case 8:
7125
- _context73.prev = 8;
7126
- _context73.t0 = _context73["catch"](1);
7127
- throw _context73.t0;
7347
+ _context75.prev = 8;
7348
+ _context75.t0 = _context75["catch"](1);
7349
+ throw _context75.t0;
7128
7350
  case 11:
7129
7351
  case "end":
7130
- return _context73.stop();
7352
+ return _context75.stop();
7131
7353
  }
7132
- }, _callee73, this, [[1, 8]]);
7354
+ }, _callee75, this, [[1, 8]]);
7133
7355
  }));
7134
7356
  function getProductList() {
7135
7357
  return _getProductList.apply(this, arguments);
@@ -7144,17 +7366,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7144
7366
  }, {
7145
7367
  key: "setOtherParams",
7146
7368
  value: function () {
7147
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(params) {
7369
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(params) {
7148
7370
  var _this$otherParams43;
7149
7371
  var _ref56,
7150
7372
  _ref56$cover,
7151
7373
  cover,
7152
7374
  previousPickupTimingScope,
7153
- _args74 = arguments;
7154
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7155
- while (1) switch (_context74.prev = _context74.next) {
7375
+ _args76 = arguments;
7376
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
7377
+ while (1) switch (_context76.prev = _context76.next) {
7156
7378
  case 0:
7157
- _ref56 = _args74.length > 1 && _args74[1] !== undefined ? _args74[1] : {}, _ref56$cover = _ref56.cover, cover = _ref56$cover === void 0 ? false : _ref56$cover;
7379
+ _ref56 = _args76.length > 1 && _args76[1] !== undefined ? _args76[1] : {}, _ref56$cover = _ref56.cover, cover = _ref56$cover === void 0 ? false : _ref56$cover;
7158
7380
  previousPickupTimingScope = this.getPickupTimingScope();
7159
7381
  if (cover) {
7160
7382
  this.otherParams = _objectSpread({}, params);
@@ -7163,17 +7385,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7163
7385
  }
7164
7386
  this.cacheId = (_this$otherParams43 = this.otherParams) === null || _this$otherParams43 === void 0 ? void 0 : _this$otherParams43.cacheId;
7165
7387
  if (previousPickupTimingScope !== this.getPickupTimingScope()) this.resetPickupTimingCache();
7166
- _context74.next = 7;
7388
+ _context76.next = 7;
7167
7389
  return this.syncOtherParamsToSubModules(params, {
7168
7390
  cover: cover
7169
7391
  });
7170
7392
  case 7:
7171
7393
  case "end":
7172
- return _context74.stop();
7394
+ return _context76.stop();
7173
7395
  }
7174
- }, _callee74, this);
7396
+ }, _callee76, this);
7175
7397
  }));
7176
- function setOtherParams(_x65) {
7398
+ function setOtherParams(_x66) {
7177
7399
  return _setOtherParams.apply(this, arguments);
7178
7400
  }
7179
7401
  return setOtherParams;