@pisell/pisellos 2.3.232 → 2.3.234

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/modules/Customer/types.d.ts +4 -0
  2. package/dist/modules/Order/index.d.ts +10 -0
  3. package/dist/modules/Order/index.js +1392 -1157
  4. package/dist/modules/Order/types.d.ts +3 -0
  5. package/dist/modules/Order/utils/bookingUuid.d.ts +4 -0
  6. package/dist/modules/Order/utils/bookingUuid.js +24 -0
  7. package/dist/modules/Order/utils/virtualSettlement.d.ts +4 -0
  8. package/dist/modules/Order/utils/virtualSettlement.js +13 -0
  9. package/dist/modules/Order/utils.d.ts +1 -0
  10. package/dist/modules/Order/utils.js +12 -6
  11. package/dist/shared/payment/loadPaymentMethods.d.ts +5 -1
  12. package/dist/shared/payment/loadPaymentMethods.js +36 -2
  13. package/dist/solution/BaseSales/index.d.ts +4 -0
  14. package/dist/solution/BaseSales/index.js +571 -435
  15. package/dist/solution/BookingTicket/index.d.ts +3 -1
  16. package/dist/solution/BookingTicket/index.js +49 -43
  17. package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +1 -0
  18. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -1
  19. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +69 -13
  20. package/dist/solution/Checkout/index.js +104 -69
  21. package/dist/solution/Checkout/types.d.ts +1 -0
  22. package/dist/solution/ScanOrder/index.js +10 -2
  23. package/dist/solution/VenueBooking/index.js +522 -490
  24. package/dist/utils/platform.d.ts +3 -0
  25. package/dist/utils/platform.js +8 -0
  26. package/lib/modules/Customer/types.d.ts +4 -0
  27. package/lib/modules/Order/index.d.ts +10 -0
  28. package/lib/modules/Order/index.js +155 -20
  29. package/lib/modules/Order/types.d.ts +3 -0
  30. package/lib/modules/Order/utils/bookingUuid.d.ts +4 -0
  31. package/lib/modules/Order/utils/bookingUuid.js +25 -0
  32. package/lib/modules/Order/utils/virtualSettlement.d.ts +4 -0
  33. package/lib/modules/Order/utils/virtualSettlement.js +9 -1
  34. package/lib/modules/Order/utils.d.ts +1 -0
  35. package/lib/modules/Order/utils.js +14 -5
  36. package/lib/shared/payment/loadPaymentMethods.d.ts +5 -1
  37. package/lib/shared/payment/loadPaymentMethods.js +14 -0
  38. package/lib/solution/BaseSales/index.d.ts +4 -0
  39. package/lib/solution/BaseSales/index.js +78 -16
  40. package/lib/solution/BookingTicket/index.d.ts +3 -1
  41. package/lib/solution/BookingTicket/index.js +4 -1
  42. package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +1 -0
  43. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +1 -1
  44. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +44 -5
  45. package/lib/solution/Checkout/index.js +21 -0
  46. package/lib/solution/Checkout/types.d.ts +1 -0
  47. package/lib/solution/ScanOrder/index.js +6 -0
  48. package/lib/solution/VenueBooking/index.js +6 -1
  49. package/lib/utils/platform.d.ts +3 -0
  50. package/lib/utils/platform.js +10 -0
  51. package/package.json +1 -1
@@ -49,14 +49,14 @@ import Decimal from 'decimal.js';
49
49
  import { cloneDeep, isEqual, mergeWith } from 'lodash-es';
50
50
  import { createModule } from "../BookingByStep/types";
51
51
  import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions, resolveIsFormSubject, sumOptionUnitPrice } from "../../modules/Order/utils";
52
- import { buildCurrencyDisplaySnapshot, getTempOrderSettlementSnapshot, isVirtualSettlementOrder } from "../../modules/Order/utils/virtualSettlement";
52
+ import { buildCurrencyDisplaySnapshot, getTempOrderSettlementKey, getTempOrderSettlementSnapshot, isVirtualSettlementOrder, VirtualCurrencyAssetNotFoundError, VirtualCurrencyBalanceError, VirtualCurrencyCustomerRequiredError } from "../../modules/Order/utils/virtualSettlement";
53
53
  import { ensureOrderPaymentNumber, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity, resolveOrderPaymentIdentity } from "../../modules/Order/payment-utils";
54
54
  import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
55
55
  import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
56
56
  import dayjs from 'dayjs';
57
57
  export * from "./types";
58
58
  import { isProductQueryHandledByOsServer, PRODUCT_QUERY_DATA_VARIANT_RELATIONS, resolveClientDataVariants, tryResolveClientDataVariants } from "../../modules/ProductList/clientDataVariants";
59
- import { isCustomerUserPlatform, normalizeRuntimePlatform } from "../../utils/platform";
59
+ import { isCustomerUserPlatform, normalizeRuntimePlatform, resolveTerminalVirtualCurrencyChannel } from "../../utils/platform";
60
60
  import { OS_POS_RECEIPT_AUTO_PRINT_PAYMENT_STATUSES_FIELD } from "../../utils/pos-receipt-auto-print";
61
61
  import { QuotationModule } from "../../modules/Quotation";
62
62
  import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
@@ -256,6 +256,9 @@ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps
256
256
  }
257
257
  }
258
258
  var mergedItem = mergedUid ? setOrderCollectionUid(kind, incomingItem, mergedUid) : cloneDeep(incomingItem);
259
+ if (kind === 'booking' && !mergedItem.uuid && currentItem.uuid !== undefined) {
260
+ mergedItem.uuid = currentItem.uuid;
261
+ }
259
262
  var persistentIdField = BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND[kind];
