@pisell/pisellos 2.2.245 → 2.2.246

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.
@@ -1802,11 +1802,39 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1802
1802
  });
1803
1803
  return JSON.stringify(items);
1804
1804
  }
1805
+ }, {
1806
+ key: "getManualDepositOverride",
1807
+ value: function getManualDepositOverride(tempOrder) {
1808
+ var _tempOrder$_extend3;
1809
+ var override = (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.manualDepositOverride;
1810
+ if (!override || _typeof(override) !== 'object') return null;
1811
+ if (typeof override.amount !== 'string') return null;
1812
+ if (typeof override.productStructuralFingerprint !== 'string') return null;
1813
+ return override;
1814
+ }
1815
+ }, {
1816
+ key: "setManualDepositOverride",
1817
+ value: function setManualDepositOverride(tempOrder, amount) {
1818
+ tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend || {}), {}, {
1819
+ manualDepositOverride: {
1820
+ amount: amount,
1821
+ productStructuralFingerprint: this.buildOrderProductsStructuralFingerprint(tempOrder.products)
1822
+ }
1823
+ });
1824
+ }
1825
+ }, {
1826
+ key: "clearManualDepositOverride",
1827
+ value: function clearManualDepositOverride(tempOrder) {
1828
+ var _tempOrder$_extend4;
1829
+ if (!((_tempOrder$_extend4 = tempOrder._extend) !== null && _tempOrder$_extend4 !== void 0 && _tempOrder$_extend4.manualDepositOverride)) return;
1830
+ tempOrder._extend = _objectSpread({}, tempOrder._extend);
1831
+ delete tempOrder._extend.manualDepositOverride;
1832
+ }
1805
1833
  }, {
1806
1834
  key: "getOriginalSalesSnapshot",
1807
1835
  value: function getOriginalSalesSnapshot(tempOrder) {
1808
- var _tempOrder$_extend3;
1809
- var snapshot = (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.originalSalesSnapshot;
1836
+ var _tempOrder$_extend5;
1837
+ var snapshot = (_tempOrder$_extend5 = tempOrder._extend) === null || _tempOrder$_extend5 === void 0 ? void 0 : _tempOrder$_extend5.originalSalesSnapshot;
1810
1838
  if (!snapshot || _typeof(snapshot) !== 'object') return null;
1811
1839
  if (typeof snapshot.productFingerprint !== 'string') return null;
1812
1840
  return snapshot;
@@ -2036,13 +2064,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2036
2064
  }, {
2037
2065
  key: "getOrderIdentity",
2038
2066
  value: function getOrderIdentity() {
2039
- var _ref41, _ref42, _tempOrder$order_id, _tempOrder$_extend4;
2067
+ var _ref41, _ref42, _tempOrder$order_id, _tempOrder$_extend6;
2040
2068
  var tempOrder = this.store.tempOrder;
2041
2069
  if (!tempOrder) return null;
2042
2070
  var lastOrderInfo = this.store.lastOrderInfo || {};
2043
2071
  var orderId = (_ref41 = (_ref42 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref42 !== void 0 ? _ref42 : lastOrderInfo.id) !== null && _ref41 !== void 0 ? _ref41 : null;
2044
2072
  return {
2045
- localId: this.cacheId || ((_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.localId),
2073
+ localId: this.cacheId || ((_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.localId),
2046
2074
  orderId: orderId,
2047
2075
  externalSaleNumber: tempOrder.external_sale_number || lastOrderInfo.external_sale_number || '',
2048
2076
  orderNumber: tempOrder.order_number || lastOrderInfo.order_number || '',
@@ -2419,21 +2447,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2419
2447
  }, {
2420
2448
  key: "applyOrderProductsDepositSummary",
2421
2449
  value: function applyOrderProductsDepositSummary(tempOrder, summary) {
2422
- var _tempOrder$_extend5;
2450
+ var _tempOrder$_extend7;
2423
2451
  var depositSummary = calculateOrderProductsDeposit(tempOrder.products || [], {
2424
- productsByUid: (_tempOrder$_extend5 = tempOrder._extend) === null || _tempOrder$_extend5 === void 0 ? void 0 : _tempOrder$_extend5.productsByUid
2452
+ productsByUid: (_tempOrder$_extend7 = tempOrder._extend) === null || _tempOrder$_extend7 === void 0 ? void 0 : _tempOrder$_extend7.productsByUid
2425
2453
  });
2454
+ var manualDepositOverride = this.getManualDepositOverride(tempOrder);
2455
+ var currentStructuralFingerprint = manualDepositOverride ? this.buildOrderProductsStructuralFingerprint(tempOrder.products) : '';
2456
+ var shouldUseManualDepositOverride = Boolean(manualDepositOverride && manualDepositOverride.productStructuralFingerprint === currentStructuralFingerprint);
2457
+ if (manualDepositOverride && !shouldUseManualDepositOverride) {
2458
+ this.clearManualDepositOverride(tempOrder);
2459
+ }
2460
+ var depositAmount = shouldUseManualDepositOverride ? manualDepositOverride.amount : depositSummary.totalText;
2461
+ var hasDepositAmount = new Decimal(depositAmount).gt(0);
2426
2462
  var nextSummary = _objectSpread(_objectSpread({}, summary), {}, {
2427
- deposit_amount: depositSummary.totalText,
2428
- deposit: depositSummary.hasDeposit ? {
2429
- total: depositSummary.totalText,
2463
+ deposit_amount: depositAmount,
2464
+ deposit: hasDepositAmount ? {
2465
+ total: depositAmount,
2430
2466
  deposit_policy_ids: depositSummary.deposit_policy_ids,
2431
2467
  deposit_policy_data: depositSummary.protocols,
2432
2468
  hasDeposit: true
2433
2469
  } : undefined
2434
2470
  });
2435
- tempOrder.deposit_amount = depositSummary.totalText;
2436
- tempOrder.is_deposit = depositSummary.hasDeposit ? 1 : 0;
2471
+ tempOrder.deposit_amount = depositAmount;
2472
+ tempOrder.is_deposit = hasDepositAmount ? 1 : 0;
2437
2473
  return nextSummary;
2438
2474
  }
2439
2475
  }, {
@@ -2655,6 +2691,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2655
2691
  var depositAmount = this.normalizeDepositAmount(amount);
2656
2692
  var previousSummary = this.store.summary || createEmptySummary();
2657
2693
  var summaryWithDeposit = this.applyDepositAmountToSummary(tempOrder, _objectSpread(_objectSpread({}, createEmptySummary()), previousSummary), depositAmount);
2694
+ this.setManualDepositOverride(tempOrder, depositAmount);
2658
2695
  var paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
2659
2696
  var summary = _objectSpread(_objectSpread({}, summaryWithDeposit), {}, {
2660
2697
  amount_gap: this.calculateSummaryAmountGap({
@@ -3827,17 +3864,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3827
3864
  key: "removeProductsFromOrder",
3828
3865
  value: (function () {
3829
3866
  var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(identities) {
3830
- var tempOrder, removedProducts, _i2, _removedProducts, product;
3831
- return _regeneratorRuntime().wrap(function _callee22$(_context24) {
3832
- while (1) switch (_context24.prev = _context24.next) {
3867
+ var _this19 = this;
3868
+ var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
3869
+ return _regeneratorRuntime().wrap(function _callee22$(_context25) {
3870
+ while (1) switch (_context25.prev = _context25.next) {
3833
3871
  case 0:
3834
3872
  tempOrder = this.ensureTempOrder();
3835
3873
  if (identities.length) {
3836
- _context24.next = 3;
3874
+ _context25.next = 3;
3837
3875
  break;
3838
3876
  }
3839
- return _context24.abrupt("return", tempOrder.products);
3877
+ return _context25.abrupt("return", tempOrder.products);
3840
3878
  case 3:
3879
+ productsBeforeRemove = tempOrder.products || [];
3880
+ bookingsBeforeRemove = tempOrder.bookings || [];
3881
+ matchedProducts = productsBeforeRemove.filter(function (item) {
3882
+ return identities.some(function (identity) {
3883
+ return isIdentityMatch(item, identity);
3884
+ });
3885
+ });
3841
3886
  removedProducts = [];
3842
3887
  tempOrder.products = tempOrder.products.filter(function (item) {
3843
3888
  var shouldRemove = identities.some(function (identity) {
@@ -3850,15 +3895,88 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3850
3895
  product = _removedProducts[_i2];
3851
3896
  this.removeLinkedBookingsForProduct(tempOrder, product);
3852
3897
  }
3853
- _context24.next = 8;
3898
+ linkedBookingUidsToRemove = new Set();
3899
+ _iterator21 = _createForOfIteratorHelper(matchedProducts);
3900
+ _context25.prev = 11;
3901
+ _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
3902
+ var _metadata8, _metadata9, _metadata10, _metadata11;
3903
+ var product, productUid, productBookingUid, isAddTimeProduct;
3904
+ return _regeneratorRuntime().wrap(function _loop3$(_context24) {
3905
+ while (1) switch (_context24.prev = _context24.next) {
3906
+ case 0:
3907
+ product = _step21.value;
3908
+ productUid = (product === null || product === void 0 || (_metadata8 = product.metadata) === null || _metadata8 === void 0 ? void 0 : _metadata8.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
3909
+ productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata9 = product.metadata) === null || _metadata9 === void 0 ? void 0 : _metadata9.booking_uid);
3910
+ isAddTimeProduct = (product === null || product === void 0 || (_metadata10 = product.metadata) === null || _metadata10 === void 0 ? void 0 : _metadata10.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.product_add_schedule_time) !== null;
3911
+ if (!isAddTimeProduct) {
3912
+ _context24.next = 6;
3913
+ break;
3914
+ }
3915
+ return _context24.abrupt("return", 1);
3916
+ case 6:
3917
+ if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
3918
+ linkedBookingUidsToRemove.add(String(productBookingUid));
3919
+ }
3920
+ if (productUid !== undefined && productUid !== null && productUid !== '') {
3921
+ bookingsBeforeRemove.forEach(function (booking) {
3922
+ var bookingUid = _this19.getBookingUniqueIdentificationNumber(booking);
3923
+ if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
3924
+ linkedBookingUidsToRemove.add(bookingUid);
3925
+ }
3926
+ });
3927
+ }
3928
+ case 8:
3929
+ case "end":
3930
+ return _context24.stop();
3931
+ }
3932
+ }, _loop3);
3933
+ });
3934
+ _iterator21.s();
3935
+ case 14:
3936
+ if ((_step21 = _iterator21.n()).done) {
3937
+ _context25.next = 20;
3938
+ break;
3939
+ }
3940
+ return _context25.delegateYield(_loop3(), "t0", 16);
3941
+ case 16:
3942
+ if (!_context25.t0) {
3943
+ _context25.next = 18;
3944
+ break;
3945
+ }
3946
+ return _context25.abrupt("continue", 18);
3947
+ case 18:
3948
+ _context25.next = 14;
3949
+ break;
3950
+ case 20:
3951
+ _context25.next = 25;
3952
+ break;
3953
+ case 22:
3954
+ _context25.prev = 22;
3955
+ _context25.t1 = _context25["catch"](11);
3956
+ _iterator21.e(_context25.t1);
3957
+ case 25:
3958
+ _context25.prev = 25;
3959
+ _iterator21.f();
3960
+ return _context25.finish(25);
3961
+ case 28:
3962
+ if (linkedBookingUidsToRemove.size > 0) {
3963
+ // 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
3964
+ tempOrder.products = (tempOrder.products || []).filter(function (line) {
3965
+ var _line$metadata, _line$metadata2, _line$metadata3;
3966
+ var lineBookingUid = (line === null || line === void 0 || (_line$metadata = line.metadata) === null || _line$metadata === void 0 ? void 0 : _line$metadata.booking_uid) || (line === null || line === void 0 ? void 0 : line.booking_uid);
3967
+ var isAddTimeProduct = (line === null || line === void 0 || (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.product_add_schedule_time) !== undefined && (line === null || line === void 0 || (_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.product_add_schedule_time) !== null;
3968
+ return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
3969
+ });
3970
+ }
3971
+ _context25.next = 31;
3854
3972
  return this.finalizeAfterProductsMutation(tempOrder);
3855
- case 8:
3856
- return _context24.abrupt("return", tempOrder.products);
3857
- case 9:
3973
+ case 31:
3974
+ return _context25.abrupt("return", tempOrder.products);
3975
+ case 32:
3858
3976
  case "end":
3859
- return _context24.stop();
3977
+ return _context25.stop();
3860
3978
  }
3861
- }, _callee22, this);
3979
+ }, _callee22, this, [[11, 22, 25, 28]]);
3862
3980
  }));
3863
3981
  function removeProductsFromOrder(_x26) {
3864
3982
  return _removeProductsFromOrder.apply(this, arguments);
@@ -3869,13 +3987,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3869
3987
  key: "removeProductFromOrder",
3870
3988
  value: function () {
3871
3989
  var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(identity) {
3872
- return _regeneratorRuntime().wrap(function _callee23$(_context25) {
3873
- while (1) switch (_context25.prev = _context25.next) {
3990
+ return _regeneratorRuntime().wrap(function _callee23$(_context26) {
3991
+ while (1) switch (_context26.prev = _context26.next) {
3874
3992
  case 0:
3875
- return _context25.abrupt("return", this.removeProductsFromOrder([identity]));
3993
+ return _context26.abrupt("return", this.removeProductsFromOrder([identity]));
3876
3994
  case 1:
3877
3995
  case "end":
3878
- return _context25.stop();
3996
+ return _context26.stop();
3879
3997
  }
3880
3998
  }, _callee23, this);
3881
3999
  }));
@@ -3893,8 +4011,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3893
4011
  value: (function () {
3894
4012
  var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
3895
4013
  var tempOrder;
3896
- return _regeneratorRuntime().wrap(function _callee24$(_context26) {
3897
- while (1) switch (_context26.prev = _context26.next) {
4014
+ return _regeneratorRuntime().wrap(function _callee24$(_context27) {
4015
+ while (1) switch (_context27.prev = _context27.next) {
3898
4016
  case 0:
3899
4017
  tempOrder = this.ensureTempOrder();
3900
4018
  tempOrder.products = [];
@@ -3905,21 +4023,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3905
4023
  productsByUid: {}
3906
4024
  });
3907
4025
  }
3908
- _context26.next = 7;
4026
+ _context27.next = 7;
3909
4027
  return this.applyPromotion();
3910
4028
  case 7:
3911
4029
  this.applyDiscount();
3912
4030
  this.sanitizeTempOrderProducts(tempOrder);
3913
- _context26.next = 11;
4031
+ _context27.next = 11;
3914
4032
  return this.recalculateSummary({
3915
4033
  createIfMissing: true
3916
4034
  });
3917
4035
  case 11:
3918
4036
  this.persistTempOrder();
3919
- return _context26.abrupt("return", tempOrder);
4037
+ return _context27.abrupt("return", tempOrder);
3920
4038
  case 13:
3921
4039
  case "end":
3922
- return _context26.stop();
4040
+ return _context27.stop();
3923
4041
  }
3924
4042
  }, _callee24, this);
3925
4043
  }));
@@ -3961,15 +4079,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3961
4079
  value: function () {
3962
4080
  var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(order) {
3963
4081
  var tempOrder, shopOrderNumber, shopFullOrderNumber;
3964
- return _regeneratorRuntime().wrap(function _callee25$(_context27) {
3965
- while (1) switch (_context27.prev = _context27.next) {
4082
+ return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4083
+ while (1) switch (_context28.prev = _context28.next) {
3966
4084
  case 0:
3967
4085
  tempOrder = this.ensureTempOrder();
3968
4086
  if (!(!order || _typeof(order) !== 'object')) {
3969
- _context27.next = 3;
4087
+ _context28.next = 3;
3970
4088
  break;
3971
4089
  }
3972
- return _context27.abrupt("return", tempOrder);
4090
+ return _context28.abrupt("return", tempOrder);
3973
4091
  case 3:
3974
4092
  shopOrderNumber = order.shop_order_number;
3975
4093
  shopFullOrderNumber = order.shop_full_order_number;
@@ -3980,13 +4098,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3980
4098
  tempOrder.shop_full_order_number = String(shopFullOrderNumber);
3981
4099
  }
3982
4100
  this.persistTempOrder();
3983
- _context27.next = 10;
4101
+ _context28.next = 10;
3984
4102
  return this.saveDraft();
3985
4103
  case 10:
3986
- return _context27.abrupt("return", tempOrder);
4104
+ return _context28.abrupt("return", tempOrder);
3987
4105
  case 11:
3988
4106
  case "end":
3989
- return _context27.stop();
4107
+ return _context28.stop();
3990
4108
  }
3991
4109
  }, _callee25, this);
3992
4110
  }));
@@ -4005,13 +4123,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4005
4123
  key: "submitTempOrder",
4006
4124
  value: (function () {
4007
4125
  var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
4008
- return _regeneratorRuntime().wrap(function _callee26$(_context28) {
4009
- while (1) switch (_context28.prev = _context28.next) {
4126
+ return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4127
+ while (1) switch (_context29.prev = _context29.next) {
4010
4128
  case 0:
4011
- return _context28.abrupt("return", this.runSubmitTempOrder(params));
4129
+ return _context29.abrupt("return", this.runSubmitTempOrder(params));
4012
4130
  case 1:
4013
4131
  case "end":
4014
- return _context28.stop();
4132
+ return _context29.stop();
4015
4133
  }
4016
4134
  }, _callee26, this);
4017
4135
  }));
@@ -4024,15 +4142,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4024
4142
  key: "submitTempOrderAsync",
4025
4143
  value: function () {
4026
4144
  var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
4027
- return _regeneratorRuntime().wrap(function _callee27$(_context29) {
4028
- while (1) switch (_context29.prev = _context29.next) {
4145
+ return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4146
+ while (1) switch (_context30.prev = _context30.next) {
4029
4147
  case 0:
4030
- return _context29.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4148
+ return _context30.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4031
4149
  syncMode: true
4032
4150
  })));
4033
4151
  case 1:
4034
4152
  case "end":
4035
- return _context29.stop();
4153
+ return _context30.stop();
4036
4154
  }
4037
4155
  }, _callee27, this);
4038
4156
  }));
@@ -4047,31 +4165,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4047
4165
  var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4048
4166
  var _params$cacheId2, _this$otherParams5, _ref70, _params$businessCode2, _this$otherParams6, _this$otherParams7;
4049
4167
  var tempOrder, latestSummary, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
4050
- return _regeneratorRuntime().wrap(function _callee28$(_context30) {
4051
- while (1) switch (_context30.prev = _context30.next) {
4168
+ return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4169
+ while (1) switch (_context31.prev = _context31.next) {
4052
4170
  case 0:
4053
4171
  tempOrder = this.ensureTempOrder();
4054
4172
  this.persistTempOrder();
4055
- _context30.next = 4;
4173
+ _context31.next = 4;
4056
4174
  return this.recalculateSummary({
4057
4175
  createIfMissing: true
4058
4176
  });
4059
4177
  case 4:
4060
- _context30.t1 = _context30.sent;
4061
- if (_context30.t1) {
4062
- _context30.next = 7;
4178
+ _context31.t1 = _context31.sent;
4179
+ if (_context31.t1) {
4180
+ _context31.next = 7;
4063
4181
  break;
4064
4182
  }
4065
- _context30.t1 = this.store.summary;
4183
+ _context31.t1 = this.store.summary;
4066
4184
  case 7:
4067
- _context30.t0 = _context30.t1;
4068
- if (_context30.t0) {
4069
- _context30.next = 10;
4185
+ _context31.t0 = _context31.t1;
4186
+ if (_context31.t0) {
4187
+ _context31.next = 10;
4070
4188
  break;
4071
4189
  }
4072
- _context30.t0 = createEmptySummary();
4190
+ _context31.t0 = createEmptySummary();
4073
4191
  case 10:
4074
- latestSummary = _context30.t0;
4192
+ latestSummary = _context31.t0;
4075
4193
  effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
4076
4194
  hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
4077
4195
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
@@ -4105,10 +4223,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4105
4223
  if (!payload.created_at) {
4106
4224
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
4107
4225
  }
4108
- _context30.next = 21;
4226
+ _context31.next = 21;
4109
4227
  return this.saveDraft();
4110
4228
  case 21:
4111
- _context30.prev = 21;
4229
+ _context31.prev = 21;
4112
4230
  this.logInfo('submitTempOrder calling sales checkout', {
4113
4231
  orderId: payload.order_id,
4114
4232
  externalSaleNumber: payload.external_sale_number,
@@ -4118,43 +4236,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4118
4236
  smallTicketDataFlag: payload.small_ticket_data_flag,
4119
4237
  syncMode: payload.sync_mode
4120
4238
  });
4121
- _context30.next = 25;
4239
+ _context31.next = 25;
4122
4240
  return this.submitSalesOrder({
4123
4241
  query: payload
4124
4242
  });
4125
4243
  case 25:
4126
- result = _context30.sent;
4127
- _context30.next = 38;
4244
+ result = _context31.sent;
4245
+ _context31.next = 38;
4128
4246
  break;
4129
4247
  case 28:
4130
- _context30.prev = 28;
4131
- _context30.t2 = _context30["catch"](21);
4132
- backendErrorResponse = this.extractSubmitErrorResponse(_context30.t2);
4248
+ _context31.prev = 28;
4249
+ _context31.t2 = _context31["catch"](21);
4250
+ backendErrorResponse = this.extractSubmitErrorResponse(_context31.t2);
4133
4251
  if (!backendErrorResponse) {
4134
- _context30.next = 35;
4252
+ _context31.next = 35;
4135
4253
  break;
4136
4254
  }
4137
4255
  this.store.syncState = 'failed';
4138
4256
  this.logSubmitBackendRejected(backendErrorResponse, payload);
4139
- return _context30.abrupt("return", backendErrorResponse);
4257
+ return _context31.abrupt("return", backendErrorResponse);
4140
4258
  case 35:
4141
4259
  this.store.syncState = 'failed';
4142
4260
  this.logError('submitTempOrder failed', {
4143
- error: _context30.t2 instanceof Error ? _context30.t2.message : String(_context30.t2),
4261
+ error: _context31.t2 instanceof Error ? _context31.t2.message : String(_context31.t2),
4144
4262
  orderId: payload.order_id,
4145
4263
  externalSaleNumber: payload.external_sale_number,
4146
4264
  paymentStatus: payload.payment_status,
4147
4265
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
4148
4266
  });
4149
- throw _context30.t2;
4267
+ throw _context31.t2;
4150
4268
  case 38:
4151
4269
  if (!this.isSubmitResponseRejected(result)) {
4152
- _context30.next = 42;
4270
+ _context31.next = 42;
4153
4271
  break;
4154
4272
  }
4155
4273
  this.store.syncState = 'failed';
4156
4274
  this.logSubmitBackendRejected(result, payload);
4157
- return _context30.abrupt("return", result);
4275
+ return _context31.abrupt("return", result);
4158
4276
  case 42:
4159
4277
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
4160
4278
  this.logInfo('runSubmitTempOrder: 提交成功', {
@@ -4163,15 +4281,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4163
4281
  tempOrder: tempOrder
4164
4282
  });
4165
4283
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
4166
- _context30.next = 51;
4284
+ _context31.next = 51;
4167
4285
  break;
4168
4286
  }
4169
4287
  tempOrder.order_id = submittedOrderId;
4170
4288
  resultRecord = result;
4171
- _context30.next = 49;
4289
+ _context31.next = 49;
4172
4290
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
4173
4291
  case 49:
4174
- _context30.next = 52;
4292
+ _context31.next = 52;
4175
4293
  break;
4176
4294
  case 51:
4177
4295
  if (this.isLocalPendingSubmitResult(result)) {
@@ -4180,10 +4298,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4180
4298
  this.store.syncState = 'submitted';
4181
4299
  }
4182
4300
  case 52:
4183
- return _context30.abrupt("return", result);
4301
+ return _context31.abrupt("return", result);
4184
4302
  case 53:
4185
4303
  case "end":
4186
- return _context30.stop();
4304
+ return _context31.stop();
4187
4305
  }
4188
4306
  }, _callee28, this, [[21, 28]]);
4189
4307
  }));
@@ -4197,8 +4315,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4197
4315
  value: function () {
4198
4316
  var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(orderId, remoteOrder) {
4199
4317
  var tempOrder;
4200
- return _regeneratorRuntime().wrap(function _callee29$(_context31) {
4201
- while (1) switch (_context31.prev = _context31.next) {
4318
+ return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4319
+ while (1) switch (_context32.prev = _context32.next) {
4202
4320
  case 0:
4203
4321
  tempOrder = this.ensureTempOrder();
4204
4322
  tempOrder.order_id = orderId;
@@ -4206,11 +4324,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4206
4324
  this.store.lastOrderInfo = remoteOrder;
4207
4325
  this.store.syncState = 'submitted';
4208
4326
  this.persistTempOrder();
4209
- _context31.next = 8;
4327
+ _context32.next = 8;
4210
4328
  return this.saveDraft();
4211
4329
  case 8:
4212
4330
  case "end":
4213
- return _context31.stop();
4331
+ return _context32.stop();
4214
4332
  }
4215
4333
  }, _callee29, this);
4216
4334
  }));
@@ -4257,10 +4375,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4257
4375
  value: function extractSubmitErrorResponse(error) {
4258
4376
  var _error$response,
4259
4377
  _error$response2,
4260
- _this19 = this;
4378
+ _this20 = this;
4261
4379
  var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
4262
4380
  return candidates.find(function (candidate) {
4263
- return _this19.isSubmitErrorResponse(candidate);
4381
+ return _this20.isSubmitErrorResponse(candidate);
4264
4382
  }) || null;
4265
4383
  }
4266
4384
  }, {
@@ -4289,8 +4407,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4289
4407
  value: function () {
4290
4408
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
4291
4409
  var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, paymentStatus, paymentSyncIdempotencyToken, submitResult;
4292
- return _regeneratorRuntime().wrap(function _callee30$(_context32) {
4293
- while (1) switch (_context32.prev = _context32.next) {
4410
+ return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4411
+ while (1) switch (_context33.prev = _context33.next) {
4294
4412
  case 0:
4295
4413
  tempOrder = this.ensureTempOrder();
4296
4414
  mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
@@ -4301,28 +4419,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4301
4419
  tempOrder.payments = mappedPayments;
4302
4420
  tempOrder.payment_status = paymentStatus;
4303
4421
  this.persistTempOrder();
4304
- _context32.next = 11;
4422
+ _context33.next = 11;
4305
4423
  return this.saveDraft();
4306
4424
  case 11:
4307
4425
  if (params.submitWhenPaid) {
4308
- _context32.next = 13;
4426
+ _context33.next = 13;
4309
4427
  break;
4310
4428
  }
4311
- return _context32.abrupt("return", {
4429
+ return _context33.abrupt("return", {
4312
4430
  isFullyPaid: isFullyPaid
4313
4431
  });
4314
4432
  case 13:
4315
4433
  if (!(this.store.syncState === 'submitting')) {
4316
- _context32.next = 15;
4434
+ _context33.next = 15;
4317
4435
  break;
4318
4436
  }
4319
- return _context32.abrupt("return", {
4437
+ return _context33.abrupt("return", {
4320
4438
  isFullyPaid: isFullyPaid
4321
4439
  });
4322
4440
  case 15:
4323
4441
  this.store.syncState = 'submitting';
4324
4442
  paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, mappedPayments);
4325
- _context32.next = 19;
4443
+ _context33.next = 19;
4326
4444
  return this.submitTempOrder({
4327
4445
  payments: mappedPayments,
4328
4446
  paymentStatus: paymentStatus,
@@ -4337,14 +4455,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4337
4455
  }
4338
4456
  });
4339
4457
  case 19:
4340
- submitResult = _context32.sent;
4341
- return _context32.abrupt("return", {
4458
+ submitResult = _context33.sent;
4459
+ return _context33.abrupt("return", {
4342
4460
  isFullyPaid: isFullyPaid,
4343
4461
  submitResult: submitResult
4344
4462
  });
4345
4463
  case 21:
4346
4464
  case "end":
4347
- return _context32.stop();
4465
+ return _context33.stop();
4348
4466
  }
4349
4467
  }, _callee30, this);
4350
4468
  }));
@@ -4440,8 +4558,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4440
4558
  var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(order) {
4441
4559
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
4442
4560
  var url, query, fetchUrl, params;
4443
- return _regeneratorRuntime().wrap(function _callee31$(_context33) {
4444
- while (1) switch (_context33.prev = _context33.next) {
4561
+ return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4562
+ while (1) switch (_context34.prev = _context34.next) {
4445
4563
  case 0:
4446
4564
  this.logInfo('submitOrder called', {
4447
4565
  url: order.url,
@@ -4461,10 +4579,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4461
4579
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
4462
4580
  scheduleDate: params.schedule_date
4463
4581
  });
4464
- return _context33.abrupt("return", this.request.post(fetchUrl, params));
4582
+ return _context34.abrupt("return", this.request.post(fetchUrl, params));
4465
4583
  case 6:
4466
4584
  case "end":
4467
- return _context33.stop();
4585
+ return _context34.stop();
4468
4586
  }
4469
4587
  }, _callee31, this);
4470
4588
  }));
@@ -4478,11 +4596,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4478
4596
  value: function () {
4479
4597
  var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
4480
4598
  var payload;
4481
- return _regeneratorRuntime().wrap(function _callee32$(_context34) {
4482
- while (1) switch (_context34.prev = _context34.next) {
4599
+ return _regeneratorRuntime().wrap(function _callee32$(_context35) {
4600
+ while (1) switch (_context35.prev = _context35.next) {
4483
4601
  case 0:
4484
4602
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
4485
- _context34.next = 2;
4603
+ _context35.next = 2;
4486
4604
  break;
4487
4605
  }
4488
4606
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -4498,12 +4616,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4498
4616
  method: 'PUT',
4499
4617
  orderIdsCount: params.order_ids.length
4500
4618
  });
4501
- return _context34.abrupt("return", this.request.put('/order/update-status', payload, {
4619
+ return _context35.abrupt("return", this.request.put('/order/update-status', payload, {
4502
4620
  isShopApi: true
4503
4621
  }));
4504
4622
  case 5:
4505
4623
  case "end":
4506
- return _context34.stop();
4624
+ return _context35.stop();
4507
4625
  }
4508
4626
  }, _callee32, this);
4509
4627
  }));
@@ -4517,17 +4635,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4517
4635
  value: function () {
4518
4636
  var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
4519
4637
  var url, payload;
4520
- return _regeneratorRuntime().wrap(function _callee33$(_context35) {
4521
- while (1) switch (_context35.prev = _context35.next) {
4638
+ return _regeneratorRuntime().wrap(function _callee33$(_context36) {
4639
+ while (1) switch (_context36.prev = _context36.next) {
4522
4640
  case 0:
4523
4641
  if (params.booking_id) {
4524
- _context35.next = 2;
4642
+ _context36.next = 2;
4525
4643
  break;
4526
4644
  }
4527
4645
  throw new Error('变更预约状态失败:booking_id 不能为空');
4528
4646
  case 2:
4529
4647
  if (params.appointment_status) {
4530
- _context35.next = 4;
4648
+ _context36.next = 4;
4531
4649
  break;
4532
4650
  }
4533
4651
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -4542,12 +4660,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4542
4660
  bookingId: params.booking_id,
4543
4661
  appointmentStatus: params.appointment_status
4544
4662
  });
4545
- return _context35.abrupt("return", this.request.put(url, payload, {
4663
+ return _context36.abrupt("return", this.request.put(url, payload, {
4546
4664
  isShopApi: true
4547
4665
  }));
4548
4666
  case 8:
4549
4667
  case "end":
4550
- return _context35.stop();
4668
+ return _context36.stop();
4551
4669
  }
4552
4670
  }, _callee33, this);
4553
4671
  }));
@@ -4572,8 +4690,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4572
4690
  var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
4573
4691
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
4574
4692
  var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
4575
- return _regeneratorRuntime().wrap(function _callee34$(_context36) {
4576
- while (1) switch (_context36.prev = _context36.next) {
4693
+ return _regeneratorRuntime().wrap(function _callee34$(_context37) {
4694
+ while (1) switch (_context37.prev = _context37.next) {
4577
4695
  case 0:
4578
4696
  // 过滤掉由在线店铺下单的 payment 支付数据
4579
4697
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -4607,7 +4725,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4607
4725
  relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
4608
4726
  paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
4609
4727
  });
4610
- _context36.prev = 4;
4728
+ _context37.prev = 4;
4611
4729
  // 构建订单数据,设置默认值并允许 params 覆盖
4612
4730
  orderData = _objectSpread({
4613
4731
  sales_channel: 'my_pisel',
@@ -4669,13 +4787,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4669
4787
  hasOrderId: !!orderData.order_id,
4670
4788
  smallTicketDataFlag: orderData.small_ticket_data_flag
4671
4789
  });
4672
- _context36.next = 12;
4790
+ _context37.next = 12;
4673
4791
  return this.request.post('/order/checkout', orderData, {
4674
4792
  osServer: true,
4675
4793
  customToast: function customToast() {}
4676
4794
  });
4677
4795
  case 12:
4678
- response = _context36.sent;
4796
+ response = _context37.sent;
4679
4797
  this.logInfo('Order API called successfully', {
4680
4798
  response: response
4681
4799
  });
@@ -4683,18 +4801,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4683
4801
  success: !!response,
4684
4802
  hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
4685
4803
  });
4686
- return _context36.abrupt("return", response);
4804
+ return _context37.abrupt("return", response);
4687
4805
  case 18:
4688
- _context36.prev = 18;
4689
- _context36.t0 = _context36["catch"](4);
4690
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context36.t0);
4806
+ _context37.prev = 18;
4807
+ _context37.t0 = _context37["catch"](4);
4808
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context37.t0);
4691
4809
  this.logInfo('Order API called failed', {
4692
- error: _context36.t0 instanceof Error ? _context36.t0.message : String(_context36.t0)
4810
+ error: _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0)
4693
4811
  });
4694
- throw _context36.t0;
4812
+ throw _context37.t0;
4695
4813
  case 23:
4696
4814
  case "end":
4697
- return _context36.stop();
4815
+ return _context37.stop();
4698
4816
  }
4699
4817
  }, _callee34, this, [[4, 18]]);
4700
4818
  }));
@@ -4708,18 +4826,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4708
4826
  value: function () {
4709
4827
  var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
4710
4828
  var url, query, fetchUrl;
4711
- return _regeneratorRuntime().wrap(function _callee35$(_context37) {
4712
- while (1) switch (_context37.prev = _context37.next) {
4829
+ return _regeneratorRuntime().wrap(function _callee35$(_context38) {
4830
+ while (1) switch (_context38.prev = _context38.next) {
4713
4831
  case 0:
4714
4832
  url = params.url, query = params.query;
4715
4833
  fetchUrl = url || '/order/sales/checkout';
4716
- return _context37.abrupt("return", this.request.post(fetchUrl, query, {
4834
+ return _context38.abrupt("return", this.request.post(fetchUrl, query, {
4717
4835
  osServer: true,
4718
4836
  customToast: function customToast() {}
4719
4837
  }));
4720
4838
  case 3:
4721
4839
  case "end":
4722
- return _context37.stop();
4840
+ return _context38.stop();
4723
4841
  }
4724
4842
  }, _callee35, this);
4725
4843
  }));
@@ -4740,30 +4858,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4740
4858
  var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
4741
4859
  var _params$emails;
4742
4860
  var orderIds;
4743
- return _regeneratorRuntime().wrap(function _callee36$(_context38) {
4744
- while (1) switch (_context38.prev = _context38.next) {
4861
+ return _regeneratorRuntime().wrap(function _callee36$(_context39) {
4862
+ while (1) switch (_context39.prev = _context39.next) {
4745
4863
  case 0:
4746
4864
  orderIds = params.order_ids || params.orderIds || [];
4747
4865
  if (orderIds.length) {
4748
- _context38.next = 3;
4866
+ _context39.next = 3;
4749
4867
  break;
4750
4868
  }
4751
4869
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
4752
4870
  case 3:
4753
4871
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
4754
- _context38.next = 5;
4872
+ _context39.next = 5;
4755
4873
  break;
4756
4874
  }
4757
4875
  throw new Error('发送支付链接需要至少一个邮箱');
4758
4876
  case 5:
4759
- return _context38.abrupt("return", this.request.post('/order/batch-email', {
4877
+ return _context39.abrupt("return", this.request.post('/order/batch-email', {
4760
4878
  order_ids: orderIds,
4761
4879
  notify_action: params.notify_action || 'order_payment_reminder',
4762
4880
  emails: params.emails
4763
4881
  }));
4764
4882
  case 6:
4765
4883
  case "end":
4766
- return _context38.stop();
4884
+ return _context39.stop();
4767
4885
  }
4768
4886
  }, _callee36, this);
4769
4887
  }));
@@ -4777,12 +4895,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4777
4895
  value: function () {
4778
4896
  var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
4779
4897
  var lookup, res;
4780
- return _regeneratorRuntime().wrap(function _callee37$(_context39) {
4781
- while (1) switch (_context39.prev = _context39.next) {
4898
+ return _regeneratorRuntime().wrap(function _callee37$(_context40) {
4899
+ while (1) switch (_context40.prev = _context40.next) {
4782
4900
  case 0:
4783
4901
  lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
4784
4902
  if (lookup) {
4785
- _context39.next = 3;
4903
+ _context40.next = 3;
4786
4904
  break;
4787
4905
  }
4788
4906
  throw new Error('加载销售详情需要 lookup');
@@ -4791,7 +4909,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4791
4909
  if (lookup.startsWith('LOCAL_')) {
4792
4910
  params.forceRemote = false;
4793
4911
  }
4794
- _context39.next = 6;
4912
+ _context40.next = 6;
4795
4913
  return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
4796
4914
  with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
4797
4915
  }, params.forceRemote ? {
@@ -4800,14 +4918,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4800
4918
  osServer: true
4801
4919
  });
4802
4920
  case 6:
4803
- res = _context39.sent;
4921
+ res = _context40.sent;
4804
4922
  if (res.code === 200) {
4805
4923
  this.store.lastOrderInfo = res.data;
4806
4924
  }
4807
- return _context39.abrupt("return", res);
4925
+ return _context40.abrupt("return", res);
4808
4926
  case 9:
4809
4927
  case "end":
4810
- return _context39.stop();
4928
+ return _context40.stop();
4811
4929
  }
4812
4930
  }, _callee37, this);
4813
4931
  }));
@@ -4828,8 +4946,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4828
4946
  var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(record, options) {
4829
4947
  var _this$store$discount13;
4830
4948
  var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount14, _this$store$discount15;
4831
- return _regeneratorRuntime().wrap(function _callee38$(_context40) {
4832
- while (1) switch (_context40.prev = _context40.next) {
4949
+ return _regeneratorRuntime().wrap(function _callee38$(_context41) {
4950
+ while (1) switch (_context41.prev = _context41.next) {
4833
4951
  case 0:
4834
4952
  raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
4835
4953
  nextTempOrder = this.normalizeTempOrderForRuntime(raw);
@@ -4855,29 +4973,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4855
4973
  currentDiscounts = typeof ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
4856
4974
  shouldSkipEmptyDiscountSync = hydratedEditDiscounts.length === 0 && currentDiscounts.length === 0;
4857
4975
  if (shouldSkipEmptyDiscountSync) {
4858
- _context40.next = 16;
4976
+ _context41.next = 16;
4859
4977
  break;
4860
4978
  }
4861
- _context40.next = 14;
4979
+ _context41.next = 14;
4862
4980
  return (_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.setOriginalDiscountList(hydratedEditDiscounts);
4863
4981
  case 14:
4864
- _context40.next = 16;
4982
+ _context41.next = 16;
4865
4983
  return (_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.setDiscountList(hydratedEditDiscounts);
4866
4984
  case 16:
4867
4985
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
4868
- _context40.next = 19;
4986
+ _context41.next = 19;
4869
4987
  break;
4870
4988
  }
4871
- _context40.next = 19;
4989
+ _context41.next = 19;
4872
4990
  return this.recalculateSummary({
4873
4991
  createIfMissing: false
4874
4992
  });
4875
4993
  case 19:
4876
4994
  this.persistTempOrder();
4877
- return _context40.abrupt("return", nextTempOrder);
4995
+ return _context41.abrupt("return", nextTempOrder);
4878
4996
  case 21:
4879
4997
  case "end":
4880
- return _context40.stop();
4998
+ return _context41.stop();
4881
4999
  }
4882
5000
  }, _callee38, this);
4883
5001
  }));
@@ -4889,7 +5007,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4889
5007
  }, {
4890
5008
  key: "normalizeTempOrderForRuntime",
4891
5009
  value: function normalizeTempOrderForRuntime(raw, options) {
4892
- var _this20 = this;
5010
+ var _this21 = this;
4893
5011
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
4894
5012
  delete nextTempOrder.summary;
4895
5013
  delete nextTempOrder.lastOrderInfo;
@@ -4908,7 +5026,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4908
5026
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
4909
5027
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
4910
5028
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
4911
- return _this20.normalizeHydratedOrderProduct(p);
5029
+ return _this21.normalizeHydratedOrderProduct(p);
4912
5030
  }) : [];
4913
5031
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
4914
5032
  return _objectSpread(_objectSpread({}, b || {}), {}, {
@@ -4936,14 +5054,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4936
5054
  };
4937
5055
  var tempOrderExtend = nextTempOrder._extend;
4938
5056
  var productsByUid = tempOrderExtend.productsByUid || {};
4939
- var _iterator21 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
4940
- _step21;
5057
+ var _iterator22 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
5058
+ _step22;
4941
5059
  try {
4942
- for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
5060
+ for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
4943
5061
  var _product$metadata8, _ref71, _ref72, _existed$origin, _rawProduct$metadata;
4944
- var _step21$value = _slicedToArray(_step21.value, 2),
4945
- index = _step21$value[0],
4946
- product = _step21$value[1];
5062
+ var _step22$value = _slicedToArray(_step22.value, 2),
5063
+ index = _step22$value[0],
5064
+ product = _step22$value[1];
4947
5065
  var uid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
4948
5066
  if (!uid) continue;
4949
5067
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
@@ -4964,9 +5082,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4964
5082
  });
4965
5083
  }
4966
5084
  } catch (err) {
4967
- _iterator21.e(err);
5085
+ _iterator22.e(err);
4968
5086
  } finally {
4969
- _iterator21.f();
5087
+ _iterator22.f();
4970
5088
  }
4971
5089
  tempOrderExtend.productsByUid = productsByUid;
4972
5090
  if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
@@ -4997,18 +5115,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4997
5115
  var segments = [];
4998
5116
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
4999
5117
  if (Array.isArray(sku.variant)) {
5000
- var _iterator22 = _createForOfIteratorHelper(sku.variant),
5001
- _step22;
5118
+ var _iterator23 = _createForOfIteratorHelper(sku.variant),
5119
+ _step23;
5002
5120
  try {
5003
- for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
5004
- var variant = _step22.value;
5121
+ for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
5122
+ var variant = _step23.value;
5005
5123
  var segment = this.formatHydratedNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
5006
5124
  if (segment) segments.push(segment);
5007
5125
  }
5008
5126
  } catch (err) {
5009
- _iterator22.e(err);
5127
+ _iterator23.e(err);
5010
5128
  } finally {
5011
- _iterator22.f();
5129
+ _iterator23.f();
5012
5130
  }
5013
5131
  }
5014
5132
  return segments.join(', ');
@@ -5036,7 +5154,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5036
5154
  }, {
5037
5155
  key: "normalizeHydratedOrderProduct",
5038
5156
  value: function normalizeHydratedOrderProduct(product) {
5039
- var _this21 = this;
5157
+ var _this22 = this;
5040
5158
  var row = _objectSpread({}, product || {});
5041
5159
  if (row.num === undefined && row.product_quantity !== undefined) {
5042
5160
  row.num = row.product_quantity;
@@ -5044,7 +5162,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5044
5162
  var productSku = ensureProductSku(row);
5045
5163
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
5046
5164
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
5047
- return _this21.normalizeHydratedProductOptionItem(optionItem || {});
5165
+ return _this22.normalizeHydratedProductOptionItem(optionItem || {});
5048
5166
  }))
5049
5167
  });
5050
5168
  delete row["product_".concat('option', "_item")];
@@ -5077,19 +5195,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5077
5195
  value: function () {
5078
5196
  var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(order_id) {
5079
5197
  var res;
5080
- return _regeneratorRuntime().wrap(function _callee39$(_context41) {
5081
- while (1) switch (_context41.prev = _context41.next) {
5198
+ return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5199
+ while (1) switch (_context42.prev = _context42.next) {
5082
5200
  case 0:
5083
- _context41.next = 2;
5201
+ _context42.next = 2;
5084
5202
  return this.request.get("/order/sales/".concat(order_id), {
5085
5203
  with: ['products', 'bookings']
5086
5204
  });
5087
5205
  case 2:
5088
- res = _context41.sent;
5089
- return _context41.abrupt("return", res);
5206
+ res = _context42.sent;
5207
+ return _context42.abrupt("return", res);
5090
5208
  case 4:
5091
5209
  case "end":
5092
- return _context41.stop();
5210
+ return _context42.stop();
5093
5211
  }
5094
5212
  }, _callee39, this);
5095
5213
  }));
@@ -5110,67 +5228,67 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5110
5228
  var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0);
5111
5229
  savedMap.set(discountKey, (savedMap.get(discountKey) || new Decimal(0)).plus(amount));
5112
5230
  };
5113
- var _iterator23 = _createForOfIteratorHelper(productList),
5114
- _step23;
5231
+ var _iterator24 = _createForOfIteratorHelper(productList),
5232
+ _step24;
5115
5233
  try {
5116
- for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
5117
- var product = _step23.value;
5234
+ for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
5235
+ var product = _step24.value;
5118
5236
  var qty = product.num || 1;
5119
- var _iterator25 = _createForOfIteratorHelper(product.discount_list || []),
5120
- _step25;
5237
+ var _iterator26 = _createForOfIteratorHelper(product.discount_list || []),
5238
+ _step26;
5121
5239
  try {
5122
- for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
5123
- var pd = _step25.value;
5240
+ for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
5241
+ var pd = _step26.value;
5124
5242
  addDiscountAmount(pd, qty);
5125
5243
  }
5126
5244
  } catch (err) {
5127
- _iterator25.e(err);
5245
+ _iterator26.e(err);
5128
5246
  } finally {
5129
- _iterator25.f();
5247
+ _iterator26.f();
5130
5248
  }
5131
- var _iterator26 = _createForOfIteratorHelper(product.product_bundle || []),
5132
- _step26;
5249
+ var _iterator27 = _createForOfIteratorHelper(product.product_bundle || []),
5250
+ _step27;
5133
5251
  try {
5134
- for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
5252
+ for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
5135
5253
  var _ref75, _bundle$num3;
5136
- var bundle = _step26.value;
5254
+ var bundle = _step27.value;
5137
5255
  var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref75 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref75 !== void 0 ? _ref75 : 1) || 1).toNumber();
5138
- var _iterator27 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
5139
- _step27;
5256
+ var _iterator28 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
5257
+ _step28;
5140
5258
  try {
5141
- for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
5142
- var _pd = _step27.value;
5259
+ for (_iterator28.s(); !(_step28 = _iterator28.n()).done;) {
5260
+ var _pd = _step28.value;
5143
5261
  addDiscountAmount(_pd, bundleQty);
5144
5262
  }
5145
5263
  } catch (err) {
5146
- _iterator27.e(err);
5264
+ _iterator28.e(err);
5147
5265
  } finally {
5148
- _iterator27.f();
5266
+ _iterator28.f();
5149
5267
  }
5150
5268
  }
5151
5269
  } catch (err) {
5152
- _iterator26.e(err);
5270
+ _iterator27.e(err);
5153
5271
  } finally {
5154
- _iterator26.f();
5272
+ _iterator27.f();
5155
5273
  }
5156
5274
  }
5157
5275
  } catch (err) {
5158
- _iterator23.e(err);
5276
+ _iterator24.e(err);
5159
5277
  } finally {
5160
- _iterator23.f();
5278
+ _iterator24.f();
5161
5279
  }
5162
- var _iterator24 = _createForOfIteratorHelper(discountList),
5163
- _step24;
5280
+ var _iterator25 = _createForOfIteratorHelper(discountList),
5281
+ _step25;
5164
5282
  try {
5165
- for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
5166
- var d = _step24.value;
5283
+ for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
5284
+ var d = _step25.value;
5167
5285
  var key = d.id;
5168
5286
  d.savedAmount = d.isSelected && key != null && savedMap.has(key) ? savedMap.get(key).toNumber() : 0;
5169
5287
  }
5170
5288
  } catch (err) {
5171
- _iterator24.e(err);
5289
+ _iterator25.e(err);
5172
5290
  } finally {
5173
- _iterator24.f();
5291
+ _iterator25.f();
5174
5292
  }
5175
5293
  }
5176
5294
  }]);