@pisell/pisellos 2.3.54 → 2.3.56

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.
@@ -42,6 +42,7 @@ import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum
42
42
  import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
43
43
  import { expandHydratedProductsForDiscountCollection, restoreHydratedBundleDiscounts } from "./utils/bundleDiscountHydration";
44
44
  import { getOrderCollectionPersistentId, getOrderCollectionUid, normalizeOrderCollections, setOrderCollectionUid } from "./utils/orderCollectionIdentity";
45
+ import { consolidateDiscountFreeProductLines, ensureUniqueProductLineUids } from "./utils/discountProductLineIdentity";
45
46
  import { DiscountModule } from "../Discount";
46
47
  import { RulesModule } from "../Rules";
47
48
  import { UnavailableReason } from "../Rules/types";
@@ -159,7 +160,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
159
160
  _step2;
160
161
  try {
161
162
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
162
- var _item$type2, _ref, _ref2, _item$discount$resour, _item$discount, _item$discount$title, _item$discount2, _item$amount, _ref3, _item$discount$origin, _item$discount3, _ref4, _ref5, _item$metadata$num, _item$metadata, _ref6, _ref7, _item$metadata$num2, _item$metadata2, _ref8, _item$discount$discou, _item$discount4, _ref9, _item$discount$origin2, _item$discount5, _item$amount2, _item$amount3, _product$product_id, _product$is_charge_ta, _ref10, _product$original_pri, _ref11, _item$discount$discou2, _item$discount6, _item$discount$discou3, _item$discount7;
163
+ var _item$type2, _ref, _ref2, _item$discount$resour, _item$discount, _item$discount$title, _item$discount2, _item$discount3, _item$discount$fixed_, _item$discount4, _item$discount5, _item$amount, _ref3, _item$discount$origin, _item$discount6, _ref4, _ref5, _item$metadata$num, _item$metadata, _ref6, _ref7, _item$metadata$num2, _item$metadata2, _ref8, _item$discount$discou, _item$discount7, _item$amount2, _item$amount3, _product$product_id, _product$is_charge_ta, _ref9, _product$original_pri, _ref10, _item$discount$discou2, _item$discount8, _item$discount$discou3, _item$discount9;
163
164
  var item = _step2.value;
164
165
  var type = (_item$type2 = item === null || item === void 0 ? void 0 : item.type) !== null && _item$type2 !== void 0 ? _item$type2 : item === null || item === void 0 ? void 0 : item.tag;
165
166
  if (!type || type === 'product') continue;
@@ -170,12 +171,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
170
171
  var key = Number.isFinite(id) ? id : String(resourceId);
171
172
  var title = (_item$discount$title = item === null || item === void 0 || (_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.title) !== null && _item$discount$title !== void 0 ? _item$discount$title : {};
172
173
  var amount = Number((item === null || item === void 0 ? void 0 : item.amount) || 0);
174
+ var discountCardType = item === null || item === void 0 || (_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.discount_card_type;
175
+ var parValue = isDiscountCard ? discountCardType === 'fixed_amount' ? (_item$discount$fixed_ = item === null || item === void 0 || (_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.fixed_amount) !== null && _item$discount$fixed_ !== void 0 ? _item$discount$fixed_ : item === null || item === void 0 ? void 0 : item.amount : item === null || item === void 0 || (_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.percent : '0';
173
176
  var detail = {
174
177
  amount: String((_item$amount = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0'),
175
178
  type: type,
176
179
  resource_id: key,
177
180
  title: title,
178
- original_amount: String((_ref3 = (_item$discount$origin = item === null || item === void 0 || (_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.original_amount) !== null && _item$discount$origin !== void 0 ? _item$discount$origin : item === null || item === void 0 ? void 0 : item.amount) !== null && _ref3 !== void 0 ? _ref3 : '0'),
181
+ original_amount: String((_ref3 = (_item$discount$origin = item === null || item === void 0 || (_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.original_amount) !== null && _item$discount$origin !== void 0 ? _item$discount$origin : item === null || item === void 0 ? void 0 : item.amount) !== null && _ref3 !== void 0 ? _ref3 : '0'),
179
182
  num: Number((_ref4 = (_ref5 = (_item$metadata$num = item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.num) !== null && _item$metadata$num !== void 0 ? _item$metadata$num : product === null || product === void 0 ? void 0 : product.num) !== null && _ref5 !== void 0 ? _ref5 : product === null || product === void 0 ? void 0 : product.product_quantity) !== null && _ref4 !== void 0 ? _ref4 : 1) || 1,
180
183
  metadata: item === null || item === void 0 ? void 0 : item.metadata,
181
184
  discount: item === null || item === void 0 ? void 0 : item.discount,
@@ -205,9 +208,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
205
208
  encoded: '',
206
209
  code: '',
207
210
  tag: type,
208
- product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.discount_product_id) !== null && _item$discount$discou !== void 0 ? _item$discount$discou : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref8 !== void 0 ? _ref8 : 0,
211
+ product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.discount_product_id) !== null && _item$discount$discou !== void 0 ? _item$discount$discou : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref8 !== void 0 ? _ref8 : 0,
209
212
  relation_type: '',
210
- par_value: String((_ref9 = (_item$discount$origin2 = item === null || item === void 0 || (_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.original_amount) !== null && _item$discount$origin2 !== void 0 ? _item$discount$origin2 : item === null || item === void 0 ? void 0 : item.amount) !== null && _ref9 !== void 0 ? _ref9 : '0'),
213
+ par_value: String(parValue !== null && parValue !== void 0 ? parValue : '0'),
211
214
  used_par_value: String((_item$amount2 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount2 !== void 0 ? _item$amount2 : '0'),
212
215
  limit_status: 'enable',
213
216
  limited_relation_product_data: {
@@ -226,7 +229,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
226
229
  id: (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : 0,
227
230
  title: '',
228
231
  is_charge_tax: (_product$is_charge_ta = product === null || product === void 0 ? void 0 : product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
229
- base_price: String((_ref10 = (_product$original_pri = product === null || product === void 0 ? void 0 : product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : product === null || product === void 0 ? void 0 : product.selling_price) !== null && _ref10 !== void 0 ? _ref10 : '0')
232
+ base_price: String((_ref9 = (_product$original_pri = product === null || product === void 0 ? void 0 : product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : product === null || product === void 0 ? void 0 : product.selling_price) !== null && _ref9 !== void 0 ? _ref9 : '0')
230
233
  },
231
234
  type: type,
232
235
  resource_id: key,
@@ -238,8 +241,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
238
241
  amount: amount,
239
242
  discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
240
243
  resource_id: key,
241
- discount_product_id: (_ref11 = (_item$discount$discou2 = item === null || item === void 0 || (_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.discount_product_id) !== null && _item$discount$discou2 !== void 0 ? _item$discount$discou2 : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref11 !== void 0 ? _ref11 : 0,
242
- discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.discount_calculation_mode) !== null && _item$discount$discou3 !== void 0 ? _item$discount$discou3 : 'item_level'
244
+ discount_product_id: (_ref10 = (_item$discount$discou2 = item === null || item === void 0 || (_item$discount8 = item.discount) === null || _item$discount8 === void 0 ? void 0 : _item$discount8.discount_product_id) !== null && _item$discount$discou2 !== void 0 ? _item$discount$discou2 : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref10 !== void 0 ? _ref10 : 0,
245
+ discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$discount9 = item.discount) === null || _item$discount9 === void 0 ? void 0 : _item$discount9.discount_calculation_mode) !== null && _item$discount$discou3 !== void 0 ? _item$discount$discou3 : 'item_level'
243
246
  }),
244
247
  applicableProductDetails: [detail],
245
248
  appliedProductDetails: [detail]
@@ -287,10 +290,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
287
290
  }
288
291
  if (Array.isArray(product.product_bundle)) {
289
292
  product.product_bundle = product.product_bundle.map(function (bundle) {
290
- var _ref12, _bundle$original_pric;
293
+ var _ref11, _bundle$original_pric;
291
294
  var hasBundleDiscount = Array.isArray(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) && bundle.discount_list.length > 0;
292
295
  if (hasBundleDiscount) return bundle;
293
- var restoredPrice = (_ref12 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref12 !== void 0 ? _ref12 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
296
+ var restoredPrice = (_ref11 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref11 !== void 0 ? _ref11 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
294
297
  if (restoredPrice === undefined || restoredPrice === null || restoredPrice === '') return bundle;
295
298
  return _objectSpread(_objectSpread({}, bundle), {}, {
296
299
  price: restoredPrice,
@@ -683,7 +686,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
683
686
  value: function () {
684
687
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
685
688
  var _this$store$discount11, _tempOrder$holder, _this$store$summary;
686
- var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, shouldRetainForLater, normalizedNewDiscountList, retainedDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13;
689
+ var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref12, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, shouldRetainForLater, normalizedNewDiscountList, retainedDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13;
687
690
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
688
691
  while (1) switch (_context6.prev = _context6.next) {
689
692
  case 0:
@@ -760,7 +763,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
760
763
  case 18:
761
764
  tempOrder = this.store.tempOrder;
762
765
  holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
763
- _ref13 = rulesModule.isDiscountListAvailable({
766
+ _ref12 = rulesModule.isDiscountListAvailable({
764
767
  productList: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
765
768
  oldDiscountList: this.getDiscountList(),
766
769
  newDiscountList: withScanList,
@@ -772,7 +775,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
772
775
  }) || {
773
776
  isAvailable: false,
774
777
  discountList: this.getDiscountList()
775
- }, isAvailable = _ref13.isAvailable, newDiscountList = _ref13.discountList, evaluatedDiscountList = _ref13.evaluatedDiscountList, unavailableReason = _ref13.unavailableReason;
778
+ }, isAvailable = _ref12.isAvailable, newDiscountList = _ref12.discountList, evaluatedDiscountList = _ref12.evaluatedDiscountList, unavailableReason = _ref12.unavailableReason;
776
779
  shouldRetainForLater = !isAvailable && unavailableReason === UnavailableReason.ProductNotApplicable && withScanList.some(isCustomerPromotionDiscount);
777
780
  normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
778
781
  retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
@@ -855,9 +858,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
855
858
  if (result !== null && result !== void 0 && result.productList) {
856
859
  var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
857
860
  tempOrder.products = this.applyProductDiscountPrices((result.productList || []).map(function (product, index) {
858
- var _ref14;
861
+ var _ref13;
859
862
  var uid = getOrderProductLineUid(product);
860
- var previous = (_ref14 = uid ? previousProductsByUid.get(uid) : undefined) !== null && _ref14 !== void 0 ? _ref14 : previousProductsByUid.get("__index__:".concat(index));
863
+ var previous = (_ref13 = uid ? previousProductsByUid.get(uid) : undefined) !== null && _ref13 !== void 0 ? _ref13 : previousProductsByUid.get("__index__:".concat(index));
861
864
  if (isManualProductDiscountProduct(previous)) {
862
865
  return previous;
863
866
  }
@@ -866,6 +869,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
866
869
  discount_list: normalizeOrderProductDiscountList(syncManualProductDiscountProductNum(mergedProduct.discount_list, mergedProduct.num))
867
870
  });
868
871
  }));
872
+ ensureUniqueProductLineUids(tempOrder);
873
+ consolidateDiscountFreeProductLines(tempOrder);
869
874
  }
870
875
  if (result !== null && result !== void 0 && result.discountList) {
871
876
  var _this$store$discount15;
@@ -1392,15 +1397,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1392
1397
  }, {
1393
1398
  key: "extractOrderIdFromSubmitResult",
1394
1399
  value: function extractOrderIdFromSubmitResult(result) {
1395
- var _ref15, _ref16, _ref17, _result$data$order_id, _result$data, _result$data2;
1396
- return (_ref15 = (_ref16 = (_ref17 = (_result$data$order_id = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.order_id) !== null && _result$data$order_id !== void 0 ? _result$data$order_id : result === null || result === void 0 ? void 0 : result.order_id) !== null && _ref17 !== void 0 ? _ref17 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref16 !== void 0 ? _ref16 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref15 !== void 0 ? _ref15 : null;
1400
+ var _ref14, _ref15, _ref16, _result$data$order_id, _result$data, _result$data2;
1401
+ return (_ref14 = (_ref15 = (_ref16 = (_result$data$order_id = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.order_id) !== null && _result$data$order_id !== void 0 ? _result$data$order_id : result === null || result === void 0 ? void 0 : result.order_id) !== null && _ref16 !== void 0 ? _ref16 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref15 !== void 0 ? _ref15 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref14 !== void 0 ? _ref14 : null;
1397
1402
  }
1398
1403
  }, {
1399
1404
  key: "calculatePaymentEffectiveAmount",
1400
1405
  value: function calculatePaymentEffectiveAmount(payment) {
1401
- var _ref18, _payment$origin_amoun;
1406
+ var _ref17, _payment$origin_amoun;
1402
1407
  var amount = new Decimal(payment.amount || 0);
1403
- var originAmount = new Decimal((_ref18 = (_payment$origin_amoun = payment.origin_amount) !== null && _payment$origin_amoun !== void 0 ? _payment$origin_amoun : payment.amount) !== null && _ref18 !== void 0 ? _ref18 : 0);
1408
+ var originAmount = new Decimal((_ref17 = (_payment$origin_amoun = payment.origin_amount) !== null && _payment$origin_amoun !== void 0 ? _payment$origin_amoun : payment.amount) !== null && _ref17 !== void 0 ? _ref17 : 0);
1404
1409
  var serviceFee = new Decimal(payment.service_fee || 0);
1405
1410
  // TODO: 后端允许 amount 表示顾客实际支付总额后,移除这个兼容分支。
1406
1411
  var effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
@@ -1600,12 +1605,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1600
1605
  }, {
1601
1606
  key: "normalizePaymentSource",
1602
1607
  value: function normalizePaymentSource(payment, options) {
1603
- var _ref19, _paymentRecord$origin;
1608
+ var _ref18, _paymentRecord$origin;
1604
1609
  var paymentRecord = payment;
1605
1610
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
1606
1611
  var normalized = ensureOrderPaymentNumber(_objectSpread(_objectSpread({}, paymentRecord), {}, {
1607
1612
  metadata: metadata,
1608
- origin_amount: (_ref19 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref19 !== void 0 ? _ref19 : '0.00'
1613
+ origin_amount: (_ref18 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref18 !== void 0 ? _ref18 : '0.00'
1609
1614
  }), (options === null || options === void 0 ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(), createUuidV4);
1610
1615
  if (paymentRecord.status !== undefined) {
1611
1616
  normalized.status = paymentRecord.status;
@@ -1956,7 +1961,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1956
1961
  _product$payment_pric,
1957
1962
  _sku$code,
1958
1963
  _sku$barcode,
1959
- _ref20,
1964
+ _ref19,
1960
1965
  _sku$variant_id,
1961
1966
  _this11 = this;
1962
1967
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
@@ -1983,24 +1988,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1983
1988
  product_sku: this.normalizeFingerprintValue({
1984
1989
  code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
1985
1990
  barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
1986
- variant_id: (_ref20 = (_sku$variant_id = sku.variant_id) !== null && _sku$variant_id !== void 0 ? _sku$variant_id : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref20 !== void 0 ? _ref20 : 0,
1991
+ variant_id: (_ref19 = (_sku$variant_id = sku.variant_id) !== null && _sku$variant_id !== void 0 ? _sku$variant_id : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref19 !== void 0 ? _ref19 : 0,
1987
1992
  variant: sku.variant || [],
1988
1993
  option: getProductSkuOptions(product || {}).map(function (option) {
1989
- var _ref21, _option$id, _option$option_group_, _ref22, _option$option_group_2, _option$num, _option$add_price;
1994
+ var _ref20, _option$id, _option$option_group_, _ref21, _option$option_group_2, _option$num, _option$add_price;
1990
1995
  return {
1991
- id: (_ref21 = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref21 !== void 0 ? _ref21 : null,
1996
+ id: (_ref20 = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref20 !== void 0 ? _ref20 : null,
1992
1997
  option_group_id: (_option$option_group_ = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : null,
1993
- option_group_item_id: (_ref22 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref22 !== void 0 ? _ref22 : null,
1998
+ option_group_item_id: (_ref21 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref21 !== void 0 ? _ref21 : null,
1994
1999
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
1995
2000
  add_price: _this11.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
1996
2001
  };
1997
2002
  })
1998
2003
  }),
1999
2004
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
2000
- var _ref23, _ref24, _bundle$bundle_produc, _ref25, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
2005
+ var _ref22, _ref23, _bundle$bundle_produc, _ref24, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
2001
2006
  return {
2002
- bundle_product_id: (_ref23 = (_ref24 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref24 !== void 0 ? _ref24 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref23 !== void 0 ? _ref23 : null,
2003
- bundle_variant_id: (_ref25 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref25 !== void 0 ? _ref25 : 0,
2007
+ bundle_product_id: (_ref22 = (_ref23 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref23 !== void 0 ? _ref23 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref22 !== void 0 ? _ref22 : null,
2008
+ bundle_variant_id: (_ref24 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref24 !== void 0 ? _ref24 : 0,
2004
2009
  num: getSafeProductNum((_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
2005
2010
  price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
2006
2011
  bundle_selling_price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
@@ -2009,10 +2014,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2009
2014
  };
2010
2015
  })),
2011
2016
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
2012
- var _ref26, _discount$type2, _ref27, _ref28, _discount$discount_id, _discount$discount;
2017
+ var _ref25, _discount$type2, _ref26, _ref27, _discount$discount_id, _discount$discount;
2013
2018
  return {
2014
- type: (_ref26 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref26 !== void 0 ? _ref26 : '',
2015
- discount_id: (_ref27 = (_ref28 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref28 !== void 0 ? _ref28 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref27 !== void 0 ? _ref27 : null,
2019
+ type: (_ref25 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref25 !== void 0 ? _ref25 : '',
2020
+ discount_id: (_ref26 = (_ref27 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref27 !== void 0 ? _ref27 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref26 !== void 0 ? _ref26 : null,
2016
2021
  amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2017
2022
  };
2018
2023
  }))
@@ -2036,14 +2041,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2036
2041
  var _product$product_id3,
2037
2042
  _product$product_vari2,
2038
2043
  _product$num2,
2039
- _ref29,
2044
+ _ref28,
2040
2045
  _metadata$unique_iden,
2041
2046
  _metadata$price_overr,
2042
2047
  _metadata$is_manual_d,
2043
2048
  _metadata$product_dis,
2044
2049
  _sku$code2,
2045
2050
  _sku$barcode2,
2046
- _ref30,
2051
+ _ref29,
2047
2052
  _sku$variant_id2,
2048
2053
  _this13 = this;
2049
2054
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
@@ -2059,7 +2064,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2059
2064
  extension_type: extensionType,
2060
2065
  num: getSafeProductNum((_product$num2 = product === null || product === void 0 ? void 0 : product.num) !== null && _product$num2 !== void 0 ? _product$num2 : product === null || product === void 0 ? void 0 : product.product_quantity),
2061
2066
  metadata: {
2062
- unique_identification_number: (_ref29 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref29 !== void 0 ? _ref29 : '',
2067
+ unique_identification_number: (_ref28 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref28 !== void 0 ? _ref28 : '',
2063
2068
  price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
2064
2069
  is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
2065
2070
  product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
@@ -2067,35 +2072,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2067
2072
  product_sku: this.normalizeFingerprintValue({
2068
2073
  code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
2069
2074
  barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
2070
- variant_id: (_ref30 = (_sku$variant_id2 = sku.variant_id) !== null && _sku$variant_id2 !== void 0 ? _sku$variant_id2 : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref30 !== void 0 ? _ref30 : 0,
2075
+ variant_id: (_ref29 = (_sku$variant_id2 = sku.variant_id) !== null && _sku$variant_id2 !== void 0 ? _sku$variant_id2 : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref29 !== void 0 ? _ref29 : 0,
2071
2076
  variant: sku.variant || [],
2072
2077
  option: getProductSkuOptions(product || {}).map(function (option) {
2073
- var _ref31, _option$id2, _option$option_group_3, _ref32, _option$option_group_4, _option$num2, _option$add_price2;
2078
+ var _ref30, _option$id2, _option$option_group_3, _ref31, _option$option_group_4, _option$num2, _option$add_price2;
2074
2079
  return {
2075
- id: (_ref31 = (_option$id2 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id2 !== void 0 ? _option$id2 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref31 !== void 0 ? _ref31 : null,
2080
+ id: (_ref30 = (_option$id2 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id2 !== void 0 ? _option$id2 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref30 !== void 0 ? _ref30 : null,
2076
2081
  option_group_id: (_option$option_group_3 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_3 !== void 0 ? _option$option_group_3 : null,
2077
- option_group_item_id: (_ref32 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref32 !== void 0 ? _ref32 : null,
2082
+ option_group_item_id: (_ref31 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref31 !== void 0 ? _ref31 : null,
2078
2083
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
2079
2084
  add_price: _this13.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
2080
2085
  };
2081
2086
  })
2082
2087
  }),
2083
2088
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
2084
- var _ref33, _bundle$bundle_id, _ref34, _bundle$bundle_group_, _ref35, _ref36, _bundle$bundle_produc2, _ref37, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
2089
+ var _ref32, _bundle$bundle_id, _ref33, _bundle$bundle_group_, _ref34, _ref35, _bundle$bundle_produc2, _ref36, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
2085
2090
  return {
2086
- bundle_id: (_ref33 = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref33 !== void 0 ? _ref33 : null,
2087
- bundle_group_id: (_ref34 = (_bundle$bundle_group_ = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle === null || bundle === void 0 ? void 0 : bundle.group_id) !== null && _ref34 !== void 0 ? _ref34 : null,
2088
- bundle_product_id: (_ref35 = (_ref36 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref36 !== void 0 ? _ref36 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref35 !== void 0 ? _ref35 : null,
2089
- bundle_variant_id: (_ref37 = (_bundle$bundle_varian2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian2 !== void 0 ? _bundle$bundle_varian2 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref37 !== void 0 ? _ref37 : 0,
2091
+ bundle_id: (_ref32 = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref32 !== void 0 ? _ref32 : null,
2092
+ bundle_group_id: (_ref33 = (_bundle$bundle_group_ = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle === null || bundle === void 0 ? void 0 : bundle.group_id) !== null && _ref33 !== void 0 ? _ref33 : null,
2093
+ bundle_product_id: (_ref34 = (_ref35 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref35 !== void 0 ? _ref35 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref34 !== void 0 ? _ref34 : null,
2094
+ bundle_variant_id: (_ref36 = (_bundle$bundle_varian2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian2 !== void 0 ? _bundle$bundle_varian2 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref36 !== void 0 ? _ref36 : 0,
2090
2095
  num: getSafeProductNum((_bundle$num2 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num2 !== void 0 ? _bundle$num2 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
2091
2096
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
2092
2097
  price_type_ext: (_bundle$price_type_ex2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : '',
2093
2098
  option: _this13.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2094
- var _ref38, _option$id3, _option$option_group_5, _ref39, _option$option_group_6, _option$num3, _option$add_price3;
2099
+ var _ref37, _option$id3, _option$option_group_5, _ref38, _option$option_group_6, _option$num3, _option$add_price3;
2095
2100
  return {
2096
- id: (_ref38 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref38 !== void 0 ? _ref38 : null,
2101
+ id: (_ref37 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref37 !== void 0 ? _ref37 : null,
2097
2102
  option_group_id: (_option$option_group_5 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_5 !== void 0 ? _option$option_group_5 : null,
2098
- option_group_item_id: (_ref39 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref39 !== void 0 ? _ref39 : null,
2103
+ option_group_item_id: (_ref38 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref38 !== void 0 ? _ref38 : null,
2099
2104
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
2100
2105
  add_price: _this13.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
2101
2106
  };
@@ -2103,10 +2108,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2103
2108
  };
2104
2109
  })),
2105
2110
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
2106
- var _ref40, _discount$type4, _ref41, _ref42, _discount$discount_id2, _discount$discount2;
2111
+ var _ref39, _discount$type4, _ref40, _ref41, _discount$discount_id2, _discount$discount2;
2107
2112
  return {
2108
- type: (_ref40 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref40 !== void 0 ? _ref40 : '',
2109
- discount_id: (_ref41 = (_ref42 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref42 !== void 0 ? _ref42 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref41 !== void 0 ? _ref41 : null,
2113
+ type: (_ref39 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref39 !== void 0 ? _ref39 : '',
2114
+ discount_id: (_ref40 = (_ref41 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref41 !== void 0 ? _ref41 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref40 !== void 0 ? _ref40 : null,
2110
2115
  amount: _this13.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2111
2116
  };
2112
2117
  }))
@@ -2409,11 +2414,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2409
2414
  }, {
2410
2415
  key: "getOrderIdentity",
2411
2416
  value: function getOrderIdentity() {
2412
- var _ref43, _ref44, _tempOrder$order_id, _tempOrder$_extend6;
2417
+ var _ref42, _ref43, _tempOrder$order_id, _tempOrder$_extend6;
2413
2418
  var tempOrder = this.store.tempOrder;
2414
2419
  if (!tempOrder) return null;
2415
2420
  var lastOrderInfo = this.store.lastOrderInfo || {};
2416
- var orderId = (_ref43 = (_ref44 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref44 !== void 0 ? _ref44 : lastOrderInfo.id) !== null && _ref43 !== void 0 ? _ref43 : null;
2421
+ var orderId = (_ref42 = (_ref43 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref43 !== void 0 ? _ref43 : lastOrderInfo.id) !== null && _ref42 !== void 0 ? _ref42 : null;
2417
2422
  return {
2418
2423
  localId: this.cacheId || ((_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.localId),
2419
2424
  orderId: orderId,
@@ -2549,6 +2554,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2549
2554
  tempOrder.products = (tempOrder.products || []).map(function (product) {
2550
2555
  return _this15.sanitizeOrderProductForTempOrder(product);
2551
2556
  });
2557
+ ensureUniqueProductLineUids(tempOrder);
2552
2558
  }
2553
2559
  }, {
2554
2560
  key: "ensureExtend",
@@ -2566,11 +2572,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2566
2572
  }, {
2567
2573
  key: "captureProductRuntime",
2568
2574
  value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
2569
- var _extend$productsByUid, _ref45, _rawProduct$_origin;
2575
+ var _extend$productsByUid, _ref44, _rawProduct$_origin;
2570
2576
  var uid = existedUid || this.getProductUid(normalizedProduct);
2571
2577
  var extend = this.ensureExtend(tempOrder);
2572
2578
  var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
2573
- var origin = (_ref45 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref45 !== void 0 ? _ref45 : existed.origin;
2579
+ var origin = (_ref44 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref44 !== void 0 ? _ref44 : existed.origin;
2574
2580
  extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
2575
2581
  origin: origin
2576
2582
  } : {});
@@ -2713,7 +2719,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2713
2719
  }, {
2714
2720
  key: "buildTempOrderHolderFromBookings",
2715
2721
  value: function buildTempOrderHolderFromBookings(tempOrder) {
2716
- var _baseHolder$customer_, _baseHolder, _ref46, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams;
2722
+ var _baseHolder$customer_, _baseHolder, _ref45, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams;
2717
2723
  var holderRecords = [];
2718
2724
  var holderNames = [];
2719
2725
  var baseHolder = null;
@@ -2760,7 +2766,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2760
2766
  }
2761
2767
  var nextHolder = {
2762
2768
  customer_id: (_baseHolder$customer_ = (_baseHolder = baseHolder) === null || _baseHolder === void 0 ? void 0 : _baseHolder.customer_id) !== null && _baseHolder$customer_ !== void 0 ? _baseHolder$customer_ : tempOrder.customer_id,
2763
- form_id: (_ref46 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_id) !== null && _ref46 !== void 0 ? _ref46 : 0,
2769
+ form_id: (_ref45 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_id) !== null && _ref45 !== void 0 ? _ref45 : 0,
2764
2770
  form_record: holderRecords
2765
2771
  };
2766
2772
  if (holderNames.length) {
@@ -2865,7 +2871,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2865
2871
  key: "recalculateSummary",
2866
2872
  value: function () {
2867
2873
  var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(options) {
2868
- var _this$otherParams2, _ref47, _salesSummaryResult$e;
2874
+ var _this$otherParams2, _ref46, _salesSummaryResult$e;
2869
2875
  var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
2870
2876
  return _regeneratorRuntime().wrap(function _callee12$(_context14) {
2871
2877
  while (1) switch (_context14.prev = _context14.next) {
@@ -2943,7 +2949,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2943
2949
  roundingAmount = paidPaymentSummary.roundingAmount;
2944
2950
  payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
2945
2951
  hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
2946
- expectAmount = hasSalesSummaryAmount ? new Decimal((_ref47 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref47 !== void 0 ? _ref47 : 0) : null;
2952
+ expectAmount = hasSalesSummaryAmount ? new Decimal((_ref46 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref46 !== void 0 ? _ref46 : 0) : null;
2947
2953
  amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
2948
2954
  rounding_amount: roundingAmount.toFixed(2)
2949
2955
  }, expectAmount ? {
@@ -3121,17 +3127,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3121
3127
  }, {
3122
3128
  key: "buildTempOrderCustomer",
3123
3129
  value: function buildTempOrderCustomer(params) {
3124
- var _ref48, _ref49, _ref50, _source$name, _ref51, _ref52, _ref53, _source$customer_name, _source$id, _source$customer_id, _ref54, _source$country_calli, _source$phone, _source$email;
3130
+ var _ref47, _ref48, _ref49, _source$name, _ref50, _ref51, _ref52, _source$customer_name, _source$id, _source$customer_id, _ref53, _source$country_calli, _source$phone, _source$email;
3125
3131
  if (!params.customerId) return null;
3126
3132
  var source = params.source ? cloneDeep(params.source) : {};
3127
- var name = (_ref48 = (_ref49 = (_ref50 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref50 !== void 0 ? _ref50 : source.customerName) !== null && _ref49 !== void 0 ? _ref49 : source.customer_name) !== null && _ref48 !== void 0 ? _ref48 : params.customerName;
3128
- var customerName = (_ref51 = (_ref52 = (_ref53 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref53 !== void 0 ? _ref53 : source.display_name) !== null && _ref52 !== void 0 ? _ref52 : source.name) !== null && _ref51 !== void 0 ? _ref51 : params.customerName;
3133
+ var name = (_ref47 = (_ref48 = (_ref49 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref49 !== void 0 ? _ref49 : source.customerName) !== null && _ref48 !== void 0 ? _ref48 : source.customer_name) !== null && _ref47 !== void 0 ? _ref47 : params.customerName;
3134
+ var customerName = (_ref50 = (_ref51 = (_ref52 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref52 !== void 0 ? _ref52 : source.display_name) !== null && _ref51 !== void 0 ? _ref51 : source.name) !== null && _ref50 !== void 0 ? _ref50 : params.customerName;
3129
3135
  return _objectSpread(_objectSpread({}, source), {}, {
3130
3136
  id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
3131
3137
  customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
3132
3138
  name: String(name || ''),
3133
3139
  customer_name: String(customerName || ''),
3134
- country_calling_code: String((_ref54 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref54 !== void 0 ? _ref54 : params.countryCallingCode),
3140
+ country_calling_code: String((_ref53 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref53 !== void 0 ? _ref53 : params.countryCallingCode),
3135
3141
  phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
3136
3142
  email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
3137
3143
  });
@@ -3235,14 +3241,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3235
3241
  }, {
3236
3242
  key: "updateTempOrderCustomer",
3237
3243
  value: function updateTempOrderCustomer(customer) {
3238
- var _tempOrder$customer_i2, _ref55, _ref56, _customer$customer_id, _ref57, _ref58, _ref59, _customer$customer_na, _ref60, _customer$country_cal, _tempOrder$customer_i3;
3244
+ var _tempOrder$customer_i2, _ref54, _ref55, _customer$customer_id, _ref56, _ref57, _ref58, _customer$customer_na, _ref59, _customer$country_cal, _tempOrder$customer_i3;
3239
3245
  var tempOrder = this.ensureTempOrder();
3240
3246
  var previousCustomerId = (_tempOrder$customer_i2 = tempOrder.customer_id) !== null && _tempOrder$customer_i2 !== void 0 ? _tempOrder$customer_i2 : null;
3241
- var customerId = (_ref55 = (_ref56 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref56 !== void 0 ? _ref56 : customer.id) !== null && _ref55 !== void 0 ? _ref55 : null;
3242
- var customerName = (_ref57 = (_ref58 = (_ref59 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref59 !== void 0 ? _ref59 : customer.display_name) !== null && _ref58 !== void 0 ? _ref58 : customer.name) !== null && _ref57 !== void 0 ? _ref57 : '';
3247
+ var customerId = (_ref54 = (_ref55 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref55 !== void 0 ? _ref55 : customer.id) !== null && _ref54 !== void 0 ? _ref54 : null;
3248
+ var customerName = (_ref56 = (_ref57 = (_ref58 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref58 !== void 0 ? _ref58 : customer.display_name) !== null && _ref57 !== void 0 ? _ref57 : customer.name) !== null && _ref56 !== void 0 ? _ref56 : '';
3243
3249
  tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
3244
3250
  tempOrder.customer_name = String(customerName || '');
3245
- tempOrder.country_calling_code = String((_ref60 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref60 !== void 0 ? _ref60 : '');
3251
+ tempOrder.country_calling_code = String((_ref59 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref59 !== void 0 ? _ref59 : '');
3246
3252
  tempOrder.phone = String(customer.phone || '');
3247
3253
  tempOrder.email = String(customer.email || '');
3248
3254
  tempOrder.customer = this.buildTempOrderCustomer({
@@ -3338,6 +3344,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3338
3344
  if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
3339
3345
  this.store.availableWalletIds = [];
3340
3346
  this.clearCustomerBoundDiscounts(tempOrder);
3347
+ this.applyDiscount();
3341
3348
  this.persistTempOrder();
3342
3349
  this.saveDraftInBackground();
3343
3350
  this.core.effects.emit(OrderHooks.OnOrderCustomerChange, null);
@@ -3756,52 +3763,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3756
3763
  }
3757
3764
  return updateVoucherOrderPaymentsAsync;
3758
3765
  }()
3766
+ }, {
3767
+ key: "normalizeShouldMergeProductResult",
3768
+ value: function normalizeShouldMergeProductResult(result) {
3769
+ if (typeof result === 'boolean') return result;
3770
+ if (result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean') {
3771
+ return result.shouldMerge;
3772
+ }
3773
+ return true;
3774
+ }
3759
3775
  }, {
3760
3776
  key: "shouldMergeProductToOrder",
3761
- value: function () {
3762
- var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
3763
- var _this$orderHooks;
3764
- var onBeforeMergeProductToOrder, result;
3765
- return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3766
- while (1) switch (_context20.prev = _context20.next) {
3767
- case 0:
3768
- onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
3769
- if (onBeforeMergeProductToOrder) {
3770
- _context20.next = 3;
3771
- break;
3772
- }
3773
- return _context20.abrupt("return", true);
3774
- case 3:
3775
- _context20.next = 5;
3776
- return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
3777
- defaultShouldMerge: true
3778
- }));
3779
- case 5:
3780
- result = _context20.sent;
3781
- if (!(typeof result === 'boolean')) {
3782
- _context20.next = 8;
3783
- break;
3784
- }
3785
- return _context20.abrupt("return", result);
3786
- case 8:
3787
- if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
3788
- _context20.next = 10;
3789
- break;
3790
- }
3791
- return _context20.abrupt("return", result.shouldMerge);
3792
- case 10:
3793
- return _context20.abrupt("return", true);
3794
- case 11:
3795
- case "end":
3796
- return _context20.stop();
3797
- }
3798
- }, _callee18, this);
3777
+ value: function shouldMergeProductToOrder(params) {
3778
+ var _this$orderHooks,
3779
+ _this26 = this;
3780
+ var onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
3781
+ if (!onBeforeMergeProductToOrder) return true;
3782
+ var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
3783
+ defaultShouldMerge: true
3799
3784
  }));
3800
- function shouldMergeProductToOrder(_x19) {
3801
- return _shouldMergeProductToOrder.apply(this, arguments);
3785
+ if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
3786
+ return Promise.resolve(result).then(function (resolved) {
3787
+ return _this26.normalizeShouldMergeProductResult(resolved);
3788
+ });
3802
3789
  }
3803
- return shouldMergeProductToOrder;
3804
- }()
3790
+ return this.normalizeShouldMergeProductResult(result);
3791
+ }
3805
3792
  }, {
3806
3793
  key: "hasOrderProductLineNote",
3807
3794
  value: function hasOrderProductLineNote(product) {
@@ -3833,30 +3820,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3833
3820
  }, {
3834
3821
  key: "finalizeProductOrderMutation",
3835
3822
  value: function () {
3836
- var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(tempOrder, options) {
3837
- return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3838
- while (1) switch (_context21.prev = _context21.next) {
3823
+ var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(tempOrder, options) {
3824
+ return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3825
+ while (1) switch (_context20.prev = _context20.next) {
3839
3826
  case 0:
3840
3827
  this.syncTempOrderHolderFromBookings(tempOrder);
3841
3828
  if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
3842
- _context21.next = 4;
3829
+ _context20.next = 4;
3843
3830
  break;
3844
3831
  }
3845
- _context21.next = 4;
3832
+ _context20.next = 4;
3846
3833
  return this.ensureEditDiscountConfigForProductChange(tempOrder);
3847
3834
  case 4:
3848
3835
  if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
3849
- _context21.next = 7;
3836
+ _context20.next = 7;
3850
3837
  break;
3851
3838
  }
3852
- _context21.next = 7;
3839
+ _context20.next = 7;
3853
3840
  return this.applyPromotion();
3854
3841
  case 7:
3855
3842
  if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
3856
3843
  this.applyDiscount();
3857
3844
  }
3858
3845
  this.sanitizeTempOrderProducts(tempOrder);
3859
- _context21.next = 11;
3846
+ _context20.next = 11;
3860
3847
  return this.recalculateSummary({
3861
3848
  createIfMissing: true
3862
3849
  });
@@ -3864,11 +3851,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3864
3851
  this.persistTempOrder();
3865
3852
  case 12:
3866
3853
  case "end":
3867
- return _context21.stop();
3854
+ return _context20.stop();
3868
3855
  }
3869
- }, _callee19, this);
3856
+ }, _callee18, this);
3870
3857
  }));
3871
- function finalizeProductOrderMutation(_x20, _x21) {
3858
+ function finalizeProductOrderMutation(_x19, _x20) {
3872
3859
  return _finalizeProductOrderMutation.apply(this, arguments);
3873
3860
  }
3874
3861
  return finalizeProductOrderMutation;
@@ -3878,154 +3865,143 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3878
3865
  * 带 booking 且 num>1 时由 `addProductToOrder` 拆成多次本方法调用(每次 num=1)。
3879
3866
  *
3880
3867
  * @example
3881
- * await this.appendProductLineToTempOrder(tempOrder, { product_id: 1, num: 1 }, booking);
3868
+ * const pending = this.appendProductLineToTempOrder(
3869
+ * tempOrder,
3870
+ * { product_id: 1, num: 1 },
3871
+ * booking,
3872
+ * );
3873
+ * if (pending) await pending;
3882
3874
  */
3883
3875
  }, {
3884
3876
  key: "appendProductLineToTempOrder",
3885
- value: (function () {
3886
- var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(tempOrder, product, booking, options) {
3887
- var _normalizedIncoming$p,
3888
- _normalizedIncoming$p2,
3889
- _booking_uid,
3890
- _metadata,
3891
- _this26 = this;
3892
- var linked, productToAdd, incomingFingerprint, normalizedIncoming, isWeighingProduct, netWeight, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, insertAtIndex, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList, mergedProduct;
3893
- return _regeneratorRuntime().wrap(function _callee20$(_context22) {
3894
- while (1) switch (_context22.prev = _context22.next) {
3895
- case 0:
3896
- linked = booking ? this.createLinkedProductAndBooking({
3897
- product: product,
3898
- booking: booking
3899
- }) : null;
3900
- productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
3901
- incomingFingerprint = buildProductLineFingerprint(getProductSkuOptions(productToAdd), productToAdd.product_bundle);
3902
- normalizedIncoming = mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd));
3903
- isWeighingProduct = Number(((_normalizedIncoming$p = normalizedIncoming.product_sku) === null || _normalizedIncoming$p === void 0 ? void 0 : _normalizedIncoming$p.open_sold_weight) || 0) === 1;
3904
- netWeight = Number((_normalizedIncoming$p2 = normalizedIncoming.product_sku) === null || _normalizedIncoming$p2 === void 0 ? void 0 : _normalizedIncoming$p2.net_weight);
3905
- if (!(isWeighingProduct && (!Number.isFinite(netWeight) || netWeight <= 0))) {
3906
- _context22.next = 8;
3907
- break;
3908
- }
3909
- throw new Error('[Order] 称重商品净重必须大于 0');
3910
- case 8:
3911
- incomingBookingUid = (_booking_uid = productToAdd.booking_uid) !== null && _booking_uid !== void 0 ? _booking_uid : (_metadata = productToAdd.metadata) === null || _metadata === void 0 ? void 0 : _metadata.booking_uid;
3912
- if (incomingBookingUid !== undefined && incomingBookingUid !== null && String(incomingBookingUid) !== '') {
3913
- normalizedIncoming.booking_uid = String(incomingBookingUid);
3914
- normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
3915
- booking_uid: String(incomingBookingUid)
3916
- });
3917
- }
3918
- normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
3919
- hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
3920
- hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
3921
- hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
3922
- shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid || isWeighingProduct;
3923
- matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
3924
- var _item$metadata3;
3925
- if (_this26.hasGoodPassDiscount(item)) return false;
3926
- if (_this26.hasOrderProductLineNote(item)) return false;
3927
- if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
3928
- if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
3929
- if (item.product_id !== productToAdd.product_id) return false;
3930
- if (item.product_variant_id !== productToAdd.product_variant_id) return false;
3931
- var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
3932
- return existedFingerprint === incomingFingerprint;
3933
- });
3934
- matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
3935
- existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
3936
- if (!matchedProduct) {
3937
- _context22.next = 24;
3938
- break;
3939
- }
3940
- _context22.next = 21;
3941
- return this.shouldMergeProductToOrder({
3942
- incomingProduct: productToAdd,
3943
- normalizedIncoming: normalizedIncoming,
3944
- matchedProduct: matchedProduct,
3945
- matchedIndex: matchedIndex,
3946
- incomingFingerprint: incomingFingerprint,
3947
- existedFingerprint: existedFingerprint,
3948
- tempOrder: tempOrder,
3949
- booking: booking
3950
- });
3951
- case 21:
3952
- _context22.t0 = _context22.sent;
3953
- _context22.next = 25;
3954
- break;
3955
- case 24:
3956
- _context22.t0 = false;
3957
- case 25:
3958
- shouldMerge = _context22.t0;
3959
- if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
3960
- this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
3961
- if (linked) {
3962
- normalizedIncoming.booking_uid = linked.bookingUid;
3963
- normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
3964
- booking_uid: linked.bookingUid
3965
- });
3966
- }
3967
- insertAtIndex = options === null || options === void 0 ? void 0 : options.insertAtIndex;
3968
- if (Number.isInteger(insertAtIndex) && Number(insertAtIndex) >= 0 && Number(insertAtIndex) < tempOrder.products.length) {
3969
- tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, insertAtIndex)), [normalizedIncoming], _toConsumableArray(tempOrder.products.slice(insertAtIndex)));
3970
- } else {
3971
- tempOrder.products = [].concat(_toConsumableArray(tempOrder.products), [normalizedIncoming]);
3972
- }
3973
- } else {
3974
- targetProduct = matchedProduct;
3975
- targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
3976
- normalizedProduct = mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
3977
- metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
3978
- unique_identification_number: targetUid
3979
- })
3980
- })));
3981
- normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
3982
- nextNum = getSafeProductNum(targetProduct.num + normalizedProduct.num);
3983
- targetIsManualProductDiscount = isManualProductDiscountProduct(targetProduct);
3984
- nextDiscountList = targetIsManualProductDiscount ? normalizeOrderProductDiscountList(syncManualProductDiscountProductNum(targetProduct.discount_list, nextNum)) : normalizedProduct.discount_list;
3985
- tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
3986
- discount_list: nextDiscountList,
3987
- metadata: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.metadata || {}), normalizedProduct.metadata || {}), {}, {
3988
- unique_identification_number: targetUid
3989
- }),
3990
- product_sku: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.product_sku || {
3991
- option: []
3992
- }), normalizedProduct.product_sku || {
3993
- option: []
3994
- }), {}, {
3995
- option: getProductSkuOptions(normalizedProduct)
3996
- })
3997
- }, targetIsManualProductDiscount ? {
3998
- selling_price: targetProduct.selling_price,
3999
- original_price: targetProduct.original_price,
4000
- payment_price: targetProduct.payment_price,
4001
- metadata: _objectSpread(_objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), targetProduct.metadata || {}), {}, {
4002
- unique_identification_number: targetUid
4003
- })
4004
- } : {}), {}, {
4005
- note: targetProduct.note,
4006
- order_detail_id: targetProduct.order_detail_id,
4007
- num: nextNum
4008
- });
4009
- this.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
4010
- if (matchedIndex !== tempOrder.products.length - 1) {
4011
- mergedProduct = tempOrder.products[matchedIndex];
4012
- tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, matchedIndex)), _toConsumableArray(tempOrder.products.slice(matchedIndex + 1)), [mergedProduct]);
4013
- }
4014
- }
4015
- if (linked) {
4016
- tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
4017
- }
4018
- case 28:
4019
- case "end":
4020
- return _context22.stop();
3877
+ value: function appendProductLineToTempOrder(tempOrder, product, booking, options) {
3878
+ var _normalizedIncoming$p,
3879
+ _normalizedIncoming$p2,
3880
+ _booking_uid,
3881
+ _metadata,
3882
+ _productToAdd$metadat,
3883
+ _origin,
3884
+ _this27 = this;
3885
+ var linked = booking ? this.createLinkedProductAndBooking({
3886
+ product: product,
3887
+ booking: booking
3888
+ }) : null;
3889
+ var productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
3890
+ var incomingFingerprint = buildProductLineFingerprint(getProductSkuOptions(productToAdd), productToAdd.product_bundle);
3891
+ var normalizedIncoming = mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd));
3892
+ var isWeighingProduct = Number(((_normalizedIncoming$p = normalizedIncoming.product_sku) === null || _normalizedIncoming$p === void 0 ? void 0 : _normalizedIncoming$p.open_sold_weight) || 0) === 1;
3893
+ var netWeight = Number((_normalizedIncoming$p2 = normalizedIncoming.product_sku) === null || _normalizedIncoming$p2 === void 0 ? void 0 : _normalizedIncoming$p2.net_weight);
3894
+ if (isWeighingProduct && (!Number.isFinite(netWeight) || netWeight <= 0)) {
3895
+ throw new Error('[Order] 称重商品净重必须大于 0');
3896
+ }
3897
+ var incomingBookingUid = (_booking_uid = productToAdd.booking_uid) !== null && _booking_uid !== void 0 ? _booking_uid : (_metadata = productToAdd.metadata) === null || _metadata === void 0 ? void 0 : _metadata.booking_uid;
3898
+ if (incomingBookingUid !== undefined && incomingBookingUid !== null && String(incomingBookingUid) !== '') {
3899
+ normalizedIncoming.booking_uid = String(incomingBookingUid);
3900
+ normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
3901
+ booking_uid: String(incomingBookingUid)
3902
+ });
3903
+ }
3904
+ normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
3905
+ var hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
3906
+ var hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
3907
+ var hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
3908
+ var isIncomingCustomItem = ((_productToAdd$metadat = productToAdd.metadata) === null || _productToAdd$metadat === void 0 || (_productToAdd$metadat = _productToAdd$metadat.origin) === null || _productToAdd$metadat === void 0 ? void 0 : _productToAdd$metadat.isCustomItem) === true || ((_origin = productToAdd._origin) === null || _origin === void 0 ? void 0 : _origin.isCustomItem) === true;
3909
+ var shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
3910
+ var matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
3911
+ var _item$metadata3;
3912
+ if (_this27.hasGoodPassDiscount(item)) return false;
3913
+ if (_this27.hasOrderProductLineNote(item)) return false;
3914
+ if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
3915
+ if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
3916
+ if (item.product_id !== productToAdd.product_id) return false;
3917
+ if (item.product_variant_id !== productToAdd.product_variant_id) return false;
3918
+ var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
3919
+ return existedFingerprint === incomingFingerprint;
3920
+ });
3921
+ var matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
3922
+ var existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
3923
+ var commitProductLine = function commitProductLine(shouldMerge) {
3924
+ if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
3925
+ _this27.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
3926
+ if (linked) {
3927
+ normalizedIncoming.booking_uid = linked.bookingUid;
3928
+ normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
3929
+ booking_uid: linked.bookingUid
3930
+ });
4021
3931
  }
4022
- }, _callee20, this);
4023
- }));
4024
- function appendProductLineToTempOrder(_x22, _x23, _x24, _x25) {
4025
- return _appendProductLineToTempOrder.apply(this, arguments);
3932
+ var insertAtIndex = options === null || options === void 0 ? void 0 : options.insertAtIndex;
3933
+ if (Number.isInteger(insertAtIndex) && Number(insertAtIndex) >= 0 && Number(insertAtIndex) < tempOrder.products.length) {
3934
+ tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, insertAtIndex)), [normalizedIncoming], _toConsumableArray(tempOrder.products.slice(insertAtIndex)));
3935
+ } else {
3936
+ tempOrder.products = [].concat(_toConsumableArray(tempOrder.products), [normalizedIncoming]);
3937
+ }
3938
+ } else {
3939
+ var _targetProduct$metada;
3940
+ var targetProduct = matchedProduct;
3941
+ var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
3942
+ var normalizedProduct = mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
3943
+ metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
3944
+ unique_identification_number: targetUid
3945
+ })
3946
+ })));
3947
+ normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
3948
+ var nextNum = getSafeProductNum(targetProduct.num + normalizedProduct.num);
3949
+ var targetIsManualProductDiscount = isManualProductDiscountProduct(targetProduct);
3950
+ var nextDiscountList = targetIsManualProductDiscount ? normalizeOrderProductDiscountList(syncManualProductDiscountProductNum(targetProduct.discount_list, nextNum)) : normalizedProduct.discount_list;
3951
+ tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
3952
+ discount_list: nextDiscountList,
3953
+ metadata: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.metadata || {}), normalizedProduct.metadata || {}), {}, {
3954
+ unique_identification_number: targetUid
3955
+ }),
3956
+ product_sku: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.product_sku || {
3957
+ option: []
3958
+ }), normalizedProduct.product_sku || {
3959
+ option: []
3960
+ }), {}, {
3961
+ option: getProductSkuOptions(normalizedProduct)
3962
+ })
3963
+ }, targetIsManualProductDiscount ? {
3964
+ selling_price: targetProduct.selling_price,
3965
+ original_price: targetProduct.original_price,
3966
+ payment_price: targetProduct.payment_price,
3967
+ metadata: _objectSpread(_objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), targetProduct.metadata || {}), {}, {
3968
+ unique_identification_number: targetUid
3969
+ })
3970
+ } : {}), {}, {
3971
+ note: targetProduct.note,
3972
+ order_detail_id: targetProduct.order_detail_id,
3973
+ num: nextNum
3974
+ });
3975
+ _this27.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
3976
+ if (matchedIndex !== tempOrder.products.length - 1) {
3977
+ var mergedProduct = tempOrder.products[matchedIndex];
3978
+ tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, matchedIndex)), _toConsumableArray(tempOrder.products.slice(matchedIndex + 1)), [mergedProduct]);
3979
+ }
3980
+ }
3981
+ if (linked) {
3982
+ tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
3983
+ }
3984
+ };
3985
+ if (!matchedProduct) {
3986
+ commitProductLine(false);
3987
+ return;
4026
3988
  }
4027
- return appendProductLineToTempOrder;
4028
- }()
3989
+ var shouldMerge = this.shouldMergeProductToOrder({
3990
+ incomingProduct: productToAdd,
3991
+ normalizedIncoming: normalizedIncoming,
3992
+ matchedProduct: matchedProduct,
3993
+ matchedIndex: matchedIndex,
3994
+ incomingFingerprint: incomingFingerprint,
3995
+ existedFingerprint: existedFingerprint,
3996
+ tempOrder: tempOrder,
3997
+ booking: booking
3998
+ });
3999
+ if (shouldMerge && _typeof(shouldMerge) === 'object' && typeof shouldMerge.then === 'function') {
4000
+ return Promise.resolve(shouldMerge).then(commitProductLine);
4001
+ }
4002
+ commitProductLine(shouldMerge);
4003
+ }
4004
+
4029
4005
  /**
4030
4006
  * 添加商品行。带 booking 时强制独立行;num>1 时拆成多条 num=1 的 product+booking(对齐 BookingByStep / ticketBooking addService)。
4031
4007
  *
@@ -4033,14 +4009,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4033
4009
  * await order.addProductToOrder({ product_id: 1, num: 3 }, { start_time: '10:00' });
4034
4010
  * // → tempOrder.products 新增 3 行,每行 num=1,bookings 3 条
4035
4011
  */
4036
- )
4037
4012
  }, {
4038
4013
  key: "addProductToOrder",
4039
4014
  value: (function () {
4040
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(product, booking, options) {
4041
- var tempOrder, insertAfterProductUid, anchorIndex, insertAtIndex, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
4042
- return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4043
- while (1) switch (_context23.prev = _context23.next) {
4015
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(product, booking, options) {
4016
+ var tempOrder, insertAfterProductUid, anchorIndex, insertAtIndex, _ref60, _productRecord$num, productRecord, splitCount, i, singleLine, _appendResult, appendResult;
4017
+ return _regeneratorRuntime().wrap(function _callee19$(_context21) {
4018
+ while (1) switch (_context21.prev = _context21.next) {
4044
4019
  case 0:
4045
4020
  tempOrder = this.ensureTempOrder();
4046
4021
  insertAfterProductUid = options === null || options === void 0 ? void 0 : options.insertAfterProductUid;
@@ -4051,60 +4026,70 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4051
4026
  }) : -1;
4052
4027
  insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
4053
4028
  if (!booking) {
4054
- _context23.next = 22;
4029
+ _context21.next = 24;
4055
4030
  break;
4056
4031
  }
4057
4032
  productRecord = product;
4058
- splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
4033
+ splitCount = getSafeProductNum((_ref60 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref60 !== void 0 ? _ref60 : 1);
4059
4034
  if (!(splitCount > 1)) {
4060
- _context23.next = 22;
4035
+ _context21.next = 24;
4061
4036
  break;
4062
4037
  }
4063
4038
  i = 0;
4064
4039
  case 9:
4065
4040
  if (!(i < splitCount)) {
4066
- _context23.next = 19;
4041
+ _context21.next = 21;
4067
4042
  break;
4068
4043
  }
4069
4044
  singleLine = cloneDeep(productRecord);
4070
4045
  singleLine.num = 1;
4071
4046
  delete singleLine.product_quantity;
4072
- _context23.next = 15;
4073
- return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking), {
4047
+ _appendResult = this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking), {
4074
4048
  insertAtIndex: insertAtIndex
4075
4049
  });
4076
- case 15:
4050
+ if (!_appendResult) {
4051
+ _context21.next = 17;
4052
+ break;
4053
+ }
4054
+ _context21.next = 17;
4055
+ return _appendResult;
4056
+ case 17:
4077
4057
  if (insertAtIndex !== undefined) insertAtIndex += 1;
4078
- case 16:
4058
+ case 18:
4079
4059
  i += 1;
4080
- _context23.next = 9;
4060
+ _context21.next = 9;
4081
4061
  break;
4082
- case 19:
4083
- _context23.next = 21;
4084
- return this.finalizeProductOrderMutation(tempOrder);
4085
4062
  case 21:
4086
- return _context23.abrupt("return", tempOrder.products);
4087
- case 22:
4088
- _context23.next = 24;
4089
- return this.appendProductLineToTempOrder(tempOrder, product, booking, {
4063
+ _context21.next = 23;
4064
+ return this.finalizeProductOrderMutation(tempOrder);
4065
+ case 23:
4066
+ return _context21.abrupt("return", tempOrder.products);
4067
+ case 24:
4068
+ appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
4090
4069
  insertAtIndex: insertAtIndex
4091
4070
  });
4092
- case 24:
4093
- _context23.next = 26;
4071
+ if (!appendResult) {
4072
+ _context21.next = 28;
4073
+ break;
4074
+ }
4075
+ _context21.next = 28;
4076
+ return appendResult;
4077
+ case 28:
4078
+ _context21.next = 30;
4094
4079
  return this.finalizeProductOrderMutation(tempOrder);
4095
- case 26:
4080
+ case 30:
4096
4081
  this.logInfo('addProductToOrder success', {
4097
4082
  product_id: product.product_id,
4098
4083
  with_booking: !!booking
4099
4084
  });
4100
- return _context23.abrupt("return", tempOrder.products);
4101
- case 28:
4085
+ return _context21.abrupt("return", tempOrder.products);
4086
+ case 32:
4102
4087
  case "end":
4103
- return _context23.stop();
4088
+ return _context21.stop();
4104
4089
  }
4105
- }, _callee21, this);
4090
+ }, _callee19, this);
4106
4091
  }));
4107
- function addProductToOrder(_x26, _x27, _x28) {
4092
+ function addProductToOrder(_x21, _x22, _x23) {
4108
4093
  return _addProductToOrder.apply(this, arguments);
4109
4094
  }
4110
4095
  return addProductToOrder;
@@ -4122,93 +4107,103 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4122
4107
  }, {
4123
4108
  key: "addProductsToOrder",
4124
4109
  value: (function () {
4125
- var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(items, options) {
4126
- var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
4127
- return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4128
- while (1) switch (_context24.prev = _context24.next) {
4110
+ var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(items, options) {
4111
+ var tempOrder, _iterator20, _step20, item, product, booking, _ref61, _productRecord$num2, productRecord, splitCount, i, singleLine, _appendResult2, appendResult;
4112
+ return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4113
+ while (1) switch (_context22.prev = _context22.next) {
4129
4114
  case 0:
4130
4115
  tempOrder = this.ensureTempOrder();
4131
4116
  if (!(!Array.isArray(items) || items.length === 0)) {
4132
- _context24.next = 3;
4117
+ _context22.next = 3;
4133
4118
  break;
4134
4119
  }
4135
- return _context24.abrupt("return", tempOrder.products);
4120
+ return _context22.abrupt("return", tempOrder.products);
4136
4121
  case 3:
4137
4122
  _iterator20 = _createForOfIteratorHelper(items || []);
4138
- _context24.prev = 4;
4123
+ _context22.prev = 4;
4139
4124
  _iterator20.s();
4140
4125
  case 6:
4141
4126
  if ((_step20 = _iterator20.n()).done) {
4142
- _context24.next = 30;
4127
+ _context22.next = 34;
4143
4128
  break;
4144
4129
  }
4145
4130
  item = _step20.value;
4146
4131
  product = item.product, booking = item.booking;
4147
4132
  if (product) {
4148
- _context24.next = 11;
4133
+ _context22.next = 11;
4149
4134
  break;
4150
4135
  }
4151
- return _context24.abrupt("continue", 28);
4136
+ return _context22.abrupt("continue", 32);
4152
4137
  case 11:
4153
4138
  if (!booking) {
4154
- _context24.next = 26;
4139
+ _context22.next = 28;
4155
4140
  break;
4156
4141
  }
4157
4142
  productRecord = product;
4158
- splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
4143
+ splitCount = getSafeProductNum((_ref61 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
4159
4144
  if (!(splitCount > 1)) {
4160
- _context24.next = 26;
4145
+ _context22.next = 28;
4161
4146
  break;
4162
4147
  }
4163
4148
  i = 0;
4164
4149
  case 16:
4165
4150
  if (!(i < splitCount)) {
4166
- _context24.next = 25;
4151
+ _context22.next = 27;
4167
4152
  break;
4168
4153
  }
4169
4154
  singleLine = cloneDeep(productRecord);
4170
4155
  singleLine.num = 1;
4171
4156
  delete singleLine.product_quantity;
4172
- _context24.next = 22;
4173
- return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
4174
- case 22:
4157
+ _appendResult2 = this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
4158
+ if (!_appendResult2) {
4159
+ _context22.next = 24;
4160
+ break;
4161
+ }
4162
+ _context22.next = 24;
4163
+ return _appendResult2;
4164
+ case 24:
4175
4165
  i += 1;
4176
- _context24.next = 16;
4166
+ _context22.next = 16;
4177
4167
  break;
4178
- case 25:
4179
- return _context24.abrupt("continue", 28);
4180
- case 26:
4181
- _context24.next = 28;
4182
- return this.appendProductLineToTempOrder(tempOrder, product, booking);
4168
+ case 27:
4169
+ return _context22.abrupt("continue", 32);
4183
4170
  case 28:
4184
- _context24.next = 6;
4171
+ appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking);
4172
+ if (!appendResult) {
4173
+ _context22.next = 32;
4174
+ break;
4175
+ }
4176
+ _context22.next = 32;
4177
+ return appendResult;
4178
+ case 32:
4179
+ _context22.next = 6;
4185
4180
  break;
4186
- case 30:
4187
- _context24.next = 35;
4181
+ case 34:
4182
+ _context22.next = 39;
4188
4183
  break;
4189
- case 32:
4190
- _context24.prev = 32;
4191
- _context24.t0 = _context24["catch"](4);
4192
- _iterator20.e(_context24.t0);
4193
- case 35:
4194
- _context24.prev = 35;
4184
+ case 36:
4185
+ _context22.prev = 36;
4186
+ _context22.t0 = _context22["catch"](4);
4187
+ _iterator20.e(_context22.t0);
4188
+ case 39:
4189
+ _context22.prev = 39;
4195
4190
  _iterator20.f();
4196
- return _context24.finish(35);
4197
- case 38:
4198
- _context24.next = 40;
4191
+ return _context22.finish(39);
4192
+ case 42:
4193
+ _context22.next = 44;
4199
4194
  return this.finalizeProductOrderMutation(tempOrder, options);
4200
- case 40:
4195
+ case 44:
4201
4196
  this.logInfo('addProductsToOrder success', {
4202
4197
  itemsCount: items.length
4203
4198
  });
4204
- return _context24.abrupt("return", tempOrder.products);
4205
- case 42:
4199
+ return _context22.abrupt("return", tempOrder.products);
4200
+ case 46:
4206
4201
  case "end":
4207
- return _context24.stop();
4202
+ return _context22.stop();
4208
4203
  }
4209
- }, _callee22, this, [[4, 32, 35, 38]]);
4204
+ }, _callee20, this, [[4, 36, 39, 42]]);
4210
4205
  }));
4211
- function addProductsToOrder(_x29, _x30) {
4206
+ function addProductsToOrder(_x24, _x25) {
4212
4207
  return _addProductsToOrder.apply(this, arguments);
4213
4208
  }
4214
4209
  return addProductsToOrder;
@@ -4235,24 +4230,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4235
4230
  }, {
4236
4231
  key: "getBundleRuntimeIdentity",
4237
4232
  value: function getBundleRuntimeIdentity(bundle) {
4238
- var _ref63, _bundle$bundle_id2, _ref64, _bundle$bundle_group_2, _ref65, _ref66, _bundle$bundle_produc3, _ref67, _bundle$bundle_varian3;
4233
+ var _ref62, _bundle$bundle_id2, _ref63, _bundle$bundle_group_2, _ref64, _ref65, _bundle$bundle_produc3, _ref66, _bundle$bundle_varian3;
4239
4234
  if (!bundle || _typeof(bundle) !== 'object') return '';
4240
- return [(_ref63 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref63 !== void 0 ? _ref63 : '', (_ref64 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref64 !== void 0 ? _ref64 : '', (_ref65 = (_ref66 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref66 !== void 0 ? _ref66 : bundle.product_id) !== null && _ref65 !== void 0 ? _ref65 : '', (_ref67 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref67 !== void 0 ? _ref67 : 0].join('|');
4235
+ return [(_ref62 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref62 !== void 0 ? _ref62 : '', (_ref63 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref63 !== void 0 ? _ref63 : '', (_ref64 = (_ref65 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref65 !== void 0 ? _ref65 : bundle.product_id) !== null && _ref64 !== void 0 ? _ref64 : '', (_ref66 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref66 !== void 0 ? _ref66 : 0].join('|');
4241
4236
  }
4242
4237
  }, {
4243
4238
  key: "preservePersistedBundlePriceFields",
4244
4239
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
4245
- var _this27 = this;
4240
+ var _this28 = this;
4246
4241
  if (!Array.isArray(nextBundles)) return nextBundles;
4247
4242
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
4248
4243
  var previousByIdentity = new Map();
4249
4244
  previousBundles.forEach(function (bundle) {
4250
- var identity = _this27.getBundleRuntimeIdentity(bundle);
4245
+ var identity = _this28.getBundleRuntimeIdentity(bundle);
4251
4246
  if (identity) previousByIdentity.set(identity, bundle);
4252
4247
  });
4253
4248
  return nextBundles.map(function (bundle, index) {
4254
4249
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
4255
- var previous = previousByIdentity.get(_this27.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
4250
+ var previous = previousByIdentity.get(_this28.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
4256
4251
  if (!previous || _typeof(previous) !== 'object') return bundle;
4257
4252
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
4258
4253
  cover: previous.cover
@@ -4388,13 +4383,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4388
4383
  delete nextProduct.metadata.main_product_original_price;
4389
4384
  delete nextProduct.metadata.price_schema_version;
4390
4385
  } else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
4391
- var _ref68, _targetProduct$metada10, _targetProduct$metada11, _ref69, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
4386
+ var _ref67, _targetProduct$metada10, _targetProduct$metada11, _ref68, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
4392
4387
  // 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
4393
4388
  // 但必须让 original 与 selling 一起随新的 option 金额移动。
4394
4389
  var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
4395
4390
  var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
4396
- var _previousMainOriginal = new Decimal(Number((_ref68 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref68 !== void 0 ? _ref68 : 0) || 0);
4397
- var _previousMainSelling = new Decimal(Number((_ref69 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref69 !== void 0 ? _ref69 : _previousMainOriginal.toNumber()) || 0);
4391
+ var _previousMainOriginal = new Decimal(Number((_ref67 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref67 !== void 0 ? _ref67 : 0) || 0);
4392
+ var _previousMainSelling = new Decimal(Number((_ref68 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref68 !== void 0 ? _ref68 : _previousMainOriginal.toNumber()) || 0);
4398
4393
  var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
4399
4394
  var previousSource = ((_targetProduct$metada14 = targetProduct.metadata) === null || _targetProduct$metada14 === void 0 ? void 0 : _targetProduct$metada14.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal.minus(previousOptionSum);
4400
4395
  var _nextMainOriginal = previousSource.plus(nextOptionSum);
@@ -4453,21 +4448,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4453
4448
  }, {
4454
4449
  key: "updateOrderProduct",
4455
4450
  value: function () {
4456
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
4451
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
4457
4452
  var tempOrder, updatedProductUid;
4458
- return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4459
- while (1) switch (_context25.prev = _context25.next) {
4453
+ return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4454
+ while (1) switch (_context23.prev = _context23.next) {
4460
4455
  case 0:
4461
4456
  tempOrder = this.ensureTempOrder();
4462
4457
  updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
4463
- _context25.next = 4;
4458
+ _context23.next = 4;
4464
4459
  return this.applyPromotion();
4465
4460
  case 4:
4466
4461
  this.applyDiscount({
4467
4462
  reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
4468
4463
  });
4469
4464
  this.sanitizeTempOrderProducts(tempOrder);
4470
- _context25.next = 8;
4465
+ _context23.next = 8;
4471
4466
  return this.recalculateSummary({
4472
4467
  createIfMissing: true
4473
4468
  });
@@ -4476,14 +4471,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4476
4471
  this.logInfo('updateOrderProduct success', {
4477
4472
  params: params
4478
4473
  });
4479
- return _context25.abrupt("return", tempOrder.products);
4474
+ return _context23.abrupt("return", tempOrder.products);
4480
4475
  case 11:
4481
4476
  case "end":
4482
- return _context25.stop();
4477
+ return _context23.stop();
4483
4478
  }
4484
- }, _callee23, this);
4479
+ }, _callee21, this);
4485
4480
  }));
4486
- function updateOrderProduct(_x31) {
4481
+ function updateOrderProduct(_x26) {
4487
4482
  return _updateOrderProduct.apply(this, arguments);
4488
4483
  }
4489
4484
  return updateOrderProduct;
@@ -4491,28 +4486,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4491
4486
  }, {
4492
4487
  key: "updateOrderProducts",
4493
4488
  value: function () {
4494
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(paramsList) {
4495
- var _this28 = this;
4489
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(paramsList) {
4490
+ var _this29 = this;
4496
4491
  var tempOrder, reapplyBookingDiscountProductUids;
4497
- return _regeneratorRuntime().wrap(function _callee24$(_context26) {
4498
- while (1) switch (_context26.prev = _context26.next) {
4492
+ return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4493
+ while (1) switch (_context24.prev = _context24.next) {
4499
4494
  case 0:
4500
4495
  tempOrder = this.ensureTempOrder();
4501
4496
  if (paramsList.length) {
4502
- _context26.next = 3;
4497
+ _context24.next = 3;
4503
4498
  break;
4504
4499
  }
4505
- return _context26.abrupt("return", tempOrder.products);
4500
+ return _context24.abrupt("return", tempOrder.products);
4506
4501
  case 3:
4507
4502
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
4508
- var updatedProductUid = _this28.applyOrderProductUpdateToTempOrder(tempOrder, params);
4503
+ var updatedProductUid = _this29.applyOrderProductUpdateToTempOrder(tempOrder, params);
4509
4504
  // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
4510
4505
  if (params.allow_booking_discount_reapply && updatedProductUid) {
4511
4506
  acc.push(String(updatedProductUid));
4512
4507
  }
4513
4508
  return acc;
4514
4509
  }, []);
4515
- _context26.next = 6;
4510
+ _context24.next = 6;
4516
4511
  return this.finalizeAfterProductsMutation(tempOrder, {
4517
4512
  reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
4518
4513
  });
@@ -4520,14 +4515,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4520
4515
  this.logInfo('updateOrderProduct success', {
4521
4516
  paramsList: paramsList
4522
4517
  });
4523
- return _context26.abrupt("return", tempOrder.products);
4518
+ return _context24.abrupt("return", tempOrder.products);
4524
4519
  case 8:
4525
4520
  case "end":
4526
- return _context26.stop();
4521
+ return _context24.stop();
4527
4522
  }
4528
- }, _callee24, this);
4523
+ }, _callee22, this);
4529
4524
  }));
4530
- function updateOrderProducts(_x32) {
4525
+ function updateOrderProducts(_x27) {
4531
4526
  return _updateOrderProducts.apply(this, arguments);
4532
4527
  }
4533
4528
  return updateOrderProducts;
@@ -4535,11 +4530,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4535
4530
  }, {
4536
4531
  key: "updateOrderProductQuantity",
4537
4532
  value: function () {
4538
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
4533
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
4539
4534
  var _targetProduct$metada17;
4540
4535
  var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
4541
- return _regeneratorRuntime().wrap(function _callee25$(_context27) {
4542
- while (1) switch (_context27.prev = _context27.next) {
4536
+ return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4537
+ while (1) switch (_context25.prev = _context25.next) {
4543
4538
  case 0:
4544
4539
  product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
4545
4540
  tempOrder = this.ensureTempOrder();
@@ -4568,7 +4563,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4568
4563
  productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
4569
4564
  }
4570
4565
  if (!(productIndex === -1)) {
4571
- _context27.next = 12;
4566
+ _context25.next = 12;
4572
4567
  break;
4573
4568
  }
4574
4569
  throw new Error('[Order] 目标商品不存在,无法更新数量');
@@ -4582,12 +4577,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4582
4577
  }));
4583
4578
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
4584
4579
  tempOrder.products[productIndex] = normalizedProduct;
4585
- _context27.next = 18;
4580
+ _context25.next = 18;
4586
4581
  return this.applyPromotion();
4587
4582
  case 18:
4588
4583
  this.applyDiscount();
4589
4584
  this.sanitizeTempOrderProducts(tempOrder);
4590
- _context27.next = 22;
4585
+ _context25.next = 22;
4591
4586
  return this.recalculateSummary({
4592
4587
  createIfMissing: true
4593
4588
  });
@@ -4596,14 +4591,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4596
4591
  this.logInfo('updateOrderProductQuantity success', {
4597
4592
  params: params
4598
4593
  });
4599
- return _context27.abrupt("return", tempOrder.products);
4594
+ return _context25.abrupt("return", tempOrder.products);
4600
4595
  case 25:
4601
4596
  case "end":
4602
- return _context27.stop();
4597
+ return _context25.stop();
4603
4598
  }
4604
- }, _callee25, this);
4599
+ }, _callee23, this);
4605
4600
  }));
4606
- function updateOrderProductQuantity(_x33) {
4601
+ function updateOrderProductQuantity(_x28) {
4607
4602
  return _updateOrderProductQuantity.apply(this, arguments);
4608
4603
  }
4609
4604
  return updateOrderProductQuantity;
@@ -4644,19 +4639,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4644
4639
  }, {
4645
4640
  key: "finalizeAfterProductsMutation",
4646
4641
  value: (function () {
4647
- var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(tempOrder, options) {
4648
- return _regeneratorRuntime().wrap(function _callee26$(_context28) {
4649
- while (1) switch (_context28.prev = _context28.next) {
4642
+ var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(tempOrder, options) {
4643
+ return _regeneratorRuntime().wrap(function _callee24$(_context26) {
4644
+ while (1) switch (_context26.prev = _context26.next) {
4650
4645
  case 0:
4651
4646
  this.syncTempOrderHolderFromBookings(tempOrder);
4652
- _context28.next = 3;
4647
+ _context26.next = 3;
4653
4648
  return this.applyPromotion();
4654
4649
  case 3:
4655
4650
  this.applyDiscount({
4656
4651
  reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
4657
4652
  });
4658
4653
  this.sanitizeTempOrderProducts(tempOrder);
4659
- _context28.next = 7;
4654
+ _context26.next = 7;
4660
4655
  return this.recalculateSummary({
4661
4656
  createIfMissing: true
4662
4657
  });
@@ -4664,11 +4659,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4664
4659
  this.persistTempOrder();
4665
4660
  case 8:
4666
4661
  case "end":
4667
- return _context28.stop();
4662
+ return _context26.stop();
4668
4663
  }
4669
- }, _callee26, this);
4664
+ }, _callee24, this);
4670
4665
  }));
4671
- function finalizeAfterProductsMutation(_x34, _x35) {
4666
+ function finalizeAfterProductsMutation(_x29, _x30) {
4672
4667
  return _finalizeAfterProductsMutation.apply(this, arguments);
4673
4668
  }
4674
4669
  return finalizeAfterProductsMutation;
@@ -4683,18 +4678,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4683
4678
  }, {
4684
4679
  key: "removeProductsFromOrder",
4685
4680
  value: (function () {
4686
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identities, options) {
4687
- var _this29 = this;
4681
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(identities, options) {
4682
+ var _this30 = this;
4688
4683
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
4689
- return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4690
- while (1) switch (_context30.prev = _context30.next) {
4684
+ return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4685
+ while (1) switch (_context28.prev = _context28.next) {
4691
4686
  case 0:
4692
4687
  tempOrder = this.ensureTempOrder();
4693
4688
  if (identities.length) {
4694
- _context30.next = 3;
4689
+ _context28.next = 3;
4695
4690
  break;
4696
4691
  }
4697
- return _context30.abrupt("return", tempOrder.products);
4692
+ return _context28.abrupt("return", tempOrder.products);
4698
4693
  case 3:
4699
4694
  productsBeforeRemove = tempOrder.products || [];
4700
4695
  bookingsBeforeRemove = tempOrder.bookings || [];
@@ -4724,29 +4719,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4724
4719
  }
4725
4720
  linkedBookingUidsToRemove = new Set();
4726
4721
  _iterator21 = _createForOfIteratorHelper(matchedProducts);
4727
- _context30.prev = 14;
4722
+ _context28.prev = 14;
4728
4723
  _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
4729
4724
  var _metadata11, _metadata12, _metadata13, _metadata14;
4730
4725
  var product, productUid, productBookingUid, isAddTimeProduct;
4731
- return _regeneratorRuntime().wrap(function _loop3$(_context29) {
4732
- while (1) switch (_context29.prev = _context29.next) {
4726
+ return _regeneratorRuntime().wrap(function _loop3$(_context27) {
4727
+ while (1) switch (_context27.prev = _context27.next) {
4733
4728
  case 0:
4734
4729
  product = _step21.value;
4735
4730
  productUid = (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
4736
4731
  productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata12 = product.metadata) === null || _metadata12 === void 0 ? void 0 : _metadata12.booking_uid);
4737
4732
  isAddTimeProduct = (product === null || product === void 0 || (_metadata13 = product.metadata) === null || _metadata13 === void 0 ? void 0 : _metadata13.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata14 = product.metadata) === null || _metadata14 === void 0 ? void 0 : _metadata14.product_add_schedule_time) !== null;
4738
4733
  if (!isAddTimeProduct) {
4739
- _context29.next = 6;
4734
+ _context27.next = 6;
4740
4735
  break;
4741
4736
  }
4742
- return _context29.abrupt("return", 1);
4737
+ return _context27.abrupt("return", 1);
4743
4738
  case 6:
4744
4739
  if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
4745
4740
  linkedBookingUidsToRemove.add(String(productBookingUid));
4746
4741
  }
4747
4742
  if (productUid !== undefined && productUid !== null && productUid !== '') {
4748
4743
  bookingsBeforeRemove.forEach(function (booking) {
4749
- var bookingUid = _this29.getBookingUniqueIdentificationNumber(booking);
4744
+ var bookingUid = _this30.getBookingUniqueIdentificationNumber(booking);
4750
4745
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
4751
4746
  linkedBookingUidsToRemove.add(bookingUid);
4752
4747
  }
@@ -4754,37 +4749,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4754
4749
  }
4755
4750
  case 8:
4756
4751
  case "end":
4757
- return _context29.stop();
4752
+ return _context27.stop();
4758
4753
  }
4759
4754
  }, _loop3);
4760
4755
  });
4761
4756
  _iterator21.s();
4762
4757
  case 17:
4763
4758
  if ((_step21 = _iterator21.n()).done) {
4764
- _context30.next = 23;
4759
+ _context28.next = 23;
4765
4760
  break;
4766
4761
  }
4767
- return _context30.delegateYield(_loop3(), "t0", 19);
4762
+ return _context28.delegateYield(_loop3(), "t0", 19);
4768
4763
  case 19:
4769
- if (!_context30.t0) {
4770
- _context30.next = 21;
4764
+ if (!_context28.t0) {
4765
+ _context28.next = 21;
4771
4766
  break;
4772
4767
  }
4773
- return _context30.abrupt("continue", 21);
4768
+ return _context28.abrupt("continue", 21);
4774
4769
  case 21:
4775
- _context30.next = 17;
4770
+ _context28.next = 17;
4776
4771
  break;
4777
4772
  case 23:
4778
- _context30.next = 28;
4773
+ _context28.next = 28;
4779
4774
  break;
4780
4775
  case 25:
4781
- _context30.prev = 25;
4782
- _context30.t1 = _context30["catch"](14);
4783
- _iterator21.e(_context30.t1);
4776
+ _context28.prev = 25;
4777
+ _context28.t1 = _context28["catch"](14);
4778
+ _iterator21.e(_context28.t1);
4784
4779
  case 28:
4785
- _context30.prev = 28;
4780
+ _context28.prev = 28;
4786
4781
  _iterator21.f();
4787
- return _context30.finish(28);
4782
+ return _context28.finish(28);
4788
4783
  case 31:
4789
4784
  if (linkedBookingUidsToRemove.size > 0) {
4790
4785
  // 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
@@ -4811,20 +4806,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4811
4806
  tempOrder.products = nextProductIndex >= 0 ? [].concat(_toConsumableArray(productsWithoutRemaining.slice(0, nextProductIndex)), [remainingProduct], _toConsumableArray(productsWithoutRemaining.slice(nextProductIndex))) : [].concat(_toConsumableArray(productsWithoutRemaining), [remainingProduct]);
4812
4807
  }
4813
4808
  }
4814
- _context30.next = 35;
4809
+ _context28.next = 35;
4815
4810
  return this.finalizeAfterProductsMutation(tempOrder);
4816
4811
  case 35:
4817
4812
  this.logInfo('removeProductsFromOrder success', {
4818
4813
  identities: identities
4819
4814
  });
4820
- return _context30.abrupt("return", tempOrder.products);
4815
+ return _context28.abrupt("return", tempOrder.products);
4821
4816
  case 37:
4822
4817
  case "end":
4823
- return _context30.stop();
4818
+ return _context28.stop();
4824
4819
  }
4825
- }, _callee27, this, [[14, 25, 28, 31]]);
4820
+ }, _callee25, this, [[14, 25, 28, 31]]);
4826
4821
  }));
4827
- function removeProductsFromOrder(_x36, _x37) {
4822
+ function removeProductsFromOrder(_x31, _x32) {
4828
4823
  return _removeProductsFromOrder.apply(this, arguments);
4829
4824
  }
4830
4825
  return removeProductsFromOrder;
@@ -4832,18 +4827,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4832
4827
  }, {
4833
4828
  key: "removeProductFromOrder",
4834
4829
  value: function () {
4835
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity, options) {
4836
- return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4837
- while (1) switch (_context31.prev = _context31.next) {
4830
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(identity, options) {
4831
+ return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4832
+ while (1) switch (_context29.prev = _context29.next) {
4838
4833
  case 0:
4839
- return _context31.abrupt("return", this.removeProductsFromOrder([identity], options));
4834
+ return _context29.abrupt("return", this.removeProductsFromOrder([identity], options));
4840
4835
  case 1:
4841
4836
  case "end":
4842
- return _context31.stop();
4837
+ return _context29.stop();
4843
4838
  }
4844
- }, _callee28, this);
4839
+ }, _callee26, this);
4845
4840
  }));
4846
- function removeProductFromOrder(_x38, _x39) {
4841
+ function removeProductFromOrder(_x33, _x34) {
4847
4842
  return _removeProductFromOrder.apply(this, arguments);
4848
4843
  }
4849
4844
  return removeProductFromOrder;
@@ -4855,10 +4850,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4855
4850
  }, {
4856
4851
  key: "clearOrderCartLines",
4857
4852
  value: (function () {
4858
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
4853
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
4859
4854
  var tempOrder;
4860
- return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4861
- while (1) switch (_context32.prev = _context32.next) {
4855
+ return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4856
+ while (1) switch (_context30.prev = _context30.next) {
4862
4857
  case 0:
4863
4858
  tempOrder = this.ensureTempOrder();
4864
4859
  tempOrder.products = [];
@@ -4869,24 +4864,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4869
4864
  productsByUid: {}
4870
4865
  });
4871
4866
  }
4872
- _context32.next = 7;
4867
+ _context30.next = 7;
4873
4868
  return this.applyPromotion();
4874
4869
  case 7:
4875
4870
  this.applyDiscount();
4876
4871
  this.sanitizeTempOrderProducts(tempOrder);
4877
- _context32.next = 11;
4872
+ _context30.next = 11;
4878
4873
  return this.recalculateSummary({
4879
4874
  createIfMissing: true
4880
4875
  });
4881
4876
  case 11:
4882
4877
  this.persistTempOrder();
4883
4878
  this.logInfo('clearOrderCartLines success', {});
4884
- return _context32.abrupt("return", tempOrder);
4879
+ return _context30.abrupt("return", tempOrder);
4885
4880
  case 14:
4886
4881
  case "end":
4887
- return _context32.stop();
4882
+ return _context30.stop();
4888
4883
  }
4889
- }, _callee29, this);
4884
+ }, _callee27, this);
4890
4885
  }));
4891
4886
  function clearOrderCartLines() {
4892
4887
  return _clearOrderCartLines.apply(this, arguments);
@@ -4897,23 +4892,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4897
4892
  }, {
4898
4893
  key: "buildCurrentSubmitPayloadForLocalPrint",
4899
4894
  value: function buildCurrentSubmitPayloadForLocalPrint(params) {
4900
- var _params$cacheId, _this$otherParams3, _ref70, _params$businessCode, _this$otherParams4, _this$otherParams5;
4895
+ var _params$cacheId, _this$otherParams3, _ref69, _params$businessCode, _this$otherParams4, _this$otherParams5;
4901
4896
  var tempOrder = this.ensureTempOrder();
4902
4897
  this.persistTempOrder();
4903
4898
  var payload = buildSubmitPayload({
4904
4899
  tempOrder: tempOrder,
4905
4900
  cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
4906
4901
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform),
4907
- businessCode: (_ref70 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode) !== null && _ref70 !== void 0 ? _ref70 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.business_code,
4902
+ businessCode: (_ref69 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode) !== null && _ref69 !== void 0 ? _ref69 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.business_code,
4908
4903
  channel: params === null || params === void 0 ? void 0 : params.channel,
4909
4904
  type: params === null || params === void 0 ? void 0 : params.type,
4910
4905
  summary: this.store.summary || createEmptySummary(),
4911
4906
  enhance: function enhance(nextPayload) {
4912
- var _ref71, _tempOrder$order_numb, _ref72, _tempOrder$shop_order, _ref73, _tempOrder$shop_full_;
4907
+ var _ref70, _tempOrder$order_numb, _ref71, _tempOrder$shop_order, _ref72, _tempOrder$shop_full_;
4913
4908
  return _objectSpread(_objectSpread({}, nextPayload), {}, {
4914
- order_number: (_ref71 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref71 !== void 0 ? _ref71 : null,
4915
- shop_order_number: (_ref72 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref72 !== void 0 ? _ref72 : null,
4916
- shop_full_order_number: (_ref73 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref73 !== void 0 ? _ref73 : null,
4909
+ order_number: (_ref70 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref70 !== void 0 ? _ref70 : null,
4910
+ shop_order_number: (_ref71 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref71 !== void 0 ? _ref71 : null,
4911
+ shop_full_order_number: (_ref72 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref72 !== void 0 ? _ref72 : null,
4917
4912
  small_ticket_data_flag: 1
4918
4913
  });
4919
4914
  }
@@ -4924,17 +4919,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4924
4919
  }, {
4925
4920
  key: "applyLocalPrintOrderNumbers",
4926
4921
  value: function () {
4927
- var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(order) {
4922
+ var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(order) {
4928
4923
  var tempOrder, shopOrderNumber, shopFullOrderNumber;
4929
- return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4930
- while (1) switch (_context33.prev = _context33.next) {
4924
+ return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4925
+ while (1) switch (_context31.prev = _context31.next) {
4931
4926
  case 0:
4932
4927
  tempOrder = this.ensureTempOrder();
4933
4928
  if (!(!order || _typeof(order) !== 'object')) {
4934
- _context33.next = 3;
4929
+ _context31.next = 3;
4935
4930
  break;
4936
4931
  }
4937
- return _context33.abrupt("return", tempOrder);
4932
+ return _context31.abrupt("return", tempOrder);
4938
4933
  case 3:
4939
4934
  shopOrderNumber = order.shop_order_number;
4940
4935
  shopFullOrderNumber = order.shop_full_order_number;
@@ -4945,17 +4940,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4945
4940
  tempOrder.shop_full_order_number = String(shopFullOrderNumber);
4946
4941
  }
4947
4942
  this.persistTempOrder();
4948
- _context33.next = 10;
4943
+ _context31.next = 10;
4949
4944
  return this.saveDraft();
4950
4945
  case 10:
4951
- return _context33.abrupt("return", tempOrder);
4946
+ return _context31.abrupt("return", tempOrder);
4952
4947
  case 11:
4953
4948
  case "end":
4954
- return _context33.stop();
4949
+ return _context31.stop();
4955
4950
  }
4956
- }, _callee30, this);
4951
+ }, _callee28, this);
4957
4952
  }));
4958
- function applyLocalPrintOrderNumbers(_x40) {
4953
+ function applyLocalPrintOrderNumbers(_x35) {
4959
4954
  return _applyLocalPrintOrderNumbers.apply(this, arguments);
4960
4955
  }
4961
4956
  return applyLocalPrintOrderNumbers;
@@ -4963,35 +4958,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4963
4958
  }, {
4964
4959
  key: "saveTempOrderAsDraft",
4965
4960
  value: function () {
4966
- var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
4961
+ var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4967
4962
  var _params$cacheId2, _this$otherParams6, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
4968
4963
  var tempOrder, latestSummary, payload;
4969
- return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4970
- while (1) switch (_context34.prev = _context34.next) {
4964
+ return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4965
+ while (1) switch (_context32.prev = _context32.next) {
4971
4966
  case 0:
4972
4967
  tempOrder = this.ensureTempOrder();
4973
4968
  this.ensureExternalSaleNumber(tempOrder);
4974
4969
  this.persistTempOrder();
4975
- _context34.next = 5;
4970
+ _context32.next = 5;
4976
4971
  return this.recalculateSummary({
4977
4972
  createIfMissing: true
4978
4973
  });
4979
4974
  case 5:
4980
- _context34.t1 = _context34.sent;
4981
- if (_context34.t1) {
4982
- _context34.next = 8;
4975
+ _context32.t1 = _context32.sent;
4976
+ if (_context32.t1) {
4977
+ _context32.next = 8;
4983
4978
  break;
4984
4979
  }
4985
- _context34.t1 = this.store.summary;
4980
+ _context32.t1 = this.store.summary;
4986
4981
  case 8:
4987
- _context34.t0 = _context34.t1;
4988
- if (_context34.t0) {
4989
- _context34.next = 11;
4982
+ _context32.t0 = _context32.t1;
4983
+ if (_context32.t0) {
4984
+ _context32.next = 11;
4990
4985
  break;
4991
4986
  }
4992
- _context34.t0 = createEmptySummary();
4987
+ _context32.t0 = createEmptySummary();
4993
4988
  case 11:
4994
- latestSummary = _context34.t0;
4989
+ latestSummary = _context32.t0;
4995
4990
  payload = buildSubmitPayload({
4996
4991
  tempOrder: tempOrder,
4997
4992
  cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
@@ -5012,17 +5007,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5012
5007
  externalSaleNumber: payload.external_sale_number,
5013
5008
  productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
5014
5009
  });
5015
- return _context34.abrupt("return", this.request.post('/order/sales/draft', payload, {
5010
+ return _context32.abrupt("return", this.request.post('/order/sales/draft', payload, {
5016
5011
  osServer: true,
5017
5012
  customToast: function customToast() {}
5018
5013
  }));
5019
5014
  case 18:
5020
5015
  case "end":
5021
- return _context34.stop();
5016
+ return _context32.stop();
5022
5017
  }
5023
- }, _callee31, this);
5018
+ }, _callee29, this);
5024
5019
  }));
5025
- function saveTempOrderAsDraft(_x41) {
5020
+ function saveTempOrderAsDraft(_x36) {
5026
5021
  return _saveTempOrderAsDraft.apply(this, arguments);
5027
5022
  }
5028
5023
  return saveTempOrderAsDraft;
@@ -5036,18 +5031,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5036
5031
  }, {
5037
5032
  key: "submitTempOrder",
5038
5033
  value: (function () {
5039
- var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
5040
- return _regeneratorRuntime().wrap(function _callee32$(_context35) {
5041
- while (1) switch (_context35.prev = _context35.next) {
5034
+ var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
5035
+ return _regeneratorRuntime().wrap(function _callee30$(_context33) {
5036
+ while (1) switch (_context33.prev = _context33.next) {
5042
5037
  case 0:
5043
- return _context35.abrupt("return", this.runSubmitTempOrder(params));
5038
+ return _context33.abrupt("return", this.runSubmitTempOrder(params));
5044
5039
  case 1:
5045
5040
  case "end":
5046
- return _context35.stop();
5041
+ return _context33.stop();
5047
5042
  }
5048
- }, _callee32, this);
5043
+ }, _callee30, this);
5049
5044
  }));
5050
- function submitTempOrder(_x42) {
5045
+ function submitTempOrder(_x37) {
5051
5046
  return _submitTempOrder.apply(this, arguments);
5052
5047
  }
5053
5048
  return submitTempOrder;
@@ -5055,20 +5050,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5055
5050
  }, {
5056
5051
  key: "submitTempOrderAsync",
5057
5052
  value: function () {
5058
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
5059
- return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5060
- while (1) switch (_context36.prev = _context36.next) {
5053
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
5054
+ return _regeneratorRuntime().wrap(function _callee31$(_context34) {
5055
+ while (1) switch (_context34.prev = _context34.next) {
5061
5056
  case 0:
5062
- return _context36.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
5057
+ return _context34.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
5063
5058
  syncMode: true
5064
5059
  })));
5065
5060
  case 1:
5066
5061
  case "end":
5067
- return _context36.stop();
5062
+ return _context34.stop();
5068
5063
  }
5069
- }, _callee33, this);
5064
+ }, _callee31, this);
5070
5065
  }));
5071
- function submitTempOrderAsync(_x43) {
5066
+ function submitTempOrderAsync(_x38) {
5072
5067
  return _submitTempOrderAsync.apply(this, arguments);
5073
5068
  }
5074
5069
  return submitTempOrderAsync;
@@ -5076,11 +5071,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5076
5071
  }, {
5077
5072
  key: "runSubmitTempOrder",
5078
5073
  value: function () {
5079
- var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5080
- var _params$cacheId3, _this$otherParams10, _ref74, _ref75, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
5074
+ var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
5075
+ var _params$cacheId3, _this$otherParams10, _ref73, _ref74, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
5081
5076
  var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
5082
- return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5083
- while (1) switch (_context37.prev = _context37.next) {
5077
+ return _regeneratorRuntime().wrap(function _callee32$(_context35) {
5078
+ while (1) switch (_context35.prev = _context35.next) {
5084
5079
  case 0:
5085
5080
  tempOrder = this.ensureTempOrder();
5086
5081
  shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
@@ -5100,26 +5095,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5100
5095
  }
5101
5096
  }
5102
5097
  this.persistTempOrder();
5103
- _context37.next = 8;
5098
+ _context35.next = 8;
5104
5099
  return this.recalculateSummary({
5105
5100
  createIfMissing: true
5106
5101
  });
5107
5102
  case 8:
5108
- _context37.t1 = _context37.sent;
5109
- if (_context37.t1) {
5110
- _context37.next = 11;
5103
+ _context35.t1 = _context35.sent;
5104
+ if (_context35.t1) {
5105
+ _context35.next = 11;
5111
5106
  break;
5112
5107
  }
5113
- _context37.t1 = this.store.summary;
5108
+ _context35.t1 = this.store.summary;
5114
5109
  case 11:
5115
- _context37.t0 = _context37.t1;
5116
- if (_context37.t0) {
5117
- _context37.next = 14;
5110
+ _context35.t0 = _context35.t1;
5111
+ if (_context35.t0) {
5112
+ _context35.next = 14;
5118
5113
  break;
5119
5114
  }
5120
- _context37.t0 = createEmptySummary();
5115
+ _context35.t0 = createEmptySummary();
5121
5116
  case 14:
5122
- latestSummary = _context37.t0;
5117
+ latestSummary = _context35.t0;
5123
5118
  effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
5124
5119
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
5125
5120
  hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
@@ -5139,7 +5134,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5139
5134
  tempOrder: tempOrder,
5140
5135
  cacheId: effectiveCacheId,
5141
5136
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform),
5142
- businessCode: (_ref74 = (_ref75 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
5137
+ businessCode: (_ref73 = (_ref74 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref73 !== void 0 ? _ref73 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
5143
5138
  channel: params === null || params === void 0 ? void 0 : params.channel,
5144
5139
  type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
5145
5140
  summary: latestSummary,
@@ -5154,10 +5149,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5154
5149
  if (!payload.created_at) {
5155
5150
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
5156
5151
  }
5157
- _context37.next = 26;
5152
+ _context35.next = 26;
5158
5153
  return this.saveDraft();
5159
5154
  case 26:
5160
- _context37.prev = 26;
5155
+ _context35.prev = 26;
5161
5156
  this.logInfo('submitTempOrder calling sales checkout', {
5162
5157
  orderId: payload.order_id,
5163
5158
  externalSaleNumber: payload.external_sale_number,
@@ -5167,43 +5162,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5167
5162
  smallTicketDataFlag: payload.small_ticket_data_flag,
5168
5163
  syncMode: payload.sync_mode
5169
5164
  });
5170
- _context37.next = 30;
5165
+ _context35.next = 30;
5171
5166
  return this.submitSalesOrder({
5172
5167
  query: payload
5173
5168
  });
5174
5169
  case 30:
5175
- result = _context37.sent;
5176
- _context37.next = 43;
5170
+ result = _context35.sent;
5171
+ _context35.next = 43;
5177
5172
  break;
5178
5173
  case 33:
5179
- _context37.prev = 33;
5180
- _context37.t2 = _context37["catch"](26);
5181
- backendErrorResponse = this.extractSubmitErrorResponse(_context37.t2);
5174
+ _context35.prev = 33;
5175
+ _context35.t2 = _context35["catch"](26);
5176
+ backendErrorResponse = this.extractSubmitErrorResponse(_context35.t2);
5182
5177
  if (!backendErrorResponse) {
5183
- _context37.next = 40;
5178
+ _context35.next = 40;
5184
5179
  break;
5185
5180
  }
5186
5181
  this.store.syncState = 'failed';
5187
5182
  this.logSubmitBackendRejected(backendErrorResponse, payload);
5188
- return _context37.abrupt("return", backendErrorResponse);
5183
+ return _context35.abrupt("return", backendErrorResponse);
5189
5184
  case 40:
5190
5185
  this.store.syncState = 'failed';
5191
5186
  this.logError('submitTempOrder failed', {
5192
- error: _context37.t2 instanceof Error ? _context37.t2.message : String(_context37.t2),
5187
+ error: _context35.t2 instanceof Error ? _context35.t2.message : String(_context35.t2),
5193
5188
  orderId: payload.order_id,
5194
5189
  externalSaleNumber: payload.external_sale_number,
5195
5190
  paymentStatus: payload.payment_status,
5196
5191
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
5197
5192
  });
5198
- throw _context37.t2;
5193
+ throw _context35.t2;
5199
5194
  case 43:
5200
5195
  if (!this.isSubmitResponseRejected(result)) {
5201
- _context37.next = 47;
5196
+ _context35.next = 47;
5202
5197
  break;
5203
5198
  }
5204
5199
  this.store.syncState = 'failed';
5205
5200
  this.logSubmitBackendRejected(result, payload);
5206
- return _context37.abrupt("return", result);
5201
+ return _context35.abrupt("return", result);
5207
5202
  case 47:
5208
5203
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
5209
5204
  this.logInfo('runSubmitTempOrder: 提交成功', {
@@ -5214,15 +5209,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5214
5209
  })
5215
5210
  });
5216
5211
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
5217
- _context37.next = 56;
5212
+ _context35.next = 56;
5218
5213
  break;
5219
5214
  }
5220
5215
  tempOrder.order_id = submittedOrderId;
5221
5216
  resultRecord = result;
5222
- _context37.next = 54;
5217
+ _context35.next = 54;
5223
5218
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
5224
5219
  case 54:
5225
- _context37.next = 57;
5220
+ _context35.next = 57;
5226
5221
  break;
5227
5222
  case 56:
5228
5223
  if (this.isLocalPendingSubmitResult(result)) {
@@ -5231,14 +5226,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5231
5226
  this.store.syncState = 'submitted';
5232
5227
  }
5233
5228
  case 57:
5234
- return _context37.abrupt("return", result);
5229
+ return _context35.abrupt("return", result);
5235
5230
  case 58:
5236
5231
  case "end":
5237
- return _context37.stop();
5232
+ return _context35.stop();
5238
5233
  }
5239
- }, _callee34, this, [[26, 33]]);
5234
+ }, _callee32, this, [[26, 33]]);
5240
5235
  }));
5241
- function runSubmitTempOrder(_x44) {
5236
+ function runSubmitTempOrder(_x39) {
5242
5237
  return _runSubmitTempOrder.apply(this, arguments);
5243
5238
  }
5244
5239
  return runSubmitTempOrder;
@@ -5246,10 +5241,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5246
5241
  }, {
5247
5242
  key: "markLocalOrderSynced",
5248
5243
  value: function () {
5249
- var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(orderId, remoteOrder) {
5244
+ var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(orderId, remoteOrder) {
5250
5245
  var tempOrder;
5251
- return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5252
- while (1) switch (_context38.prev = _context38.next) {
5246
+ return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5247
+ while (1) switch (_context36.prev = _context36.next) {
5253
5248
  case 0:
5254
5249
  tempOrder = this.ensureTempOrder();
5255
5250
  tempOrder.order_id = orderId;
@@ -5257,15 +5252,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5257
5252
  this.store.lastOrderInfo = remoteOrder;
5258
5253
  this.store.syncState = 'submitted';
5259
5254
  this.persistTempOrder();
5260
- _context38.next = 8;
5255
+ _context36.next = 8;
5261
5256
  return this.saveDraft();
5262
5257
  case 8:
5263
5258
  case "end":
5264
- return _context38.stop();
5259
+ return _context36.stop();
5265
5260
  }
5266
- }, _callee35, this);
5261
+ }, _callee33, this);
5267
5262
  }));
5268
- function markLocalOrderSynced(_x45, _x46) {
5263
+ function markLocalOrderSynced(_x40, _x41) {
5269
5264
  return _markLocalOrderSynced.apply(this, arguments);
5270
5265
  }
5271
5266
  return markLocalOrderSynced;
@@ -5308,10 +5303,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5308
5303
  value: function extractSubmitErrorResponse(error) {
5309
5304
  var _error$response,
5310
5305
  _error$response2,
5311
- _this30 = this;
5306
+ _this31 = this;
5312
5307
  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];
5313
5308
  return candidates.find(function (candidate) {
5314
- return _this30.isSubmitErrorResponse(candidate);
5309
+ return _this31.isSubmitErrorResponse(candidate);
5315
5310
  }) || null;
5316
5311
  }
5317
5312
  }, {
@@ -5338,33 +5333,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5338
5333
  }, {
5339
5334
  key: "syncPaymentsToOrder",
5340
5335
  value: function () {
5341
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5342
- var _this31 = this,
5336
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5337
+ var _this32 = this,
5343
5338
  _params$confirmPendin;
5344
5339
  var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitParams, submitResult;
5345
- return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5346
- while (1) switch (_context39.prev = _context39.next) {
5340
+ return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5341
+ while (1) switch (_context37.prev = _context37.next) {
5347
5342
  case 0:
5348
5343
  tempOrder = this.ensureTempOrder();
5349
5344
  needsPaymentNumber = (params.payments || []).some(function (payment) {
5350
5345
  return String(payment.payment_number || '').trim() === '';
5351
5346
  });
5352
5347
  if (!needsPaymentNumber) {
5353
- _context39.next = 8;
5348
+ _context37.next = 8;
5354
5349
  break;
5355
5350
  }
5356
- _context39.next = 5;
5351
+ _context37.next = 5;
5357
5352
  return this.getPaymentNumberDevicePrefixAsync();
5358
5353
  case 5:
5359
- _context39.t0 = _context39.sent;
5360
- _context39.next = 9;
5354
+ _context37.t0 = _context37.sent;
5355
+ _context37.next = 9;
5361
5356
  break;
5362
5357
  case 8:
5363
- _context39.t0 = 'LOCAL';
5358
+ _context37.t0 = 'LOCAL';
5364
5359
  case 9:
5365
- devicePrefix = _context39.t0;
5360
+ devicePrefix = _context37.t0;
5366
5361
  mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
5367
- return _this31.normalizePaymentSource(payment, {
5362
+ return _this32.normalizePaymentSource(payment, {
5368
5363
  defaultPaid: false,
5369
5364
  devicePrefix: devicePrefix
5370
5365
  });
@@ -5377,20 +5372,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5377
5372
  tempOrder.payments = effectivePayments;
5378
5373
  tempOrder.payment_status = paymentStatus;
5379
5374
  this.persistTempOrder();
5380
- _context39.next = 21;
5375
+ _context37.next = 21;
5381
5376
  return this.saveDraft();
5382
5377
  case 21:
5383
5378
  if (params.submitWhenPaid) {
5384
- _context39.next = 23;
5379
+ _context37.next = 23;
5385
5380
  break;
5386
5381
  }
5387
- return _context39.abrupt("return", completion);
5382
+ return _context37.abrupt("return", completion);
5388
5383
  case 23:
5389
5384
  if (!(this.store.syncState === 'submitting')) {
5390
- _context39.next = 25;
5385
+ _context37.next = 25;
5391
5386
  break;
5392
5387
  }
5393
- return _context39.abrupt("return", completion);
5388
+ return _context37.abrupt("return", completion);
5394
5389
  case 25:
5395
5390
  this.store.syncState = 'submitting';
5396
5391
  paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
@@ -5409,32 +5404,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5409
5404
  }
5410
5405
  };
5411
5406
  if (!(params.checkoutSyncTaskEnabled === false)) {
5412
- _context39.next = 34;
5407
+ _context37.next = 34;
5413
5408
  break;
5414
5409
  }
5415
- _context39.next = 31;
5410
+ _context37.next = 31;
5416
5411
  return this.submitTempOrderAsync(submitParams);
5417
5412
  case 31:
5418
- _context39.t1 = _context39.sent;
5419
- _context39.next = 37;
5413
+ _context37.t1 = _context37.sent;
5414
+ _context37.next = 37;
5420
5415
  break;
5421
5416
  case 34:
5422
- _context39.next = 36;
5417
+ _context37.next = 36;
5423
5418
  return this.submitTempOrder(submitParams);
5424
5419
  case 36:
5425
- _context39.t1 = _context39.sent;
5420
+ _context37.t1 = _context37.sent;
5426
5421
  case 37:
5427
- submitResult = _context39.t1;
5428
- return _context39.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
5422
+ submitResult = _context37.t1;
5423
+ return _context37.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
5429
5424
  submitResult: submitResult
5430
5425
  }));
5431
5426
  case 39:
5432
5427
  case "end":
5433
- return _context39.stop();
5428
+ return _context37.stop();
5434
5429
  }
5435
- }, _callee36, this);
5430
+ }, _callee34, this);
5436
5431
  }));
5437
- function syncPaymentsToOrder(_x47) {
5432
+ function syncPaymentsToOrder(_x42) {
5438
5433
  return _syncPaymentsToOrder.apply(this, arguments);
5439
5434
  }
5440
5435
  return syncPaymentsToOrder;
@@ -5442,7 +5437,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5442
5437
  }, {
5443
5438
  key: "createOrder",
5444
5439
  value: function createOrder(params) {
5445
- var _this32 = this;
5440
+ var _this33 = this;
5446
5441
  var order = _objectSpread({
5447
5442
  type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
5448
5443
  // 要从外面拿,virtual
@@ -5474,7 +5469,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5474
5469
 
5475
5470
  // 为预约补齐 holder 信息
5476
5471
  if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
5477
- ensureCartItemOriginHolder(item, _this32.window);
5472
+ ensureCartItemOriginHolder(item, _this33.window);
5478
5473
  }
5479
5474
 
5480
5475
  // 购物车是否为普通商品
@@ -5531,11 +5526,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5531
5526
  }, {
5532
5527
  key: "submitOrder",
5533
5528
  value: function () {
5534
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(order) {
5529
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(order) {
5535
5530
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
5536
5531
  var url, query, fetchUrl, params;
5537
- return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5538
- while (1) switch (_context40.prev = _context40.next) {
5532
+ return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5533
+ while (1) switch (_context38.prev = _context38.next) {
5539
5534
  case 0:
5540
5535
  this.logInfo('submitOrder called', {
5541
5536
  url: order.url,
@@ -5555,14 +5550,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5555
5550
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
5556
5551
  scheduleDate: params.schedule_date
5557
5552
  });
5558
- return _context40.abrupt("return", this.request.post(fetchUrl, params));
5553
+ return _context38.abrupt("return", this.request.post(fetchUrl, params));
5559
5554
  case 6:
5560
5555
  case "end":
5561
- return _context40.stop();
5556
+ return _context38.stop();
5562
5557
  }
5563
- }, _callee37, this);
5558
+ }, _callee35, this);
5564
5559
  }));
5565
- function submitOrder(_x48) {
5560
+ function submitOrder(_x43) {
5566
5561
  return _submitOrder.apply(this, arguments);
5567
5562
  }
5568
5563
  return submitOrder;
@@ -5570,13 +5565,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5570
5565
  }, {
5571
5566
  key: "cancelOrder",
5572
5567
  value: function () {
5573
- var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5568
+ var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5574
5569
  var payload;
5575
- return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5576
- while (1) switch (_context41.prev = _context41.next) {
5570
+ return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5571
+ while (1) switch (_context39.prev = _context39.next) {
5577
5572
  case 0:
5578
5573
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
5579
- _context41.next = 2;
5574
+ _context39.next = 2;
5580
5575
  break;
5581
5576
  }
5582
5577
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -5592,16 +5587,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5592
5587
  method: 'PUT',
5593
5588
  orderIdsCount: params.order_ids.length
5594
5589
  });
5595
- return _context41.abrupt("return", this.request.put('/order/update-status', payload, {
5590
+ return _context39.abrupt("return", this.request.put('/order/update-status', payload, {
5596
5591
  isShopApi: true
5597
5592
  }));
5598
5593
  case 5:
5599
5594
  case "end":
5600
- return _context41.stop();
5595
+ return _context39.stop();
5601
5596
  }
5602
- }, _callee38, this);
5597
+ }, _callee36, this);
5603
5598
  }));
5604
- function cancelOrder(_x49) {
5599
+ function cancelOrder(_x44) {
5605
5600
  return _cancelOrder.apply(this, arguments);
5606
5601
  }
5607
5602
  return cancelOrder;
@@ -5609,19 +5604,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5609
5604
  }, {
5610
5605
  key: "changeBookingStatus",
5611
5606
  value: function () {
5612
- var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
5607
+ var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
5613
5608
  var url, payload;
5614
- return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5615
- while (1) switch (_context42.prev = _context42.next) {
5609
+ return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5610
+ while (1) switch (_context40.prev = _context40.next) {
5616
5611
  case 0:
5617
5612
  if (params.booking_id) {
5618
- _context42.next = 2;
5613
+ _context40.next = 2;
5619
5614
  break;
5620
5615
  }
5621
5616
  throw new Error('变更预约状态失败:booking_id 不能为空');
5622
5617
  case 2:
5623
5618
  if (params.appointment_status) {
5624
- _context42.next = 4;
5619
+ _context40.next = 4;
5625
5620
  break;
5626
5621
  }
5627
5622
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -5636,16 +5631,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5636
5631
  bookingId: params.booking_id,
5637
5632
  appointmentStatus: params.appointment_status
5638
5633
  });
5639
- return _context42.abrupt("return", this.request.put(url, payload, {
5634
+ return _context40.abrupt("return", this.request.put(url, payload, {
5640
5635
  isShopApi: true
5641
5636
  }));
5642
5637
  case 8:
5643
5638
  case "end":
5644
- return _context42.stop();
5639
+ return _context40.stop();
5645
5640
  }
5646
- }, _callee39, this);
5641
+ }, _callee37, this);
5647
5642
  }));