260
263
  if (isBaseSalesBlankValue(mergedItem[persistentIdField]) && !isBaseSalesBlankValue(identityMergedItem[persistentIdField])) {
261
264
  mergedItem[persistentIdField] = identityMergedItem[persistentIdField];
@@ -1017,6 +1020,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1017
1020
  if (!effects || typeof effects.on !== 'function') return;
1018
1021
  this.paymentMethodsChangedUnsubscribe = effects.on(PAYMENT_METHODS_CHANGED_EVENT, /*#__PURE__*/function () {
1019
1022
  var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(payload) {
1023
+ var channel, _this5$store$order;
1020
1024
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1021
1025
  while (1) switch (_context6.prev = _context6.next) {
1022
1026
  case 0:
@@ -1026,9 +1030,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1026
1030
  }
1027
1031
  return _context6.abrupt("return");
1028
1032
  case 2:
1029
- _context6.next = 4;
1033
+ channel = _this5.getTerminalVirtualCurrencyChannel();
1034
+ if (channel) {
1035
+ (_this5$store$order = _this5.store.order) === null || _this5$store$order === void 0 || _this5$store$order.syncTerminalVirtualCurrencyPaymentMethods(channel, payload.newMethods);
1036
+ }
1037
+ _context6.next = 6;
1030
1038
  return _this5.getPaymentMethodsAsync();
1031
- case 4:
1039
+ case 6:
1032
1040
  case "end":
1033
1041
  return _context6.stop();
1034
1042
  }
@@ -2398,6 +2406,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2398
2406
  var _this$otherParams17;
2399
2407
  return ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.enableMultiCurrencySettlement) === true;
2400
2408
  }
2409
+ }, {
2410
+ key: "getTerminalVirtualCurrencyChannel",
2411
+ value: function getTerminalVirtualCurrencyChannel() {
2412
+ var _this$otherParams18, _this$otherParams$bus2, _this$otherParams19, _this$otherParams20;
2413
+ if (!this.isMultiCurrencySettlementEnabled()) return undefined;
2414
+ return resolveTerminalVirtualCurrencyChannel((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform, (_this$otherParams$bus2 = (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.businessCode) !== null && _this$otherParams$bus2 !== void 0 ? _this$otherParams$bus2 : (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.business_code);
2415
+ }
2401
2416
  }, {
2402
2417
  key: "isActiveVirtualSettlementOrder",
2403
2418
  value: function isActiveVirtualSettlementOrder(tempOrder) {
@@ -2520,11 +2535,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2520
2535
  key: "initializeSalesRuntime",
2521
2536
  value: function () {
2522
2537
  var _initializeSalesRuntime = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(core) {
2523
- var _this$otherParams18,
2538
+ var _this$otherParams21,
2524
2539
  _this$appPlugin2,
2525
2540
  _this$appPlugin2$getA,
2526
2541
  _this17 = this,
2527
- _this$otherParams19;
2542
+ _this$otherParams22;
2528
2543
  var options,
2529
2544
  app,
2530
2545
  targetCacheData,
@@ -2540,7 +2555,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2540
2555
  this.paymentNumberDevicePrefix = null;
2541
2556
  // this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
2542
2557
  this.otherParams = options.otherParams || {};
2543
- this.cacheId = (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.cacheId;
2558
+ this.cacheId = (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.cacheId;
2544
2559
  this.reusedSharedSubModuleNames.clear();
2545
2560
  this.window = core.getPlugin('window');
2546
2561
  this.request = core.getPlugin('request');
@@ -2582,7 +2597,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2582
2597
  _context18.next = 20;
2583
2598
  return this.store.schedule.loadAllSchedule();
2584
2599
  case 20:
2585
- if (this.store.order && typeof ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.enableTempOrderPersist) === 'boolean') {
2600
+ if (this.store.order && typeof ((_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.enableTempOrderPersist) === 'boolean') {
2586
2601
  this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
2587
2602
  }
2588
2603
  _context18.next = 23;
@@ -3147,11 +3162,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3147
3162
  key: "loadContactInfoOpenData",
3148
3163
  value: function () {
3149
3164
  var _loadContactInfoOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
3150
- var _this$otherParams$ope2, _this$otherParams20;
3165
+ var _this$otherParams$ope2, _this$otherParams23;
3151
3166
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3152
3167
  while (1) switch (_context26.prev = _context26.next) {
3153
3168
  case 0:
3154
- return _context26.abrupt("return", (_this$otherParams$ope2 = (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.openData) !== null && _this$otherParams$ope2 !== void 0 ? _this$otherParams$ope2 : null);
3169
+ return _context26.abrupt("return", (_this$otherParams$ope2 = (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.openData) !== null && _this$otherParams$ope2 !== void 0 ? _this$otherParams$ope2 : null);
3155
3170
  case 1:
3156
3171
  case "end":
3157
3172
  return _context26.stop();
@@ -4683,76 +4698,82 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4683
4698
  }, {
4684
4699
  key: "buildVirtualSettlementSubmitData",
4685
4700
  value: function () {
4686
- var _buildVirtualSettlementSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
4687
- var settlement, tempOrder, currencyProductId, summary, amount, customerId, asset, balance, amountText, paymentNumber, payment, _paymentMethod$custom, paymentMethods, paymentMethod;
4701
+ var _buildVirtualSettlementSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(settlement, terminalPaymentMethod) {
4702
+ var tempOrder, currencyProductId, summary, amount, customerId, asset, balance, amountText, paymentNumber, metadata, payment, _paymentMethod$custom, paymentMethod;
4688
4703
  return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4689
4704
  while (1) switch (_context43.prev = _context43.next) {
4690
4705
  case 0:
4691
- settlement = this.buildVirtualSettlementOrderData();
4692
4706
  if (!(!settlement || !this.store.order)) {
4693
- _context43.next = 3;
4707
+ _context43.next = 2;
4694
4708
  break;
4695
4709
  }
4696
4710
  return _context43.abrupt("return", null);
4697
- case 3:
4711
+ case 2:
4698
4712
  tempOrder = this.store.order.getTempOrder();
4699
4713
  currencyProductId = settlement.currencyProductId;
4700
- _context43.next = 7;
4714
+ _context43.next = 6;
4701
4715
  return this.store.order.recalculateSummary({
4702
4716
  createIfMissing: true
4703
4717
  });
4704
- case 7:
4718
+ case 6:
4705
4719
  summary = _context43.sent;
4706
4720
  amount = new Decimal((summary === null || summary === void 0 ? void 0 : summary.total_amount) || 0).toDecimalPlaces(2);
4707
4721
  customerId = Number((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id) || 0);
4722
+ if (!(terminalPaymentMethod && amount.gt(0) && !(customerId > 1))) {
4723
+ _context43.next = 11;
4724
+ break;
4725
+ }
4726
+ throw new VirtualCurrencyCustomerRequiredError();
4727
+ case 11:
4708
4728
  if (!(amount.gt(0) && customerId > 0 && customerId !== 1)) {
4709
- _context43.next = 13;
4729
+ _context43.next = 14;
4710
4730
  break;
4711
4731
  }
4712
- _context43.next = 13;
4732
+ _context43.next = 14;
4713
4733
  return this.store.order.loadDiscountConfig({
4714
4734
  customerId: customerId,
4715
4735
  action: tempOrder !== null && tempOrder !== void 0 && tempOrder.order_id ? 'edit' : 'create',
4716
4736
  orderId: Number(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) || undefined,
4717
4737
  apply: false
4718
4738
  });
4719
- case 13:
4739
+ case 14:
4720
4740
  asset = this.store.order.getVirtualCurrencyList().find(function (item) {
4721
4741
  return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
4722
4742
  });
4723
4743
  if (!amount.lte(0)) {
4724
- _context43.next = 16;
4744
+ _context43.next = 17;
4725
4745
  break;
4726
4746
  }
4727
4747
  return _context43.abrupt("return", _objectSpread(_objectSpread({}, settlement), {}, {
4728
4748
  payments: []
4729
4749
  }));
4730
- case 16:
4750
+ case 17:
4731
4751
  if (asset) {
4732
- _context43.next = 18;
4752
+ _context43.next = 19;
4733
4753
  break;
4734
4754
  }
4735
- throw new Error('No matching virtual currency card is available.');
4736
- case 18:
4755
+ throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
4756
+ case 19:
4737
4757
  balance = new Decimal(asset.balance || 0);
4738
4758
  if (!balance.lt(amount)) {
4739
- _context43.next = 21;
4759
+ _context43.next = 22;
4740
4760
  break;
4741
4761
  }
4742
- throw new Error('Insufficient virtual currency balance.');
4743
- case 21:
4762
+ throw new VirtualCurrencyBalanceError(balance.toFixed(2), amount.toFixed(2));
4763
+ case 22:
4744
4764
  amountText = amount.toFixed(2);
4745
4765
  paymentNumber = "LOCAL_".concat(createUuidV4());
4746
- if (!this.store.order.isOnlineStorePlatform()) {
4747
- _context43.next = 27;
4766
+ metadata = {
4767
+ unique_payment_number: createUuidV4()
4768
+ };
4769
+ if (!(!terminalPaymentMethod && this.store.order.isOnlineStorePlatform())) {
4770
+ _context43.next = 29;
4748
4771
  break;
4749
4772
  }
4750
4773
  payment = {
4751
4774
  payment_number: paymentNumber,
4752
4775
  amount: amount.toNumber(),
4753
- metadata: {
4754
- unique_payment_number: createUuidV4()
4755
- },
4776
+ metadata: metadata,
4756
4777
  tag: asset.tag,
4757
4778
  voucher_id: asset.id,
4758
4779
  wallet_pass_usage_unit: {
@@ -4761,22 +4782,31 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4761
4782
  },
4762
4783
  wallet_pass_use_value: amountText
4763
4784
  };
4764
- _context43.next = 34;
4785
+ _context43.next = 40;
4765
4786
  break;
4766
- case 27:
4767
- _context43.next = 29;
4768
- return this.getPaymentMethodsAsync();
4769
4787
  case 29:
4770
- paymentMethods = _context43.sent;
4771
- paymentMethod = paymentMethods.find(function (method) {
4788
+ if (!(terminalPaymentMethod !== null && terminalPaymentMethod !== void 0)) {
4789
+ _context43.next = 33;
4790
+ break;
4791
+ }
4792
+ _context43.t0 = terminalPaymentMethod;
4793
+ _context43.next = 36;
4794
+ break;
4795
+ case 33:
4796
+ _context43.next = 35;
4797
+ return this.getPaymentMethodsAsync();
4798
+ case 35:
4799
+ _context43.t0 = _context43.sent.find(function (method) {
4772
4800
  return String(method.code || '').toUpperCase() === 'PRODUCTVOUCHER';
4773
4801
  });
4802
+ case 36:
4803
+ paymentMethod = _context43.t0;
4774
4804
  if (paymentMethod) {
4775
- _context43.next = 33;
4805
+ _context43.next = 39;
4776
4806
  break;
4777
4807
  }
4778
4808
  throw new Error('PRODUCTVOUCHER payment method is unavailable.');
4779
- case 33:
4809
+ case 39:
4780
4810
  payment = {
4781
4811
  payment_number: paymentNumber,
4782
4812
  amount: amountText,
@@ -4793,19 +4823,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4793
4823
  points: 1
4794
4824
  },
4795
4825
  wallet_pass_use_value: amountText,
4796
- metadata: {}
4826
+ metadata: metadata
4797
4827
  };
4798
- case 34:
4828
+ case 40:
4799
4829
  return _context43.abrupt("return", _objectSpread(_objectSpread({}, settlement), {}, {
4800
4830
  payments: [payment]
4801
4831
  }));
4802
- case 35:
4832
+ case 41:
4803
4833
  case "end":
4804
4834
  return _context43.stop();
4805
4835
  }
4806
4836
  }, _callee43, this);
4807
4837
  }));
4808
- function buildVirtualSettlementSubmitData() {
4838
+ function buildVirtualSettlementSubmitData(_x33, _x34) {
4809
4839
  return _buildVirtualSettlementSubmitData.apply(this, arguments);
4810
4840
  }
4811
4841
  return buildVirtualSettlementSubmitData;
@@ -4820,8 +4850,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4820
4850
  key: "submitSalesOrder",
4821
4851
  value: (function () {
4822
4852
  var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
4823
- var _params$smallTicketDa, _this$otherParams21, _this$otherParams22, _this$otherParams23, _this$otherParams24;
4824
- var isDeferredPayment, virtualPaymentSettlement, virtualSettlement, inferredPaymentStatus, smallTicketDataFlag, virtualSettlementEnhancePayload, configuredEnhancePayload, _enhancePayload, submitParams;
4853
+ var _this21 = this,
4854
+ _params$smallTicketDa,
4855
+ _this$otherParams24,
4856
+ _this$otherParams25,
4857
+ _this$otherParams26,
4858
+ _this$otherParams27;
4859
+ var isDeferredPayment, checkoutOrder, virtualOrderData, checkoutCustomerId, checkoutSettlementKey, virtualPaymentChannel, terminalPaymentMethod, readCheckoutLines, checkoutLines, assertCheckoutCartUnchanged, virtualPaymentSettlement, submitsTerminalVirtualPayment, virtualSettlement, inferredPaymentStatus, smallTicketDataFlag, virtualSettlementEnhancePayload, configuredEnhancePayload, _enhancePayload, submitParams;
4825
4860
  return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4826
4861
  while (1) switch (_context44.prev = _context44.next) {
4827
4862
  case 0:
@@ -4844,21 +4879,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4844
4879
  });
4845
4880
  case 7:
4846
4881
  isDeferredPayment = (params === null || params === void 0 ? void 0 : params.paymentExecution) === 'deferred';
4882
+ checkoutOrder = this.store.order.getTempOrder();
4883
+ virtualOrderData = this.buildVirtualSettlementOrderData();
4884
+ checkoutCustomerId = checkoutOrder === null || checkoutOrder === void 0 ? void 0 : checkoutOrder.customer_id;
4885
+ checkoutSettlementKey = getTempOrderSettlementKey(checkoutOrder);
4886
+ virtualPaymentChannel = virtualOrderData ? this.getTerminalVirtualCurrencyChannel() : undefined;
4887
+ terminalPaymentMethod = virtualPaymentChannel ? this.store.order.getTerminalVirtualCurrencyPaymentMethod(virtualPaymentChannel, virtualPaymentChannel === 'pos' ? this.getPaymentMethods() : undefined) : undefined;
4888
+ readCheckoutLines = function readCheckoutLines() {
4889
+ return checkoutOrder === null || checkoutOrder === void 0 ? void 0 : checkoutOrder.products.map(function (product) {
4890
+ var _product$product_vari3, _product$num2;
4891
+ return [String(product.product_id), String((_product$product_vari3 = product.product_variant_id) !== null && _product$product_vari3 !== void 0 ? _product$product_vari3 : 0), Number((_product$num2 = product.num) !== null && _product$num2 !== void 0 ? _product$num2 : 1)];
4892
+ });
4893
+ };
4894
+ checkoutLines = terminalPaymentMethod && !isDeferredPayment ? readCheckoutLines() : undefined;
4895
+ assertCheckoutCartUnchanged = function assertCheckoutCartUnchanged() {
4896
+ var _this21$store$order;
4897
+ if (terminalPaymentMethod && (((_this21$store$order = _this21.store.order) === null || _this21$store$order === void 0 ? void 0 : _this21$store$order.getTempOrder()) !== checkoutOrder || (checkoutOrder === null || checkoutOrder === void 0 ? void 0 : checkoutOrder.customer_id) !== checkoutCustomerId || getTempOrderSettlementKey(checkoutOrder) !== checkoutSettlementKey || checkoutLines && !isEqual(readCheckoutLines(), checkoutLines))) {
4898
+ throw salesGuardError('The cart changed. Please try again.');
4899
+ }
4900
+ };
4847
4901
  if (!isDeferredPayment) {
4848
- _context44.next = 12;
4902
+ _context44.next = 21;
4849
4903
  break;
4850
4904
  }
4851
4905
  _context44.t0 = null;
4852
- _context44.next = 15;
4906
+ _context44.next = 24;
4853
4907
  break;
4854
- case 12:
4855
- _context44.next = 14;
4856
- return this.buildVirtualSettlementSubmitData();
4857
- case 14:
4908
+ case 21:
4909
+ _context44.next = 23;
4910
+ return this.buildVirtualSettlementSubmitData(virtualOrderData, terminalPaymentMethod);
4911
+ case 23:
4858
4912
  _context44.t0 = _context44.sent;
4859
- case 15:
4913
+ case 24:
4860
4914
  virtualPaymentSettlement = _context44.t0;
4861
- virtualSettlement = isDeferredPayment ? this.buildVirtualSettlementOrderData() : virtualPaymentSettlement; // this.store.order.persistTempOrder();
4915
+ assertCheckoutCartUnchanged();
4916
+ submitsTerminalVirtualPayment = Boolean(terminalPaymentMethod && (virtualPaymentSettlement === null || virtualPaymentSettlement === void 0 ? void 0 : virtualPaymentSettlement.payments.length));
4917
+ virtualSettlement = isDeferredPayment ? virtualOrderData : virtualPaymentSettlement; // this.store.order.persistTempOrder();
4862
4918
  inferredPaymentStatus = isDeferredPayment ? undefined : this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
4863
4919
  smallTicketDataFlag = (_params$smallTicketDa = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa !== void 0 ? _params$smallTicketDa : this.getDefaultCheckoutSmallTicketDataFlag();
4864
4920
  virtualSettlementEnhancePayload = virtualSettlement ? function (payload, ctx) {
@@ -4890,10 +4946,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4890
4946
  } : configuredEnhancePayload;
4891
4947
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
4892
4948
  cacheId: this.cacheId,
4893
- platform: (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.platform,
4894
- businessCode: ((_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.businessCode) || ((_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.business_code),
4895
- channel: this.getSubmitOrderSalesChannel(),
4896
- type: (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.type,
4949
+ platform: virtualPaymentChannel === 'kiosk' ? 'kiosk' : (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.platform,
4950
+ 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),
4951
+ channel: virtualPaymentChannel === 'kiosk' ? 'kiosk' : this.getSubmitOrderSalesChannel(),
4952
+ type: (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.type,
4897
4953
  request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
4898
4954
  }, isDeferredPayment ? {
4899
4955
  payments: []
@@ -4913,8 +4969,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4913
4969
  enhancePayload: function enhancePayload(payload, ctx) {
4914
4970
  var _callerPayload$metada2, _currencySettlementCo2;
4915
4971
  var callerPayload = _enhancePayload ? _enhancePayload(payload, ctx) : payload;
4972
+ if (terminalPaymentMethod && virtualPaymentSettlement) {
4973
+ var _callerPayload$summar, _summary$total_amount, _callerPayload$paymen, _payment$amount;
4974
+ assertCheckoutCartUnchanged();
4975
+ if (virtualPaymentChannel === 'kiosk') {
4976
+ var _this21$store$order2;
4977
+ var currentMethod = (_this21$store$order2 = _this21.store.order) === null || _this21$store$order2 === void 0 ? void 0 : _this21$store$order2.getTerminalVirtualCurrencyPaymentMethod('kiosk');
4978
+ if (_this21.getTerminalVirtualCurrencyChannel() !== 'kiosk' || (currentMethod === null || currentMethod === void 0 ? void 0 : currentMethod.id) !== terminalPaymentMethod.id) {
4979
+ throw salesGuardError('The payment method changed. Please try again.');
4980
+ }
4981
+ }
4982
+ var summary = (_callerPayload$summar = callerPayload.summary) !== null && _callerPayload$summar !== void 0 ? _callerPayload$summar : payload.summary;
4983
+ var orderAmount = Decimal.max(0, (_summary$total_amount = summary === null || summary === void 0 ? void 0 : summary.total_amount) !== null && _summary$total_amount !== void 0 ? _summary$total_amount : 0).toDecimalPlaces(2);
4984
+ var payment = (_callerPayload$paymen = callerPayload.payments) === null || _callerPayload$paymen === void 0 ? void 0 : _callerPayload$paymen.find(function (item) {
4985
+ return item.code === terminalPaymentMethod.code;
4986
+ });
4987
+ if (!orderAmount.eq((_payment$amount = payment === null || payment === void 0 ? void 0 : payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : 0)) {
4988
+ throw salesGuardError('The cart changed. Please try again.');
4989
+ }
4990
+ }
4916
4991
  var currencySettlementConfig = ((_callerPayload$metada2 = callerPayload.metadata) === null || _callerPayload$metada2 === void 0 ? void 0 : _callerPayload$metada2.currency_settlement_config) || {};
4917
- return _objectSpread(_objectSpread({}, callerPayload), {}, {
4992
+ return _objectSpread(_objectSpread(_objectSpread({}, callerPayload), submitsTerminalVirtualPayment ? {
4993
+ payment_status: 'paid'
4994
+ } : {}), {}, {
4918
4995
  metadata: _objectSpread(_objectSpread({}, callerPayload.metadata || {}), {}, {
4919
4996
  currency_settlement_config: _objectSpread(_objectSpread({}, currencySettlementConfig), {}, {
4920
4997
  settlement_type: 'virtual_currency',
@@ -4930,14 +5007,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4930
5007
  } : _enhancePayload !== undefined ? {
4931
5008
  enhancePayload: _enhancePayload
4932
5009
  } : {});
4933
- return _context44.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
4934
- case 24:
5010
+ return _context44.abrupt("return", !submitsTerminalVirtualPayment && this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
5011
+ case 35:
4935
5012
  case "end":
4936
5013
  return _context44.stop();
4937
5014
  }
4938
5015
  }, _callee44, this);
4939
5016
  }));
4940
- function submitSalesOrder(_x33) {
5017
+ function submitSalesOrder(_x35) {
4941
5018
  return _submitSalesOrder.apply(this, arguments);
4942
5019
  }
4943
5020
  return submitSalesOrder;
@@ -5040,7 +5117,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5040
5117
  }
5041
5118
  }, _callee45, this, [[18, 23]]);
5042
5119
  }));
5043
- function finalizeLocalEftposPayment(_x34) {
5120
+ function finalizeLocalEftposPayment(_x36) {
5044
5121
  return _finalizeLocalEftposPayment.apply(this, arguments);
5045
5122
  }
5046
5123
  return finalizeLocalEftposPayment;
@@ -5160,7 +5237,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5160
5237
  key: "saveSalesOrderDraft",
5161
5238
  value: function () {
5162
5239
  var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
5163
- var _params$platform, _this$otherParams25, _this$otherParams26, _this$otherParams27, _params$channel, _params$type, _this$otherParams28;
5240
+ var _params$platform, _this$otherParams28, _this$otherParams29, _this$otherParams30, _params$channel, _params$type, _this$otherParams31;
5164
5241
  return _regeneratorRuntime().wrap(function _callee47$(_context47) {
5165
5242
  while (1) switch (_context47.prev = _context47.next) {
5166
5243
  case 0:
@@ -5181,10 +5258,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5181
5258
  case 5:
5182
5259
  return _context47.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
5183
5260
  cacheId: this.cacheId,
5184
- platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.platform,
5185
- businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.businessCode) || ((_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.business_code),
5261
+ platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.platform,
5262
+ businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.businessCode) || ((_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.business_code),
5186
5263
  channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
5187
- type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.type
5264
+ type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.type
5188
5265
  }, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
5189
5266
  enhancePayload: params.enhancePayload
5190
5267
  } : {})));
@@ -5194,7 +5271,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5194
5271
  }
5195
5272
  }, _callee47, this);
5196
5273
  }));
5197
- function saveSalesOrderDraft(_x35) {
5274
+ function saveSalesOrderDraft(_x37) {
5198
5275
  return _saveSalesOrderDraft.apply(this, arguments);
5199
5276
  }
5200
5277
  return saveSalesOrderDraft;
@@ -5203,7 +5280,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5203
5280
  key: "submitTempOrderAsync",
5204
5281
  value: function () {
5205
5282
  var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
5206
- var _params$smallTicketDa2, _this$otherParams29, _this$otherParams30, _this$otherParams31, _this$otherParams32;
5283
+ var _params$smallTicketDa2, _this$otherParams32, _this$otherParams33, _this$otherParams34, _this$otherParams35;
5207
5284
  var inferredPaymentStatus, smallTicketDataFlag, enhancePayload, submitParams;
5208
5285
  return _regeneratorRuntime().wrap(function _callee48$(_context48) {
5209
5286
  while (1) switch (_context48.prev = _context48.next) {
@@ -5231,10 +5308,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5231
5308
  enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params === null || params === void 0 ? void 0 : params.enhancePayload);
5232
5309
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
5233
5310
  cacheId: this.cacheId,
5234
- platform: (_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.platform,
5235
- businessCode: ((_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.businessCode) || ((_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.business_code),
5311
+ platform: (_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.platform,
5312
+ businessCode: ((_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.businessCode) || ((_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.business_code),
5236
5313
  channel: this.getSubmitOrderSalesChannel(),
5237
- type: (_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.type,
5314
+ type: (_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35.type,
5238
5315
  request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
5239
5316
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
5240
5317
  payments: params.payments
@@ -5254,7 +5331,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5254
5331
  }
5255
5332
  }, _callee48, this);
5256
5333
  }));
5257
- function submitTempOrderAsync(_x36) {
5334
+ function submitTempOrderAsync(_x38) {
5258
5335
  return _submitTempOrderAsync.apply(this, arguments);
5259
5336
  }
5260
5337
  return submitTempOrderAsync;
@@ -5266,8 +5343,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5266
5343
  }, {
5267
5344
  key: "shouldUseCheckoutSyncTask",
5268
5345
  value: function shouldUseCheckoutSyncTask() {
5269
- var _this$otherParams33;
5270
- var configured = (_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.checkoutSyncTaskEnabled;
5346
+ var _this$otherParams36;
5347
+ var configured = (_this$otherParams36 = this.otherParams) === null || _this$otherParams36 === void 0 ? void 0 : _this$otherParams36.checkoutSyncTaskEnabled;
5271
5348
  return typeof configured === 'boolean' ? configured : true;
5272
5349
  }
5273
5350
 
@@ -5281,7 +5358,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5281
5358
  key: "printLocalOrderReceipt",
5282
5359
  value: function () {
5283
5360
  var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(lookup) {
5284
- var _this$otherParams34, _this$otherParams35, _this$otherParams36, _this$otherParams37;
5361
+ var _this$otherParams37, _this$otherParams38, _this$otherParams39, _this$otherParams40;
5285
5362
  var hasLookup, lookupPayload, context, payload, invoiceLayoutConfig, invoiceTemplateSettings, printPayload, response, _this$store$order$app, _this$store$order19, _data;
5286
5363
  return _regeneratorRuntime().wrap(function _callee49$(_context49) {
5287
5364
  while (1) switch (_context49.prev = _context49.next) {
@@ -5299,10 +5376,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5299
5376
  external_sale_number: lookup
5300
5377
  };
5301
5378
  context = {
5302
- platform: (_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.platform,
5303
- businessCode: ((_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35.businessCode) || ((_this$otherParams36 = this.otherParams) === null || _this$otherParams36 === void 0 ? void 0 : _this$otherParams36.business_code),
5379
+ platform: (_this$otherParams37 = this.otherParams) === null || _this$otherParams37 === void 0 ? void 0 : _this$otherParams37.platform,
5380
+ businessCode: ((_this$otherParams38 = this.otherParams) === null || _this$otherParams38 === void 0 ? void 0 : _this$otherParams38.businessCode) || ((_this$otherParams39 = this.otherParams) === null || _this$otherParams39 === void 0 ? void 0 : _this$otherParams39.business_code),
5304
5381
  channel: this.getSubmitOrderSalesChannel(),
5305
- type: (_this$otherParams37 = this.otherParams) === null || _this$otherParams37 === void 0 ? void 0 : _this$otherParams37.type
5382
+ type: (_this$otherParams40 = this.otherParams) === null || _this$otherParams40 === void 0 ? void 0 : _this$otherParams40.type
5306
5383
  };
5307
5384
  payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
5308
5385
  lookup_order_from_db: 1,
@@ -5346,7 +5423,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5346
5423
  }
5347
5424
  }, _callee49, this);
5348
5425
  }));
5349
- function printLocalOrderReceipt(_x37) {
5426
+ function printLocalOrderReceipt(_x39) {
5350
5427
  return _printLocalOrderReceipt.apply(this, arguments);
5351
5428
  }
5352
5429
  return printLocalOrderReceipt;
@@ -5368,7 +5445,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5368
5445
  key: "syncPaymentsToOrder",
5369
5446
  value: function () {
5370
5447
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
5371
- var _ref51, _params$businessCode, _this$otherParams38, _this$otherParams39, _params$channel2;
5448
+ var _ref51, _params$businessCode, _this$otherParams41, _this$otherParams42, _params$channel2;
5372
5449
  var businessCode, channel, enhancePayload, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
5373
5450
  return _regeneratorRuntime().wrap(function _callee50$(_context50) {
5374
5451
  while (1) switch (_context50.prev = _context50.next) {
@@ -5379,7 +5456,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5379
5456
  }
5380
5457
  throw new Error('order 模块未初始化');
5381
5458
  case 2:
5382
- businessCode = (_ref51 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams38 = this.otherParams) === null || _this$otherParams38 === void 0 ? void 0 : _this$otherParams38.businessCode) !== null && _ref51 !== void 0 ? _ref51 : (_this$otherParams39 = this.otherParams) === null || _this$otherParams39 === void 0 ? void 0 : _this$otherParams39.business_code;
5459
+ businessCode = (_ref51 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams41 = this.otherParams) === null || _this$otherParams41 === void 0 ? void 0 : _this$otherParams41.businessCode) !== null && _ref51 !== void 0 ? _ref51 : (_this$otherParams42 = this.otherParams) === null || _this$otherParams42 === void 0 ? void 0 : _this$otherParams42.business_code;
5383
5460
  channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
5384
5461
  enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params.enhancePayload);
5385
5462
  syncParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, params), {}, {
@@ -5463,7 +5540,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5463
5540
  }
5464
5541
  }, _callee50, this, [[13, 30]]);
5465
5542
  }));
5466
- function syncPaymentsToOrder(_x38) {
5543
+ function syncPaymentsToOrder(_x40) {
5467
5544
  return _syncPaymentsToOrder.apply(this, arguments);
5468
5545
  }
5469
5546
  return syncPaymentsToOrder;
@@ -5500,13 +5577,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5500
5577
  }, {
5501
5578
  key: "scheduleQueuedAutoPaymentSyncFlush",
5502
5579
  value: function scheduleQueuedAutoPaymentSyncFlush() {
5503
- var _this21 = this;
5580
+ var _this22 = this;
5504
5581
  var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
5505
5582
  if (!this.queuedAutoPaymentSync) return;
5506
5583
  if (this.autoPaymentSyncTimer) return;
5507
5584
  this.autoPaymentSyncTimer = setTimeout(function () {
5508
- _this21.autoPaymentSyncTimer = null;
5509
- void _this21.flushQueuedAutoPaymentSync();
5585
+ _this22.autoPaymentSyncTimer = null;
5586
+ void _this22.flushQueuedAutoPaymentSync();
5510
5587
  }, delay);
5511
5588
  }
5512
5589
  }, {
@@ -5633,7 +5710,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5633
5710
  }
5634
5711
  }, _callee52, this);
5635
5712
  }));
5636
- function addOrderPaymentAsync(_x39) {
5713
+ function addOrderPaymentAsync(_x41) {
5637
5714
  return _addOrderPaymentAsync.apply(this, arguments);
5638
5715
  }
5639
5716
  return addOrderPaymentAsync;
@@ -5641,12 +5718,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5641
5718
  }, {
5642
5719
  key: "addOrderPaymentWithDevicePrefix",
5643
5720
  value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
5644
- var _this$otherParams40,
5721
+ var _this$otherParams43,
5645
5722
  _paymentRecord$paymen,
5646
5723
  _paymentRecord$create,
5647
5724
  _ref52,
5648
5725
  _paymentRecord$origin,
5649
- _this22 = this;
5726
+ _this23 = this;
5650
5727
  if (!this.store.order) throw new Error('order 模块未初始化');
5651
5728
  var paymentRecord = payment;
5652
5729
  var paymentAmount = new Decimal(paymentRecord.amount || 0);
@@ -5657,7 +5734,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5657
5734
  return this.store.order.getOrderPayments();
5658
5735
  }
5659
5736
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
5660
- var shopWalletPassId = (_this$otherParams40 = this.otherParams) === null || _this$otherParams40 === void 0 ? void 0 : _this$otherParams40.shop_wallet_pass_id;
5737
+ var shopWalletPassId = (_this$otherParams43 = this.otherParams) === null || _this$otherParams43 === void 0 ? void 0 : _this$otherParams43.shop_wallet_pass_id;
5661
5738
  if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
5662
5739
  metadata.shop_wallet_pass_id = shopWalletPassId;
5663
5740
  }
@@ -5690,7 +5767,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5690
5767
  submitWhenPaid: true,
5691
5768
  smallTicketDataFlag: 1
5692
5769
  }).catch(function (error) {
5693
- _this22.logError('auto sync payments failed', {
5770
+ _this23.logError('auto sync payments failed', {
5694
5771
  error: error instanceof Error ? error.message : String(error)
5695
5772
  });
5696
5773
  });
@@ -5821,7 +5898,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5821
5898
  }
5822
5899
  }, _callee53, this, [[17, 23]]);
5823
5900
  }));
5824
- function updateOrderPayment(_x40, _x41) {
5901
+ function updateOrderPayment(_x42, _x43) {
5825
5902
  return _updateOrderPayment.apply(this, arguments);
5826
5903
  }
5827
5904
  return updateOrderPayment;
@@ -5860,7 +5937,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5860
5937
  }
5861
5938
  }, _callee54, this);
5862
5939
  }));
