@pisell/pisellos 2.3.154 → 2.3.156

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;
@@ -1399,7 +1410,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1399
1410
  value: function () {
1400
1411
  var _resolveProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
1401
1412
  var _this7 = this;
1402
- var selectedProducts, productIds, ids, handledByOsServer, canUseLocalFastPath, productsById, queryPayload, cachedRawProducts, authoritativeProducts, missingIds, remoteRawProducts;
1413
+ var selectedProducts, productIds, ids, handledByOsServer, canUseLocalFastPath, productsById, shouldAlignSelectedVariantPrice, queryPayload, cachedRawProducts, authoritativeProducts, missingIds, remoteRawProducts;
1403
1414
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1404
1415
  while (1) switch (_context10.prev = _context10.next) {
1405
1416
  case 0:
@@ -1423,7 +1434,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1423
1434
  handledByOsServer = this.request ? isProductQueryHandledByOsServer(this.core, this.request) : false;
1424
1435
  canUseLocalFastPath = this.isCustomerUserPriceQuery() && !handledByOsServer;
1425
1436
  if (canUseLocalFastPath) {
1426
- _context10.next = 14;
1437
+ _context10.next = 15;
1427
1438
  break;
1428
1439
  }
1429
1440
  if (this.request) {
@@ -1443,10 +1454,37 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1443
1454
  });
1444
1455
  case 12:
1445
1456
  productsById = _context10.sent;
1446
- return _context10.abrupt("return", productIds.map(function (productId) {
1447
- return productId === null ? null : productsById.get(productId) || null;
1457
+ shouldAlignSelectedVariantPrice = handledByOsServer && this.preferAuthoritativeProductQueryPrice();
1458
+ return _context10.abrupt("return", productIds.map(function (productId, index) {
1459
+ var _authoritativeProduct;
1460
+ var authoritativeProduct = productId === null ? null : productsById.get(productId) || null;
1461
+ if (!shouldAlignSelectedVariantPrice || !authoritativeProduct) return authoritativeProduct;
1462
+ var selectedProduct = selectedProducts[index];
1463
+ var selectedVariantId = _this7.getSelectedProductVariantId(selectedProduct);
1464
+ if (!selectedVariantId || _this7.getSelectedProductVariantId(authoritativeProduct) === selectedVariantId) {
1465
+ return authoritativeProduct;
1466
+ }
1467
+
1468
+ // OS 返回的是目录商品;已命中的智能价格不能被规格基础价覆盖。
1469
+ var appliedFields = (_authoritativeProduct = authoritativeProduct._dataVariant) === null || _authoritativeProduct === void 0 ? void 0 : _authoritativeProduct.appliedFields;
1470
+ if (Array.isArray(appliedFields) && ['price', 'selling_price', 'original_price', 'base_price'].some(function (field) {
1471
+ return appliedFields.includes(field);
1472
+ })) {
1473
+ return authoritativeProduct;
1474
+ }
1475
+ var selectedVariant = Array.isArray(authoritativeProduct.variant) ? authoritativeProduct.variant.find(function (variant) {
1476
+ return Number(variant === null || variant === void 0 ? void 0 : variant.id) === selectedVariantId;
1477
+ }) : undefined;
1478
+ var selectedPrice = [selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.price, selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.selling_price, selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.base_price, params.priceQueries[index].fallback_price, selectedProduct.price, selectedProduct.selling_price, selectedProduct.original_price].find(function (value) {
1479
+ return (typeof value === 'number' || typeof value === 'string' && value.trim() !== '') && Number.isFinite(Number(value));
1480
+ });
1481
+
1482
+ // 每行独立保留所选规格价格(含 0 元),避免同商品多规格共用目录对象串价。
1483
+ return selectedPrice === undefined ? authoritativeProduct : _objectSpread(_objectSpread({}, authoritativeProduct), {}, {
1484
+ price: selectedPrice
1485
+ });
1448
1486
  }));
1449
- case 14:
1487
+ case 15:
1450
1488
  queryPayload = this.buildPriceQueryPayload({
1451
1489
  ids: ids,
1452
1490
  schedule: params.schedule,
@@ -1466,25 +1504,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1466
1504
  return productId !== null && !authoritativeProducts[index];
1467
1505
  })));
1468
1506
  if (missingIds.length) {
1469
- _context10.next = 20;
1507
+ _context10.next = 21;
1470
1508
  break;
1471
1509
  }
1472
1510
  return _context10.abrupt("return", authoritativeProducts);
1473
- case 20:
1511
+ case 21:
1474
1512
  if (this.request) {
1475
- _context10.next = 22;
1513
+ _context10.next = 23;
1476
1514
  break;
1477
1515
  }
1478
1516
  return _context10.abrupt("return", authoritativeProducts);
1479
- case 22:
1480
- _context10.next = 24;
1517
+ case 23:
1518
+ _context10.next = 25;
1481
1519
  return this.loadProductsForPriceQuery({
1482
1520
  ids: missingIds,
1483
1521
  schedule: params.schedule,
1484
1522
  customerId: params.customerId,
1485
1523
  channel: params.channel
1486
1524
  });
1487
- case 24:
1525
+ case 25:
1488
1526
  remoteRawProducts = _context10.sent;
1489
1527
  authoritativeProducts.forEach(function (authoritativeProduct, index) {
1490
1528
  if (authoritativeProduct) return;
@@ -1506,7 +1544,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1506
1544
  authoritativeProducts[index] = rawProduct ? _this7.prepareRawProductForPriceQuery(rawProduct, selectedProducts[index]) || rawProduct : null;
1507
1545
  });
1508
1546
  return _context10.abrupt("return", authoritativeProducts);
1509
- case 27:
1547
+ case 28:
1510
1548
  case "end":
1511
1549
  return _context10.stop();
1512
1550
  }
@@ -2145,8 +2183,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2145
2183
  }
2146
2184
  }
2147
2185
  try {
2148
- var _this$store$order3, _this$store$order3$ge, _this$logger, _this$logger$addLog, _orderIdentity$orderI, _orderIdentity$extern, _orderIdentity$shopOr;
2149
- 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);
2150
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, {
2151
2189
  type: 'info',
2152
2190
  title: 'syncAppDataToTempOrder',
@@ -2486,8 +2524,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2486
2524
  }, {
2487
2525
  key: "getTempOrder",
2488
2526
  value: function getTempOrder() {
2489
- var _this$store$order4;
2490
- 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;
2491
2529
  return result;
2492
2530
  }
2493
2531
  }, {
@@ -2738,8 +2776,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2738
2776
  }, {
2739
2777
  key: "getPickupTimingBooking",
2740
2778
  value: function getPickupTimingBooking() {
2741
- var _this$store$order5;
2742
- 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;
2743
2781
  }
2744
2782
  }, {
2745
2783
  key: "setPickupTimingBooking",
@@ -2750,8 +2788,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2750
2788
  }, {
2751
2789
  key: "clearPickupTimingBooking",
2752
2790
  value: function clearPickupTimingBooking() {
2753
- var _this$store$order6;
2754
- (_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();
2755
2793
  }
2756
2794
  }, {
2757
2795
  key: "updateTempOrderContactsInfo",
@@ -3190,8 +3228,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3190
3228
  }, {
3191
3229
  key: "getDiscountConfigOrderIdentityKey",
3192
3230
  value: function getDiscountConfigOrderIdentityKey(tempOrder) {
3193
- var _this$store$order7, _this$store$order7$ge, _ref43, _identity$orderId, _tempOrder$request_un, _ref44, _identity$externalSal, _ref45, _ref46, _identity$localId, _tempOrder$_extend3;
3194
- 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);
3195
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 : '']);
3196
3234
  }
3197
3235
  }, {
@@ -3199,17 +3237,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3199
3237
  value: function () {
3200
3238
  var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
3201
3239
  var _this$store$order$get2,
3202
- _this$store$order8,
3240
+ _this$store$order10,
3203
3241
  _tempOrder$customer2,
3204
3242
  _tempOrder$_extend4,
3205
3243
  _tempOrder$_extend5,
3206
3244
  _discountModule$getDi,
3207
3245
  _discountModule$getOr,
3208
3246
  _this$store$order$get3,
3209
- _this$store$order9,
3247
+ _this$store$order11,
3210
3248
  _this18 = this,
3211
3249
  _discountModule$getDi3;
3212
- 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;
3213
3251
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3214
3252
  while (1) switch (_context29.prev = _context29.next) {
3215
3253
  case 0:
@@ -3223,7 +3261,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3223
3261
  orderStore = this.store.order.store || {};
3224
3262
  discountModule = orderStore.discount;
3225
3263
  rulesModule = orderStore.rules;
3226
- 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);
3227
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);
3228
3266
  currentDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
3229
3267
  originalDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
@@ -3233,7 +3271,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3233
3271
  discountAction = (params === null || params === void 0 ? void 0 : params.action) || (orderId ? 'edit' : 'create');
3234
3272
  requestOrderIdentityKey = this.getDiscountConfigOrderIdentityKey(tempOrder);
3235
3273
  discountConfigCacheKey = JSON.stringify([customerId, discountAction, Number(orderId) || 0, requestOrderIdentityKey]);
3236
- 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);
3237
3275
  isCurrentRequest = function isCurrentRequest() {
3238
3276
  var _this18$store$order, _this18$store$order$g, _this18$store$order2, _this18$store$order2$;
3239
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);
@@ -3277,7 +3315,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3277
3315
  orderId: Number(orderId) || undefined,
3278
3316
  apply: false
3279
3317
  }); // OrderModule increments this epoch synchronously before its first await.
3280
- 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);
3281
3319
  _context29.next = 29;
3282
3320
  return prepareConfigPromise;
3283
3321
  case 29:
@@ -3569,15 +3607,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3569
3607
  }, {
3570
3608
  key: "getAvailableWalletIds",
3571
3609
  value: function getAvailableWalletIds() {
3572
- var _this$store$order11;
3573
- 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 [];
3574
3612
  return this.store.order.getAvailableWalletIds();
3575
3613
  }
3576
3614
  }, {
3577
3615
  key: "getVirtualCurrencyList",
3578
3616
  value: function getVirtualCurrencyList() {
3579
- var _this$store$order12;
3580
- 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 [];
3581
3619
  return this.store.order.getVirtualCurrencyList();
3582
3620
  }
3583
3621
  }, {
@@ -4385,29 +4423,240 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4385
4423
  return submitSalesOrder;
4386
4424
  }())
4387
4425
  }, {
4388
- key: "saveSalesOrderDraft",
4426
+ key: "finalizeLocalEftposPayment",
4389
4427
  value: function () {
4390
- var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
4391
- 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;
4392
4431
  return _regeneratorRuntime().wrap(function _callee38$(_context38) {
4393
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) {
4394
4643
  case 0:
4395
4644
  if (this.store.order) {
4396
- _context38.next = 2;
4645
+ _context40.next = 2;
4397
4646
  break;
4398
4647
  }
4399
4648
  throw new Error('BaseSales 解决方案需要 order 模块支持');
4400
4649
  case 2:
4401
4650
  if (!this.isPickupTimingEnabled()) {
4402
- _context38.next = 5;
4651
+ _context40.next = 5;
4403
4652
  break;
4404
4653
  }
4405
- _context38.next = 5;
4654
+ _context40.next = 5;
4406
4655
  return this.preparePickupTimingForCheckout({
4407
4656
  freeze: false
4408
4657
  });
4409
4658
  case 5:
4410
- return _context38.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
4659
+ return _context40.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
4411
4660
  cacheId: this.cacheId,
4412
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,
4413
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),
@@ -4418,11 +4667,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4418
4667
  } : {})));
4419
4668
  case 6:
4420
4669
  case "end":
4421
- return _context38.stop();
4670
+ return _context40.stop();
4422
4671
  }
4423
- }, _callee38, this);
4672
+ }, _callee40, this);
4424
4673
  }));
4425
- function saveSalesOrderDraft(_x29) {
4674
+ function saveSalesOrderDraft(_x30) {
4426
4675
  return _saveSalesOrderDraft.apply(this, arguments);
4427
4676
  }
4428
4677
  return saveSalesOrderDraft;
@@ -4430,23 +4679,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4430
4679
  }, {
4431
4680
  key: "submitTempOrderAsync",
4432
4681
  value: function () {
4433
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
4682
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
4434
4683
  var _params$smallTicketDa2, _this$otherParams28, _this$otherParams29, _this$otherParams30, _this$otherParams31;
4435
4684
  var inferredPaymentStatus, smallTicketDataFlag, enhancePayload, submitParams;
4436
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
4437
- while (1) switch (_context39.prev = _context39.next) {
4685
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
4686
+ while (1) switch (_context41.prev = _context41.next) {
4438
4687
  case 0:
4439
4688
  if (this.store.order) {
4440
- _context39.next = 2;
4689
+ _context41.next = 2;
4441
4690
  break;
4442
4691
  }
4443
4692
  throw new Error('BaseSales 解决方案需要 order 模块支持');
4444
4693
  case 2:
4445
4694
  if (!this.isPickupTimingEnabled()) {
4446
- _context39.next = 5;
4695
+ _context41.next = 5;
4447
4696
  break;
4448
4697
  }
4449
- _context39.next = 5;
4698
+ _context41.next = 5;
4450
4699
  return this.preparePickupTimingForCheckout({
4451
4700
  freeze: true
4452
4701
  });
@@ -4472,14 +4721,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4472
4721
  } : {}), enhancePayload !== undefined ? {
4473
4722
  enhancePayload: enhancePayload
4474
4723
  } : {});
4475
- return _context39.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
4724
+ return _context41.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
4476
4725
  case 10:
4477
4726
  case "end":
4478
- return _context39.stop();
4727
+ return _context41.stop();
4479
4728
  }