5648
- function changeBookingStatus(_x50) {
5643
+ function changeBookingStatus(_x45) {
5649
5644
  return _changeBookingStatus.apply(this, arguments);
5650
5645
  }
5651
5646
  return changeBookingStatus;
@@ -5663,11 +5658,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5663
5658
  }, {
5664
5659
  key: "createOrderByCheckout",
5665
5660
  value: (function () {
5666
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
5661
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5667
5662
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
5668
5663
  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;
5669
- return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5670
- while (1) switch (_context43.prev = _context43.next) {
5664
+ return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5665
+ while (1) switch (_context41.prev = _context41.next) {
5671
5666
  case 0:
5672
5667
  // 过滤掉由在线店铺下单的 payment 支付数据
5673
5668
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -5701,7 +5696,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5701
5696
  relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
5702
5697
  paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
5703
5698
  });
5704
- _context43.prev = 4;
5699
+ _context41.prev = 4;
5705
5700
  // 构建订单数据,设置默认值并允许 params 覆盖
5706
5701
  orderData = _objectSpread({
5707
5702
  sales_channel: 'my_pisel',
@@ -5763,13 +5758,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5763
5758
  hasOrderId: !!orderData.order_id,
5764
5759
  smallTicketDataFlag: orderData.small_ticket_data_flag
5765
5760
  });
5766
- _context43.next = 12;
5761
+ _context41.next = 12;
5767
5762
  return this.request.post('/order/checkout', orderData, {
5768
5763
  osServer: true,
5769
5764
  customToast: function customToast() {}
5770
5765
  });
5771
5766
  case 12:
5772
- response = _context43.sent;
5767
+ response = _context41.sent;
5773
5768
  this.logInfo('Order API called successfully', {
5774
5769
  response: response
5775
5770
  });
@@ -5777,22 +5772,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5777
5772
  success: !!response,
5778
5773
  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)
5779
5774
  });