5863
- function updateVoucherOrderPaymentsAsync(_x42, _x43) {
5940
+ function updateVoucherOrderPaymentsAsync(_x44, _x45) {
5864
5941
  return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
5865
5942
  }
5866
5943
  return updateVoucherOrderPaymentsAsync;
@@ -5894,7 +5971,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5894
5971
  // const products = tempOrder?.products?.filter(n => n.product_id)
5895
5972
 
5896
5973
  var walletProducts = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products.map(function (product) {
5897
- var _product$holder_id, _product$product_vari3, _product$is_charge_ta, _metadata$main_produc, _metadata$main_produc2;
5974
+ var _product$holder_id, _product$product_vari4, _product$is_charge_ta, _metadata$main_produc, _metadata$main_produc2;
5898
5975
  var metadata = product.metadata || {};
5899
5976
  var rawHolderId = hasProductBooking(product) ? (_product$holder_id = product.holder_id) !== null && _product$holder_id !== void 0 ? _product$holder_id : metadata.holder_id : getProductHolderRelations(tempOrder, product).filter(function (relation) {
5900
5977
  return relation.holder_type === 'form';
@@ -5905,7 +5982,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5905
5982
  var holder_id = Number.isInteger(Number(holderIdValue)) ? Number(holderIdValue) : undefined;
5906
5983
  return {
5907
5984
  product_id: product.product_id || 0,
5908
- product_variant_id: String((_product$product_vari3 = product.product_variant_id) !== null && _product$product_vari3 !== void 0 ? _product$product_vari3 : ''),
5985
+ product_variant_id: String((_product$product_vari4 = product.product_variant_id) !== null && _product$product_vari4 !== void 0 ? _product$product_vari4 : ''),
5909
5986
  quantity: product.num || 1,
5910
5987
  is_price_include_tax: tempOrder.is_price_include_tax,
5911
5988
  is_charge_tax: (_product$is_charge_ta = product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
@@ -6034,7 +6111,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6034
6111
  }
6035
6112
  }, _callee55, this);
6036
6113
  }));
6037
- function initWalletData(_x44) {
6114
+ function initWalletData(_x46) {
6038
6115
  return _initWalletData.apply(this, arguments);
6039
6116
  }
6040
6117
  return initWalletData;
@@ -6105,7 +6182,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6105
6182
  }
6106
6183
  }, _callee56, this);
6107
6184
  }));
6108
- function publishWalletAssetsState(_x45) {
6185
+ function publishWalletAssetsState(_x47) {
6109
6186
  return _publishWalletAssetsState.apply(this, arguments);
6110
6187
  }
6111
6188
  return publishWalletAssetsState;
@@ -6186,7 +6263,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6186
6263
  }
6187
6264
  }, _callee57, this);
6188
6265
  }));
6189
- function syncSelectedWalletAssets(_x46) {
6266
+ function syncSelectedWalletAssets(_x48) {
6190
6267
  return _syncSelectedWalletAssets.apply(this, arguments);
6191
6268
  }
6192
6269
  return syncSelectedWalletAssets;
@@ -6244,7 +6321,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6244
6321
  }
6245
6322
  }, _callee58, this);
6246
6323
  }));
6247
- function importWalletAssetsSnapshot(_x47) {
6324
+ function importWalletAssetsSnapshot(_x49) {
6248
6325
  return _importWalletAssetsSnapshot.apply(this, arguments);
6249
6326
  }
6250
6327
  return importWalletAssetsSnapshot;
@@ -6338,7 +6415,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6338
6415
  }
6339
6416
  }, _callee59, this);
6340
6417
  }));
6341
- function refreshWalletAssets(_x48) {
6418
+ function refreshWalletAssets(_x50) {
6342
6419
  return _refreshWalletAssets.apply(this, arguments);
6343
6420
  }
6344
6421
  return refreshWalletAssets;
@@ -6371,7 +6448,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6371
6448
  }