4480
- }, _callee39, this);
4729
+ }, _callee41, this);
4481
4730
  }));
4482
- function submitTempOrderAsync(_x30) {
4731
+ function submitTempOrderAsync(_x31) {
4483
4732
  return _submitTempOrderAsync.apply(this, arguments);
4484
4733
  }
4485
4734
  return submitTempOrderAsync;
@@ -4505,14 +4754,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4505
4754
  }, {
4506
4755
  key: "printLocalOrderReceipt",
4507
4756
  value: function () {
4508
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(lookup) {
4757
+ var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(lookup) {
4509
4758
  var _this$otherParams33, _this$otherParams34, _this$otherParams35, _this$otherParams36;
4510
- var hasLookup, lookupPayload, context, payload, invoiceLayoutConfig, invoiceTemplateSettings, printPayload, response, _this$store$order$app, _this$store$order13, _data;
4511
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
4512
- 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) {
4513
4762
  case 0:
4514
4763
  if (this.store.order) {
4515
- _context40.next = 2;
4764
+ _context42.next = 2;
4516
4765
  break;
4517
4766
  }
4518
4767
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -4550,28 +4799,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4550
4799
  } : {}), invoiceTemplateSettings ? {
4551
4800
  template_settings: cloneDeep(invoiceTemplateSettings)
4552
4801
  } : {});
4553
- _context40.next = 11;
4802
+ _context42.next = 11;
4554
4803
  return this.request.post('/local/print-order', printPayload, {
4555
4804
  osServer: true,
4556
4805
  customToast: function customToast() {}
4557
4806
  });
4558
4807
  case 11:
4559
- response = _context40.sent;
4808
+ response = _context42.sent;
4560
4809
  if (hasLookup) {
4561
- _context40.next = 15;
4810
+ _context42.next = 15;
4562
4811
  break;
4563
4812
  }
4564
- _context40.next = 15;
4565
- 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);
4566
4815
  case 15:
4567
- return _context40.abrupt("return", response);
4816
+ return _context42.abrupt("return", response);
4568
4817
  case 16:
4569
4818
  case "end":
4570
- return _context40.stop();
4819
+ return _context42.stop();
4571
4820
  }
4572
- }, _callee40, this);
4821
+ }, _callee42, this);
4573
4822
  }));
4574
- function printLocalOrderReceipt(_x31) {
4823
+ function printLocalOrderReceipt(_x32) {
4575
4824
  return _printLocalOrderReceipt.apply(this, arguments);
4576
4825
  }
4577
4826
  return printLocalOrderReceipt;
@@ -4579,27 +4828,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4579
4828
  }, {
4580
4829
  key: "getSubmitPaymentStatus",
4581
4830
  value: function getSubmitPaymentStatus(paymentStatus) {
4582
- var _this$store$order14, _this$store$order14$g;
4831
+ var _this$store$order17, _this$store$order17$g;
4583
4832
  if (paymentStatus !== undefined) return paymentStatus;
4584
- 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);
4585
4834
  if (!amountSnapshot) return undefined;
4586
4835
  try {
4587
4836
  return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
4588
- } catch (_unused5) {
4837
+ } catch (_unused7) {
4589
4838
  return undefined;
4590
4839
  }
4591
4840
  }
4592
4841
  }, {
4593
4842
  key: "syncPaymentsToOrder",
4594
4843
  value: function () {
4595
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
4844
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
4596
4845
  var _ref48, _params$businessCode, _this$otherParams37, _this$otherParams38, _params$channel2;
4597
4846
  var businessCode, channel, enhancePayload, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
4598
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
4599
- while (1) switch (_context41.prev = _context41.next) {
4847
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4848
+ while (1) switch (_context43.prev = _context43.next) {
4600
4849
  case 0:
4601
4850
  if (this.store.order) {
4602
- _context41.next = 2;
4851
+ _context43.next = 2;
4603
4852
  break;
4604
4853
  }
4605
4854
  throw new Error('order 模块未初始化');
@@ -4618,14 +4867,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4618
4867
  } : {});
4619
4868
  syncState = this.store.order.getOrderSyncState();
4620
4869
  if (!(params.submitWhenPaid && syncState === 'submitting')) {
4621
- _context41.next = 10;
4870
+ _context43.next = 10;
4622
4871
  break;
4623
4872
  }
4624
4873
  this.queueLatestAutoPaymentSync();
4625
- return _context41.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
4874
+ return _context43.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
4626
4875
  case 10:
4627
4876
  payments = params.payments || [];
4628
- _context41.next = 13;
4877
+ _context43.next = 13;
4629
4878
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
4630
4879
  payments: payments,
4631
4880
  params: syncParams,
@@ -4633,11 +4882,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4633
4882
  orderSnapshot: this.store.order.getOrderSnapshot()
4634
4883
  });
4635
4884
  case 13:
4636
- _context41.prev = 13;
4637
- _context41.next = 16;
4885
+ _context43.prev = 13;
4886
+ _context43.next = 16;
4638
4887
  return this.store.order.syncPaymentsToOrder(syncParams);
4639
4888
  case 16:
4640
- syncResult = _context41.sent;
4889
+ syncResult = _context43.sent;
4641
4890
  latestPayments = this.store.order.getOrderPayments();
4642
4891
  amountSnapshot = this.store.order.getOrderAmountSnapshot();
4643
4892
  orderSnapshot = this.store.order.getOrderSnapshot();
@@ -4655,25 +4904,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4655
4904
  depositAmount: syncResult.depositAmount,
4656
4905
  orderExpectedAmount: syncResult.orderExpectedAmount
4657
4906
  };
4658
- _context41.next = 23;
4907
+ _context43.next = 23;
4659
4908
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
4660
4909
  case 23:
4661
4910
  if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
4662
- _context41.next = 26;
4911
+ _context43.next = 26;
4663
4912
  break;
4664
4913
  }
4665
- _context41.next = 26;
4914
+ _context43.next = 26;
4666
4915
  return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
4667
4916
  case 26:
4668
4917
  this.scheduleQueuedAutoPaymentSyncFlush(0);
4669
- return _context41.abrupt("return", syncResult);
4918
+ return _context43.abrupt("return", syncResult);
4670
4919
  case 30:
4671
- _context41.prev = 30;
4672
- _context41.t0 = _context41["catch"](13);
4673
- _context41.next = 34;
4920
+ _context43.prev = 30;
4921
+ _context43.t0 = _context43["catch"](13);
4922
+ _context43.next = 34;
4674
4923
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
4675
4924
  ok: false,
4676
- error: _context41.t0,
4925
+ error: _context43.t0,
4677
4926
  payments: this.store.order.getOrderPayments(),
4678
4927
  params: syncParams,
4679
4928
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
@@ -4681,14 +4930,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4681
4930
  });
4682
4931
  case 34:
4683
4932
  this.scheduleQueuedAutoPaymentSyncFlush(0);
4684
- throw _context41.t0;
4933
+ throw _context43.t0;
4685
4934
  case 36:
4686
4935
  case "end":
4687
- return _context41.stop();
4936
+ return _context43.stop();
4688
4937
  }
4689
- }, _callee41, this, [[13, 30]]);
4938
+ }, _callee43, this, [[13, 30]]);
4690
4939
  }));
4691
- function syncPaymentsToOrder(_x32) {
4940
+ function syncPaymentsToOrder(_x33) {
4692
4941
  return _syncPaymentsToOrder.apply(this, arguments);
4693
4942
  }
4694
4943
  return syncPaymentsToOrder;
@@ -4737,46 +4986,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4737
4986
  }, {
4738
4987
  key: "flushQueuedAutoPaymentSync",
4739
4988
  value: function () {
4740
- var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
4989
+ var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
4741
4990
  var payments;
4742
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4743
- while (1) switch (_context42.prev = _context42.next) {
4991
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4992
+ while (1) switch (_context44.prev = _context44.next) {
4744
4993
  case 0:
4745
4994
  if (this.store.order) {
4746
- _context42.next = 2;
4995
+ _context44.next = 2;
4747
4996
  break;
4748
4997
  }
4749
- return _context42.abrupt("return");
4998
+ return _context44.abrupt("return");
4750
4999
  case 2:
4751
5000
  if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
4752
- _context42.next = 4;
5001
+ _context44.next = 4;
4753
5002
  break;
4754
5003
  }
4755
- return _context42.abrupt("return");
5004
+ return _context44.abrupt("return");
4756
5005
  case 4:
4757
5006
  if (!(this.store.order.getOrderSyncState() === 'submitting')) {
4758
- _context42.next = 7;
5007
+ _context44.next = 7;
4759
5008
  break;
4760
5009
  }
4761
5010
  this.scheduleQueuedAutoPaymentSyncFlush();
4762
- return _context42.abrupt("return");
5011
+ return _context44.abrupt("return");
4763
5012
  case 7:
4764
5013
  this.autoPaymentSyncFlushing = true;
4765
- _context42.prev = 8;
5014
+ _context44.prev = 8;
4766
5015
  case 9:
4767
5016
  if (!this.queuedAutoPaymentSync) {
4768
- _context42.next = 18;
5017
+ _context44.next = 18;
4769
5018
  break;
4770
5019
  }
4771
5020
  this.queuedAutoPaymentSync = false;
4772
5021
  payments = this.store.order.getOrderPayments();
4773
5022
  if (payments.length) {
4774
- _context42.next = 14;
5023
+ _context44.next = 14;
4775
5024
  break;
4776
5025
  }
4777
- return _context42.abrupt("continue", 9);
5026
+ return _context44.abrupt("continue", 9);
4778
5027
  case 14:
4779
- _context42.next = 16;
5028
+ _context44.next = 16;
4780
5029
  return this.syncPaymentsToOrder({
4781
5030
  payments: payments,
4782
5031
  paymentStatus: this.getPaymentStatusForSync(payments),
@@ -4784,29 +5033,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4784
5033
  smallTicketDataFlag: 1
4785
5034
  });
4786
5035
  case 16:
4787
- _context42.next = 9;
5036
+ _context44.next = 9;
4788
5037
  break;
4789
5038
  case 18:
4790
- _context42.next = 23;
5039
+ _context44.next = 23;
4791
5040
  break;
4792
5041
  case 20:
4793
- _context42.prev = 20;
4794
- _context42.t0 = _context42["catch"](8);
5042
+ _context44.prev = 20;
5043
+ _context44.t0 = _context44["catch"](8);
4795
5044
  this.logError('queued auto sync payments failed', {
4796
- error: _context42.t0 instanceof Error ? _context42.t0.message : String(_context42.t0)
5045
+ error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
4797
5046
  });
4798
5047
  case 23:
4799
- _context42.prev = 23;
5048
+ _context44.prev = 23;
4800
5049
  this.autoPaymentSyncFlushing = false;
4801
5050
  if (this.queuedAutoPaymentSync) {
4802
5051
  this.scheduleQueuedAutoPaymentSyncFlush(0);
4803
5052
  }
4804
- return _context42.finish(23);
5053
+ return _context44.finish(23);
4805
5054
  case 27:
4806
5055
  case "end":
4807
- return _context42.stop();
5056
+ return _context44.stop();
4808
5057
  }
4809
- }, _callee42, this, [[8, 20, 23, 27]]);
5058
+ }, _callee44, this, [[8, 20, 23, 27]]);
4810
5059
  }));
4811
5060
  function flushQueuedAutoPaymentSync() {
4812
5061
  return _flushQueuedAutoPaymentSync.apply(this, arguments);
@@ -4830,35 +5079,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4830
5079
  }, {
4831
5080
  key: "addOrderPaymentAsync",
4832
5081
  value: (function () {
4833
- var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(payment) {
5082
+ var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(payment) {
4834
5083
  var paymentRecord, hasPaymentNumber, devicePrefix;
4835
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4836
- while (1) switch (_context43.prev = _context43.next) {
5084
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
5085
+ while (1) switch (_context45.prev = _context45.next) {
4837
5086
  case 0:
4838
5087
  paymentRecord = payment;
4839
5088
  hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
4840
5089
  if (!hasPaymentNumber) {
4841
- _context43.next = 6;
5090
+ _context45.next = 6;
4842
5091
  break;
4843
5092
  }
4844
- _context43.t0 = 'LOCAL';
4845
- _context43.next = 9;
5093
+ _context45.t0 = 'LOCAL';
5094
+ _context45.next = 9;
4846
5095
  break;
4847
5096
  case 6:
4848
- _context43.next = 8;
5097
+ _context45.next = 8;
4849
5098
  return this.getPaymentNumberDevicePrefixAsync();
4850
5099
  case 8:
4851
- _context43.t0 = _context43.sent;
5100
+ _context45.t0 = _context45.sent;
4852
5101
  case 9:
4853
- devicePrefix = _context43.t0;
4854
- return _context43.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
5102
+ devicePrefix = _context45.t0;
5103
+ return _context45.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
4855
5104
  case 11:
4856
5105
  case "end":
4857
- return _context43.stop();
5106
+ return _context45.stop();
4858
5107
  }
4859
- }, _callee43, this);
5108
+ }, _callee45, this);
4860
5109
  }));