5780
- return _context43.abrupt("return", response);
5775
+ return _context41.abrupt("return", response);
5781
5776
  case 18:
5782
- _context43.prev = 18;
5783
- _context43.t0 = _context43["catch"](4);
5784
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context43.t0);
5777
+ _context41.prev = 18;
5778
+ _context41.t0 = _context41["catch"](4);
5779
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context41.t0);
5785
5780
  this.logInfo('Order API called failed', {
5786
- error: _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0)
5781
+ error: _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0)
5787
5782
  });
5788
- throw _context43.t0;
5783
+ throw _context41.t0;
5789
5784
  case 23:
5790
5785
  case "end":
5791
- return _context43.stop();
5786
+ return _context41.stop();
5792
5787
  }
5793
- }, _callee40, this, [[4, 18]]);
5788
+ }, _callee38, this, [[4, 18]]);
5794
5789
  }));
5795
- function createOrderByCheckout(_x51) {
5790
+ function createOrderByCheckout(_x46) {
5796
5791
  return _createOrderByCheckout.apply(this, arguments);
5797
5792
  }
5798
5793
  return createOrderByCheckout;
@@ -5800,24 +5795,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5800
5795
  }, {
5801
5796
  key: "submitSalesOrder",
5802
5797
  value: function () {
5803
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
5798
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
5804
5799
  var url, query, fetchUrl;
5805
- return _regeneratorRuntime().wrap(function _callee41$(_context44) {
5806
- while (1) switch (_context44.prev = _context44.next) {
5800
+ return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5801
+ while (1) switch (_context42.prev = _context42.next) {
5807
5802
  case 0:
5808
5803
  url = params.url, query = params.query;
5809
5804
  fetchUrl = url || '/order/sales/checkout';
5810
- return _context44.abrupt("return", this.request.post(fetchUrl, query, {
5805
+ return _context42.abrupt("return", this.request.post(fetchUrl, query, {
5811
5806
  osServer: true,
5812
5807
  customToast: function customToast() {}
5813
5808
  }));
5814
5809
  case 3:
5815
5810
  case "end":
5816
- return _context44.stop();
5811
+ return _context42.stop();
5817
5812
  }
5818
- }, _callee41, this);
5813
+ }, _callee39, this);
5819
5814
  }));
5820
- function submitSalesOrder(_x52) {
5815
+ function submitSalesOrder(_x47) {
5821
5816
  return _submitSalesOrder.apply(this, arguments);
5822
5817
  }
5823
5818
  return submitSalesOrder;
@@ -5831,37 +5826,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5831
5826
  }, {
5832
5827
  key: "sendCustomerPayLink",
5833
5828
  value: (function () {
5834
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
5829
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
5835
5830
  var _params$emails;
5836
5831
  var orderIds;
5837
- return _regeneratorRuntime().wrap(function _callee42$(_context45) {
5838
- while (1) switch (_context45.prev = _context45.next) {
5832
+ return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5833
+ while (1) switch (_context43.prev = _context43.next) {
5839
5834
  case 0:
5840
5835
  orderIds = params.order_ids || params.orderIds || [];
5841
5836
  if (orderIds.length) {
5842
- _context45.next = 3;
5837
+ _context43.next = 3;
5843
5838
  break;
5844
5839
  }
5845
5840
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
5846
5841
  case 3:
5847
5842
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
5848
- _context45.next = 5;
5843
+ _context43.next = 5;
5849
5844
  break;
5850
5845
  }
5851
5846
  throw new Error('发送支付链接需要至少一个邮箱');
5852
5847
  case 5:
5853
- return _context45.abrupt("return", this.request.post('/order/batch-email', {
5848
+ return _context43.abrupt("return", this.request.post('/order/batch-email', {
5854
5849
  order_ids: orderIds,
5855
5850
  notify_action: params.notify_action || 'order_payment_reminder',
5856
5851
  emails: params.emails
5857
5852
  }));
5858
5853
  case 6:
5859
5854
  case "end":
5860
- return _context45.stop();
5855
+ return _context43.stop();
5861
5856
  }
5862
- }, _callee42, this);
5857
+ }, _callee40, this);
5863
5858
  }));
5864
- function sendCustomerPayLink(_x53) {
5859
+ function sendCustomerPayLink(_x48) {
5865
5860
  return _sendCustomerPayLink.apply(this, arguments);
5866
5861
  }
5867
5862
  return sendCustomerPayLink;
@@ -5869,14 +5864,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5869
5864
  }, {
5870
5865
  key: "getSalesOrderByLookup",
5871
5866
  value: function () {
5872
- var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
5867
+ var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
5873
5868
  var lookup, res;
5874
- return _regeneratorRuntime().wrap(function _callee43$(_context46) {
5875
- while (1) switch (_context46.prev = _context46.next) {
5869
+ return _regeneratorRuntime().wrap(function _callee41$(_context44) {
5870
+ while (1) switch (_context44.prev = _context44.next) {
5876
5871
  case 0:
5877
5872
  lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
5878
5873
  if (lookup) {
5879
- _context46.next = 3;
5874
+ _context44.next = 3;
5880
5875
  break;
5881
5876
  }
5882
5877
  throw new Error('加载销售详情需要 lookup');
@@ -5885,7 +5880,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5885
5880
  if (lookup.startsWith('LOCAL_')) {
5886
5881
  params.forceRemote = false;
5887
5882
  }
5888
- _context46.next = 6;
5883
+ _context44.next = 6;
5889
5884
  return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
5890
5885
  with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'refunds']
5891
5886
  }, params.forceRemote ? {
@@ -5894,18 +5889,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5894
5889
  osServer: true
5895
5890
  });
5896
5891
  case 6:
5897
- res = _context46.sent;
5892
+ res = _context44.sent;
5898
5893
  if (res.code === 200) {
5899
5894
  this.store.lastOrderInfo = res.data;
5900
5895
  }
5901
- return _context46.abrupt("return", res);
5896
+ return _context44.abrupt("return", res);
5902
5897
  case 9:
5903
5898
  case "end":
5904
- return _context46.stop();
5899
+ return _context44.stop();
5905
5900
  }
5906
- }, _callee43, this);
5901
+ }, _callee41, this);
5907
5902
  }));