6372
6449
  }, _callee60, this);
6373
6450
  }));
6374
- function selectWalletAsset(_x49) {
6451
+ function selectWalletAsset(_x51) {
6375
6452
  return _selectWalletAsset.apply(this, arguments);
6376
6453
  }
6377
6454
  return selectWalletAsset;
@@ -6401,7 +6478,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6401
6478
  }
6402
6479
  }, _callee61, this);
6403
6480
  }));
6404
- function updateWalletAssetAmount(_x50) {
6481
+ function updateWalletAssetAmount(_x52) {
6405
6482
  return _updateWalletAssetAmount.apply(this, arguments);
6406
6483
  }
6407
6484
  return updateWalletAssetAmount;
@@ -6446,7 +6523,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6446
6523
  }
6447
6524
  }, _callee62, this);
6448
6525
  }));
6449
- function scanWalletAsset(_x51) {
6526
+ function scanWalletAsset(_x53) {
6450
6527
  return _scanWalletAsset.apply(this, arguments);
6451
6528
  }
6452
6529
  return scanWalletAsset;
@@ -6551,6 +6628,65 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6551
6628
  value: function getPaymentMethods() {
6552
6629
  return _toConsumableArray(this.paymentMethodsCache);
6553
6630
  }
6631
+ }, {
6632
+ key: "checkTerminalVirtualCurrencyPaymentMethod",
6633
+ value: function () {
6634
+ var _checkTerminalVirtualCurrencyPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(channel) {
6635
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6636
+ while (1) switch (_context65.prev = _context65.next) {
6637
+ case 0:
6638
+ if (this.store.order) {
6639
+ _context65.next = 2;
6640
+ break;
6641
+ }
6642
+ return _context65.abrupt("return", false);
6643
+ case 2:
6644
+ _context65.prev = 2;
6645
+ _context65.next = 5;
6646
+ return this.store.order.refreshTerminalVirtualCurrencyPaymentMethod(channel);
6647
+ case 5:
6648
+ return _context65.abrupt("return", true);
6649
+ case 8:
6650
+ _context65.prev = 8;
6651
+ _context65.t0 = _context65["catch"](2);
6652
+ return _context65.abrupt("return", false);
6653
+ case 11:
6654
+ case "end":
6655
+ return _context65.stop();
6656
+ }
6657
+ }, _callee65, this, [[2, 8]]);
6658
+ }));
6659
+ function checkTerminalVirtualCurrencyPaymentMethod(_x54) {
6660
+ return _checkTerminalVirtualCurrencyPaymentMethod.apply(this, arguments);
6661
+ }
6662
+ return checkTerminalVirtualCurrencyPaymentMethod;
6663
+ }()
6664
+ }, {
6665
+ key: "hasPosVirtualCurrencyPaymentMethod",
6666
+ value: function hasPosVirtualCurrencyPaymentMethod() {
6667
+ return this.checkTerminalVirtualCurrencyPaymentMethod('pos');
6668
+ }
6669
+ }, {
6670
+ key: "hasTerminalVirtualCurrencyPaymentMethod",
6671
+ value: function () {
6672
+ var _hasTerminalVirtualCurrencyPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66() {
6673
+ var channel;
6674
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6675
+ while (1) switch (_context66.prev = _context66.next) {
6676
+ case 0:
6677
+ channel = this.getTerminalVirtualCurrencyChannel();
6678
+ return _context66.abrupt("return", channel ? this.checkTerminalVirtualCurrencyPaymentMethod(channel) : false);
6679
+ case 2:
6680
+ case "end":
6681
+ return _context66.stop();
6682
+ }
6683
+ }, _callee66, this);
6684
+ }));
6685
+ function hasTerminalVirtualCurrencyPaymentMethod() {
6686
+ return _hasTerminalVirtualCurrencyPaymentMethod.apply(this, arguments);
6687
+ }
6688
+ return hasTerminalVirtualCurrencyPaymentMethod;
6689
+ }()
6554
6690
  }, {
6555
6691
  key: "findCashPaymentMethod",
6556
6692
  value: function findCashPaymentMethod(paymentMethods, paymentMethodId) {
@@ -6578,7 +6714,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6578
6714
  }
6579
6715
  try {
6580
6716
  return total.plus(payment.amount || 0).plus(payment.rounding_amount || 0);
6581
- } catch (_unused8) {
6717
+ } catch (_unused9) {
6582
6718
  return total;
6583
6719
  }
6584
6720
  }, new Decimal(0));
@@ -6588,8 +6724,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6588
6724
  }, {
6589
6725
  key: "getCashPaymentConfig",
6590
6726
  value: (function () {
6591
- var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65() {
6592
- var _this$store$order30, _this$store$order30$g, _this$store$order31, _this$store$order31$g, _this$otherParams41;
6727
+ var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67() {
6728
+ var _this$store$order30, _this$store$order30$g, _this$store$order31, _this$store$order31$g, _this$otherParams44;
6593
6729
  var options,
6594
6730
  paymentMethods,
6595
6731
  paymentMethod,
@@ -6598,13 +6734,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6598
6734
  amountDue,
6599
6735
  currency,
6600
6736
  recommendedAmounts,
6601
- _args65 = arguments;
6602
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6603
- while (1) switch (_context65.prev = _context65.next) {
6737
+ _args67 = arguments;
6738
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6739
+ while (1) switch (_context67.prev = _context67.next) {
6604
6740
  case 0:
6605
- options = _args65.length > 0 && _args65[0] !== undefined ? _args65[0] : {};
6741
+ options = _args67.length > 0 && _args67[0] !== undefined ? _args67[0] : {};
6606
6742
  if (this.store.payment) {
6607
- _context65.next = 3;
6743
+ _context67.next = 3;
6608
6744
  break;
6609
6745
  }
6610
6746
  throw new Error('payment 模块未初始化');
@@ -6612,17 +6748,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6612
6748
  paymentMethods = this.getPaymentMethods();
6613
6749
  paymentMethod = this.findCashPaymentMethod(paymentMethods, options.paymentMethodId);
6614
6750
  if (paymentMethod) {
6615
- _context65.next = 10;
6751
+ _context67.next = 10;
6616
6752
  break;
6617
6753
  }
6618
- _context65.next = 8;
6754
+ _context67.next = 8;
6619
6755
  return this.getPaymentMethodsAsync();
6620
6756
  case 8:
6621
- paymentMethods = _context65.sent;
6757
+ paymentMethods = _context67.sent;
6622
6758
  paymentMethod = this.findCashPaymentMethod(paymentMethods, options.paymentMethodId);
6623
6759
  case 10:
6624
6760
  if (!(!paymentMethod && options.paymentMethodId !== undefined)) {
6625
- _context65.next = 12;
6761
+ _context67.next = 12;
6626
6762
  break;
6627
6763
  }
6628
6764
  throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u73B0\u91D1\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(options.paymentMethodId));
@@ -6630,9 +6766,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6630
6766
  amountSnapshot = (_this$store$order30 = this.store.order) === null || _this$store$order30 === void 0 || (_this$store$order30$g = _this$store$order30.getOrderAmountSnapshot) === null || _this$store$order30$g === void 0 ? void 0 : _this$store$order30$g.call(_this$store$order30);
6631
6767
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
6632
6768
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
6633
- currency = ((_this$store$order31 = this.store.order) === null || _this$store$order31 === void 0 || (_this$store$order31$g = _this$store$order31.getTempOrder) === null || _this$store$order31$g === void 0 || (_this$store$order31$g = _this$store$order31$g.call(_this$store$order31)) === null || _this$store$order31$g === void 0 ? void 0 : _this$store$order31$g.currency_code) || ((_this$otherParams41 = this.otherParams) === null || _this$otherParams41 === void 0 ? void 0 : _this$otherParams41.currency) || 'USD';
6769
+ currency = ((_this$store$order31 = this.store.order) === null || _this$store$order31 === void 0 || (_this$store$order31$g = _this$store$order31.getTempOrder) === null || _this$store$order31$g === void 0 || (_this$store$order31$g = _this$store$order31$g.call(_this$store$order31)) === null || _this$store$order31$g === void 0 ? void 0 : _this$store$order31$g.currency_code) || ((_this$otherParams44 = this.otherParams) === null || _this$otherParams44 === void 0 ? void 0 : _this$otherParams44.currency) || 'USD';
6634
6770
  recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
6635
- return _context65.abrupt("return", {
6771
+ return _context67.abrupt("return", {
6636
6772
  available: Boolean(paymentMethod && amountDue > 0),
6637
6773
  paymentMethod: paymentMethod,
6638
6774
  amountDue: amountDue,
@@ -6640,9 +6776,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6640
6776
  });
6641
6777
  case 18:
6642
6778
  case "end":
6643
- return _context65.stop();
6779
+ return _context67.stop();
6644
6780
  }
6645
- }, _callee65, this);
6781
+ }, _callee67, this);
6646
6782
  }));