4861
- function addOrderPaymentAsync(_x33) {
5110
+ function addOrderPaymentAsync(_x34) {
4862
5111
  return _addOrderPaymentAsync.apply(this, arguments);
4863
5112
  }
4864
5113
  return addOrderPaymentAsync;
@@ -4927,7 +5176,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4927
5176
  }, {
4928
5177
  key: "updateOrderPayment",
4929
5178
  value: (function () {
4930
- var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(paymentIdentity, updates) {
5179
+ var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(paymentIdentity, updates) {
4931
5180
  var _result$payment, _result$payment2;
4932
5181
  var options,
4933
5182
  matchMode,
@@ -4944,13 +5193,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4944
5193
  shouldSubmit,
4945
5194
  syncResult,
4946
5195
  _options$smallTicketD2,
4947
- _args44 = arguments;
4948
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4949
- 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) {
4950
5199
  case 0:
4951
- options = _args44.length > 2 && _args44[2] !== undefined ? _args44[2] : {};
5200
+ options = _args46.length > 2 && _args46[2] !== undefined ? _args46[2] : {};
4952
5201
  if (this.store.order) {
4953
- _context44.next = 3;
5202
+ _context46.next = 3;
4954
5203
  break;
4955
5204
  }
4956
5205
  throw new Error('order 模块未初始化');
@@ -4959,15 +5208,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4959
5208
  previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
4960
5209
  previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
4961
5210
  if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
4962
- _context44.next = 13;
5211
+ _context46.next = 13;
4963
5212
  break;
4964
5213
  }
4965
5214
  currentPayments = this.store.order.getOrderPayments();
4966
5215
  if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
4967
- _context44.next = 12;
5216
+ _context46.next = 12;
4968
5217
  break;
4969
5218
  }
4970
- _context44.next = 11;
5219
+ _context46.next = 11;
4971
5220
  return this.syncPaymentsToOrder({
4972
5221
  payments: currentPayments,
4973
5222
  paymentStatus: this.getPaymentStatusForSync(currentPayments),
@@ -4975,9 +5224,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4975
5224
  smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
4976
5225
  });
4977
5226
  case 11:
4978
- _syncResult = _context44.sent;
5227
+ _syncResult = _context46.sent;
4979
5228
  case 12:
4980
- return _context44.abrupt("return", _objectSpread({
5229
+ return _context46.abrupt("return", _objectSpread({
4981
5230
  updated: false,
4982
5231
  payment: previousPayment,
4983
5232
  payments: currentPayments,
@@ -4986,44 +5235,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4986
5235
  syncResult: _syncResult
4987
5236
  } : {}));
4988
5237
  case 13:
4989
- _context44.next = 15;
5238
+ _context46.next = 15;
4990
5239
  return this.store.order.updateOrderPayment(paymentIdentity, updates, {
4991
5240
  matchBy: matchMode
4992
5241
  });
4993
5242
  case 15:
4994
- result = _context44.sent;
5243
+ result = _context46.sent;
4995
5244
  if (!(options.persistDraft !== false)) {
4996
- _context44.next = 29;
5245
+ _context46.next = 29;
4997
5246
  break;
4998
5247
  }
4999
- _context44.prev = 17;
5000
- _context44.next = 20;
5248
+ _context46.prev = 17;
5249
+ _context46.next = 20;
5001
5250
  return this.saveSalesOrderDraft();
5002
5251
  case 20:
5003
- draftResult = _context44.sent;
5004
- _context44.next = 29;
5252
+ draftResult = _context46.sent;
5253
+ _context46.next = 29;
5005
5254
  break;
5006
5255
  case 23:
5007
- _context44.prev = 23;
5008
- _context44.t0 = _context44["catch"](17);
5009
- draftError = _context44.t0;
5256
+ _context46.prev = 23;
5257
+ _context46.t0 = _context46["catch"](17);
5258
+ draftError = _context46.t0;
5010
5259
  this.logError('updateOrderPayment: 保存支付草稿失败', {
5011
5260
  paymentIdentity: paymentIdentity,
5012
- error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
5261
+ error: _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0)
5013
5262
  });
5014
5263
  if (options.submitWhenPaid) {
5015
- _context44.next = 29;
5264
+ _context46.next = 29;
5016
5265
  break;
5017
5266
  }
5018
- throw _context44.t0;
5267
+ throw _context46.t0;
5019
5268
  case 29:
5020
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';
5021
5270
  shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
5022
5271
  if (!shouldSubmit) {
5023
- _context44.next = 35;
5272
+ _context46.next = 35;
5024
5273
  break;
5025
5274
  }
5026
- _context44.next = 34;
5275
+ _context46.next = 34;
5027
5276
  return this.syncPaymentsToOrder({
5028
5277
  payments: result.payments,
5029
5278
  paymentStatus: this.getPaymentStatusForSync(result.payments),
@@ -5031,9 +5280,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5031
5280
  smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
5032
5281
  });
5033
5282
  case 34:
5034
- syncResult = _context44.sent;
5283
+ syncResult = _context46.sent;
5035
5284
  case 35:
5036
- return _context44.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
5285
+ return _context46.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
5037
5286
  draftResult: draftResult
5038
5287
  } : {}), draftError !== undefined ? {
5039
5288
  draftError: draftError
@@ -5042,11 +5291,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5042
5291
  } : {}));
5043
5292
  case 36:
5044
5293
  case "end":
5045
- return _context44.stop();
5294
+ return _context46.stop();
5046
5295
  }
5047
- }, _callee44, this, [[17, 23]]);
5296
+ }, _callee46, this, [[17, 23]]);
5048
5297
  }));
5049
- function updateOrderPayment(_x34, _x35) {
5298
+ function updateOrderPayment(_x35, _x36) {
5050
5299
  return _updateOrderPayment.apply(this, arguments);
5051
5300
  }
5052
5301
  return updateOrderPayment;
@@ -5068,24 +5317,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5068
5317
  }, {
5069
5318
  key: "updateVoucherOrderPaymentsAsync",
5070
5319
  value: function () {
5071
- var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(payments, options) {
5072
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
5073
- 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) {
5074
5323
  case 0:
5075
5324
  if (this.store.order) {
5076
- _context45.next = 2;
5325
+ _context47.next = 2;
5077
5326
  break;
5078
5327
  }
5079
5328
  throw new Error('order 模块未初始化');
5080
5329
  case 2:
5081
- return _context45.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
5330
+ return _context47.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
5082
5331
  case 3:
5083
5332
  case "end":
5084
- return _context45.stop();
5333
+ return _context47.stop();
5085
5334
  }
5086
- }, _callee45, this);
5335
+ }, _callee47, this);
5087
5336
  }));
5088
- function updateVoucherOrderPaymentsAsync(_x36, _x37) {
5337
+ function updateVoucherOrderPaymentsAsync(_x37, _x38) {
5089
5338
  return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
5090
5339
  }
5091
5340
  return updateVoucherOrderPaymentsAsync;
@@ -5111,8 +5360,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5111
5360
  }, {
5112
5361
  key: "getWalletProductList",
5113
5362
  value: function getWalletProductList() {
5114
- var _this$store$order15, _tempOrder$products;
5115
- 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();
5116
5365
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
5117
5366
  // 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
5118
5367
  // debugger
@@ -5172,8 +5421,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5172
5421
  }, {
5173
5422
  key: "buildWalletInitBusinessData",
5174
5423
  value: function buildWalletInitBusinessData(params) {
5175
- var _this$store$order16, _params$order_wait_pa, _ref50, _tempOrder$is_price_i;
5176
- 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();
5177
5426
  var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
5178
5427
  var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
5179
5428
  if (!tempOrder || !amount) return null;
@@ -5196,20 +5445,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5196
5445
  }, {
5197
5446
  key: "initWalletData",
5198
5447
  value: function () {
5199
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
5200
- 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;
5201
5450
  var snapshot, walletBusinessData, result;
5202
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
5203
- while (1) switch (_context46.prev = _context46.next) {
5451
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
5452
+ while (1) switch (_context48.prev = _context48.next) {
5204
5453
  case 0:
5205
5454
  if (this.store.order) {
5206
- _context46.next = 2;
5455
+ _context48.next = 2;
5207
5456
  break;
5208
5457
  }
5209
5458
  throw new Error('order 模块未初始化');
5210
5459
  case 2:
5211
5460
  if (this.store.payment) {
5212
- _context46.next = 4;
5461
+ _context48.next = 4;
5213
5462
  break;
5214
5463
  }
5215
5464
  throw new Error('payment 模块未初始化');
@@ -5217,10 +5466,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5217
5466
  snapshot = this.store.order.getOrderSnapshot();
5218
5467
  walletBusinessData = this.buildWalletInitBusinessData(params);
5219
5468
  if (walletBusinessData) {
5220
- _context46.next = 8;
5469
+ _context48.next = 8;
5221
5470
  break;
5222
5471
  }
5223
- return _context46.abrupt("return", {
5472
+ return _context48.abrupt("return", {
5224
5473
  walletRecommendList: [],
5225
5474
  userIdentificationCodes: [],
5226
5475
  transformList: [],
@@ -5228,15 +5477,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5228
5477
  products: []
5229
5478
  });
5230
5479
  case 8:
5231
- _context46.next = 10;
5480
+ _context48.next = 10;
5232
5481
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
5233
5482
  case 10:
5234
- result = _context46.sent;
5235
- (_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, {
5236
5485
  customerId: walletBusinessData.customer_id,
5237
5486
  orderIdentity: snapshot === null || snapshot === void 0 ? void 0 : snapshot.identity
5238
5487
  });
5239
- _context46.next = 14;
5488
+ _context48.next = 14;
5240
5489
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
5241
5490
  orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
5242
5491
  customerId: walletBusinessData.customer_id,
@@ -5248,14 +5497,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5248
5497
  timestamp: Date.now()
5249
5498
  });
5250
5499
  case 14:
5251
- return _context46.abrupt("return", result);
5500
+ return _context48.abrupt("return", result);
5252
5501
  case 15:
5253
5502
  case "end":
5254
- return _context46.stop();
5503
+ return _context48.stop();
5255
5504
  }
5256
- }, _callee46, this);
5505
+ }, _callee48, this);
5257
5506
  }));
5258
- function initWalletData(_x38) {
5507
+ function initWalletData(_x39) {
5259
5508
  return _initWalletData.apply(this, arguments);
5260
5509
  }
5261
5510
  return initWalletData;
@@ -5263,8 +5512,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5263
5512
  }, {
5264
5513
  key: "getCommittedWalletAssets",
5265
5514
  value: function getCommittedWalletAssets() {
5266
- var _this$store$order18, _this$store$order18$g;
5267
- 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)) || [];
5268
5517
  var committed = payments.filter(function (payment) {
5269
5518
  var voucherId = payment === null || payment === void 0 ? void 0 : payment.voucher_id;
5270
5519
  if (voucherId === undefined || voucherId === null || voucherId === 0) {
@@ -5306,27 +5555,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5306
5555
  }, {
5307
5556
  key: "publishWalletAssetsState",
5308
5557
  value: function () {
5309
- var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(state) {
5558
+ var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(state) {
5310
5559
  var changeSource,
5311
- _args47 = arguments;
5312
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
5313
- 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) {
5314
5563
  case 0:
5315
- changeSource = _args47.length > 1 && _args47[1] !== undefined ? _args47[1] : 'derived';
5316
- _context47.next = 3;
5564
+ changeSource = _args49.length > 1 && _args49[1] !== undefined ? _args49[1] : 'derived';
5565
+ _context49.next = 3;
5317
5566
  return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
5318
5567
  state: state,
5319
5568
  changeSource: changeSource
5320
5569
  });
5321
5570
  case 3:
5322
- return _context47.abrupt("return", state);
5571
+ return _context49.abrupt("return", state);
5323
5572
  case 4:
5324
5573
  case "end":
5325
- return _context47.stop();
5574
+ return _context49.stop();
5326
5575
  }
5327
- }, _callee47, this);
5576
+ }, _callee49, this);
5328
5577
  }));
5329
- function publishWalletAssetsState(_x39) {
5578
+ function publishWalletAssetsState(_x40) {
5330
5579
  return _publishWalletAssetsState.apply(this, arguments);
5331
5580
  }
5332
5581
  return publishWalletAssetsState;
@@ -5334,26 +5583,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5334
5583
  }, {
5335
5584
  key: "syncSelectedWalletAssets",
5336
5585
  value: function () {
5337
- var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(state) {
5586
+ var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(state) {
5338
5587
  var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
5339
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
5340
- while (1) switch (_context48.prev = _context48.next) {
5588
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
5589
+ while (1) switch (_context50.prev = _context50.next) {
5341
5590
  case 0:
5342
5591
  if (!(!this.store.order || !this.store.payment)) {
5343
- _context48.next = 2;
5592
+ _context50.next = 2;
5344
5593
  break;
5345
5594
  }
5346
5595
  throw new Error('订单或支付模块未初始化');
5347
5596
  case 2:
5348
5597
  paymentMethods = this.getPaymentMethods();
5349
5598
  if (!(!paymentMethods.length && state.selectedItems.length)) {
5350
- _context48.next = 7;
5599
+ _context50.next = 7;
5351
5600
  break;
5352
5601
  }
5353
- _context48.next = 6;
5602
+ _context50.next = 6;
5354
5603
  return this.getPaymentMethodsAsync();
5355
5604
  case 6:
5356
- paymentMethods = _context48.sent;
5605
+ paymentMethods = _context50.sent;
5357
5606
  case 7:
5358
5607
  methodByCode = new Map(paymentMethods.map(function (method) {
5359
5608
  return [String(method.code || '').toUpperCase(), method];
@@ -5395,19 +5644,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5395
5644
  payments = this.updateVoucherOrderPayments(voucherPayments, {
5396
5645
  status: 'payment_pending'
5397
5646
  });
5398
- _context48.next = 14;
5647
+ _context50.next = 14;
5399
5648
  return this.store.order.recalculateSummary({
5400
5649
  createIfMissing: true
5401
5650
  });
5402
5651
  case 14:
5403
- return _context48.abrupt("return", payments);
5652
+ return _context50.abrupt("return", payments);
5404
5653
  case 15:
5405
5654
  case "end":
5406
- return _context48.stop();
5655
+ return _context50.stop();
5407
5656
  }
5408
- }, _callee48, this);
5657
+ }, _callee50, this);
5409
5658
  }));
5410
- function syncSelectedWalletAssets(_x40) {
5659
+ function syncSelectedWalletAssets(_x41) {
5411
5660
  return _syncSelectedWalletAssets.apply(this, arguments);
5412
5661
  }
5413
5662
  return syncSelectedWalletAssets;
@@ -5441,31 +5690,31 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5441
5690
  }, {
5442
5691
  key: "importWalletAssetsSnapshot",
5443
5692
  value: (function () {
5444
- var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(snapshot) {
5445
- 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;
5446
5695
  var state;
5447
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
5448
- while (1) switch (_context49.prev = _context49.next) {
5696
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5697
+ while (1) switch (_context51.prev = _context51.next) {
5449
5698
  case 0:
5450
5699
  if (this.store.payment) {
5451
- _context49.next = 2;
5700
+ _context51.next = 2;
5452
5701
  break;
5453
5702
  }
5454
5703
  throw new Error('payment 模块未初始化');
5455
5704
  case 2:
5456
5705
  state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
5457
- (_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);
5458
- _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;
5459
5708
  return this.syncSelectedWalletAssets(state);
5460
5709
  case 6:
5461
- return _context49.abrupt("return", this.publishWalletAssetsState(state));
5710
+ return _context51.abrupt("return", this.publishWalletAssetsState(state));
5462
5711
  case 7:
5463
5712
  case "end":
5464
- return _context49.stop();
5713
+ return _context51.stop();
5465
5714
  }
5466
- }, _callee49, this);
5715
+ }, _callee51, this);
5467
5716
  }));