5908
- function getSalesOrderByLookup(_x54) {
5903
+ function getSalesOrderByLookup(_x49) {
5909
5904
  return _getSalesOrderByLookup.apply(this, arguments);
5910
5905
  }
5911
5906
  return getSalesOrderByLookup;
@@ -5919,11 +5914,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5919
5914
  }, {
5920
5915
  key: "hydrateTempOrderFromRecord",
5921
5916
  value: (function () {
5922
- var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(record, options) {
5917
+ var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(record, options) {
5923
5918
  var _this$store$discount20;
5924
5919
  var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount21, _this$store$discount22;
5925
- return _regeneratorRuntime().wrap(function _callee44$(_context47) {
5926
- while (1) switch (_context47.prev = _context47.next) {
5920
+ return _regeneratorRuntime().wrap(function _callee42$(_context45) {
5921
+ while (1) switch (_context45.prev = _context45.next) {
5927
5922
  case 0:
5928
5923
  sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
5929
5924
  identityReadySource = this.seedAnonymousBookingUidsFromProducts(sourceRaw);
@@ -5993,34 +5988,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5993
5988
  nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
5994
5989
  shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
5995
5990
  if (shouldSkipEmptyDiscountSync) {
5996
- _context47.next = 31;
5991
+ _context45.next = 31;
5997
5992
  break;
5998
5993
  }
5999
5994
  OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
6000
- _context47.next = 29;
5995
+ _context45.next = 29;
6001
5996
  return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setOriginalDiscountList(nextDiscounts);
6002
5997
  case 29:
6003
- _context47.next = 31;
5998
+ _context45.next = 31;
6004
5999
  return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList(nextDiscounts);
6005
6000
  case 31:
6006
6001
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
6007
- _context47.next = 34;
6002
+ _context45.next = 34;
6008
6003
  break;
6009
6004
  }
6010
- _context47.next = 34;
6005
+ _context45.next = 34;
6011
6006
  return this.recalculateSummary({
6012
6007
  createIfMissing: false
6013
6008
  });
6014
6009
  case 34:
6015
6010
  this.persistTempOrder();
6016
- return _context47.abrupt("return", nextTempOrder);
6011
+ return _context45.abrupt("return", nextTempOrder);
6017
6012
  case 36:
6018
6013
  case "end":
6019
- return _context47.stop();
6014
+ return _context45.stop();
6020
6015
  }
6021
- }, _callee44, this);
6016
+ }, _callee42, this);
6022
6017
  }));
6023
- function hydrateTempOrderFromRecord(_x55, _x56) {
6018
+ function hydrateTempOrderFromRecord(_x50, _x51) {
6024
6019
  return _hydrateTempOrderFromRecord.apply(this, arguments);
6025
6020
  }
6026
6021
  return hydrateTempOrderFromRecord;
@@ -6134,7 +6129,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6134
6129
  }, {
6135
6130
  key: "normalizeTempOrderForRuntime",
6136
6131
  value: function normalizeTempOrderForRuntime(raw, options) {
6137
- var _this33 = this;
6132
+ var _this34 = this;
6138
6133
  var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
6139
6134
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
6140
6135
  // ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
@@ -6158,12 +6153,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6158
6153
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
6159
6154
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
6160
6155
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
6161
- return _this33.normalizeHydratedOrderProduct(p, {
6156
+ return _this34.normalizeHydratedOrderProduct(p, {
6162
6157
  makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
6163
6158
  });
6164
6159
  }) : [];
6165
6160
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
6166
- var booking = _this33.normalizeHydratedBookingHolder(b || {});
6161
+ var booking = _this34.normalizeHydratedBookingHolder(b || {});
6167
6162
  return _objectSpread(_objectSpread({}, booking), {}, {
6168
6163
  is_all: normalizeBookingIsAll(booking),
6169
6164
  sub_type: normalizeBookingSubType(booking)
@@ -6193,7 +6188,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6193
6188
  _step24;
6194
6189
  try {
6195
6190
  for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
6196
- var _product$metadata11, _ref76, _ref77, _existed$origin, _rawProduct$metadata;
6191
+ var _product$metadata11, _ref75, _ref76, _existed$origin, _rawProduct$metadata;
6197
6192
  var _step24$value = _slicedToArray(_step24.value, 2),
6198
6193
  index = _step24$value[0],
6199
6194
  product = _step24$value[1];
@@ -6201,7 +6196,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6201
6196
  if (!uid) continue;
6202
6197
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
6203
6198
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
6204
- var origin = (_ref76 = (_ref77 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref77 !== void 0 ? _ref77 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref76 !== void 0 ? _ref76 : rawProduct;
6199
+ var origin = (_ref75 = (_ref76 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref76 !== void 0 ? _ref76 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref75 !== void 0 ? _ref75 : rawProduct;
6205
6200
  var originSnapshot = cloneDeep(origin);
6206
6201
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
6207
6202
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -6330,10 +6325,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6330
6325
  }, {
6331
6326
  key: "normalizeHydratedProductOptionItem",
6332
6327
  value: function normalizeHydratedProductOptionItem(optionItem) {
6333
- var _ref78, _optionItem$num, _ref79, _optionItem$add_price;
6334
- var rawNum = (_ref78 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref78 !== void 0 ? _ref78 : 1;
6328
+ var _ref77, _optionItem$num, _ref78, _optionItem$add_price;
6329
+ var rawNum = (_ref77 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref77 !== void 0 ? _ref77 : 1;
6335
6330
  var parsedNum = Number(rawNum);
6336
- var rawPrice = (_ref79 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref79 !== void 0 ? _ref79 : 0;
6331
+ var rawPrice = (_ref78 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref78 !== void 0 ? _ref78 : 0;
6337
6332
  var parsedPrice = Number(rawPrice);
6338
6333
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
6339
6334
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -6350,7 +6345,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6350
6345
  }, {
6351
6346
  key: "normalizeHydratedOrderProduct",
6352
6347
  value: function normalizeHydratedOrderProduct(product, options) {
6353
- var _this34 = this;
6348
+ var _this35 = this;
6354
6349
  var row = _objectSpread({}, product || {});
6355
6350
  if (row.num === undefined && row.product_quantity !== undefined) {
6356
6351
  row.num = row.product_quantity;
@@ -6358,7 +6353,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6358
6353
  var productSku = ensureProductSku(row);
6359
6354
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
6360
6355
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
6361
- return _this34.normalizeHydratedProductOptionItem(optionItem || {});
6356
+ return _this35.normalizeHydratedProductOptionItem(optionItem || {});
6362
6357
  }))
6363
6358
  });
6364
6359
  delete row["product_".concat('option', "_item")];
@@ -6395,27 +6390,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6395
6390
  }, {
6396
6391
  key: "getOrderInfo",
6397
6392
  value: function () {
6398
- var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(order_id) {
6393
+ var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(order_id) {
6399
6394
  var res;
6400
- return _regeneratorRuntime().wrap(function _callee45$(_context48) {
6401
- while (1) switch (_context48.prev = _context48.next) {
6395
+ return _regeneratorRuntime().wrap(function _callee43$(_context46) {
6396
+ while (1) switch (_context46.prev = _context46.next) {
6402
6397
  case 0:
6403
- _context48.next = 2;
6398
+ _context46.next = 2;
6404
6399
  return this.request.get("/order/sales/".concat(order_id), {
6405
6400
  with: ['products', 'bookings']
6406
6401
  }, {
6407
6402
  osServer: true
6408
6403
  });
6409
6404
  case 2:
6410
- res = _context48.sent;
6411
- return _context48.abrupt("return", res);
6405
+ res = _context46.sent;
6406
+ return _context46.abrupt("return", res);
6412
6407
  case 4:
6413
6408
  case "end":
6414
- return _context48.stop();
6409
+ return _context46.stop();
6415
6410
  }
6416
- }, _callee45, this);
6411
+ }, _callee43, this);
6417
6412
  }));
6418
- function getOrderInfo(_x57) {
6413
+ function getOrderInfo(_x52) {
6419
6414
  return _getOrderInfo.apply(this, arguments);
6420
6415
  }
6421
6416
  return getOrderInfo;
@@ -6474,10 +6469,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6474
6469
  _step29;
6475
6470
  try {
6476
6471
  for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
6477
- var _ref80, _bundle$num3;
6478
6472
  var bundle = _step29.value;
6479
6473
  var isPersistedBundleProduct = isPersistedProduct || Boolean((bundle === null || bundle === void 0 ? void 0 : bundle.order_detail_id) || (bundle === null || bundle === void 0 ? void 0 : bundle.orderDetailId) || (bundle === null || bundle === void 0 ? void 0 : bundle.booking_id));
6480
- var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref80 = (_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 && _ref80 !== void 0 ? _ref80 : 1) || 1).toNumber();
6474
+ var bundleQty = Number(qty) || 1;
6481
6475
  var _iterator30 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
6482
6476
  _step30;
6483
6477
  try {