6647
6783
  function getCashPaymentConfig() {
6648
6784
  return _getCashPaymentConfig.apply(this, arguments);
@@ -6659,45 +6795,45 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6659
6795
  }, {
6660
6796
  key: "confirmWalletPayment",
6661
6797
  value: (function () {
6662
- var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66() {
6798
+ var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68() {
6663
6799
  var _this$store$order$get9, _this$store$order32, _this$store$order$get11, _this$store$order$get12, _this$store$order34;
6664
6800
  var beforePayments, pendingWalletAmount, amountSnapshot, _this$store$order$get10, _this$store$order33, _submitResult, _latestAmountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
6665
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6666
- while (1) switch (_context66.prev = _context66.next) {
6801
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6802
+ while (1) switch (_context68.prev = _context68.next) {
6667
6803
  case 0:
6668
6804
  if (this.store.order) {
6669
- _context66.next = 2;
6805
+ _context68.next = 2;
6670
6806
  break;
6671
6807
  }
6672
6808
  throw new Error('order 模块未初始化');
6673
6809
  case 2:
6674
- _context66.next = 4;
6810
+ _context68.next = 4;
6675
6811
  return this.validateContactInfo();
6676
6812
  case 4:
6677
6813
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
6678
6814
  pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
6679
6815
  amountSnapshot = (_this$store$order$get9 = (_this$store$order32 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get9 === void 0 ? void 0 : _this$store$order$get9.call(_this$store$order32);
6680
6816
  if (!pendingWalletAmount.lte(0)) {
6681
- _context66.next = 16;
6817
+ _context68.next = 16;
6682
6818
  break;
6683
6819
  }
6684
6820
  this.logWarning('confirmWalletPayment: 未发现待确认 Wallet 支付,跳过 Wallet 确认并按普通订单提交', {
6685
6821
  amountGap: amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap
6686
6822
  });
6687
- _context66.next = 11;
6823
+ _context68.next = 11;
6688
6824
  return this.submitSalesOrder({
6689
6825
  smallTicketDataFlag: 1
6690
6826
  });
6691
6827
  case 11:
6692
- _submitResult = _context66.sent;
6828
+ _submitResult = _context68.sent;
6693
6829
  if (!isRejectedSalesSubmitResult(_submitResult)) {
6694
- _context66.next = 14;
6830
+ _context68.next = 14;
6695
6831
  break;
6696
6832
  }
6697
6833
  throw new Error(getSalesSubmitErrorMessage(_submitResult, '订单提交失败'));
6698
6834
  case 14:
6699
6835
  _latestAmountSnapshot = (_this$store$order$get10 = (_this$store$order33 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get10 === void 0 ? void 0 : _this$store$order$get10.call(_this$store$order33);
6700
- return _context66.abrupt("return", {
6836
+ return _context68.abrupt("return", {
6701
6837
  submitResult: _submitResult,
6702
6838
  payments: this.store.order.getOrderPayments(),
6703
6839
  isOrderFullyPaid: new Decimal((_latestAmountSnapshot === null || _latestAmountSnapshot === void 0 ? void 0 : _latestAmountSnapshot.amountGap) || 0).lte(0)
@@ -6705,74 +6841,74 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6705
6841
  case 16:
6706
6842
  effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
6707
6843
  if (!effectiveAmountDue.gt(0.01)) {
6708
- _context66.next = 19;
6844
+ _context68.next = 19;
6709
6845
  break;
6710
6846
  }
6711
6847
  throw new Error('Wallet 支付尚未覆盖全部待支付金额');
6712
6848
  case 19:
6713
6849
  beforePaymentStatus = (_this$store$order$get11 = this.store.order.getTempOrder()) === null || _this$store$order$get11 === void 0 ? void 0 : _this$store$order$get11.payment_status;
6714
- _context66.prev = 20;
6715
- _context66.next = 23;
6850
+ _context68.prev = 20;
6851
+ _context68.next = 23;
6716
6852
  return this.submitSalesOrder({
6717
6853
  smallTicketDataFlag: 1,
6718
6854
  confirmPendingVoucherPayments: true
6719
6855
  });
6720
6856
  case 23:
6721
- submitResult = _context66.sent;
6857
+ submitResult = _context68.sent;
6722
6858
  if (!isRejectedSalesSubmitResult(submitResult)) {
6723
- _context66.next = 26;
6859
+ _context68.next = 26;
6724
6860
  break;
6725
6861
  }
6726
6862
  throw new Error(getSalesSubmitErrorMessage(submitResult, 'Wallet 支付确认失败'));
6727
6863
  case 26:
6728
- _context66.next = 36;
6864
+ _context68.next = 36;
6729
6865
  break;
6730
6866
  case 28:
6731
- _context66.prev = 28;
6732
- _context66.t0 = _context66["catch"](20);
6867
+ _context68.prev = 28;
6868
+ _context68.t0 = _context68["catch"](20);
6733
6869
  this.store.order.setOrderPayments(beforePayments);
6734
6870
  restoredTempOrder = this.store.order.getTempOrder();
6735
6871
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
6736
6872
  restoredTempOrder.payment_status = beforePaymentStatus;
6737
6873
  this.store.order.persistTempOrder();
6738
6874
  }
6739
- _context66.next = 35;
6875
+ _context68.next = 35;
6740
6876
  return this.store.order.recalculateSummary({
6741
6877
  createIfMissing: true
6742
6878
  });
6743
6879
  case 35:
6744
- throw _context66.t0;
6880
+ throw _context68.t0;
6745
6881
  case 36:
6746
6882
  if (!this.store.payment) {
6747
- _context66.next = 47;
6883
+ _context68.next = 47;
6748
6884
  break;
6749
6885
  }
6750
- _context66.prev = 37;
6886
+ _context68.prev = 37;
6751
6887
  committed = this.getCommittedWalletAssets();
6752
6888
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
6753
- _context66.next = 42;
6889
+ _context68.next = 42;
6754
6890
  return this.publishWalletAssetsState(walletState, 'local');
6755
6891
  case 42:
6756
- _context66.next = 47;
6892
+ _context68.next = 47;
6757
6893
  break;
6758
6894
  case 44:
6759
- _context66.prev = 44;
6760
- _context66.t1 = _context66["catch"](37);
6895
+ _context68.prev = 44;
6896
+ _context68.t1 = _context68["catch"](37);
6761
6897
  this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
6762
- error: _context66.t1 instanceof Error ? _context66.t1.message : String(_context66.t1)
6898
+ error: _context68.t1 instanceof Error ? _context68.t1.message : String(_context68.t1)
6763
6899
  });
6764
6900
  case 47:
6765
6901
  latestAmountSnapshot = (_this$store$order$get12 = (_this$store$order34 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get12 === void 0 ? void 0 : _this$store$order$get12.call(_this$store$order34);
6766
- return _context66.abrupt("return", {
6902
+ return _context68.abrupt("return", {
6767
6903
  submitResult: submitResult,
6768
6904
  payments: this.store.order.getOrderPayments(),
6769
6905
  isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
6770
6906
  });
6771
6907
  case 49:
6772
6908
  case "end":
6773
- return _context66.stop();
6909
+ return _context68.stop();
6774
6910
  }
6775
- }, _callee66, this, [[20, 28], [37, 44]]);
6911
+ }, _callee68, this, [[20, 28], [37, 44]]);
6776
6912
  }));
6777
6913
  function confirmWalletPayment() {
6778
6914
  return _confirmWalletPayment.apply(this, arguments);
@@ -6787,56 +6923,56 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6787
6923
  }, {
6788
6924
  key: "payCash",
6789
6925
  value: (function () {
6790
- var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(params) {
6791
- var _this$store$order$get13, _params$actualPaidAmo, _this$otherParams42, _this$window, _this$window$postMess;
6926
+ var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(params) {
6927
+ var _this$store$order$get13, _params$actualPaidAmo, _this$otherParams45, _this$window, _this$window$postMess;
6792
6928
  var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, actualPaidAmount, changeAmount, shopWalletPassId, paymentTimestamp, payments, payment, syncResult, committed, walletState, restoredTempOrder;
6793
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6794
- while (1) switch (_context67.prev = _context67.next) {
6929
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6930
+ while (1) switch (_context69.prev = _context69.next) {
6795
6931
  case 0:
6796
6932
  if (this.store.order) {
6797
- _context67.next = 2;
6933
+ _context69.next = 2;
6798
6934
  break;
6799
6935
  }
6800
6936
  throw new Error('order 模块未初始化');
6801
6937
  case 2:
6802
- _context67.next = 4;
6938
+ _context69.next = 4;
6803
6939
  return this.validateContactInfo();
6804
6940
  case 4:
6805
6941
  amount = Number(params.amount || 0);
6806
6942
  if (!(!Number.isFinite(amount) || amount <= 0)) {
6807
- _context67.next = 7;
6943
+ _context69.next = 7;
6808
6944
  break;
6809
6945
  }
6810
6946
  throw new Error('现金支付金额必须大于 0');
6811
6947
  case 7:
6812
6948
  if (!(params.paymentMethodId === undefined)) {
6813
- _context67.next = 13;
6949
+ _context69.next = 13;
6814
6950
  break;
6815
6951
  }
6816
- _context67.next = 10;
6952
+ _context69.next = 10;
6817
6953
  return this.getCashPaymentConfig();
6818
6954
  case 10:
6819
- _context67.t0 = _context67.sent;
6820
- _context67.next = 16;
6955
+ _context69.t0 = _context69.sent;
6956
+ _context69.next = 16;
6821
6957
  break;
6822
6958
  case 13:
6823
- _context67.next = 15;
6959
+ _context69.next = 15;
6824
6960
  return this.getCashPaymentConfig({
6825
6961
  paymentMethodId: params.paymentMethodId
6826
6962
  });
6827
6963
  case 15:
6828
- _context67.t0 = _context67.sent;
6964
+ _context69.t0 = _context69.sent;
6829
6965
  case 16:
6830
- config = _context67.t0;
6966
+ config = _context69.t0;
6831
6967
  paymentMethod = config.paymentMethod;
6832
6968
  if (paymentMethod) {
6833
- _context67.next = 20;
6969
+ _context69.next = 20;
6834
6970
  break;
6835
6971
  }
6836
6972
  throw new Error('未找到可用的 CASHMANUAL 支付方式');
6837
6973
  case 20:
6838
6974
  if (!(config.amountDue <= 0)) {
6839
- _context67.next = 22;
6975
+ _context69.next = 22;
6840
6976
  break;
6841
6977
  }
6842
6978
  throw new Error('当前订单没有待支付金额');
@@ -6844,7 +6980,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6844
6980
  roundingAmount = Number(params.roundingAmount || 0);
6845
6981
  effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
6846
6982
  if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
6847
- _context67.next = 26;
6983
+ _context69.next = 26;
6848
6984
  break;
6849
6985
  }
6850
6986
  throw new Error('现金支付金额超过当前待支付金额');
@@ -6854,18 +6990,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6854
6990
  uniquePaymentNumber = createUuidV4();
6855
6991
  actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
6856
6992
  changeAmount = Number(params.changeAmount || 0);
6857
- shopWalletPassId = (_this$otherParams42 = this.otherParams) === null || _this$otherParams42 === void 0 ? void 0 : _this$otherParams42.shop_wallet_pass_id;
6993
+ shopWalletPassId = (_this$otherParams45 = this.otherParams) === null || _this$otherParams45 === void 0 ? void 0 : _this$otherParams45.shop_wallet_pass_id;
6858
6994
  if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
6859
- _context67.next = 34;
6995
+ _context69.next = 34;
6860
6996
  break;
6861
6997
  }
6862
6998
  throw new Error('顾客实收现金不能小于支付金额');
6863
6999
  case 34:
6864
7000
  if (!this.isPickupTimingEnabled()) {
6865
- _context67.next = 37;
7001
+ _context69.next = 37;
6866
7002
  break;
6867
7003
  }
6868
- _context67.next = 37;
7004
+ _context69.next = 37;
6869
7005
  return this.preparePickupTimingForCheckout({
6870
7006
  freeze: true
6871
7007
  });
@@ -6902,8 +7038,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6902
7038
  var _item$metadata2;
6903
7039
  return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
6904
7040
  });
6905
- _context67.prev = 42;
6906
- _context67.next = 45;
7041
+ _context69.prev = 42;
7042
+ _context69.next = 45;
6907
7043
  return this.syncPaymentsToOrder({
6908
7044
  payments: payments,
6909
7045
  submitWhenPaid: true,
@@ -6911,50 +7047,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6911
7047
  confirmPendingVoucherPayments: true
6912
7048
  });
6913
7049
  case 45:
6914
- syncResult = _context67.sent;
7050
+ syncResult = _context69.sent;
6915
7051
  if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
6916
- _context67.next = 48;
7052
+ _context69.next = 48;
6917
7053
  break;
6918
7054
  }
6919
7055
  throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
6920
7056
  case 48:
6921
7057
  if (!this.store.payment) {
6922
- _context67.next = 53;
7058
+ _context69.next = 53;
6923
7059
  break;
6924
7060
  }
6925
7061
  committed = this.getCommittedWalletAssets();
6926
7062
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
6927
- _context67.next = 53;
7063
+ _context69.next = 53;
6928
7064
  return this.publishWalletAssetsState(walletState, 'local');
6929
7065
  case 53:
6930
- return _context67.abrupt("return", {
7066
+ return _context69.abrupt("return", {
6931
7067
  payment: payment || {},
6932
7068
  payments: this.store.order.getOrderPayments(),
6933
7069
  syncResult: syncResult,
6934
7070
  isOrderFullyPaid: syncResult.isOrderFullyPaid
6935
7071
  });
6936
7072
  case 56:
6937
- _context67.prev = 56;
6938
- _context67.t1 = _context67["catch"](42);
7073
+ _context69.prev = 56;
7074
+ _context69.t1 = _context69["catch"](42);
6939
7075
  this.store.order.setOrderPayments(beforePayments);
6940
7076
  restoredTempOrder = this.store.order.getTempOrder();
6941
7077
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
6942
7078
  restoredTempOrder.payment_status = beforePaymentStatus;
6943
7079
  this.store.order.persistTempOrder();
6944
7080
  }
6945
- _context67.next = 63;
7081
+ _context69.next = 63;
6946
7082
  return this.store.order.recalculateSummary({
6947
7083
  createIfMissing: true
6948
7084
  });
6949
7085
  case 63:
6950
- throw _context67.t1;
7086
+ throw _context69.t1;
6951
7087
  case 64:
6952
7088
  case "end":
6953
- return _context67.stop();
7089
+ return _context69.stop();
6954
7090
  }
6955
- }, _callee67, this, [[42, 56]]);
7091
+ }, _callee69, this, [[42, 56]]);
6956
7092
  }));
6957
- function payCash(_x52) {
7093
+ function payCash(_x55) {
6958
7094
  return _payCash.apply(this, arguments);
6959
7095
  }
6960
7096
  return payCash;
@@ -6970,21 +7106,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6970
7106
  }, {
6971
7107
  key: "commitPaymentMethodPayment",
6972
7108
  value: (function () {
6973
- var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(params) {
7109
+ var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
6974
7110
  var _this$store$order$get14, _this$store$order35, _this$store$order$get15, _params$metadata, _params$originAmount;
6975
7111
  var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
6976
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6977
- while (1) switch (_context68.prev = _context68.next) {
7112
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
7113
+ while (1) switch (_context70.prev = _context70.next) {
6978
7114
  case 0:
6979
7115
  if (this.store.order) {
6980
- _context68.next = 2;
7116
+ _context70.next = 2;
6981
7117
  break;
6982
7118
  }
6983
7119
  throw new Error('order 模块未初始化');
6984
7120
  case 2:
6985
7121
  amount = Number(params.amount || 0);
6986
7122
  if (!(!Number.isFinite(amount) || amount <= 0)) {
6987
- _context68.next = 5;
7123
+ _context70.next = 5;
6988
7124
  break;
6989
7125
  }
6990
7126
  throw new Error('支付金额必须大于 0');
@@ -7000,17 +7136,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7000
7136
  };
7001
7137
  paymentMethod = findPaymentMethod();
7002
7138
  if (paymentMethod) {
7003
- _context68.next = 13;
7139
+ _context70.next = 13;
7004
7140
  break;
7005
7141
  }
7006
- _context68.next = 11;
7142
+ _context70.next = 11;
7007
7143
  return this.getPaymentMethodsAsync();
7008
7144
  case 11:
7009
- paymentMethods = _context68.sent;
7145
+ paymentMethods = _context70.sent;
7010
7146
  paymentMethod = findPaymentMethod();
7011
7147
  case 13:
7012
7148
  if (paymentMethod) {
7013
- _context68.next = 15;
7149
+ _context70.next = 15;
7014
7150
  break;
7015
7151
  }
7016
7152
  throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
@@ -7019,13 +7155,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7019
7155
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
7020
7156
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
7021
7157
  if (!amountDue.lte(0)) {
7022
- _context68.next = 20;
7158
+ _context70.next = 20;
7023
7159
  break;
7024
7160
  }
7025
7161
  throw new Error('当前订单没有待支付金额');
7026
7162
  case 20:
7027
7163
  if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
7028
- _context68.next = 22;
7164
+ _context70.next = 22;
7029
7165
  break;
7030
7166
  }
7031
7167
  throw new Error('支付金额超过当前待支付金额');
@@ -7065,8 +7201,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7065
7201
  var _item$metadata3;
7066
7202
  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;
7067
7203
  });
7068
- _context68.prev = 31;
7069
- _context68.next = 34;
7204
+ _context70.prev = 31;
7205
+ _context70.next = 34;
7070
7206
  return this.syncPaymentsToOrder({
7071
7207
  payments: payments,
7072
7208
  submitWhenPaid: true,
@@ -7074,50 +7210,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7074
7210
  confirmPendingVoucherPayments: true
7075
7211
  });
7076
7212
  case 34:
7077
- syncResult = _context68.sent;
7213
+ syncResult = _context70.sent;
7078
7214
  if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
7079
- _context68.next = 37;
7215
+ _context70.next = 37;
7080
7216
  break;
7081
7217
  }
7082
7218
  throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
7083
7219
  case 37:
7084
7220
  if (!this.store.payment) {
7085
- _context68.next = 42;
7221
+ _context70.next = 42;
7086
7222
  break;
7087
7223
  }
7088
7224
  committed = this.getCommittedWalletAssets();
7089
7225
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
7090
- _context68.next = 42;
7226
+ _context70.next = 42;
7091
7227
  return this.publishWalletAssetsState(walletState, 'local');
7092
7228
  case 42:
7093
- return _context68.abrupt("return", {
7229
+ return _context70.abrupt("return", {
7094
7230
  payment: payment || {},
7095
7231
  payments: this.store.order.getOrderPayments(),
7096
7232
  syncResult: syncResult,
7097
7233
  isOrderFullyPaid: syncResult.isOrderFullyPaid
7098
7234
  });
7099
7235
  case 45:
7100
- _context68.prev = 45;
7101
- _context68.t0 = _context68["catch"](31);
7236
+ _context70.prev = 45;
7237
+ _context70.t0 = _context70["catch"](31);
7102
7238
  this.store.order.setOrderPayments(beforePayments);
7103
7239
  restoredTempOrder = this.store.order.getTempOrder();
7104
7240
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
7105
7241
  restoredTempOrder.payment_status = beforePaymentStatus;
7106
7242
  this.store.order.persistTempOrder();
7107
7243
  }
7108
- _context68.next = 52;
7244
+ _context70.next = 52;
7109
7245
  return this.store.order.recalculateSummary({
7110
7246
  createIfMissing: true
7111
7247
  });
7112
7248
  case 52:
7113
- throw _context68.t0;
7249
+ throw _context70.t0;
7114
7250
  case 53:
7115
7251
  case "end":
7116
- return _context68.stop();
7252
+ return _context70.stop();
7117
7253
  }
7118
- }, _callee68, this, [[31, 45]]);
7254
+ }, _callee70, this, [[31, 45]]);
7119
7255
  }));