5468
- function importWalletAssetsSnapshot(_x41) {
5717
+ function importWalletAssetsSnapshot(_x42) {
5469
5718
  return _importWalletAssetsSnapshot.apply(this, arguments);
5470
5719
  }
5471
5720
  return importWalletAssetsSnapshot;
@@ -5477,20 +5726,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5477
5726
  }, {
5478
5727
  key: "refreshWalletAssets",
5479
5728
  value: (function () {
5480
- var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
5729
+ var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
5481
5730
  var _this$store$order$get6, _previousState$custom, _businessData$custome;
5482
- var refreshSequence, wallet, businessData, emptyState, pointCardSnapshotMergeContext, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, _this$store$order$mer2, _this$store$order20, _wallet$getUserIdenti, committed;
5483
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
5484
- 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) {
5485
5734
  case 0:
5486
5735
  if (this.store.order) {
5487
- _context50.next = 2;
5736
+ _context52.next = 2;
5488
5737
  break;
5489
5738
  }
5490
5739
  throw new Error('order 模块未初始化');
5491
5740
  case 2:
5492
5741
  if (this.store.payment) {
5493
- _context50.next = 4;
5742
+ _context52.next = 4;
5494
5743
  break;
5495
5744
  }
5496
5745
  throw new Error('payment 模块未初始化');
@@ -5499,7 +5748,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5499
5748
  wallet = this.store.payment.wallet;
5500
5749
  businessData = this.buildWalletInitBusinessData(params);
5501
5750
  if (businessData) {
5502
- _context50.next = 12;
5751
+ _context52.next = 12;
5503
5752
  break;
5504
5753
  }
5505
5754
  wallet.clearAllCache();
@@ -5507,7 +5756,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5507
5756
  this.updateVoucherOrderPayments([], {
5508
5757
  status: 'payment_pending'
5509
5758
  });
5510
- return _context50.abrupt("return", this.publishWalletAssetsState(emptyState));
5759
+ return _context52.abrupt("return", this.publishWalletAssetsState(emptyState));
5511
5760
  case 12:
5512
5761
  pointCardSnapshotMergeContext = {
5513
5762
  customerId: businessData.customer_id,
@@ -5517,49 +5766,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5517
5766
  hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
5518
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 : '');
5519
5768
  if (!customerChanged) {
5520
- _context50.next = 21;
5769
+ _context52.next = 21;
5521
5770
  break;
5522
5771
  }
5523
5772
  clearedState = wallet.clearWalletAssetSelection();
5524
5773
  this.updateVoucherOrderPayments([], {
5525
5774
  status: 'payment_pending'
5526
5775
  });
5527
- _context50.next = 21;
5776
+ _context52.next = 21;
5528
5777
  return this.publishWalletAssetsState(clearedState);
5529
5778
  case 21:
5530
5779
  refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
5531
5780
  preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged,
5532
5781
  retainSearchResultCodes: params === null || params === void 0 ? void 0 : params.retainSearchResultCodes
5533
5782
  });
5534
- _context50.next = 24;
5783
+ _context52.next = 24;
5535
5784
  return this.publishWalletAssetsState(wallet.getWalletAssetsState());
5536
5785
  case 24:
5537
- _context50.next = 26;
5786
+ _context52.next = 26;
5538
5787
  return refreshTask;
5539
5788
  case 26:
5540
- state = _context50.sent;
5789
+ state = _context52.sent;
5541
5790
  if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
5542
- _context50.next = 29;
5791
+ _context52.next = 29;
5543
5792
  break;
5544
5793
  }
5545
- return _context50.abrupt("return", wallet.getWalletAssetsState());
5794
+ return _context52.abrupt("return", wallet.getWalletAssetsState());
5546
5795
  case 29:
5547
5796
  if (state.status !== 'error') {
5548
5797
  committed = this.getCommittedWalletAssets();
5549
5798
  state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
5550
- (_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);
5551
5800
  }
5552
- _context50.next = 32;
5801
+ _context52.next = 32;
5553
5802
  return this.syncSelectedWalletAssets(state);
5554
5803
  case 32:
5555
- return _context50.abrupt("return", this.publishWalletAssetsState(state));
5804
+ return _context52.abrupt("return", this.publishWalletAssetsState(state));
5556
5805
  case 33:
5557
5806
  case "end":
5558
- return _context50.stop();
5807
+ return _context52.stop();
5559
5808
  }
5560
- }, _callee50, this);
5809
+ }, _callee52, this);
5561
5810
  }));
5562
- function refreshWalletAssets(_x42) {
5811
+ function refreshWalletAssets(_x43) {
5563
5812
  return _refreshWalletAssets.apply(this, arguments);
5564
5813
  }
5565
5814
  return refreshWalletAssets;
@@ -5567,13 +5816,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5567
5816
  }, {
5568
5817
  key: "selectWalletAsset",
5569
5818
  value: (function () {
5570
- var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
5819
+ var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
5571
5820
  var state;
5572
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5573
- while (1) switch (_context51.prev = _context51.next) {
5821
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5822
+ while (1) switch (_context53.prev = _context53.next) {
5574
5823
  case 0:
5575
5824
  if (this.store.payment) {
5576
- _context51.next = 2;
5825
+ _context53.next = 2;
5577
5826
  break;
5578
5827
  }
5579
5828
  throw new Error('payment 模块未初始化');
@@ -5582,17 +5831,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5582
5831
  selected: params.selected,
5583
5832
  source: params.source
5584
5833
  });
5585
- _context51.next = 5;
5834
+ _context53.next = 5;
5586
5835
  return this.syncSelectedWalletAssets(state);
5587
5836
  case 5:
5588
- return _context51.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5837
+ return _context53.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5589
5838
  case 6:
5590
5839
  case "end":
5591
- return _context51.stop();
5840
+ return _context53.stop();
5592
5841
  }
5593
- }, _callee51, this);
5842
+ }, _callee53, this);
5594
5843
  }));
5595
- function selectWalletAsset(_x43) {
5844
+ function selectWalletAsset(_x44) {
5596
5845
  return _selectWalletAsset.apply(this, arguments);
5597
5846
  }
5598
5847
  return selectWalletAsset;
@@ -5600,29 +5849,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5600
5849
  }, {
5601
5850
  key: "updateWalletAssetAmount",
5602
5851
  value: (function () {
5603
- var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
5852
+ var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
5604
5853
  var state;
5605
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5606
- while (1) switch (_context52.prev = _context52.next) {
5854
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5855
+ while (1) switch (_context54.prev = _context54.next) {
5607
5856
  case 0:
5608
5857
  if (this.store.payment) {
5609
- _context52.next = 2;
5858
+ _context54.next = 2;
5610
5859
  break;
5611
5860
  }
5612
5861
  throw new Error('payment 模块未初始化');
5613
5862
  case 2:
5614
5863
  state = this.store.payment.wallet.updateWalletAssetAmount(params.assetId, params.amount);
5615
- _context52.next = 5;
5864
+ _context54.next = 5;
5616
5865
  return this.syncSelectedWalletAssets(state);
5617
5866
  case 5:
5618
- return _context52.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5867
+ return _context54.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5619
5868
  case 6:
5620
5869
  case "end":
5621
- return _context52.stop();
5870
+ return _context54.stop();
5622
5871
  }
5623
- }, _callee52, this);
5872
+ }, _callee54, this);
5624
5873
  }));
5625
- function updateWalletAssetAmount(_x44) {
5874
+ function updateWalletAssetAmount(_x45) {
5626
5875
  return _updateWalletAssetAmount.apply(this, arguments);
5627
5876
  }
5628
5877
  return updateWalletAssetAmount;
@@ -5630,13 +5879,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5630
5879
  }, {
5631
5880
  key: "scanWalletAsset",
5632
5881
  value: (function () {
5633
- var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(code) {
5882
+ var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(code) {
5634
5883
  var wallet, businessData, result;
5635
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5636
- while (1) switch (_context53.prev = _context53.next) {
5884
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5885
+ while (1) switch (_context55.prev = _context55.next) {
5637
5886
  case 0:
5638
5887
  if (this.store.payment) {
5639
- _context53.next = 2;
5888
+ _context55.next = 2;
5640
5889
  break;
5641
5890
  }
5642
5891
  throw new Error('payment 模块未初始化');
@@ -5646,28 +5895,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5646
5895
  if (businessData) {
5647
5896
  wallet.generateWalletParams(businessData);
5648
5897
  }
5649
- _context53.next = 7;
5898
+ _context55.next = 7;
5650
5899
  return wallet.scanWalletAssetAsync(code);
5651
5900
  case 7:
5652
- result = _context53.sent;
5901
+ result = _context55.sent;
5653
5902
  if (!(result.type === 'normalCode')) {
5654
- _context53.next = 13;
5903
+ _context55.next = 13;
5655
5904
  break;
5656
5905
  }
5657
- _context53.next = 11;
5906
+ _context55.next = 11;
5658
5907
  return this.syncSelectedWalletAssets(result.state);
5659
5908
  case 11:
5660
- _context53.next = 13;
5909
+ _context55.next = 13;
5661
5910
  return this.publishWalletAssetsState(result.state, 'local');
5662
5911
  case 13:
5663
- return _context53.abrupt("return", result);
5912
+ return _context55.abrupt("return", result);
5664
5913
  case 14:
5665
5914
  case "end":
5666
- return _context53.stop();
5915
+ return _context55.stop();
5667
5916
  }
5668
- }, _callee53, this);
5917
+ }, _callee55, this);
5669
5918
  }));
5670
- function scanWalletAsset(_x45) {
5919
+ function scanWalletAsset(_x46) {
5671
5920
  return _scanWalletAsset.apply(this, arguments);
5672
5921
  }
5673
5922
  return scanWalletAsset;
@@ -5675,27 +5924,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5675
5924
  }, {
5676
5925
  key: "clearWalletAssetSelection",
5677
5926
  value: (function () {
5678
- var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
5927
+ var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56() {
5679
5928
  var state;
5680
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5681
- while (1) switch (_context54.prev = _context54.next) {
5929
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5930
+ while (1) switch (_context56.prev = _context56.next) {
5682
5931
  case 0:
5683
5932
  if (this.store.payment) {
5684
- _context54.next = 2;
5933
+ _context56.next = 2;
5685
5934
  break;
5686
5935
  }
5687
5936
  throw new Error('payment 模块未初始化');
5688
5937
  case 2:
5689
5938
  state = this.store.payment.wallet.clearWalletAssetSelection();
5690
- _context54.next = 5;
5939
+ _context56.next = 5;
5691
5940
  return this.syncSelectedWalletAssets(state);
5692
5941
  case 5:
5693
- return _context54.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5942
+ return _context56.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5694
5943
  case 6:
5695
5944
  case "end":
5696
- return _context54.stop();
5945
+ return _context56.stop();
5697
5946
  }
5698
- }, _callee54, this);
5947
+ }, _callee56, this);
5699
5948
  }));
5700
5949
  function clearWalletAssetSelection() {
5701
5950
  return _clearWalletAssetSelection.apply(this, arguments);
@@ -5712,11 +5961,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5712
5961
  }, {
5713
5962
  key: "updateOrderCustomer",
5714
5963
  value: function updateOrderCustomer(customer) {
5715
- 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;
5716
5965
  if (!this.store.order) throw new Error('order 模块未初始化');
5717
- 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));
5718
5967
  var result = this.store.order.updateTempOrderCustomer(customer);
5719
- 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));
5720
5969
  if (String(previousCustomerId) !== String(nextCustomerId)) {
5721
5970
  this.discountConfigCacheKey = null;
5722
5971
  this.hasManualDiscountSelection = false;
@@ -5732,35 +5981,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5732
5981
  }, {
5733
5982
  key: "getPaymentMethodsAsync",
5734
5983
  value: (function () {
5735
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
5984
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57() {
5736
5985
  var response, paymentMethods;
5737
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5738
- while (1) switch (_context55.prev = _context55.next) {
5986
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5987
+ while (1) switch (_context57.prev = _context57.next) {
5739
5988
  case 0:
5740
- _context55.prev = 0;
5741
- _context55.next = 3;
5989
+ _context57.prev = 0;
5990
+ _context57.next = 3;
5742
5991
  return this.request.get('/pay/custom-payment/all', {
5743
5992
  filterPaymentMethods: true
5744
5993
  }, {
5745
5994
  osServer: true
5746
5995
  });
5747
5996
  case 3:
5748
- response = _context55.sent;
5997
+ response = _context57.sent;
5749
5998
  paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
5750
5999
  this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
5751
- return _context55.abrupt("return", this.getPaymentMethods());
6000
+ return _context57.abrupt("return", this.getPaymentMethods());
5752
6001
  case 9:
5753
- _context55.prev = 9;
5754
- _context55.t0 = _context55["catch"](0);
6002
+ _context57.prev = 9;
6003
+ _context57.t0 = _context57["catch"](0);
5755
6004
  this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
5756
- error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
6005
+ error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0)
5757
6006
  });
5758
- return _context55.abrupt("return", this.getPaymentMethods());
6007
+ return _context57.abrupt("return", this.getPaymentMethods());
5759
6008
  case 13:
5760
6009
  case "end":
5761
- return _context55.stop();
6010
+ return _context57.stop();
5762
6011
  }
5763
- }, _callee55, this, [[0, 9]]);
6012
+ }, _callee57, this, [[0, 9]]);
5764
6013
  }));
5765
6014
  function getPaymentMethodsAsync() {
5766
6015
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -5791,15 +6040,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5791
6040
  }, {
5792
6041
  key: "getPendingWalletPaymentAmount",
5793
6042
  value: function getPendingWalletPaymentAmount() {
5794
- var _this$store$order23, _this$store$order23$g;
5795
- 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)) || [];
5796
6045
  return payments.reduce(function (total, payment) {
5797
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) {
5798
6047
  return total;
5799
6048
  }
5800
6049
  try {
5801
6050
  return total.plus(payment.amount || 0).plus(payment.rounding_amount || 0);
5802
- } catch (_unused6) {
6051
+ } catch (_unused8) {
5803
6052
  return total;
5804
6053
  }
5805
6054
  }, new Decimal(0));
@@ -5809,8 +6058,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5809
6058
  }, {
5810
6059
  key: "getCashPaymentConfig",
5811
6060
  value: (function () {
5812
- var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56() {
5813
- 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;
5814
6063
  var options,
5815
6064
  paymentMethods,
5816
6065
  paymentMethod,
@@ -5819,13 +6068,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5819
6068
  amountDue,
5820
6069
  currency,
5821
6070
  recommendedAmounts,
5822
- _args56 = arguments;
5823
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5824
- 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) {
5825
6074
  case 0:
5826
- options = _args56.length > 0 && _args56[0] !== undefined ? _args56[0] : {};
6075
+ options = _args58.length > 0 && _args58[0] !== undefined ? _args58[0] : {};
5827
6076
  if (this.store.payment) {
5828
- _context56.next = 3;
6077
+ _context58.next = 3;
5829
6078
  break;
5830
6079
  }
5831
6080
  throw new Error('payment 模块未初始化');
@@ -5833,27 +6082,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5833
6082
  paymentMethods = this.getPaymentMethods();
5834
6083
  paymentMethod = this.findCashPaymentMethod(paymentMethods, options.paymentMethodId);
5835
6084
  if (paymentMethod) {
5836
- _context56.next = 10;
6085
+ _context58.next = 10;
5837
6086
  break;
5838
6087
  }
5839
- _context56.next = 8;
6088
+ _context58.next = 8;
5840
6089
  return this.getPaymentMethodsAsync();
5841
6090
  case 8:
5842
- paymentMethods = _context56.sent;
6091
+ paymentMethods = _context58.sent;
5843
6092
  paymentMethod = this.findCashPaymentMethod(paymentMethods, options.paymentMethodId);
5844
6093
  case 10:
5845
6094
  if (!(!paymentMethod && options.paymentMethodId !== undefined)) {
5846
- _context56.next = 12;
6095
+ _context58.next = 12;
5847
6096
  break;
5848
6097
  }
5849
6098
  throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u73B0\u91D1\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(options.paymentMethodId));
5850
6099
  case 12:
5851
- 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);
5852
6101
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
5853
6102
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
5854
- 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';
5855
6104
  recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
5856
- return _context56.abrupt("return", {
6105
+ return _context58.abrupt("return", {
5857
6106
  available: Boolean(paymentMethod && amountDue > 0),
5858
6107
  paymentMethod: paymentMethod,
5859
6108
  amountDue: amountDue,
@@ -5861,9 +6110,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5861
6110
  });
5862
6111
  case 18:
5863
6112
  case "end":
5864
- return _context56.stop();
6113
+ return _context58.stop();
5865
6114
  }
5866
- }, _callee56, this);
6115
+ }, _callee58, this);
5867
6116
  }));
5868
6117
  function getCashPaymentConfig() {
5869
6118
  return _getCashPaymentConfig.apply(this, arguments);
@@ -5880,42 +6129,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5880
6129
  }, {
5881
6130
  key: "confirmWalletPayment",
5882
6131
  value: (function () {
5883
- var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57() {
5884
- var _this$store$order$get9, _this$store$order26, _this$store$order$get11, _this$store$order$get12, _this$store$order28;
5885
- var beforePayments, pendingWalletAmount, amountSnapshot, _this$store$order$get10, _this$store$order27, _submitResult, _latestAmountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
5886
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5887
- 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) {
5888
6137
  case 0:
5889
6138
  if (this.store.order) {
5890
- _context57.next = 2;
6139
+ _context59.next = 2;
5891
6140
  break;
5892
6141
  }
5893
6142
  throw new Error('order 模块未初始化');
5894
6143
  case 2:
5895
6144
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
5896
6145
  pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
5897
- 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);
5898
6147
  if (!pendingWalletAmount.lte(0)) {
5899
- _context57.next = 14;
6148
+ _context59.next = 14;
5900
6149
  break;
5901
6150
  }
5902
6151
  this.logWarning('confirmWalletPayment: 未发现待确认 Wallet 支付,跳过 Wallet 确认并按普通订单提交', {
5903
6152
  amountGap: amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap
5904
6153
  });
5905
- _context57.next = 9;
6154
+ _context59.next = 9;
5906
6155
  return this.submitSalesOrder({
5907
6156
  smallTicketDataFlag: 1
5908
6157
  });
5909
6158
  case 9:
5910
- _submitResult = _context57.sent;
6159
+ _submitResult = _context59.sent;
5911
6160
  if (!isRejectedSalesSubmitResult(_submitResult)) {
5912
- _context57.next = 12;
6161
+ _context59.next = 12;
5913
6162
  break;
5914
6163
  }
5915
6164
  throw new Error(getSalesSubmitErrorMessage(_submitResult, '订单提交失败'));
5916
6165
  case 12:
5917
- _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);
5918
- 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", {
5919
6168
  submitResult: _submitResult,
5920
6169
  payments: this.store.order.getOrderPayments(),
5921
6170
  isOrderFullyPaid: new Decimal((_latestAmountSnapshot === null || _latestAmountSnapshot === void 0 ? void 0 : _latestAmountSnapshot.amountGap) || 0).lte(0)
@@ -5923,74 +6172,74 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5923
6172
  case 14:
5924
6173
  effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
5925
6174
  if (!effectiveAmountDue.gt(0.01)) {
5926
- _context57.next = 17;
6175
+ _context59.next = 17;
5927
6176
  break;
5928
6177
  }
5929
6178
  throw new Error('Wallet 支付尚未覆盖全部待支付金额');
5930
6179
  case 17:
5931
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;
5932
- _context57.prev = 18;
5933
- _context57.next = 21;
6181
+ _context59.prev = 18;
6182
+ _context59.next = 21;
5934
6183
  return this.submitSalesOrder({
5935
6184
  smallTicketDataFlag: 1,
5936
6185
  confirmPendingVoucherPayments: true
5937
6186
  });
5938
6187
  case 21:
5939
- submitResult = _context57.sent;
6188
+ submitResult = _context59.sent;
5940
6189
  if (!isRejectedSalesSubmitResult(submitResult)) {
5941
- _context57.next = 24;
6190
+ _context59.next = 24;
5942
6191
  break;
5943
6192
  }
5944
6193
  throw new Error(getSalesSubmitErrorMessage(submitResult, 'Wallet 支付确认失败'));
5945
6194
  case 24:
5946
- _context57.next = 34;
6195
+ _context59.next = 34;
5947
6196
  break;
5948
6197
  case 26:
5949
- _context57.prev = 26;
5950
- _context57.t0 = _context57["catch"](18);
6198
+ _context59.prev = 26;
6199
+ _context59.t0 = _context59["catch"](18);
5951
6200
  this.store.order.setOrderPayments(beforePayments);
5952
6201
  restoredTempOrder = this.store.order.getTempOrder();
5953
6202
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
5954
6203
  restoredTempOrder.payment_status = beforePaymentStatus;
5955
6204
  this.store.order.persistTempOrder();
5956
6205
  }
5957
- _context57.next = 33;
6206
+ _context59.next = 33;
5958
6207
  return this.store.order.recalculateSummary({
5959
6208
  createIfMissing: true
5960
6209
  });
5961
6210
  case 33:
5962
- throw _context57.t0;
6211
+ throw _context59.t0;
5963
6212
  case 34:
5964
6213
  if (!this.store.payment) {
5965
- _context57.next = 45;
6214
+ _context59.next = 45;
5966
6215
  break;
5967
6216
  }
5968
- _context57.prev = 35;
6217
+ _context59.prev = 35;
5969
6218
  committed = this.getCommittedWalletAssets();
5970
6219
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
5971
- _context57.next = 40;
6220
+ _context59.next = 40;
5972
6221
  return this.publishWalletAssetsState(walletState, 'local');
5973
6222
  case 40:
5974
- _context57.next = 45;
6223
+ _context59.next = 45;
5975
6224
  break;
5976
6225
  case 42:
5977
- _context57.prev = 42;
5978
- _context57.t1 = _context57["catch"](35);
6226
+ _context59.prev = 42;
6227
+ _context59.t1 = _context59["catch"](35);
5979
6228
  this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
5980
- error: _context57.t1 instanceof Error ? _context57.t1.message : String(_context57.t1)
6229
+ error: _context59.t1 instanceof Error ? _context59.t1.message : String(_context59.t1)
5981
6230
  });
5982
6231
  case 45:
5983
- 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);
5984
- 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", {
5985
6234
  submitResult: submitResult,
5986
6235
  payments: this.store.order.getOrderPayments(),
5987
6236
  isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
5988
6237
  });
5989
6238
  case 47:
5990
6239
  case "end":
5991
- return _context57.stop();
6240
+ return _context59.stop();
5992
6241
  }
5993
- }, _callee57, this, [[18, 26], [35, 42]]);
6242
+ }, _callee59, this, [[18, 26], [35, 42]]);
5994
6243
  }));