7120
- function commitPaymentMethodPayment(_x53) {
7256
+ function commitPaymentMethodPayment(_x56) {
7121
7257
  return _commitPaymentMethodPayment.apply(this, arguments);
7122
7258
  }
7123
7259
  return commitPaymentMethodPayment;
@@ -7132,40 +7268,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7132
7268
  }, {
7133
7269
  key: "roundAmount",
7134
7270
  value: (function () {
7135
- var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(params) {
7271
+ var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params) {
7136
7272
  var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
7137
7273
  var amount, cashManualPayment;
7138
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
7139
- while (1) switch (_context69.prev = _context69.next) {
7274
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7275
+ while (1) switch (_context71.prev = _context71.next) {
7140
7276
  case 0:
7141
7277
  amount = params.amount;
7142
7278
  cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
7143
7279
  return paymentMethod.code === 'CASHMANUAL';
7144
7280
  });
7145
7281
  if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
7146
- _context69.next = 4;
7282
+ _context71.next = 4;
7147
7283
  break;
7148
7284
  }
7149
- return _context69.abrupt("return", {
7285
+ return _context71.abrupt("return", {
7150
7286
  originalAmount: amount.toString(),
7151
7287
  roundedAmount: amount.toString(),
7152
7288
  roundingDifference: '0.00'
7153
7289
  });
7154
7290
  case 4:
7155
7291
  if (this.payment) {
7156
- _context69.next = 6;
7292
+ _context71.next = 6;
7157
7293
  break;
7158
7294
  }
7159
7295
  throw new Error('payment 模块未初始化');
7160
7296
  case 6:
7161
- return _context69.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));
7297
+ return _context71.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));
7162
7298
  case 7:
7163
7299
  case "end":
7164
- return _context69.stop();
7300
+ return _context71.stop();
7165
7301
  }
7166
- }, _callee69, this);
7302
+ }, _callee71, this);
7167
7303
  }));
7168
- function roundAmount(_x54) {
7304
+ function roundAmount(_x57) {
7169
7305
  return _roundAmount.apply(this, arguments);
7170
7306
  }
7171
7307
  return roundAmount;
@@ -7180,49 +7316,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7180
7316
  }, {
7181
7317
  key: "sendCustomerPayLink",
7182
7318
  value: (function () {
7183
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
7319
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(params) {
7184
7320
  var orderIds, _ref56, _ref57, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
7185
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
7186
- while (1) switch (_context70.prev = _context70.next) {
7321
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7322
+ while (1) switch (_context72.prev = _context72.next) {
7187
7323
  case 0:
7188
7324
  if (this.store.order) {
7189
- _context70.next = 2;
7325
+ _context72.next = 2;
7190
7326
  break;
7191
7327
  }
7192
7328
  throw new Error('order 模块未初始化');
7193
7329
  case 2:
7194
7330
  orderIds = params.order_ids || params.orderIds || [];
7195
7331
  if (!(!orderIds.length || params.submitBeforeSend)) {
7196
- _context70.next = 11;
7332
+ _context72.next = 11;
7197
7333
  break;
7198
7334
  }
7199
- _context70.next = 6;
7335
+ _context72.next = 6;
7200
7336
  return this.submitSalesOrder({
7201
7337
  smallTicketDataFlag: 1
7202
7338
  });
7203
7339
  case 6:
7204
- submitResult = _context70.sent;
7340
+ submitResult = _context72.sent;
7205
7341
  orderId = (_ref56 = (_ref57 = (_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 && _ref57 !== void 0 ? _ref57 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref56 !== void 0 ? _ref56 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
7206
7342
  if (orderId) {
7207
- _context70.next = 10;
7343
+ _context72.next = 10;
7208
7344
  break;
7209
7345
  }
7210
7346
  throw new Error('本地订单提交云端失败,无法发送支付链接');
7211
7347
  case 10:
7212
7348
  orderIds = [orderId];
7213
7349
  case 11:
7214
- return _context70.abrupt("return", this.store.order.sendCustomerPayLink({
7350
+ return _context72.abrupt("return", this.store.order.sendCustomerPayLink({
7215
7351
  emails: params.emails,
7216
7352
  notify_action: params.notify_action,
7217
7353
  order_ids: orderIds
7218
7354
  }));
7219
7355
  case 12:
7220
7356
  case "end":
7221
- return _context70.stop();
7357
+ return _context72.stop();
7222
7358
  }
7223
- }, _callee70, this);
7359
+ }, _callee72, this);
7224
7360
  }));
7225
- function sendCustomerPayLink(_x55) {
7361
+ function sendCustomerPayLink(_x58) {
7226
7362
  return _sendCustomerPayLink.apply(this, arguments);
7227
7363
  }
7228
7364
  return sendCustomerPayLink;
@@ -7237,14 +7373,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7237
7373
  }, {
7238
7374
  key: "calculateVenueCatalogProductBookingPrice",
7239
7375
  value: (function () {
7240
- var _calculateVenueCatalogProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params, source) {
7376
+ var _calculateVenueCatalogProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(params, source) {
7241
7377
  var _params$customer_id;
7242
7378
  var customerId, channel, queryPayload, authoritativeProduct;
7243
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
7244
- while (1) switch (_context71.prev = _context71.next) {
7379
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7380
+ while (1) switch (_context73.prev = _context73.next) {
7245
7381
  case 0:
7246
7382
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
7247
- _context71.next = 3;
7383
+ _context73.next = 3;
7248
7384
  return this.prepareProductPriceQueryContext(customerId);
7249
7385
  case 3:
7250
7386
  channel = this.getPriceQueryChannel(params.channel);
@@ -7261,14 +7397,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7261
7397
  queryPayload: queryPayload
7262
7398
  });
7263
7399
  if (authoritativeProduct) {
7264
- _context71.next = 8;
7400
+ _context73.next = 8;
7265
7401
  break;
7266
7402
  }
7267
7403
  throw Object.assign(new Error('Complete product pricing rules are not ready. Please retry.'), {
7268
7404
  code: 'VENUE_LOCAL_PRICE_UNAVAILABLE'
7269
7405
  });
7270
7406
  case 8:
7271
- return _context71.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
7407
+ return _context73.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
7272
7408
  channel: channel,
7273
7409
  customer_id: customerId,
7274
7410
  product: this.mergeProductForPriceQuery(params.product, authoritativeProduct),
@@ -7277,11 +7413,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7277
7413
  })));
7278
7414
  case 9:
7279
7415
  case "end":
7280
- return _context71.stop();
7416
+ return _context73.stop();
7281
7417
  }
7282
- }, _callee71, this);
7418
+ }, _callee73, this);
7283
7419
  }));
7284
- function calculateVenueCatalogProductBookingPrice(_x56, _x57) {
7420
+ function calculateVenueCatalogProductBookingPrice(_x59, _x60) {
7285
7421
  return _calculateVenueCatalogProductBookingPrice.apply(this, arguments);
7286
7422
  }
7287
7423
  return calculateVenueCatalogProductBookingPrice;
@@ -7289,25 +7425,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7289
7425
  }, {
7290
7426
  key: "calculateProductBookingPrice",
7291
7427
  value: function () {
7292
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(params) {
7428
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(params) {
7293
7429
  var _yield$this$calculate, _yield$this$calculate2, result;
7294
- return _regeneratorRuntime().wrap(function _callee72$(_context72) {
7295
- while (1) switch (_context72.prev = _context72.next) {
7430
+ return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7431
+ while (1) switch (_context74.prev = _context74.next) {
7296
7432
  case 0:
7297
- _context72.next = 2;
7433
+ _context74.next = 2;
7298
7434
  return this.calculateProductBookingPrices([params]);
7299
7435
  case 2:
7300
- _yield$this$calculate = _context72.sent;
7436
+ _yield$this$calculate = _context74.sent;
7301
7437
  _yield$this$calculate2 = _slicedToArray(_yield$this$calculate, 1);
7302
7438
  result = _yield$this$calculate2[0];
7303
- return _context72.abrupt("return", result);
7439
+ return _context74.abrupt("return", result);
7304
7440
  case 6:
7305
7441
  case "end":
7306
- return _context72.stop();
7442
+ return _context74.stop();
7307
7443
  }
7308
- }, _callee72, this);
7444
+ }, _callee74, this);
7309
7445
  }));