5995
6244
  function confirmWalletPayment() {
5996
6245
  return _confirmWalletPayment.apply(this, arguments);
@@ -6005,53 +6254,53 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6005
6254
  }, {
6006
6255
  key: "payCash",
6007
6256
  value: (function () {
6008
- var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
6257
+ var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
6009
6258
  var _this$store$order$get13, _params$actualPaidAmo, _this$otherParams41, _this$window, _this$window$postMess;
6010
6259
  var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
6011
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
6012
- while (1) switch (_context58.prev = _context58.next) {
6260
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
6261
+ while (1) switch (_context60.prev = _context60.next) {
6013
6262
  case 0:
6014
6263
  if (this.store.order) {
6015
- _context58.next = 2;
6264
+ _context60.next = 2;
6016
6265
  break;
6017
6266
  }
6018
6267
  throw new Error('order 模块未初始化');
6019
6268
  case 2:
6020
6269
  amount = Number(params.amount || 0);
6021
6270
  if (!(!Number.isFinite(amount) || amount <= 0)) {
6022
- _context58.next = 5;
6271
+ _context60.next = 5;
6023
6272
  break;
6024
6273
  }
6025
6274
  throw new Error('现金支付金额必须大于 0');
6026
6275
  case 5:
6027
6276
  if (!(params.paymentMethodId === undefined)) {
6028
- _context58.next = 11;
6277
+ _context60.next = 11;
6029
6278
  break;
6030
6279
  }
6031
- _context58.next = 8;
6280
+ _context60.next = 8;
6032
6281
  return this.getCashPaymentConfig();
6033
6282
  case 8:
6034
- _context58.t0 = _context58.sent;
6035
- _context58.next = 14;
6283
+ _context60.t0 = _context60.sent;
6284
+ _context60.next = 14;
6036
6285
  break;
6037
6286
  case 11:
6038
- _context58.next = 13;
6287
+ _context60.next = 13;
6039
6288
  return this.getCashPaymentConfig({
6040
6289
  paymentMethodId: params.paymentMethodId
6041
6290
  });
6042
6291
  case 13:
6043
- _context58.t0 = _context58.sent;
6292
+ _context60.t0 = _context60.sent;
6044
6293
  case 14:
6045
- config = _context58.t0;
6294
+ config = _context60.t0;
6046
6295
  paymentMethod = config.paymentMethod;
6047
6296
  if (paymentMethod) {
6048
- _context58.next = 18;
6297
+ _context60.next = 18;
6049
6298
  break;
6050
6299
  }
6051
6300
  throw new Error('未找到可用的 CASHMANUAL 支付方式');
6052
6301
  case 18:
6053
6302
  if (!(config.amountDue <= 0)) {
6054
- _context58.next = 20;
6303
+ _context60.next = 20;
6055
6304
  break;
6056
6305
  }
6057
6306
  throw new Error('当前订单没有待支付金额');
@@ -6059,7 +6308,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6059
6308
  roundingAmount = Number(params.roundingAmount || 0);
6060
6309
  effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
6061
6310
  if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
6062
- _context58.next = 24;
6311
+ _context60.next = 24;
6063
6312
  break;
6064
6313
  }
6065
6314
  throw new Error('现金支付金额超过当前待支付金额');
@@ -6072,16 +6321,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6072
6321
  changeAmount = Number(params.changeAmount || 0);
6073
6322
  shopWalletPassId = (_this$otherParams41 = this.otherParams) === null || _this$otherParams41 === void 0 ? void 0 : _this$otherParams41.shop_wallet_pass_id;
6074
6323
  if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
6075
- _context58.next = 33;
6324
+ _context60.next = 33;
6076
6325
  break;
6077
6326
  }
6078
6327
  throw new Error('顾客实收现金不能小于支付金额');
6079
6328
  case 33:
6080
6329
  if (!this.isPickupTimingEnabled()) {
6081
- _context58.next = 36;
6330
+ _context60.next = 36;
6082
6331
  break;
6083
6332
  }
6084
- _context58.next = 36;
6333
+ _context60.next = 36;
6085
6334
  return this.preparePickupTimingForCheckout({
6086
6335
  freeze: true
6087
6336
  });
@@ -6116,8 +6365,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6116
6365
  var _item$metadata2;
6117
6366
  return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
6118
6367
  });
6119
- _context58.prev = 39;
6120
- _context58.next = 42;
6368
+ _context60.prev = 39;
6369
+ _context60.next = 42;
6121
6370
  return this.syncPaymentsToOrder({
6122
6371
  payments: payments,
6123
6372
  submitWhenPaid: true,
@@ -6125,50 +6374,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6125
6374
  confirmPendingVoucherPayments: true
6126
6375
  });
6127
6376
  case 42:
6128
- syncResult = _context58.sent;
6377
+ syncResult = _context60.sent;
6129
6378
  if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
6130
- _context58.next = 45;
6379
+ _context60.next = 45;
6131
6380
  break;
6132
6381
  }
6133
6382
  throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
6134
6383
  case 45:
6135
6384
  if (!this.store.payment) {
6136
- _context58.next = 50;
6385
+ _context60.next = 50;
6137
6386
  break;
6138
6387
  }
6139
6388
  committed = this.getCommittedWalletAssets();
6140
6389
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
6141
- _context58.next = 50;
6390
+ _context60.next = 50;
6142
6391
  return this.publishWalletAssetsState(walletState, 'local');
6143
6392
  case 50:
6144
- return _context58.abrupt("return", {
6393
+ return _context60.abrupt("return", {
6145
6394
  payment: payment || {},
6146
6395
  payments: this.store.order.getOrderPayments(),
6147
6396
  syncResult: syncResult,
6148
6397
  isOrderFullyPaid: syncResult.isOrderFullyPaid
6149
6398
  });
6150
6399
  case 53:
6151
- _context58.prev = 53;
6152
- _context58.t1 = _context58["catch"](39);
6400
+ _context60.prev = 53;
6401
+ _context60.t1 = _context60["catch"](39);
6153
6402
  this.store.order.setOrderPayments(beforePayments);
6154
6403
  restoredTempOrder = this.store.order.getTempOrder();
6155
6404
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
6156
6405
  restoredTempOrder.payment_status = beforePaymentStatus;
6157
6406
  this.store.order.persistTempOrder();
6158
6407
  }
6159
- _context58.next = 60;
6408
+ _context60.next = 60;
6160
6409
  return this.store.order.recalculateSummary({
6161
6410
  createIfMissing: true
6162
6411
  });
6163
6412
  case 60:
6164
- throw _context58.t1;
6413
+ throw _context60.t1;
6165
6414
  case 61:
6166
6415
  case "end":
6167
- return _context58.stop();
6416
+ return _context60.stop();
6168
6417
  }
6169
- }, _callee58, this, [[39, 53]]);
6418
+ }, _callee60, this, [[39, 53]]);
6170
6419
  }));
6171
- function payCash(_x46) {
6420
+ function payCash(_x47) {
6172
6421
  return _payCash.apply(this, arguments);
6173
6422
  }
6174
6423
  return payCash;
@@ -6184,21 +6433,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6184
6433
  }, {
6185
6434
  key: "commitPaymentMethodPayment",
6186
6435
  value: (function () {
6187
- var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
6188
- 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;
6189
6438
  var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
6190
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
6191
- while (1) switch (_context59.prev = _context59.next) {
6439
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6440
+ while (1) switch (_context61.prev = _context61.next) {
6192
6441
  case 0:
6193
6442
  if (this.store.order) {
6194
- _context59.next = 2;
6443
+ _context61.next = 2;
6195
6444
  break;
6196
6445
  }
6197
6446
  throw new Error('order 模块未初始化');
6198
6447
  case 2:
6199
6448
  amount = Number(params.amount || 0);
6200
6449
  if (!(!Number.isFinite(amount) || amount <= 0)) {
6201
- _context59.next = 5;
6450
+ _context61.next = 5;
6202
6451
  break;
6203
6452
  }
6204
6453
  throw new Error('支付金额必须大于 0');
@@ -6214,32 +6463,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6214
6463
  };
6215
6464
  paymentMethod = findPaymentMethod();
6216
6465
  if (paymentMethod) {
6217
- _context59.next = 13;
6466
+ _context61.next = 13;
6218
6467
  break;
6219
6468
  }
6220
- _context59.next = 11;
6469
+ _context61.next = 11;
6221
6470
  return this.getPaymentMethodsAsync();
6222
6471
  case 11:
6223
- paymentMethods = _context59.sent;
6472
+ paymentMethods = _context61.sent;
6224
6473
  paymentMethod = findPaymentMethod();
6225
6474
  case 13:
6226
6475
  if (paymentMethod) {
6227
- _context59.next = 15;
6476
+ _context61.next = 15;
6228
6477
  break;
6229
6478
  }
6230
6479
  throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
6231
6480
  case 15:
6232
- 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);
6233
6482
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
6234
6483
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
6235
6484
  if (!amountDue.lte(0)) {
6236
- _context59.next = 20;
6485
+ _context61.next = 20;
6237
6486
  break;
6238
6487
  }
6239
6488
  throw new Error('当前订单没有待支付金额');
6240
6489
  case 20:
6241
6490
  if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
6242
- _context59.next = 22;
6491
+ _context61.next = 22;
6243
6492
  break;
6244
6493
  }
6245
6494
  throw new Error('支付金额超过当前待支付金额');
@@ -6278,8 +6527,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6278
6527
  var _item$metadata3;
6279
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;
6280
6529
  });
6281
- _context59.prev = 30;
6282
- _context59.next = 33;
6530
+ _context61.prev = 30;
6531
+ _context61.next = 33;
6283
6532
  return this.syncPaymentsToOrder({
6284
6533
  payments: payments,
6285
6534
  submitWhenPaid: true,
@@ -6287,50 +6536,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6287
6536
  confirmPendingVoucherPayments: true
6288
6537
  });
6289
6538
  case 33:
6290
- syncResult = _context59.sent;
6539
+ syncResult = _context61.sent;
6291
6540
  if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
6292
- _context59.next = 36;
6541
+ _context61.next = 36;
6293
6542
  break;
6294
6543
  }
6295
6544
  throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
6296
6545
  case 36:
6297
6546
  if (!this.store.payment) {
6298
- _context59.next = 41;
6547
+ _context61.next = 41;
6299
6548
  break;
6300
6549
  }
6301
6550
  committed = this.getCommittedWalletAssets();
6302
6551
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
6303
- _context59.next = 41;
6552
+ _context61.next = 41;
6304
6553
  return this.publishWalletAssetsState(walletState, 'local');
6305
6554
  case 41:
6306
- return _context59.abrupt("return", {
6555
+ return _context61.abrupt("return", {
6307
6556
  payment: payment || {},
6308
6557
  payments: this.store.order.getOrderPayments(),
6309
6558
  syncResult: syncResult,
6310
6559
  isOrderFullyPaid: syncResult.isOrderFullyPaid
6311
6560
  });
6312
6561
  case 44:
6313
- _context59.prev = 44;
6314
- _context59.t0 = _context59["catch"](30);
6562
+ _context61.prev = 44;
6563
+ _context61.t0 = _context61["catch"](30);
6315
6564
  this.store.order.setOrderPayments(beforePayments);
6316
6565
  restoredTempOrder = this.store.order.getTempOrder();
6317
6566
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
6318
6567
  restoredTempOrder.payment_status = beforePaymentStatus;
6319
6568
  this.store.order.persistTempOrder();
6320
6569
  }
6321
- _context59.next = 51;
6570
+ _context61.next = 51;
6322
6571
  return this.store.order.recalculateSummary({
6323
6572
  createIfMissing: true
6324
6573
  });
6325
6574
  case 51:
6326
- throw _context59.t0;
6575
+ throw _context61.t0;
6327
6576
  case 52:
6328
6577
  case "end":
6329
- return _context59.stop();
6578
+ return _context61.stop();
6330
6579
  }
6331
- }, _callee59, this, [[30, 44]]);
6580
+ }, _callee61, this, [[30, 44]]);
6332
6581
  }));
6333
- function commitPaymentMethodPayment(_x47) {
6582
+ function commitPaymentMethodPayment(_x48) {
6334
6583
  return _commitPaymentMethodPayment.apply(this, arguments);
6335
6584
  }
6336
6585
  return commitPaymentMethodPayment;
@@ -6345,40 +6594,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6345
6594
  }, {
6346
6595
  key: "roundAmount",
6347
6596
  value: (function () {
6348
- var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
6597
+ var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
6349
6598
  var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
6350
6599
  var amount, cashManualPayment;
6351
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
6352
- while (1) switch (_context60.prev = _context60.next) {
6600
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6601
+ while (1) switch (_context62.prev = _context62.next) {
6353
6602
  case 0:
6354
6603
  amount = params.amount;
6355
6604
  cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
6356
6605
  return paymentMethod.code === 'CASHMANUAL';
6357
6606
  });
6358
6607
  if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
6359
- _context60.next = 4;
6608
+ _context62.next = 4;
6360
6609
  break;
6361
6610
  }
6362
- return _context60.abrupt("return", {
6611
+ return _context62.abrupt("return", {
6363
6612
  originalAmount: amount.toString(),
6364
6613
  roundedAmount: amount.toString(),
6365
6614
  roundingDifference: '0.00'
6366
6615
  });
6367
6616
  case 4:
6368
6617
  if (this.payment) {
6369
- _context60.next = 6;
6618
+ _context62.next = 6;
6370
6619
  break;
6371
6620
  }
6372
6621
  throw new Error('payment 模块未初始化');
6373
6622
  case 6:
6374
- 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));
6375
6624
  case 7:
6376
6625
  case "end":
6377
- return _context60.stop();
6626
+ return _context62.stop();
6378
6627
  }
6379
- }, _callee60, this);
6628
+ }, _callee62, this);
6380
6629
  }));
6381
- function roundAmount(_x48) {
6630
+ function roundAmount(_x49) {
6382
6631
  return _roundAmount.apply(this, arguments);
6383
6632
  }
6384
6633
  return roundAmount;
@@ -6393,49 +6642,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6393
6642
  }, {
6394
6643
  key: "sendCustomerPayLink",
6395
6644
  value: (function () {
6396
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
6645
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
6397
6646
  var orderIds, _ref53, _ref54, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
6398
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6399
- while (1) switch (_context61.prev = _context61.next) {
6647
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6648
+ while (1) switch (_context63.prev = _context63.next) {
6400
6649
  case 0:
6401
6650
  if (this.store.order) {
6402
- _context61.next = 2;
6651
+ _context63.next = 2;
6403
6652
  break;
6404
6653
  }
6405
6654
  throw new Error('order 模块未初始化');
6406
6655
  case 2:
6407
6656
  orderIds = params.order_ids || params.orderIds || [];
6408
6657
  if (!(!orderIds.length || params.submitBeforeSend)) {
6409
- _context61.next = 11;
6658
+ _context63.next = 11;
6410
6659
  break;
6411
6660
  }
6412
- _context61.next = 6;
6661
+ _context63.next = 6;
6413
6662
  return this.submitSalesOrder({
6414
6663
  smallTicketDataFlag: 1
6415
6664
  });
6416
6665
  case 6:
6417
- submitResult = _context61.sent;
6666
+ submitResult = _context63.sent;
6418
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;
6419
6668
  if (orderId) {
6420
- _context61.next = 10;
6669
+ _context63.next = 10;
6421
6670
  break;
6422
6671
  }
6423
6672
  throw new Error('本地订单提交云端失败,无法发送支付链接');
6424
6673
  case 10:
6425
6674
  orderIds = [orderId];
6426
6675
  case 11:
6427
- return _context61.abrupt("return", this.store.order.sendCustomerPayLink({
6676
+ return _context63.abrupt("return", this.store.order.sendCustomerPayLink({
6428
6677
  emails: params.emails,
6429
6678
  notify_action: params.notify_action,
6430
6679
  order_ids: orderIds
6431
6680
  }));
6432
6681
  case 12:
6433
6682
  case "end":
6434
- return _context61.stop();
6683
+ return _context63.stop();
6435
6684
  }
6436
- }, _callee61, this);
6685
+ }, _callee63, this);
6437
6686
  }));
6438
- function sendCustomerPayLink(_x49) {
6687
+ function sendCustomerPayLink(_x50) {
6439
6688
  return _sendCustomerPayLink.apply(this, arguments);
6440
6689
  }
6441
6690
  return sendCustomerPayLink;
@@ -6448,20 +6697,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6448
6697
  }, {
6449
6698
  key: "calculateProductBookingPrice",
6450
6699
  value: function () {
6451
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
6700
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
6452
6701
  var _params$customer_id;
6453
6702
  var useCustomerUserPricing, quotation, customerId, channel, _yield$this$resolvePr, _yield$this$resolvePr2, authoritativeProduct, product;
6454
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6455
- while (1) switch (_context62.prev = _context62.next) {
6703
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6704
+ while (1) switch (_context64.prev = _context64.next) {
6456
6705
  case 0:
6457
6706
  useCustomerUserPricing = this.isCustomerUserPriceQuery();
6458
6707
  quotation = useCustomerUserPricing ? undefined : this.store.quotation;
6459
6708
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
6460
- _context62.next = 5;
6709
+ _context64.next = 5;
6461
6710
  return this.prepareProductPriceQueryContext(customerId);
6462
6711
  case 5:
6463
6712
  channel = this.getPriceQueryChannel(params.channel);
6464
- _context62.next = 8;
6713
+ _context64.next = 8;
6465
6714
  return this.resolveProductsForPriceQuery({
6466
6715
  priceQueries: [params],
6467
6716
  schedule: this.getPriceQuerySchedule(params),
@@ -6469,22 +6718,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6469
6718
  channel: channel
6470
6719
  });
6471
6720
  case 8:
6472
- _yield$this$resolvePr = _context62.sent;
6721
+ _yield$this$resolvePr = _context64.sent;
6473
6722
  _yield$this$resolvePr2 = _slicedToArray(_yield$this$resolvePr, 1);
6474
6723
  authoritativeProduct = _yield$this$resolvePr2[0];
6475
6724
  product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
6476
6725
  if (useCustomerUserPricing) {
6477
- _context62.next = 15;
6726
+ _context64.next = 15;
6478
6727
  break;
6479
6728
  }
6480
- _context62.next = 15;
6729
+ _context64.next = 15;
6481
6730
  return this.loadQuotationForPriceQuery({
6482
6731
  quotation: quotation,
6483
6732
  customer_id: customerId,
6484
6733
  channel: channel
6485
6734
  });
6486
6735
  case 15:
6487
- return _context62.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
6736
+ return _context64.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
6488
6737
  channel: channel,
6489
6738
  product: product,
6490
6739
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
@@ -6493,11 +6742,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6493
6742
  })));
6494
6743
  case 16:
6495
6744
  case "end":
6496
- return _context62.stop();
6745
+ return _context64.stop();
6497
6746
  }
6498
- }, _callee62, this);
6747
+ }, _callee64, this);
6499
6748
  }));
6500
- function calculateProductBookingPrice(_x50) {
6749
+ function calculateProductBookingPrice(_x51) {
6501
6750
  return _calculateProductBookingPrice.apply(this, arguments);
6502
6751
  }
6503
6752
  return calculateProductBookingPrice;
@@ -6544,8 +6793,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6544
6793
  }, {
6545
6794
  key: "hasSmartPricingStrategies",
6546
6795
  value: function hasSmartPricingStrategies() {
6547
- var _this$core6;
6548
- 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;
6549
6798
  if (!evaluator || typeof evaluator.getStrategyConfigs !== 'function') {
6550
6799
  return false;
6551
6800
  }
@@ -6581,17 +6830,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6581
6830
  }, {
6582
6831
  key: "calculateProductBookingPrices",
6583
6832
  value: function () {
6584
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(paramsList) {
6833
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(paramsList) {
6585
6834
  var _this22 = this;
6586
6835
  var useCustomerUserPricing, quotation, currentOrderCustomerId, resolvedChannels, authoritativeProducts, groups, quotationContexts;
6587
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6588
- while (1) switch (_context64.prev = _context64.next) {
6836
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6837
+ while (1) switch (_context66.prev = _context66.next) {
6589
6838
  case 0:
6590
6839
  if (paramsList.length) {
6591
- _context64.next = 2;
6840
+ _context66.next = 2;
6592
6841
  break;
6593
6842
  }
6594
- return _context64.abrupt("return", []);
6843
+ return _context66.abrupt("return", []);
6595
6844
  case 2:
6596
6845
  useCustomerUserPricing = this.isCustomerUserPriceQuery();
6597
6846
  quotation = useCustomerUserPricing ? undefined : this.store.quotation;
@@ -6618,20 +6867,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6618
6867
  group.indices.push(index);
6619
6868
  groups.set(groupKey, group);
6620
6869
  });
6621
- _context64.next = 11;
6870
+ _context66.next = 11;
6622
6871
  return Promise.all(Array.from(groups.values()).map( /*#__PURE__*/function () {
6623
- var _ref55 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(group) {
6872
+ var _ref55 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(group) {
6624
6873
  var priceQueries, resolvedProducts;
6625
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6626
- while (1) switch (_context63.prev = _context63.next) {
6874
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6875
+ while (1) switch (_context65.prev = _context65.next) {
6627
6876
  case 0:
6628
- _context63.next = 2;
6877
+ _context65.next = 2;
6629
6878
  return _this22.prepareProductPriceQueryContext(group.customerId);
6630
6879
  case 2:
6631
6880
  priceQueries = group.indices.map(function (index) {
6632
6881
  return paramsList[index];
6633
6882
  });
6634
- _context63.next = 5;
6883
+ _context65.next = 5;
6635
6884
  return _this22.resolveProductsForPriceQuery({
6636
6885
  priceQueries: priceQueries,
6637
6886
  schedule: group.schedule,
@@ -6639,23 +6888,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6639
6888
  channel: group.channel
6640
6889
  });
6641
6890
  case 5:
6642
- resolvedProducts = _context63.sent;
6891
+ resolvedProducts = _context65.sent;
6643
6892
  group.indices.forEach(function (originalIndex, groupIndex) {
6644
6893
  authoritativeProducts[originalIndex] = resolvedProducts[groupIndex] || null;
6645
6894
  });
6646
6895
  case 7:
6647
6896
  case "end":
6648
- return _context63.stop();
6897
+ return _context65.stop();
6649
6898
  }
6650
- }, _callee63);
6899
+ }, _callee65);
6651
6900
  }));
6652
- return function (_x52) {
6901
+ return function (_x53) {
6653
6902
  return _ref55.apply(this, arguments);
6654
6903
  };
6655
6904
  }()));
6656
6905
  case 11:
6657
6906
  if (useCustomerUserPricing) {
6658
- _context64.next = 16;
6907
+ _context66.next = 16;
6659
6908
  break;
6660
6909
  }
6661
6910
  quotationContexts = new Map();
@@ -6669,14 +6918,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6669
6918
  customer_id: (_params$customer_id3 = params.customer_id) !== null && _params$customer_id3 !== void 0 ? _params$customer_id3 : currentOrderCustomerId
6670
6919
  });
6671
6920
  });
6672
- _context64.next = 16;
6921
+ _context66.next = 16;
6673
6922
  return Promise.all(Array.from(quotationContexts.values()).map(function (context) {
6674
6923
  return _this22.loadQuotationForPriceQuery(_objectSpread({
6675
6924
  quotation: quotation
6676
6925
  }, context));
6677
6926
  }));
6678
6927
  case 16:
6679
- return _context64.abrupt("return", paramsList.map(function (params, index) {
6928
+ return _context66.abrupt("return", paramsList.map(function (params, index) {
6680
6929
  var _params$customer_id4;
6681
6930
  var productInput = params.product || {};
6682
6931
  var authoritativeProduct = authoritativeProducts[index];
@@ -6693,11 +6942,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6693
6942
  }));
6694
6943
  case 17:
6695
6944
  case "end":
6696
- return _context64.stop();
6945
+ return _context66.stop();
6697
6946
  }
6698
- }, _callee64, this);
6947
+ }, _callee66, this);
6699
6948
  }));
6700
- function calculateProductBookingPrices(_x51) {
6949
+ function calculateProductBookingPrices(_x52) {
6701
6950
  return _calculateProductBookingPrices.apply(this, arguments);
6702
6951
  }
6703
6952
  return calculateProductBookingPrices;
@@ -6705,47 +6954,47 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6705
6954
  }, {
6706
6955
  key: "addProductToOrder",
6707
6956
  value: function () {
6708
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(product, booking, options) {
6957
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(product, booking, options) {
6709
6958
  var products;
6710
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6711
- while (1) switch (_context65.prev = _context65.next) {
6959
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6960
+ while (1) switch (_context67.prev = _context67.next) {
6712
6961
  case 0:
6713
- _context65.prev = 0;
6962
+ _context67.prev = 0;
6714
6963
  if (this.store.order) {
6715
- _context65.next = 3;
6964
+ _context67.next = 3;
6716
6965
  break;
6717
6966
  }
6718
6967
  throw new Error('order 模块未初始化');
6719
6968
  case 3:
6720
6969
  if (!(options === undefined)) {
6721
- _context65.next = 9;
6970
+ _context67.next = 9;
6722
6971
  break;
6723
6972
  }
6724
- _context65.next = 6;
6973
+ _context67.next = 6;
6725
6974
  return this.store.order.addProductToOrder(product, booking);
6726
6975
  case 6:
6727
- _context65.t0 = _context65.sent;
6728
- _context65.next = 12;
6976
+ _context67.t0 = _context67.sent;
6977
+ _context67.next = 12;
6729
6978
  break;
6730
6979
  case 9:
6731
- _context65.next = 11;
6980
+ _context67.next = 11;
6732
6981
  return this.store.order.addProductToOrder(product, booking, options);
6733
6982
  case 11:
6734
- _context65.t0 = _context65.sent;
6983
+ _context67.t0 = _context67.sent;
6735
6984
  case 12:
6736
- products = _context65.t0;
6737
- return _context65.abrupt("return", products);
6985
+ products = _context67.t0;
6986
+ return _context67.abrupt("return", products);
6738
6987
  case 16:
6739
- _context65.prev = 16;
6740
- _context65.t1 = _context65["catch"](0);
6741
- throw _context65.t1;
6988
+ _context67.prev = 16;
6989
+ _context67.t1 = _context67["catch"](0);
6990
+ throw _context67.t1;
6742
6991
  case 19:
6743
6992
  case "end":
6744
- return _context65.stop();
6993
+ return _context67.stop();
6745
6994
  }
6746
- }, _callee65, this, [[0, 16]]);
6995
+ }, _callee67, this, [[0, 16]]);
6747
6996
  }));
6748
- function addProductToOrder(_x53, _x54, _x55) {
6997
+ function addProductToOrder(_x54, _x55, _x56) {
6749
6998
  return _addProductToOrder.apply(this, arguments);
6750
6999
  }
6751
7000
  return addProductToOrder;
@@ -6753,34 +7002,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6753
7002
  }, {
6754
7003
  key: "updateOrderProduct",
6755
7004
  value: function () {
6756
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(params) {
7005
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(params) {
6757
7006
  var products;
6758
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6759
- while (1) switch (_context66.prev = _context66.next) {
7007
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
7008
+ while (1) switch (_context68.prev = _context68.next) {
6760
7009
  case 0:
6761
- _context66.prev = 0;
7010
+ _context68.prev = 0;
6762
7011
  if (this.store.order) {
6763
- _context66.next = 3;
7012
+ _context68.next = 3;
6764
7013
  break;
6765
7014
  }
6766
7015
  throw new Error('order 模块未初始化');
6767
7016
  case 3:
6768
- _context66.next = 5;
7017
+ _context68.next = 5;
6769
7018
  return this.store.order.updateOrderProduct(params);
6770
7019
  case 5:
6771
- products = _context66.sent;
6772
- return _context66.abrupt("return", products);
7020
+ products = _context68.sent;
7021
+ return _context68.abrupt("return", products);
6773
7022
  case 9:
6774
- _context66.prev = 9;
6775
- _context66.t0 = _context66["catch"](0);
6776
- throw _context66.t0;
7023
+ _context68.prev = 9;
7024
+ _context68.t0 = _context68["catch"](0);
7025
+ throw _context68.t0;
6777
7026
  case 12:
6778
7027
  case "end":
6779
- return _context66.stop();
7028
+ return _context68.stop();
6780
7029
  }
6781
- }, _callee66, this, [[0, 9]]);
7030
+ }, _callee68, this, [[0, 9]]);
6782
7031
  }));