7310
- function calculateProductBookingPrice(_x58) {
7446
+ function calculateProductBookingPrice(_x61) {
7311
7447
  return _calculateProductBookingPrice.apply(this, arguments);
7312
7448
  }
7313
7449
  return calculateProductBookingPrice;
@@ -7315,7 +7451,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7315
7451
  }, {
7316
7452
  key: "getQuotationCustomerScopeInfo",
7317
7453
  value: function getQuotationCustomerScopeInfo() {
7318
- var _this23 = this;
7454
+ var _this24 = this;
7319
7455
  var quotation = this.store.quotation;
7320
7456
  if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
7321
7457
  return quotation.getQuotationCustomerScopeInfo();
@@ -7327,7 +7463,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7327
7463
  }).map(function (item) {
7328
7464
  var localSeen = new Set();
7329
7465
  var customers = item.customer.filter(function (customer) {
7330
- var customerId = _this23.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
7466
+ var customerId = _this24.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
7331
7467
  if (!customerId || localSeen.has(customerId)) return false;
7332
7468
  localSeen.add(customerId);
7333
7469
  if (!customerById.has(customerId)) customerById.set(customerId, customer);
@@ -7391,20 +7527,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7391
7527
  }, {
7392
7528
  key: "resolveProductBookingPriceGroups",
7393
7529
  value: function () {
7394
- var _resolveProductBookingPriceGroups = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(paramsList, currentOrderCustomerId) {
7395
- var _this24 = this,
7396
- _this$otherParams43;
7530
+ var _resolveProductBookingPriceGroups = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(paramsList, currentOrderCustomerId) {
7531
+ var _this25 = this,
7532
+ _this$otherParams46;
7397
7533
  var strictDurationPricing,
7398
7534
  resolvedChannels,
7399
7535
  authoritativeProducts,
7400
7536
  groups,
7401
- _args74 = arguments;
7402
- return _regeneratorRuntime().wrap(function _callee74$(_context74) {
7403
- while (1) switch (_context74.prev = _context74.next) {
7537
+ _args76 = arguments;
7538
+ return _regeneratorRuntime().wrap(function _callee76$(_context76) {
7539
+ while (1) switch (_context76.prev = _context76.next) {
7404
7540
  case 0:
7405
- strictDurationPricing = _args74.length > 2 && _args74[2] !== undefined ? _args74[2] : false;
7541
+ strictDurationPricing = _args76.length > 2 && _args76[2] !== undefined ? _args76[2] : false;
7406
7542
  resolvedChannels = paramsList.map(function (params) {
7407
- return _this24.getPriceQueryChannel(params.channel);
7543
+ return _this25.getPriceQueryChannel(params.channel);
7408
7544
  });
7409
7545
  authoritativeProducts = paramsList.map(function () {
7410
7546
  return null;
@@ -7412,10 +7548,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7412
7548
  groups = new Map();
7413
7549
  paramsList.forEach(function (params, index) {
7414
7550
  var _params$customer_id2;
7415
- var schedule = _this24.getPriceQuerySchedule(params);
7551
+ var schedule = _this25.getPriceQuerySchedule(params);
7416
7552
  var channel = resolvedChannels[index];
7417
7553
  var customerId = (_params$customer_id2 = params.customer_id) !== null && _params$customer_id2 !== void 0 ? _params$customer_id2 : currentOrderCustomerId;
7418
- var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || '', _this24.normalizePriceContextCustomerId(customerId) || ''].join('|');
7554
+ var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || '', _this25.normalizePriceContextCustomerId(customerId) || ''].join('|');
7419
7555
  var group = groups.get(groupKey) || {
7420
7556
  indices: [],
7421
7557
  schedule: schedule,
@@ -7425,21 +7561,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7425
7561
  group.indices.push(index);
7426
7562
  groups.set(groupKey, group);
7427
7563
  });
7428
- _context74.next = 7;
7564
+ _context76.next = 7;
7429
7565
  return forEachPriceQueryGroup(Array.from(groups.values()), /*#__PURE__*/function () {
7430
- var _ref58 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(group) {
7566
+ var _ref58 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(group) {
7431
7567
  var priceQueries, resolvedProducts;
7432
- return _regeneratorRuntime().wrap(function _callee73$(_context73) {
7433
- while (1) switch (_context73.prev = _context73.next) {
7568
+ return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7569
+ while (1) switch (_context75.prev = _context75.next) {
7434
7570
  case 0:
7435
- _context73.next = 2;
7436
- return _this24.prepareProductPriceQueryContext(group.customerId);
7571
+ _context75.next = 2;
7572
+ return _this25.prepareProductPriceQueryContext(group.customerId);
7437
7573
  case 2:
7438
7574
  priceQueries = group.indices.map(function (index) {
7439
7575
  return paramsList[index];
7440
7576
  });
7441
- _context73.next = 5;
7442
- return _this24.resolveProductsForPriceQuery({
7577
+ _context75.next = 5;
7578
+ return _this25.resolveProductsForPriceQuery({
7443
7579
  priceQueries: priceQueries,
7444
7580
  schedule: group.schedule,
7445
7581
  customerId: group.customerId,
@@ -7447,29 +7583,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7447
7583
  strictDurationPricing: strictDurationPricing
7448
7584
  });
7449
7585
  case 5:
7450
- resolvedProducts = _context73.sent;
7586
+ resolvedProducts = _context75.sent;
7451
7587
  group.indices.forEach(function (originalIndex, groupIndex) {
7452
7588
  authoritativeProducts[originalIndex] = resolvedProducts[groupIndex] || null;
7453
7589
  });
7454
7590
  case 7:
7455
7591
  case "end":
7456
- return _context73.stop();
7592
+ return _context75.stop();
7457
7593
  }
7458
- }, _callee73);
7594
+ }, _callee75);
7459
7595
  }));
7460
- return function (_x61) {
7596
+ return function (_x64) {
7461
7597
  return _ref58.apply(this, arguments);
7462
7598
  };
7463
- }(), normalizeRuntimePlatform((_this$otherParams43 = this.otherParams) === null || _this$otherParams43 === void 0 ? void 0 : _this$otherParams43.platform) === 'pos' ? 4 : groups.size);
7599
+ }(), normalizeRuntimePlatform((_this$otherParams46 = this.otherParams) === null || _this$otherParams46 === void 0 ? void 0 : _this$otherParams46.platform) === 'pos' ? 4 : groups.size);
7464
7600
  case 7:
7465
- return _context74.abrupt("return", authoritativeProducts);
7601
+ return _context76.abrupt("return", authoritativeProducts);
7466
7602
  case 8:
7467
7603
  case "end":
7468
- return _context74.stop();
7604
+ return _context76.stop();
7469
7605
  }
7470
- }, _callee74, this);
7606
+ }, _callee76, this);
7471
7607
  }));
7472
- function resolveProductBookingPriceGroups(_x59, _x60) {
7608
+ function resolveProductBookingPriceGroups(_x62, _x63) {
7473
7609
  return _resolveProductBookingPriceGroups.apply(this, arguments);
7474
7610
  }
7475
7611
  return resolveProductBookingPriceGroups;
@@ -7477,34 +7613,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7477
7613
  }, {
7478
7614
  key: "calculateProductBookingPrices",
7479
7615
  value: function () {
7480
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(paramsList) {
7481
- var _this$otherParams44,
7482
- _this25 = this;
7616
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(paramsList) {
7617
+ var _this$otherParams47,
7618
+ _this26 = this;
7483
7619
  var useCustomerUserPricing, isPos, quotation, currentOrderCustomerId, resolvedChannels, authoritativeProducts, plans, segmentQueries, segmentQueryIndices, segmentProducts, quotationContexts;
7484
- return _regeneratorRuntime().wrap(function _callee75$(_context75) {
7485
- while (1) switch (_context75.prev = _context75.next) {
7620
+ return _regeneratorRuntime().wrap(function _callee77$(_context77) {
7621
+ while (1) switch (_context77.prev = _context77.next) {
7486
7622
  case 0:
7487
7623
  if (paramsList.length) {
7488
- _context75.next = 2;
7624
+ _context77.next = 2;
7489
7625
  break;
7490
7626
  }
7491
- return _context75.abrupt("return", []);
7627
+ return _context77.abrupt("return", []);
7492
7628
  case 2:
7493
7629
  useCustomerUserPricing = this.isCustomerUserPriceQuery();
7494
- isPos = normalizeRuntimePlatform((_this$otherParams44 = this.otherParams) === null || _this$otherParams44 === void 0 ? void 0 : _this$otherParams44.platform) === 'pos';
7630
+ isPos = normalizeRuntimePlatform((_this$otherParams47 = this.otherParams) === null || _this$otherParams47 === void 0 ? void 0 : _this$otherParams47.platform) === 'pos';
7495
7631
  quotation = useCustomerUserPricing ? undefined : this.store.quotation;
7496
7632
  currentOrderCustomerId = this.getCurrentOrderCustomerId();
7497
7633
  resolvedChannels = paramsList.map(function (params) {
7498
- return _this25.getPriceQueryChannel(params.channel);
7634
+ return _this26.getPriceQueryChannel(params.channel);
7499
7635
  });
7500
- _context75.next = 9;
7636
+ _context77.next = 9;
7501
7637
  return this.resolveProductBookingPriceGroups(paramsList, currentOrderCustomerId);
7502
7638
  case 9:
7503
- authoritativeProducts = _context75.sent;
7639
+ authoritativeProducts = _context77.sent;
7504
7640
  if (!paramsList.some(function (params, index) {
7505
7641
  return params.requireAuthoritativePrice && !authoritativeProducts[index];
7506
7642
  })) {
7507
- _context75.next = 12;
7643
+ _context77.next = 12;
7508
7644
  break;
7509
7645
  }
7510
7646
  throw new Error('The current customer product price is unavailable. Please retry before paying.');
@@ -7538,20 +7674,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7538
7674
  return queryIndex;
7539
7675
  })) || [];
7540
7676
  });
7541
- _context75.next = 17;
7677
+ _context77.next = 17;
7542
7678
  return this.resolveProductBookingPriceGroups(segmentQueries, currentOrderCustomerId, true);
7543
7679
  case 17:
7544
- segmentProducts = _context75.sent;
7680
+ segmentProducts = _context77.sent;
7545
7681
  if (!segmentProducts.some(function (product) {
7546
7682
  return !product;
7547
7683
  })) {
7548
- _context75.next = 20;
7684
+ _context77.next = 20;
7549
7685
  break;
7550
7686
  }
7551
7687
  throw durationPricingUnavailable('An authoritative product is missing for a billing unit.');
7552
7688
  case 20:
7553
7689
  if (useCustomerUserPricing) {
7554
- _context75.next = 25;
7690
+ _context77.next = 25;
7555
7691
  break;
7556
7692
  }
7557
7693
  quotationContexts = new Map();
@@ -7566,18 +7702,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7566
7702
  customer_id: (_params$customer_id3 = params.customer_id) !== null && _params$customer_id3 !== void 0 ? _params$customer_id3 : currentOrderCustomerId
7567
7703
  });
7568
7704
  });
7569
- _context75.next = 25;
7705
+ _context77.next = 25;
7570
7706
  return Promise.all(Array.from(quotationContexts.values()).map(function (context) {
7571
- return _this25.loadQuotationForPriceQuery(_objectSpread({
7707
+ return _this26.loadQuotationForPriceQuery(_objectSpread({
7572
7708
  quotation: quotation
7573
7709
  }, context));
7574
7710
  }));
7575
7711
  case 25:
7576
- return _context75.abrupt("return", paramsList.map(function (params, index) {
7712
+ return _context77.abrupt("return", paramsList.map(function (params, index) {
7577
7713
  var _params$customer_id4, _authoritativeProduct2, _params$duration;
7578
7714
  var productInput = params.product || {};
7579
7715
  var authoritativeProduct = authoritativeProducts[index];
7580
- var product = _this25.mergeProductForPriceQuery(productInput, authoritativeProduct);
7716
+ var product = _this26.mergeProductForPriceQuery(productInput, authoritativeProduct);
7581
7717
  var customerId = (_params$customer_id4 = params.customer_id) !== null && _params$customer_id4 !== void 0 ? _params$customer_id4 : currentOrderCustomerId;
7582
7718
  var channel = resolvedChannels[index];
7583
7719
  var plan = plans[index];
@@ -7588,7 +7724,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7588
7724
  var prices = unitProducts.map(function (unitProduct, unitIndex) {
7589
7725
  return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
7590
7726
  channel: channel,
7591
- product: _this25.mergeProductForPriceQuery(unitIndex === 0 ? productInput : _objectSpread(_objectSpread({}, productInput), {}, {
7727
+ product: _this26.mergeProductForPriceQuery(unitIndex === 0 ? productInput : _objectSpread(_objectSpread({}, productInput), {}, {
7592
7728
  product_bundle: undefined
7593
7729
  }), unitProduct),
7594
7730
  booking: _objectSpread(_objectSpread({}, params.booking), {}, {
@@ -7614,7 +7750,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7614
7750
  product: product,
7615
7751
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
7616
7752
  customer_id: customerId,
7617
- quotation: authoritativeProduct && _this25.preferAuthoritativeProductQueryPrice() ? undefined : quotation
7753
+ quotation: authoritativeProduct && _this26.preferAuthoritativeProductQueryPrice() ? undefined : quotation
7618
7754
  }));
7619
7755
  return changedToFixed ? _objectSpread(_objectSpread({}, result), {}, {
7620
7756
  pricing_method: {
@@ -7625,11 +7761,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7625
7761
  }));
7626
7762
  case 26:
7627
7763
  case "end":
7628
- return _context75.stop();
7764
+ return _context77.stop();
7629
7765
  }
7630
- }, _callee75, this);
7766
+ }, _callee77, this);
7631
7767
  }));
7632
- function calculateProductBookingPrices(_x62) {
7768
+ function calculateProductBookingPrices(_x65) {
7633
7769
  return _calculateProductBookingPrices.apply(this, arguments);
7634
7770
  }
7635
7771
  return calculateProductBookingPrices;
@@ -7649,47 +7785,47 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7649
7785
  }, {
7650
7786
  key: "addProductToOrder",
7651
7787
  value: function () {
7652
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(product, booking, options) {
7788
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78(product, booking, options) {
7653
7789
  var products;
7654
- return _regeneratorRuntime().wrap(function _callee76$(_context76) {
7655
- while (1) switch (_context76.prev = _context76.next) {
7790
+ return _regeneratorRuntime().wrap(function _callee78$(_context78) {
7791
+ while (1) switch (_context78.prev = _context78.next) {
7656
7792
  case 0:
7657
- _context76.prev = 0;
7793
+ _context78.prev = 0;
7658
7794
  if (this.store.order) {
7659
- _context76.next = 3;
7795
+ _context78.next = 3;
7660
7796
  break;
7661
7797
  }
7662
7798
  throw new Error('order 模块未初始化');
7663
7799
  case 3:
7664
7800
  if (!(options === undefined)) {
7665
- _context76.next = 9;
7801
+ _context78.next = 9;
7666
7802
  break;
7667
7803
  }
7668
- _context76.next = 6;
7804
+ _context78.next = 6;
7669
7805
  return this.store.order.addProductToOrder(product, booking);
7670
7806
  case 6:
7671
- _context76.t0 = _context76.sent;
7672
- _context76.next = 12;
7807
+ _context78.t0 = _context78.sent;
7808
+ _context78.next = 12;
7673
7809
  break;
7674
7810
  case 9:
7675
- _context76.next = 11;
7811
+ _context78.next = 11;
7676
7812
  return this.store.order.addProductToOrder(product, booking, options);
7677
7813
  case 11:
7678
- _context76.t0 = _context76.sent;
7814
+ _context78.t0 = _context78.sent;
7679
7815
  case 12:
7680
- products = _context76.t0;
7681
- return _context76.abrupt("return", products);
7816
+ products = _context78.t0;
7817
+ return _context78.abrupt("return", products);
7682
7818
  case 16:
7683
- _context76.prev = 16;
7684
- _context76.t1 = _context76["catch"](0);
7685
- throw _context76.t1;
7819
+ _context78.prev = 16;
7820
+ _context78.t1 = _context78["catch"](0);
7821
+ throw _context78.t1;
7686
7822
  case 19:
7687
7823
  case "end":
7688
- return _context76.stop();
7824
+ return _context78.stop();
7689
7825
  }
7690
- }, _callee76, this, [[0, 16]]);
7826
+ }, _callee78, this, [[0, 16]]);
7691
7827
  }));
7692
- function addProductToOrder(_x63, _x64, _x65) {
7828
+ function addProductToOrder(_x66, _x67, _x68) {
7693
7829
  return _addProductToOrder.apply(this, arguments);
7694
7830
  }
7695
7831
  return addProductToOrder;
@@ -7697,34 +7833,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7697
7833
  }, {
7698
7834
  key: "updateOrderProduct",
7699
7835
  value: function () {
7700
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(params) {
7836
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79(params) {
7701
7837
  var products;
7702
- return _regeneratorRuntime().wrap(function _callee77$(_context77) {
7703
- while (1) switch (_context77.prev = _context77.next) {
7838
+ return _regeneratorRuntime().wrap(function _callee79$(_context79) {
7839
+ while (1) switch (_context79.prev = _context79.next) {
7704
7840
  case 0:
7705
- _context77.prev = 0;
7841
+ _context79.prev = 0;
7706
7842
  if (this.store.order) {
7707
- _context77.next = 3;
7843
+ _context79.next = 3;
7708
7844
  break;
7709
7845
  }
7710
7846
  throw new Error('order 模块未初始化');
7711
7847
  case 3:
7712
- _context77.next = 5;
7848
+ _context79.next = 5;
7713
7849
  return this.store.order.updateOrderProduct(params);
7714
7850
  case 5:
7715
- products = _context77.sent;
7716
- return _context77.abrupt("return", products);
7851
+ products = _context79.sent;
7852
+ return _context79.abrupt("return", products);
7717
7853
  case 9:
7718
- _context77.prev = 9;
7719
- _context77.t0 = _context77["catch"](0);
7720
- throw _context77.t0;
7854
+ _context79.prev = 9;
7855
+ _context79.t0 = _context79["catch"](0);
7856
+ throw _context79.t0;
7721
7857
  case 12:
7722
7858
  case "end":
7723
- return _context77.stop();
7859
+ return _context79.stop();
7724
7860
  }
7725
- }, _callee77, this, [[0, 9]]);
7861
+ }, _callee79, this, [[0, 9]]);
7726
7862
  }));
7727
- function updateOrderProduct(_x66) {
7863
+ function updateOrderProduct(_x69) {
7728
7864
  return _updateOrderProduct.apply(this, arguments);
7729
7865
  }
7730
7866
  return updateOrderProduct;
@@ -7732,34 +7868,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7732
7868
  }, {
7733
7869
  key: "updateOrderProducts",
7734
7870
  value: function () {
7735
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78(paramsList, options) {
7871
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(paramsList, options) {
7736
7872
  var products;
7737
- return _regeneratorRuntime().wrap(function _callee78$(_context78) {
7738
- while (1) switch (_context78.prev = _context78.next) {
7873
+ return _regeneratorRuntime().wrap(function _callee80$(_context80) {
7874
+ while (1) switch (_context80.prev = _context80.next) {
7739
7875
  case 0:
7740
- _context78.prev = 0;
7876
+ _context80.prev = 0;
7741
7877
  if (this.store.order) {
7742
- _context78.next = 3;
7878
+ _context80.next = 3;
7743
7879
  break;
7744
7880
  }
7745
7881
  throw new Error('order 模块未初始化');
7746
7882
  case 3:
7747
- _context78.next = 5;
7883
+ _context80.next = 5;
7748
7884
  return this.store.order.updateOrderProducts(paramsList, options);
7749
7885
  case 5:
7750
- products = _context78.sent;
7751
- return _context78.abrupt("return", products);
7886
+ products = _context80.sent;
7887
+ return _context80.abrupt("return", products);
7752
7888
  case 9:
7753
- _context78.prev = 9;
7754
- _context78.t0 = _context78["catch"](0);
7755
- throw _context78.t0;
7889
+ _context80.prev = 9;
7890
+ _context80.t0 = _context80["catch"](0);
7891
+ throw _context80.t0;
7756
7892
  case 12:
7757
7893
  case "end":
7758
- return _context78.stop();
7894
+ return _context80.stop();
7759
7895
  }
7760
- }, _callee78, this, [[0, 9]]);
7896
+ }, _callee80, this, [[0, 9]]);
7761
7897
  }));
7762
- function updateOrderProducts(_x67, _x68) {
7898
+ function updateOrderProducts(_x70, _x71) {
7763
7899
  return _updateOrderProducts.apply(this, arguments);
7764
7900
  }
7765
7901
  return updateOrderProducts;
@@ -7767,34 +7903,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7767
7903
  }, {
7768
7904
  key: "updateOrderProductQuantity",
7769
7905
  value: function () {
7770
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79(params) {
7906
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81(params) {
7771
7907
  var products;
7772
- return _regeneratorRuntime().wrap(function _callee79$(_context79) {
7773
- while (1) switch (_context79.prev = _context79.next) {
7908
+ return _regeneratorRuntime().wrap(function _callee81$(_context81) {
7909
+ while (1) switch (_context81.prev = _context81.next) {
7774
7910
  case 0:
7775
- _context79.prev = 0;
7911
+ _context81.prev = 0;
7776
7912
  if (this.store.order) {
7777
- _context79.next = 3;
7913
+ _context81.next = 3;
7778
7914
  break;
7779
7915
  }
7780
7916
  throw new Error('order 模块未初始化');
7781
7917
  case 3:
7782
- _context79.next = 5;
7918
+ _context81.next = 5;
7783
7919
  return this.store.order.updateOrderProductQuantity(params);
7784
7920
  case 5:
7785
- products = _context79.sent;
7786
- return _context79.abrupt("return", products);
7921
+ products = _context81.sent;
7922
+ return _context81.abrupt("return", products);
7787
7923
  case 9:
7788
- _context79.prev = 9;
7789
- _context79.t0 = _context79["catch"](0);
7790
- throw _context79.t0;
7924
+ _context81.prev = 9;
7925
+ _context81.t0 = _context81["catch"](0);
7926
+ throw _context81.t0;
7791
7927
  case 12:
7792
7928
  case "end":
7793
- return _context79.stop();
7929
+ return _context81.stop();
7794
7930
  }
7795
- }, _callee79, this, [[0, 9]]);
7931
+ }, _callee81, this, [[0, 9]]);
7796
7932
  }));
7797
- function updateOrderProductQuantity(_x69) {
7933
+ function updateOrderProductQuantity(_x72) {
7798
7934
  return _updateOrderProductQuantity.apply(this, arguments);
7799
7935
  }
7800
7936
  return updateOrderProductQuantity;
@@ -7817,12 +7953,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7817
7953
  }, {
7818
7954
  key: "setOrderProductLineNote",
7819
7955
  value: (function () {
7820
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(identity, note) {
7956
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82(identity, note) {
7821
7957
  var params, products;
7822
- return _regeneratorRuntime().wrap(function _callee80$(_context80) {
7823
- while (1) switch (_context80.prev = _context80.next) {
7958
+ return _regeneratorRuntime().wrap(function _callee82$(_context82) {
7959
+ while (1) switch (_context82.prev = _context82.next) {
7824
7960
  case 0:
7825
- _context80.prev = 0;
7961
+ _context82.prev = 0;
7826
7962
  params = {
7827
7963
  product_id: identity.product_id,
7828
7964
  product_variant_id: identity.product_variant_id,
@@ -7837,22 +7973,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7837
7973
  params.product_sku = identity.product_sku;
7838
7974
  }
7839
7975
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
7840
- _context80.next = 7;
7976
+ _context82.next = 7;
7841
7977
  return this.updateOrderProduct(params);
7842
7978
  case 7:
7843
- products = _context80.sent;
7844
- return _context80.abrupt("return", products);
7979
+ products = _context82.sent;
7980
+ return _context82.abrupt("return", products);
7845
7981
  case 11:
7846
- _context80.prev = 11;
7847
- _context80.t0 = _context80["catch"](0);
7848
- throw _context80.t0;
7982
+ _context82.prev = 11;
7983
+ _context82.t0 = _context82["catch"](0);
7984
+ throw _context82.t0;
7849
7985
  case 14:
7850
7986
  case "end":
7851
- return _context80.stop();
7987
+ return _context82.stop();
7852
7988
  }
7853
- }, _callee80, this, [[0, 11]]);
7989
+ }, _callee82, this, [[0, 11]]);
7854
7990
  }));
7855
- function setOrderProductLineNote(_x70, _x71) {
7991
+ function setOrderProductLineNote(_x73, _x74) {
7856
7992
  return _setOrderProductLineNote.apply(this, arguments);
7857
7993
  }
7858
7994
  return setOrderProductLineNote;
@@ -7867,45 +8003,45 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7867
8003
  }, {
7868
8004
  key: "removeProductsFromOrder",
7869
8005
  value: (function () {
7870
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81(identities, options) {
7871
- return _regeneratorRuntime().wrap(function _callee81$(_context81) {
7872
- while (1) switch (_context81.prev = _context81.next) {
8006
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83(identities, options) {
8007
+ return _regeneratorRuntime().wrap(function _callee83$(_context83) {
8008
+ while (1) switch (_context83.prev = _context83.next) {
7873
8009
  case 0:
7874
- _context81.prev = 0;
8010
+ _context83.prev = 0;
7875
8011
  if (this.store.order) {
7876
- _context81.next = 3;
8012
+ _context83.next = 3;
7877
8013
  break;
7878
8014
  }
7879
8015
  throw new Error('order 模块未初始化');
7880
8016
  case 3:
7881
8017
  if (!(options === undefined)) {
7882
- _context81.next = 9;
8018
+ _context83.next = 9;
7883
8019
  break;
7884
8020
  }
7885
- _context81.next = 6;
8021
+ _context83.next = 6;
7886
8022
  return this.store.order.removeProductsFromOrder(identities);
7887
8023
  case 6:
7888
- _context81.t0 = _context81.sent;
7889
- _context81.next = 12;
8024
+ _context83.t0 = _context83.sent;
8025
+ _context83.next = 12;
7890
8026
  break;
7891
8027
  case 9:
7892
- _context81.next = 11;
8028
+ _context83.next = 11;
7893
8029
  return this.store.order.removeProductsFromOrder(identities, options);
7894
8030
  case 11:
7895
- _context81.t0 = _context81.sent;
8031
+ _context83.t0 = _context83.sent;
7896
8032
  case 12:
7897
- return _context81.abrupt("return", _context81.t0);
8033
+ return _context83.abrupt("return", _context83.t0);
7898
8034
  case 15:
7899
- _context81.prev = 15;
7900
- _context81.t1 = _context81["catch"](0);
7901
- throw _context81.t1;
8035
+ _context83.prev = 15;
8036
+ _context83.t1 = _context83["catch"](0);
8037
+ throw _context83.t1;
7902
8038
  case 18:
7903
8039
  case "end":
7904
- return _context81.stop();
8040
+ return _context83.stop();
7905
8041
  }
7906
- }, _callee81, this, [[0, 15]]);
8042
+ }, _callee83, this, [[0, 15]]);
7907
8043
  }));
7908
- function removeProductsFromOrder(_x72, _x73) {
8044
+ function removeProductsFromOrder(_x75, _x76) {
7909
8045
  return _removeProductsFromOrder.apply(this, arguments);
7910
8046
  }
7911
8047
  return removeProductsFromOrder;
@@ -7913,18 +8049,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7913
8049
  }, {
7914
8050
  key: "removeProductFromOrder",
7915
8051
  value: function () {
7916
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82(identity, options) {
7917
- return _regeneratorRuntime().wrap(function _callee82$(_context82) {
7918
- while (1) switch (_context82.prev = _context82.next) {
8052
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee84(identity, options) {
8053
+ return _regeneratorRuntime().wrap(function _callee84$(_context84) {
8054
+ while (1) switch (_context84.prev = _context84.next) {
7919
8055
  case 0:
7920
- return _context82.abrupt("return", this.removeProductsFromOrder([identity], options));
8056
+ return _context84.abrupt("return", this.removeProductsFromOrder([identity], options));
7921
8057
  case 1:
7922
8058
  case "end":
7923
- return _context82.stop();
8059
+ return _context84.stop();
7924
8060
  }
7925
- }, _callee82, this);
8061
+ }, _callee84, this);
7926
8062
  }));
7927
- function removeProductFromOrder(_x74, _x75) {
8063
+ function removeProductFromOrder(_x77, _x78) {
7928
8064
  return _removeProductFromOrder.apply(this, arguments);
7929
8065
  }
7930
8066
  return removeProductFromOrder;
@@ -7974,23 +8110,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
7974
8110
  }, {
7975
8111
  key: "applyPromotion",
7976
8112
  value: (function () {
7977
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83() {
7978
- return _regeneratorRuntime().wrap(function _callee83$(_context83) {
7979
- while (1) switch (_context83.prev = _context83.next) {
8113
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee85() {
8114
+ return _regeneratorRuntime().wrap(function _callee85$(_context85) {
8115
+ while (1) switch (_context85.prev = _context85.next) {
7980
8116
  case 0:
7981
8117
  if (this.store.order) {
7982
- _context83.next = 2;
8118
+ _context85.next = 2;
7983
8119
  break;
7984
8120
  }
7985
8121
  throw new Error('order 模块未初始化');
7986
8122
  case 2:
7987
- _context83.next = 4;
8123
+ _context85.next = 4;
7988
8124
  return this.store.order.applyPromotion();
7989
8125
  case 4:
7990
8126
  case "end":
7991
- return _context83.stop();
8127
+ return _context85.stop();
7992
8128
  }
7993
- }, _callee83, this);
8129
+ }, _callee85, this);
7994
8130
  }));
7995
8131
  function applyPromotion() {
7996
8132
  return _applyPromotion.apply(this, arguments);
@@ -8017,18 +8153,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
8017
8153
  }, {
8018
8154
  key: "getProductList",
8019
8155
  value: function () {
8020
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee84() {
8021
- var _this$otherParams45;
8156
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee86() {
8157
+ var _this$otherParams48;
8022
8158
  var menu_list_ids, _this$store$products, res;
8023
- return _regeneratorRuntime().wrap(function _callee84$(_context84) {
8024
- while (1) switch (_context84.prev = _context84.next) {
8159
+ return _regeneratorRuntime().wrap(function _callee86$(_context86) {
8160
+ while (1) switch (_context86.prev = _context86.next) {
8025
8161
  case 0:
8026
8162
  // 可以直接通过配置里的 menu 读取
8027
- menu_list_ids = ((_this$otherParams45 = this.otherParams) === null || _this$otherParams45 === void 0 || (_this$otherParams45 = _this$otherParams45.dineInConfig) === null || _this$otherParams45 === void 0 ? void 0 : _this$otherParams45['menu.associated_menus'].map(function (n) {
8163
+ menu_list_ids = ((_this$otherParams48 = this.otherParams) === null || _this$otherParams48 === void 0 || (_this$otherParams48 = _this$otherParams48.dineInConfig) === null || _this$otherParams48 === void 0 ? void 0 : _this$otherParams48['menu.associated_menus'].map(function (n) {
8028
8164
  return Number(n.value);
8029
8165
  })) || [];
8030
- _context84.prev = 1;
8031
- _context84.next = 4;
8166
+ _context86.prev = 1;
8167
+ _context86.next = 4;
8032
8168
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
8033
8169
  menu_list_ids: menu_list_ids,
8034
8170
  cacheId: this.cacheId,
@@ -8036,17 +8172,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
8036
8172
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
8037
8173
  });
8038
8174
  case 4:
8039
- res = _context84.sent;
8040
- return _context84.abrupt("return", res);
8175
+ res = _context86.sent;
8176
+ return _context86.abrupt("return", res);
8041
8177
  case 8:
8042
- _context84.prev = 8;
8043
- _context84.t0 = _context84["catch"](1);
8044
- throw _context84.t0;
8178
+ _context86.prev = 8;
8179
+ _context86.t0 = _context86["catch"](1);
8180
+ throw _context86.t0;
8045
8181
  case 11:
8046
8182
  case "end":
8047
- return _context84.stop();
8183
+ return _context86.stop();
8048
8184
  }
8049
- }, _callee84, this, [[1, 8]]);
8185
+ }, _callee86, this, [[1, 8]]);
8050
8186
  }));
8051
8187
  function getProductList() {
8052
8188
  return _getProductList.apply(this, arguments);
@@ -8061,36 +8197,36 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
8061
8197
  }, {
8062
8198
  key: "setOtherParams",
8063
8199
  value: function () {
8064
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee85(params) {
8065
- var _this$otherParams46;
8200
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee87(params) {
8201
+ var _this$otherParams49;
8066
8202
  var _ref59,
8067
8203
  _ref59$cover,
8068
8204
  cover,
8069
8205
  previousPickupTimingScope,
8070
- _args85 = arguments;
8071
- return _regeneratorRuntime().wrap(function _callee85$(_context85) {
8072
- while (1) switch (_context85.prev = _context85.next) {
8206
+ _args87 = arguments;
8207
+ return _regeneratorRuntime().wrap(function _callee87$(_context87) {
8208
+ while (1) switch (_context87.prev = _context87.next) {
8073
8209
  case 0:
8074
- _ref59 = _args85.length > 1 && _args85[1] !== undefined ? _args85[1] : {}, _ref59$cover = _ref59.cover, cover = _ref59$cover === void 0 ? false : _ref59$cover;
8210
+ _ref59 = _args87.length > 1 && _args87[1] !== undefined ? _args87[1] : {}, _ref59$cover = _ref59.cover, cover = _ref59$cover === void 0 ? false : _ref59$cover;
8075
8211
  previousPickupTimingScope = this.getPickupTimingScope();
8076
8212
  if (cover) {
8077
8213
  this.otherParams = _objectSpread({}, params);
8078
8214
  } else {
8079
8215
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
8080
8216
  }
8081
- this.cacheId = (_this$otherParams46 = this.otherParams) === null || _this$otherParams46 === void 0 ? void 0 : _this$otherParams46.cacheId;
8217
+ this.cacheId = (_this$otherParams49 = this.otherParams) === null || _this$otherParams49 === void 0 ? void 0 : _this$otherParams49.cacheId;
8082
8218
  if (previousPickupTimingScope !== this.getPickupTimingScope()) this.resetPickupTimingCache();
8083
- _context85.next = 7;
8219
+ _context87.next = 7;
8084
8220
  return this.syncOtherParamsToSubModules(params, {
8085
8221
  cover: cover
8086
8222
  });
8087
8223
  case 7:
8088
8224
  case "end":
8089
- return _context85.stop();
8225
+ return _context87.stop();
8090
8226
  }
8091
- }, _callee85, this);
8227
+ }, _callee87, this);
8092
8228
  }));
8093
- function setOtherParams(_x76) {
8229
+ function setOtherParams(_x79) {
8094
8230
  return _setOtherParams.apply(this, arguments);
8095
8231
  }
8096
8232
  return setOtherParams;