6783
- function updateOrderProduct(_x56) {
7032
+ function updateOrderProduct(_x57) {
6784
7033
  return _updateOrderProduct.apply(this, arguments);
6785
7034
  }
6786
7035
  return updateOrderProduct;
@@ -6788,34 +7037,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6788
7037
  }, {
6789
7038
  key: "updateOrderProducts",
6790
7039
  value: function () {
6791
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(paramsList) {
7040
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(paramsList) {
6792
7041
  var products;
6793
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6794
- while (1) switch (_context67.prev = _context67.next) {
7042
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
7043
+ while (1) switch (_context69.prev = _context69.next) {
6795
7044
  case 0:
6796
- _context67.prev = 0;
7045
+ _context69.prev = 0;
6797
7046
  if (this.store.order) {
6798
- _context67.next = 3;
7047
+ _context69.next = 3;
6799
7048
  break;
6800
7049
  }
6801
7050
  throw new Error('order 模块未初始化');
6802
7051
  case 3:
6803
- _context67.next = 5;
7052
+ _context69.next = 5;
6804
7053
  return this.store.order.updateOrderProducts(paramsList);
6805
7054
  case 5:
6806
- products = _context67.sent;
6807
- return _context67.abrupt("return", products);
7055
+ products = _context69.sent;
7056
+ return _context69.abrupt("return", products);
6808
7057
  case 9:
6809
- _context67.prev = 9;
6810
- _context67.t0 = _context67["catch"](0);
6811
- throw _context67.t0;
7058
+ _context69.prev = 9;
7059
+ _context69.t0 = _context69["catch"](0);
7060
+ throw _context69.t0;
6812
7061
  case 12:
6813
7062
  case "end":
6814
- return _context67.stop();
7063
+ return _context69.stop();
6815
7064
  }
6816
- }, _callee67, this, [[0, 9]]);
7065
+ }, _callee69, this, [[0, 9]]);
6817
7066
  }));
6818
- function updateOrderProducts(_x57) {
7067
+ function updateOrderProducts(_x58) {
6819
7068
  return _updateOrderProducts.apply(this, arguments);
6820
7069
  }
6821
7070
  return updateOrderProducts;
@@ -6823,34 +7072,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6823
7072
  }, {
6824
7073
  key: "updateOrderProductQuantity",
6825
7074
  value: function () {
6826
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(params) {
7075
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
6827
7076
  var products;
6828
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6829
- while (1) switch (_context68.prev = _context68.next) {
7077
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
7078
+ while (1) switch (_context70.prev = _context70.next) {
6830
7079
  case 0:
6831
- _context68.prev = 0;
7080
+ _context70.prev = 0;
6832
7081
  if (this.store.order) {
6833
- _context68.next = 3;
7082
+ _context70.next = 3;
6834
7083
  break;
6835
7084
  }
6836
7085
  throw new Error('order 模块未初始化');
6837
7086
  case 3:
6838
- _context68.next = 5;
7087
+ _context70.next = 5;
6839
7088
  return this.store.order.updateOrderProductQuantity(params);
6840
7089
  case 5:
6841
- products = _context68.sent;
6842
- return _context68.abrupt("return", products);
7090
+ products = _context70.sent;
7091
+ return _context70.abrupt("return", products);
6843
7092
  case 9:
6844
- _context68.prev = 9;
6845
- _context68.t0 = _context68["catch"](0);
6846
- throw _context68.t0;
7093
+ _context70.prev = 9;
7094
+ _context70.t0 = _context70["catch"](0);
7095
+ throw _context70.t0;
6847
7096
  case 12:
6848
7097
  case "end":
6849
- return _context68.stop();
7098
+ return _context70.stop();
6850
7099
  }
6851
- }, _callee68, this, [[0, 9]]);
7100
+ }, _callee70, this, [[0, 9]]);
6852
7101
  }));
6853
- function updateOrderProductQuantity(_x58) {
7102
+ function updateOrderProductQuantity(_x59) {
6854
7103
  return _updateOrderProductQuantity.apply(this, arguments);
6855
7104
  }
6856
7105
  return updateOrderProductQuantity;
@@ -6873,12 +7122,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6873
7122
  }, {
6874
7123
  key: "setOrderProductLineNote",
6875
7124
  value: (function () {
6876
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(identity, note) {
7125
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(identity, note) {
6877
7126
  var params, products;
6878
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6879
- while (1) switch (_context69.prev = _context69.next) {
7127
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7128
+ while (1) switch (_context71.prev = _context71.next) {
6880
7129
  case 0:
6881
- _context69.prev = 0;
7130
+ _context71.prev = 0;
6882
7131
  params = {
6883
7132
  product_id: identity.product_id,
6884
7133
  product_variant_id: identity.product_variant_id,
@@ -6893,22 +7142,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6893
7142
  params.product_sku = identity.product_sku;
6894
7143
  }
6895
7144
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
6896
- _context69.next = 7;
7145
+ _context71.next = 7;
6897
7146
  return this.updateOrderProduct(params);
6898
7147
  case 7:
6899
- products = _context69.sent;
6900
- return _context69.abrupt("return", products);
7148
+ products = _context71.sent;
7149
+ return _context71.abrupt("return", products);
6901
7150
  case 11:
6902
- _context69.prev = 11;
6903
- _context69.t0 = _context69["catch"](0);
6904
- throw _context69.t0;
7151
+ _context71.prev = 11;
7152
+ _context71.t0 = _context71["catch"](0);
7153
+ throw _context71.t0;
6905
7154
  case 14:
6906
7155
  case "end":
6907
- return _context69.stop();
7156
+ return _context71.stop();
6908
7157
  }
6909
- }, _callee69, this, [[0, 11]]);
7158
+ }, _callee71, this, [[0, 11]]);
6910
7159
  }));
6911
- function setOrderProductLineNote(_x59, _x60) {
7160
+ function setOrderProductLineNote(_x60, _x61) {
6912
7161
  return _setOrderProductLineNote.apply(this, arguments);
6913
7162
  }
6914
7163
  return setOrderProductLineNote;
@@ -6923,45 +7172,45 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6923
7172
  }, {
6924
7173
  key: "removeProductsFromOrder",
6925
7174
  value: (function () {
6926
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(identities, options) {
6927
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
6928
- 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) {
6929
7178
  case 0:
6930
- _context70.prev = 0;
7179
+ _context72.prev = 0;
6931
7180
  if (this.store.order) {
6932
- _context70.next = 3;
7181
+ _context72.next = 3;
6933
7182
  break;
6934
7183
  }
6935
7184
  throw new Error('order 模块未初始化');
6936
7185
  case 3:
6937
7186
  if (!(options === undefined)) {
6938
- _context70.next = 9;
7187
+ _context72.next = 9;
6939
7188
  break;
6940
7189
  }
6941
- _context70.next = 6;
7190
+ _context72.next = 6;
6942
7191
  return this.store.order.removeProductsFromOrder(identities);
6943
7192
  case 6:
6944
- _context70.t0 = _context70.sent;
6945
- _context70.next = 12;
7193
+ _context72.t0 = _context72.sent;
7194
+ _context72.next = 12;
6946
7195
  break;
6947
7196
  case 9:
6948
- _context70.next = 11;
7197
+ _context72.next = 11;
6949
7198
  return this.store.order.removeProductsFromOrder(identities, options);
6950
7199
  case 11:
6951
- _context70.t0 = _context70.sent;
7200
+ _context72.t0 = _context72.sent;
6952
7201
  case 12:
6953
- return _context70.abrupt("return", _context70.t0);
7202
+ return _context72.abrupt("return", _context72.t0);
6954
7203
  case 15:
6955
- _context70.prev = 15;
6956
- _context70.t1 = _context70["catch"](0);
6957
- throw _context70.t1;
7204
+ _context72.prev = 15;
7205
+ _context72.t1 = _context72["catch"](0);
7206
+ throw _context72.t1;
6958
7207
  case 18:
6959
7208
  case "end":
6960
- return _context70.stop();
7209
+ return _context72.stop();
6961
7210
  }
6962
- }, _callee70, this, [[0, 15]]);
7211
+ }, _callee72, this, [[0, 15]]);
6963
7212
  }));
6964
- function removeProductsFromOrder(_x61, _x62) {
7213
+ function removeProductsFromOrder(_x62, _x63) {
6965
7214
  return _removeProductsFromOrder.apply(this, arguments);
6966
7215
  }
6967
7216
  return removeProductsFromOrder;
@@ -6969,18 +7218,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6969
7218
  }, {
6970
7219
  key: "removeProductFromOrder",
6971
7220
  value: function () {
6972
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(identity, options) {
6973
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
6974
- 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) {
6975
7224
  case 0:
6976
- return _context71.abrupt("return", this.removeProductsFromOrder([identity], options));
7225
+ return _context73.abrupt("return", this.removeProductsFromOrder([identity], options));
6977
7226
  case 1:
6978
7227
  case "end":
6979
- return _context71.stop();
7228
+ return _context73.stop();
6980
7229
  }
6981
- }, _callee71, this);
7230
+ }, _callee73, this);
6982
7231
  }));
6983
- function removeProductFromOrder(_x63, _x64) {
7232
+ function removeProductFromOrder(_x64, _x65) {
6984
7233
  return _removeProductFromOrder.apply(this, arguments);
6985
7234
  }
6986
7235
  return removeProductFromOrder;
@@ -7030,23 +7279,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7030
7279
  }, {
7031
7280
  key: "applyPromotion",
7032
7281
  value: (function () {
7033
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72() {
7034
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7035
- 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) {
7036
7285
  case 0:
7037
7286
  if (this.store.order) {
7038
- _context72.next = 2;
7287
+ _context74.next = 2;
7039
7288
  break;
7040
7289
  }
7041
7290
  throw new Error('order 模块未初始化');
7042
7291
  case 2:
7043
- _context72.next = 4;
7292
+ _context74.next = 4;
7044
7293
  return this.store.order.applyPromotion();
7045
7294
  case 4:
7046
7295
  case "end":
7047
- return _context72.stop();
7296
+ return _context74.stop();
7048
7297
  }
7049
- }, _callee72, this);
7298
+ }, _callee74, this);
7050
7299
  }));
7051
7300
  function applyPromotion() {
7052
7301
  return _applyPromotion.apply(this, arguments);
@@ -7056,16 +7305,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7056
7305
  }, {
7057
7306
  key: "getUnfulfilledPromotions",
7058
7307
  value: function getUnfulfilledPromotions() {
7059
- var _this$store$order30;
7060
- 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()) || [];
7061
7310
  }
7062
7311
 
7063
7312
  /** 最近一次促销计算输出的赠品操作 diff。 */
7064
7313
  }, {
7065
7314
  key: "getLastGiftActions",
7066
7315
  value: function getLastGiftActions() {
7067
- var _this$store$order31;
7068
- 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;
7069
7318
  }
7070
7319
 
7071
7320
  // 获取商品列表
@@ -7073,18 +7322,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7073
7322
  }, {
7074
7323
  key: "getProductList",
7075
7324
  value: function () {
7076
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73() {
7325
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75() {
7077
7326
  var _this$otherParams42;
7078
7327
  var menu_list_ids, _this$store$products, res;
7079
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7080
- while (1) switch (_context73.prev = _context73.next) {
7328
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7329
+ while (1) switch (_context75.prev = _context75.next) {
7081
7330
  case 0:
7082
7331
  // 可以直接通过配置里的 menu 读取
7083
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) {
7084
7333
  return Number(n.value);
7085
7334
  })) || [];
7086
- _context73.prev = 1;
7087
- _context73.next = 4;
7335
+ _context75.prev = 1;
7336
+ _context75.next = 4;
7088
7337
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
7089
7338
  menu_list_ids: menu_list_ids,
7090
7339
  cacheId: this.cacheId,
@@ -7092,17 +7341,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7092
7341
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
7093
7342
  });
7094
7343
  case 4:
7095
- res = _context73.sent;
7096
- return _context73.abrupt("return", res);
7344
+ res = _context75.sent;
7345
+ return _context75.abrupt("return", res);
7097
7346
  case 8:
7098
- _context73.prev = 8;
7099
- _context73.t0 = _context73["catch"](1);
7100
- throw _context73.t0;
7347
+ _context75.prev = 8;
7348
+ _context75.t0 = _context75["catch"](1);
7349
+ throw _context75.t0;
7101
7350
  case 11:
7102
7351
  case "end":
7103
- return _context73.stop();
7352
+ return _context75.stop();
7104
7353
  }
7105
- }, _callee73, this, [[1, 8]]);
7354
+ }, _callee75, this, [[1, 8]]);
7106
7355
  }));
7107
7356
  function getProductList() {
7108
7357
  return _getProductList.apply(this, arguments);
@@ -7117,17 +7366,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7117
7366
  }, {
7118
7367
  key: "setOtherParams",
7119
7368
  value: function () {
7120
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(params) {
7369
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(params) {
7121
7370
  var _this$otherParams43;
7122
7371
  var _ref56,
7123
7372
  _ref56$cover,
7124
7373
  cover,
7125
7374
  previousPickupTimingScope,
7126
- _args74 = arguments;
7127
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7128
- 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) {
7129
7378
  case 0:
7130
- _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;
7131
7380
  previousPickupTimingScope = this.getPickupTimingScope();
7132
7381
  if (cover) {
7133
7382
  this.otherParams = _objectSpread({}, params);
@@ -7136,17 +7385,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7136
7385
  }
7137
7386
  this.cacheId = (_this$otherParams43 = this.otherParams) === null || _this$otherParams43 === void 0 ? void 0 : _this$otherParams43.cacheId;
7138
7387
  if (previousPickupTimingScope !== this.getPickupTimingScope()) this.resetPickupTimingCache();
7139
- _context74.next = 7;
7388
+ _context76.next = 7;
7140
7389
  return this.syncOtherParamsToSubModules(params, {
7141
7390
  cover: cover
7142
7391
  });
7143
7392
  case 7:
7144
7393
  case "end":
7145
- return _context74.stop();
7394
+ return _context76.stop();
7146
7395
  }
7147
- }, _callee74, this);
7396
+ }, _callee76, this);
7148
7397
  }));
7149
- function setOtherParams(_x65) {
7398
+ function setOtherParams(_x66) {
7150
7399
  return _setOtherParams.apply(this, arguments);
7151
7400
  }
7152
7401
  return setOtherParams;