@pisell/pisellos 2.2.249 → 2.2.250

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.
@@ -1224,9 +1224,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1224
1224
  }, {
1225
1225
  key: "calculatePaymentEffectiveAmount",
1226
1226
  value: function calculatePaymentEffectiveAmount(payment) {
1227
- var amount = new Decimal(payment.amount || 0).minus(new Decimal(payment.service_fee || 0));
1227
+ var _ref17, _payment$origin_amoun;
1228
+ var amount = new Decimal(payment.amount || 0);
1229
+ 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);
1230
+ var serviceFee = new Decimal(payment.service_fee || 0);
1231
+ // TODO: 后端允许 amount 表示顾客实际支付总额后,移除这个兼容分支。
1232
+ var effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
1228
1233
  var rounding = new Decimal(payment.rounding_amount || 0);
1229
- return amount.minus(rounding);
1234
+ return effectiveAmount.minus(rounding);
1230
1235
  }
1231
1236
  }, {
1232
1237
  key: "calculatePaymentTotal",
@@ -1312,7 +1317,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1312
1317
  }, {
1313
1318
  key: "normalizePaymentSource",
1314
1319
  value: function normalizePaymentSource(payment, options) {
1315
- var _ref17, _paymentRecord$origin;
1320
+ var _ref18, _paymentRecord$origin;
1316
1321
  var paymentRecord = payment;
1317
1322
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
1318
1323
  if (!metadata.unique_payment_number) {
@@ -1320,7 +1325,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1320
1325
  }
1321
1326
  var normalized = _objectSpread(_objectSpread({}, paymentRecord), {}, {
1322
1327
  metadata: metadata,
1323
- origin_amount: (_ref17 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref17 !== void 0 ? _ref17 : '0.00'
1328
+ origin_amount: (_ref18 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref18 !== void 0 ? _ref18 : '0.00'
1324
1329
  });
1325
1330
  if (paymentRecord.status !== undefined) {
1326
1331
  normalized.status = paymentRecord.status;
@@ -1654,7 +1659,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1654
1659
  _product$payment_pric,
1655
1660
  _sku$code,
1656
1661
  _sku$barcode,
1657
- _ref18,
1662
+ _ref19,
1658
1663
  _sku$variant_id,
1659
1664
  _this8 = this;
1660
1665
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
@@ -1681,24 +1686,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1681
1686
  product_sku: this.normalizeFingerprintValue({
1682
1687
  code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
1683
1688
  barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
1684
- variant_id: (_ref18 = (_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 && _ref18 !== void 0 ? _ref18 : 0,
1689
+ 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,
1685
1690
  variant: sku.variant || [],
1686
1691
  option: getProductSkuOptions(product || {}).map(function (option) {
1687
- var _ref19, _option$id, _option$option_group_, _ref20, _option$option_group_2, _option$num, _option$add_price;
1692
+ var _ref20, _option$id, _option$option_group_, _ref21, _option$option_group_2, _option$num, _option$add_price;
1688
1693
  return {
1689
- id: (_ref19 = (_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 && _ref19 !== void 0 ? _ref19 : null,
1694
+ 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,
1690
1695
  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,
1691
- option_group_item_id: (_ref20 = (_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 && _ref20 !== void 0 ? _ref20 : null,
1696
+ 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,
1692
1697
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
1693
1698
  add_price: _this8.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)
1694
1699
  };
1695
1700
  })
1696
1701
  }),
1697
1702
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
1698
- var _ref21, _ref22, _bundle$bundle_produc, _ref23, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
1703
+ var _ref22, _ref23, _bundle$bundle_produc, _ref24, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
1699
1704
  return {
1700
- bundle_product_id: (_ref21 = (_ref22 = (_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 && _ref22 !== void 0 ? _ref22 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref21 !== void 0 ? _ref21 : null,
1701
- bundle_variant_id: (_ref23 = (_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 && _ref23 !== void 0 ? _ref23 : 0,
1705
+ 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,
1706
+ 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,
1702
1707
  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),
1703
1708
  price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
1704
1709
  bundle_selling_price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
@@ -1707,10 +1712,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1707
1712
  };
1708
1713
  })),
1709
1714
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
1710
- var _ref24, _discount$type2, _ref25, _ref26, _discount$discount_id, _discount$discount;
1715
+ var _ref25, _discount$type2, _ref26, _ref27, _discount$discount_id, _discount$discount;
1711
1716
  return {
1712
- type: (_ref24 = (_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 && _ref24 !== void 0 ? _ref24 : '',
1713
- discount_id: (_ref25 = (_ref26 = (_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 && _ref26 !== void 0 ? _ref26 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref25 !== void 0 ? _ref25 : null,
1717
+ 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 : '',
1718
+ 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,
1714
1719
  amount: _this8.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1715
1720
  };
1716
1721
  }))
@@ -1734,14 +1739,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1734
1739
  var _product$product_id3,
1735
1740
  _product$product_vari2,
1736
1741
  _product$num2,
1737
- _ref27,
1742
+ _ref28,
1738
1743
  _metadata$unique_iden,
1739
1744
  _metadata$price_overr,
1740
1745
  _metadata$is_manual_d,
1741
1746
  _metadata$product_dis,
1742
1747
  _sku$code2,
1743
1748
  _sku$barcode2,
1744
- _ref28,
1749
+ _ref29,
1745
1750
  _sku$variant_id2,
1746
1751
  _this10 = this;
1747
1752
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
@@ -1757,7 +1762,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1757
1762
  extension_type: extensionType,
1758
1763
  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),
1759
1764
  metadata: {
1760
- unique_identification_number: (_ref27 = (_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 && _ref27 !== void 0 ? _ref27 : '',
1765
+ 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 : '',
1761
1766
  price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
1762
1767
  is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
1763
1768
  product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
@@ -1765,35 +1770,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1765
1770
  product_sku: this.normalizeFingerprintValue({
1766
1771
  code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
1767
1772
  barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
1768
- variant_id: (_ref28 = (_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 && _ref28 !== void 0 ? _ref28 : 0,
1773
+ 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,
1769
1774
  variant: sku.variant || [],
1770
1775
  option: getProductSkuOptions(product || {}).map(function (option) {
1771
- var _ref29, _option$id2, _option$option_group_3, _ref30, _option$option_group_4, _option$num2, _option$add_price2;
1776
+ var _ref30, _option$id2, _option$option_group_3, _ref31, _option$option_group_4, _option$num2, _option$add_price2;
1772
1777
  return {
1773
- id: (_ref29 = (_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 && _ref29 !== void 0 ? _ref29 : null,
1778
+ 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,
1774
1779
  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,
1775
- option_group_item_id: (_ref30 = (_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 && _ref30 !== void 0 ? _ref30 : null,
1780
+ 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,
1776
1781
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
1777
1782
  add_price: _this10.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)
1778
1783
  };
1779
1784
  })
1780
1785
  }),
1781
1786
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
1782
- var _ref31, _bundle$bundle_id, _ref32, _bundle$bundle_group_, _ref33, _ref34, _bundle$bundle_produc2, _ref35, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
1787
+ 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;
1783
1788
  return {
1784
- bundle_id: (_ref31 = (_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 && _ref31 !== void 0 ? _ref31 : null,
1785
- bundle_group_id: (_ref32 = (_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 && _ref32 !== void 0 ? _ref32 : null,
1786
- bundle_product_id: (_ref33 = (_ref34 = (_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 && _ref34 !== void 0 ? _ref34 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref33 !== void 0 ? _ref33 : null,
1787
- bundle_variant_id: (_ref35 = (_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 && _ref35 !== void 0 ? _ref35 : 0,
1789
+ 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,
1790
+ 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,
1791
+ 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,
1792
+ 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,
1788
1793
  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),
1789
1794
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
1790
1795
  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 : '',
1791
1796
  option: _this10.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
1792
- var _ref36, _option$id3, _option$option_group_5, _ref37, _option$option_group_6, _option$num3, _option$add_price3;
1797
+ var _ref37, _option$id3, _option$option_group_5, _ref38, _option$option_group_6, _option$num3, _option$add_price3;
1793
1798
  return {
1794
- id: (_ref36 = (_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 && _ref36 !== void 0 ? _ref36 : null,
1799
+ 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,
1795
1800
  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,
1796
- option_group_item_id: (_ref37 = (_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 && _ref37 !== void 0 ? _ref37 : null,
1801
+ 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,
1797
1802
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
1798
1803
  add_price: _this10.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)
1799
1804
  };
@@ -1801,10 +1806,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1801
1806
  };
1802
1807
  })),
1803
1808
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
1804
- var _ref38, _discount$type4, _ref39, _ref40, _discount$discount_id2, _discount$discount2;
1809
+ var _ref39, _discount$type4, _ref40, _ref41, _discount$discount_id2, _discount$discount2;
1805
1810
  return {
1806
- type: (_ref38 = (_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 && _ref38 !== void 0 ? _ref38 : '',
1807
- discount_id: (_ref39 = (_ref40 = (_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 && _ref40 !== void 0 ? _ref40 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref39 !== void 0 ? _ref39 : null,
1811
+ 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 : '',
1812
+ 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,
1808
1813
  amount: _this10.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1809
1814
  };
1810
1815
  }))
@@ -2084,11 +2089,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2084
2089
  }, {
2085
2090
  key: "getOrderIdentity",
2086
2091
  value: function getOrderIdentity() {
2087
- var _ref41, _ref42, _tempOrder$order_id, _tempOrder$_extend6;
2092
+ var _ref42, _ref43, _tempOrder$order_id, _tempOrder$_extend6;
2088
2093
  var tempOrder = this.store.tempOrder;
2089
2094
  if (!tempOrder) return null;
2090
2095
  var lastOrderInfo = this.store.lastOrderInfo || {};
2091
- var orderId = (_ref41 = (_ref42 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref42 !== void 0 ? _ref42 : lastOrderInfo.id) !== null && _ref41 !== void 0 ? _ref41 : null;
2096
+ 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;
2092
2097
  return {
2093
2098
  localId: this.cacheId || ((_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.localId),
2094
2099
  orderId: orderId,
@@ -2241,11 +2246,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2241
2246
  }, {
2242
2247
  key: "captureProductRuntime",
2243
2248
  value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
2244
- var _extend$productsByUid, _ref43, _rawProduct$_origin;
2249
+ var _extend$productsByUid, _ref44, _rawProduct$_origin;
2245
2250
  var uid = existedUid || this.getProductUid(normalizedProduct);
2246
2251
  var extend = this.ensureExtend(tempOrder);
2247
2252
  var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
2248
- var origin = (_ref43 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref43 !== void 0 ? _ref43 : existed.origin;
2253
+ var origin = (_ref44 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref44 !== void 0 ? _ref44 : existed.origin;
2249
2254
  extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
2250
2255
  origin: origin
2251
2256
  } : {});
@@ -2346,7 +2351,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2346
2351
  }, {
2347
2352
  key: "buildTempOrderHolderFromBookings",
2348
2353
  value: function buildTempOrderHolderFromBookings(tempOrder) {
2349
- var _baseHolder$customer_, _baseHolder, _ref44, _baseHolder$form_id, _baseHolder2, _tempOrder$holder5, _baseHolder3, _this$otherParams;
2354
+ var _baseHolder$customer_, _baseHolder, _ref45, _baseHolder$form_id, _baseHolder2, _tempOrder$holder5, _baseHolder3, _this$otherParams;
2350
2355
  var holderRecords = [];
2351
2356
  var holderNames = [];
2352
2357
  var baseHolder = null;
@@ -2393,7 +2398,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2393
2398
  }
2394
2399
  var nextHolder = {
2395
2400
  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,
2396
- form_id: (_ref44 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder5 = tempOrder.holder) === null || _tempOrder$holder5 === void 0 ? void 0 : _tempOrder$holder5.form_id) !== null && _ref44 !== void 0 ? _ref44 : 0,
2401
+ 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$holder5 = tempOrder.holder) === null || _tempOrder$holder5 === void 0 ? void 0 : _tempOrder$holder5.form_id) !== null && _ref45 !== void 0 ? _ref45 : 0,
2397
2402
  form_record: holderRecords
2398
2403
  };
2399
2404
  if (holderNames.length) {
@@ -2496,7 +2501,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2496
2501
  key: "recalculateSummary",
2497
2502
  value: function () {
2498
2503
  var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
2499
- var _ref45, _salesSummaryResult$e;
2504
+ var _ref46, _salesSummaryResult$e;
2500
2505
  var tempOrder, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
2501
2506
  return _regeneratorRuntime().wrap(function _callee11$(_context13) {
2502
2507
  while (1) switch (_context13.prev = _context13.next) {
@@ -2569,7 +2574,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2569
2574
  roundingAmount = paidPaymentSummary.roundingAmount;
2570
2575
  payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
2571
2576
  hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
2572
- expectAmount = hasSalesSummaryAmount ? new Decimal((_ref45 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref45 !== void 0 ? _ref45 : 0) : null;
2577
+ 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;
2573
2578
  amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
2574
2579
  rounding_amount: roundingAmount.toFixed(2)
2575
2580
  }, expectAmount ? {
@@ -2747,17 +2752,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2747
2752
  }, {
2748
2753
  key: "buildTempOrderCustomer",
2749
2754
  value: function buildTempOrderCustomer(params) {
2750
- var _ref46, _ref47, _ref48, _source$name, _ref49, _ref50, _ref51, _source$customer_name, _source$id, _source$customer_id, _ref52, _source$country_calli, _source$phone, _source$email;
2755
+ 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;
2751
2756
  if (!params.customerId) return null;
2752
2757
  var source = params.source ? cloneDeep(params.source) : {};
2753
- var name = (_ref46 = (_ref47 = (_ref48 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref48 !== void 0 ? _ref48 : source.customerName) !== null && _ref47 !== void 0 ? _ref47 : source.customer_name) !== null && _ref46 !== void 0 ? _ref46 : params.customerName;
2754
- var customerName = (_ref49 = (_ref50 = (_ref51 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref51 !== void 0 ? _ref51 : source.display_name) !== null && _ref50 !== void 0 ? _ref50 : source.name) !== null && _ref49 !== void 0 ? _ref49 : params.customerName;
2758
+ 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;
2759
+ 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;
2755
2760
  return _objectSpread(_objectSpread({}, source), {}, {
2756
2761
  id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
2757
2762
  customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
2758
2763
  name: String(name || ''),
2759
2764
  customer_name: String(customerName || ''),
2760
- country_calling_code: String((_ref52 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref52 !== void 0 ? _ref52 : params.countryCallingCode),
2765
+ 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),
2761
2766
  phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
2762
2767
  email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
2763
2768
  });
@@ -2856,14 +2861,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2856
2861
  }, {
2857
2862
  key: "updateTempOrderCustomer",
2858
2863
  value: function updateTempOrderCustomer(customer) {
2859
- var _tempOrder$customer_i2, _ref53, _ref54, _customer$customer_id, _ref55, _ref56, _ref57, _customer$customer_na, _ref58, _customer$country_cal, _tempOrder$customer_i3;
2864
+ var _tempOrder$customer_i2, _ref54, _ref55, _customer$customer_id, _ref56, _ref57, _ref58, _customer$customer_na, _ref59, _customer$country_cal, _tempOrder$customer_i3;
2860
2865
  var tempOrder = this.ensureTempOrder();
2861
2866
  var previousCustomerId = (_tempOrder$customer_i2 = tempOrder.customer_id) !== null && _tempOrder$customer_i2 !== void 0 ? _tempOrder$customer_i2 : null;
2862
- var customerId = (_ref53 = (_ref54 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref54 !== void 0 ? _ref54 : customer.id) !== null && _ref53 !== void 0 ? _ref53 : null;
2863
- var customerName = (_ref55 = (_ref56 = (_ref57 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref57 !== void 0 ? _ref57 : customer.display_name) !== null && _ref56 !== void 0 ? _ref56 : customer.name) !== null && _ref55 !== void 0 ? _ref55 : '';
2867
+ 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;
2868
+ 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 : '';
2864
2869
  tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
2865
2870
  tempOrder.customer_name = String(customerName || '');
2866
- tempOrder.country_calling_code = String((_ref58 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref58 !== void 0 ? _ref58 : '');
2871
+ 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 : '');
2867
2872
  tempOrder.phone = String(customer.phone || '');
2868
2873
  tempOrder.email = String(customer.email || '');
2869
2874
  tempOrder.customer = this.buildTempOrderCustomer({
@@ -3408,7 +3413,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3408
3413
  key: "addProductToOrder",
3409
3414
  value: (function () {
3410
3415
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(product, booking) {
3411
- var tempOrder, _ref59, _productRecord$num, productRecord, splitCount, i, singleLine;
3416
+ var tempOrder, _ref60, _productRecord$num, productRecord, splitCount, i, singleLine;
3412
3417
  return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3413
3418
  while (1) switch (_context19.prev = _context19.next) {
3414
3419
  case 0:
@@ -3418,7 +3423,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3418
3423
  break;
3419
3424
  }
3420
3425
  productRecord = product;
3421
- splitCount = getSafeProductNum((_ref59 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref59 !== void 0 ? _ref59 : 1);
3426
+ splitCount = getSafeProductNum((_ref60 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref60 !== void 0 ? _ref60 : 1);
3422
3427
  if (!(splitCount > 1)) {
3423
3428
  _context19.next = 18;
3424
3429
  break;
@@ -3476,7 +3481,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3476
3481
  key: "addProductsToOrder",
3477
3482
  value: (function () {
3478
3483
  var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(items, options) {
3479
- var tempOrder, _iterator20, _step20, item, product, booking, _ref60, _productRecord$num2, productRecord, splitCount, i, singleLine;
3484
+ var tempOrder, _iterator20, _step20, item, product, booking, _ref61, _productRecord$num2, productRecord, splitCount, i, singleLine;
3480
3485
  return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3481
3486
  while (1) switch (_context20.prev = _context20.next) {
3482
3487
  case 0:
@@ -3508,7 +3513,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3508
3513
  break;
3509
3514
  }
3510
3515
  productRecord = product;
3511
- splitCount = getSafeProductNum((_ref60 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref60 !== void 0 ? _ref60 : 1);
3516
+ splitCount = getSafeProductNum((_ref61 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
3512
3517
  if (!(splitCount > 1)) {
3513
3518
  _context20.next = 26;
3514
3519
  break;
@@ -3585,9 +3590,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3585
3590
  }, {
3586
3591
  key: "getBundleRuntimeIdentity",
3587
3592
  value: function getBundleRuntimeIdentity(bundle) {
3588
- var _ref61, _bundle$bundle_id2, _ref62, _bundle$bundle_group_2, _ref63, _ref64, _bundle$bundle_produc3, _ref65, _bundle$bundle_varian3;
3593
+ var _ref62, _bundle$bundle_id2, _ref63, _bundle$bundle_group_2, _ref64, _ref65, _bundle$bundle_produc3, _ref66, _bundle$bundle_varian3;
3589
3594
  if (!bundle || _typeof(bundle) !== 'object') return '';
3590
- return [(_ref61 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref61 !== void 0 ? _ref61 : '', (_ref62 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref62 !== void 0 ? _ref62 : '', (_ref63 = (_ref64 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref64 !== void 0 ? _ref64 : bundle.product_id) !== null && _ref63 !== void 0 ? _ref63 : '', (_ref65 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref65 !== void 0 ? _ref65 : 0].join('|');
3595
+ 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('|');
3591
3596
  }
3592
3597
  }, {
3593
3598
  key: "preservePersistedBundlePriceFields",
@@ -4104,23 +4109,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4104
4109
  }, {
4105
4110
  key: "buildCurrentSubmitPayloadForLocalPrint",
4106
4111
  value: function buildCurrentSubmitPayloadForLocalPrint(params) {
4107
- var _params$cacheId, _this$otherParams2, _ref66, _params$businessCode, _this$otherParams3, _this$otherParams4;
4112
+ var _params$cacheId, _this$otherParams2, _ref67, _params$businessCode, _this$otherParams3, _this$otherParams4;
4108
4113
  var tempOrder = this.ensureTempOrder();
4109
4114
  this.persistTempOrder();
4110
4115
  var payload = buildSubmitPayload({
4111
4116
  tempOrder: tempOrder,
4112
4117
  cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
4113
4118
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform),
4114
- businessCode: (_ref66 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.businessCode) !== null && _ref66 !== void 0 ? _ref66 : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.business_code,
4119
+ businessCode: (_ref67 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.businessCode) !== null && _ref67 !== void 0 ? _ref67 : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.business_code,
4115
4120
  channel: params === null || params === void 0 ? void 0 : params.channel,
4116
4121
  type: params === null || params === void 0 ? void 0 : params.type,
4117
4122
  summary: this.store.summary || createEmptySummary(),
4118
4123
  enhance: function enhance(nextPayload) {
4119
- var _ref67, _tempOrder$order_numb, _ref68, _tempOrder$shop_order, _ref69, _tempOrder$shop_full_;
4124
+ var _ref68, _tempOrder$order_numb, _ref69, _tempOrder$shop_order, _ref70, _tempOrder$shop_full_;
4120
4125
  return _objectSpread(_objectSpread({}, nextPayload), {}, {
4121
- order_number: (_ref67 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref67 !== void 0 ? _ref67 : null,
4122
- shop_order_number: (_ref68 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref68 !== void 0 ? _ref68 : null,
4123
- shop_full_order_number: (_ref69 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref69 !== void 0 ? _ref69 : null,
4126
+ order_number: (_ref68 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref68 !== void 0 ? _ref68 : null,
4127
+ shop_order_number: (_ref69 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref69 !== void 0 ? _ref69 : null,
4128
+ shop_full_order_number: (_ref70 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref70 !== void 0 ? _ref70 : null,
4124
4129
  small_ticket_data_flag: 1
4125
4130
  });
4126
4131
  }
@@ -4217,7 +4222,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4217
4222
  key: "runSubmitTempOrder",
4218
4223
  value: function () {
4219
4224
  var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4220
- var _params$cacheId2, _this$otherParams5, _ref70, _params$businessCode2, _this$otherParams6, _this$otherParams7;
4225
+ var _params$cacheId2, _this$otherParams5, _ref71, _params$businessCode2, _this$otherParams6, _this$otherParams7;
4221
4226
  var tempOrder, latestSummary, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
4222
4227
  return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4223
4228
  while (1) switch (_context31.prev = _context31.next) {
@@ -4263,7 +4268,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4263
4268
  tempOrder: tempOrder,
4264
4269
  cacheId: effectiveCacheId,
4265
4270
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
4266
- businessCode: (_ref70 = (_params$businessCode2 = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref70 !== void 0 ? _ref70 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
4271
+ businessCode: (_ref71 = (_params$businessCode2 = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref71 !== void 0 ? _ref71 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
4267
4272
  channel: params === null || params === void 0 ? void 0 : params.channel,
4268
4273
  type: params === null || params === void 0 ? void 0 : params.type,
4269
4274
  summary: latestSummary,
@@ -5112,7 +5117,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5112
5117
  _step22;
5113
5118
  try {
5114
5119
  for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
5115
- var _product$metadata8, _ref71, _ref72, _existed$origin, _rawProduct$metadata;
5120
+ var _product$metadata8, _ref72, _ref73, _existed$origin, _rawProduct$metadata;
5116
5121
  var _step22$value = _slicedToArray(_step22.value, 2),
5117
5122
  index = _step22$value[0],
5118
5123
  product = _step22$value[1];
@@ -5120,7 +5125,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5120
5125
  if (!uid) continue;
5121
5126
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
5122
5127
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
5123
- var origin = (_ref71 = (_ref72 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref72 !== void 0 ? _ref72 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref71 !== void 0 ? _ref71 : rawProduct;
5128
+ var origin = (_ref72 = (_ref73 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref73 !== void 0 ? _ref73 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref72 !== void 0 ? _ref72 : rawProduct;
5124
5129
  var originSnapshot = cloneDeep(origin);
5125
5130
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
5126
5131
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -5230,10 +5235,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5230
5235
  }, {
5231
5236
  key: "normalizeHydratedProductOptionItem",
5232
5237
  value: function normalizeHydratedProductOptionItem(optionItem) {
5233
- var _ref73, _optionItem$num, _ref74, _optionItem$add_price;
5234
- var rawNum = (_ref73 = (_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 && _ref73 !== void 0 ? _ref73 : 1;
5238
+ var _ref74, _optionItem$num, _ref75, _optionItem$add_price;
5239
+ var rawNum = (_ref74 = (_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 && _ref74 !== void 0 ? _ref74 : 1;
5235
5240
  var parsedNum = Number(rawNum);
5236
- var rawPrice = (_ref74 = (_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 && _ref74 !== void 0 ? _ref74 : 0;
5241
+ var rawPrice = (_ref75 = (_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 && _ref75 !== void 0 ? _ref75 : 0;
5237
5242
  var parsedPrice = Number(rawPrice);
5238
5243
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
5239
5244
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -5360,10 +5365,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5360
5365
  _step27;
5361
5366
  try {
5362
5367
  for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
5363
- var _ref75, _bundle$num3;
5368
+ var _ref76, _bundle$num3;
5364
5369
  var bundle = _step27.value;
5365
5370
  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));
5366
- var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref75 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref75 !== void 0 ? _ref75 : 1) || 1).toNumber();
5371
+ var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref76 = (_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 && _ref76 !== void 0 ? _ref76 : 1) || 1).toNumber();
5367
5372
  var _iterator28 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
5368
5373
  _step28;
5369
5374
  try {
@@ -6392,6 +6392,9 @@ var Server = /*#__PURE__*/function () {
6392
6392
  if (changedOrders.length === 0) {
6393
6393
  return;
6394
6394
  }
6395
+ // 如果当前开启了 checkout 弹窗,先不进行刷新,下面的代码会导致在全局搜索页调用 bookingTicket.destroy()
6396
+ // 导致模块被销毁 ,checkout 弹窗永远无法关闭
6397
+ if (window.isPaymentModalPluginOpen) return;
6395
6398
  var _iterator20 = _createForOfIteratorHelper(this.salesSearchSubscribers.entries()),
6396
6399
  _step20;
6397
6400
  try {
@@ -193,7 +193,7 @@ export declare class OrderModule extends BaseModule implements Module {
193
193
  private findOrderIndexByIdentity;
194
194
  private getOrderCompletenessScore;
195
195
  private pickPreferredOrder;
196
- private getProductMergeKey;
196
+ private getProductIdentityKeys;
197
197
  private mergeOrderProductLists;
198
198
  private getPaymentMergeKey;
199
199
  private mergeOrderPaymentLists;
@@ -1899,20 +1899,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1899
1899
  return left;
1900
1900
  }
1901
1901
  }, {
1902
- key: "getProductMergeKey",
1903
- value: function getProductMergeKey(product) {
1902
+ key: "getProductIdentityKeys",
1903
+ value: function getProductIdentityKeys(product) {
1904
1904
  var _record$metadata;
1905
1905
  var record = product;
1906
- if (!record) return '';
1906
+ if (!record) return [];
1907
+ var keys = [];
1907
1908
  var metadataUid = (_record$metadata = record.metadata) === null || _record$metadata === void 0 ? void 0 : _record$metadata.unique_identification_number;
1908
- if (!this.isBlankIdentityValue(metadataUid)) return "uid:".concat(String(metadataUid));
1909
+ if (!this.isBlankIdentityValue(metadataUid)) keys.push("uid:".concat(String(metadataUid)));
1909
1910
  var topLevelUid = record.unique_identification_number;
1910
- if (!this.isBlankIdentityValue(topLevelUid)) return "uid:".concat(String(topLevelUid));
1911
+ if (!this.isBlankIdentityValue(topLevelUid)) keys.push("uid:".concat(String(topLevelUid)));
1911
1912
  var orderDetailId = record.order_detail_id;
1912
- if (!this.isBlankIdentityValue(orderDetailId)) return "detail:".concat(String(orderDetailId));
1913
+ if (!this.isBlankIdentityValue(orderDetailId)) keys.push("detail:".concat(String(orderDetailId)));
1913
1914
  var bookingUid = record.booking_uid;
1914
- if (!this.isBlankIdentityValue(bookingUid)) return "booking:".concat(String(bookingUid));
1915
- return '';
1915
+ if (!this.isBlankIdentityValue(bookingUid)) keys.push("booking:".concat(String(bookingUid)));
1916
+ return keys;
1916
1917
  }
1917
1918
  }, {
1918
1919
  key: "mergeOrderProductLists",
@@ -1927,8 +1928,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1927
1928
  try {
1928
1929
  for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
1929
1930
  var item = _step13.value;
1930
- var key = this.getProductMergeKey(item);
1931
- if (key) seenKeys.add(key);
1931
+ var keys = this.getProductIdentityKeys(item);
1932
+ var _iterator15 = _createForOfIteratorHelper(keys),
1933
+ _step15;
1934
+ try {
1935
+ for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
1936
+ var key = _step15.value;
1937
+ seenKeys.add(key);
1938
+ }
1939
+ } catch (err) {
1940
+ _iterator15.e(err);
1941
+ } finally {
1942
+ _iterator15.f();
1943
+ }
1932
1944
  }
1933
1945
  } catch (err) {
1934
1946
  _iterator13.e(err);
@@ -1941,9 +1953,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1941
1953
  try {
1942
1954
  for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
1943
1955
  var _item = _step14.value;
1944
- var _key = this.getProductMergeKey(_item);
1945
- if (!_key || seenKeys.has(_key)) continue;
1946
- seenKeys.add(_key);
1956
+ var _keys = this.getProductIdentityKeys(_item);
1957
+ if (_keys.length === 0 || _keys.some(function (key) {
1958
+ return seenKeys.has(key);
1959
+ })) continue;
1960
+ var _iterator16 = _createForOfIteratorHelper(_keys),
1961
+ _step16;
1962
+ try {
1963
+ for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
1964
+ var _key = _step16.value;
1965
+ seenKeys.add(_key);
1966
+ }
1967
+ } catch (err) {
1968
+ _iterator16.e(err);
1969
+ } finally {
1970
+ _iterator16.f();
1971
+ }
1947
1972
  result.push(cloneDeep(_item));
1948
1973
  }
1949
1974
  } catch (err) {
@@ -1981,19 +2006,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1981
2006
  if (incomingList.length === 0) return cloneDeep(existingList);
1982
2007
  if (existingList.length === 0) return cloneDeep(incomingList);
1983
2008
  var existingByKey = new Map();
1984
- var _iterator15 = _createForOfIteratorHelper(existingList),
1985
- _step15;
2009
+ var _iterator17 = _createForOfIteratorHelper(existingList),
2010
+ _step17;
1986
2011
  try {
1987
- for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
1988
- var payment = _step15.value;
2012
+ for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
2013
+ var payment = _step17.value;
1989
2014
  var key = this.getPaymentMergeKey(payment);
1990
2015
  if (!key) continue;
1991
2016
  existingByKey.set(key, payment);
1992
2017
  }
1993
2018
  } catch (err) {
1994
- _iterator15.e(err);
2019
+ _iterator17.e(err);
1995
2020
  } finally {
1996
- _iterator15.f();
2021
+ _iterator17.f();
1997
2022
  }
1998
2023
  return incomingList.map(function (payment) {
1999
2024
  var incomingPayment = payment;
@@ -2054,30 +2079,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2054
2079
  key: "summarizeDuplicateOrders",
2055
2080
  value: function summarizeDuplicateOrders(orders) {
2056
2081
  var groups = new Map();
2057
- var _iterator16 = _createForOfIteratorHelper(orders),
2058
- _step16;
2082
+ var _iterator18 = _createForOfIteratorHelper(orders),
2083
+ _step18;
2059
2084
  try {
2060
- for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
2061
- var order = _step16.value;
2062
- var _iterator17 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(order)),
2063
- _step17;
2085
+ for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
2086
+ var order = _step18.value;
2087
+ var _iterator19 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(order)),
2088
+ _step19;
2064
2089
  try {
2065
- for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
2066
- var key = _step17.value;
2090
+ for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
2091
+ var key = _step19.value;
2067
2092
  var group = groups.get(key) || [];
2068
2093
  group.push(order);
2069
2094
  groups.set(key, group);
2070
2095
  }
2071
2096
  } catch (err) {
2072
- _iterator17.e(err);
2097
+ _iterator19.e(err);
2073
2098
  } finally {
2074
- _iterator17.f();
2099
+ _iterator19.f();
2075
2100
  }
2076
2101
  }
2077
2102
  } catch (err) {
2078
- _iterator16.e(err);
2103
+ _iterator18.e(err);
2079
2104
  } finally {
2080
- _iterator16.f();
2105
+ _iterator18.f();
2081
2106
  }
2082
2107
  return _toConsumableArray(groups.entries()).filter(function (_ref2) {
2083
2108
  var _ref3 = _slicedToArray(_ref2, 2),
@@ -2119,11 +2144,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2119
2144
  value: function compactOrderListByIdentity(orders, source) {
2120
2145
  var list = [];
2121
2146
  var removedCount = 0;
2122
- var _iterator18 = _createForOfIteratorHelper(orders),
2123
- _step18;
2147
+ var _iterator20 = _createForOfIteratorHelper(orders),
2148
+ _step20;
2124
2149
  try {
2125
- for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
2126
- var order = _step18.value;
2150
+ for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
2151
+ var order = _step20.value;
2127
2152
  var matchIndex = this.findOrderIndexByIdentity(list, order);
2128
2153
  if (matchIndex < 0) {
2129
2154
  list.push(order);
@@ -2133,9 +2158,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2133
2158
  removedCount += 1;
2134
2159
  }
2135
2160
  } catch (err) {
2136
- _iterator18.e(err);
2161
+ _iterator20.e(err);
2137
2162
  } finally {
2138
- _iterator18.f();
2163
+ _iterator20.f();
2139
2164
  }
2140
2165
  if (removedCount > 0) {
2141
2166
  this.logWarning('订单列表重复项已压缩', {
@@ -2285,11 +2310,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2285
2310
  var merged = remoteOrders.map(function (order) {
2286
2311
  return _this19.normalizeRemoteSyncedOrder(order);
2287
2312
  });
2288
- var _iterator19 = _createForOfIteratorHelper(existingOrders),
2289
- _step19;
2313
+ var _iterator21 = _createForOfIteratorHelper(existingOrders),
2314
+ _step21;
2290
2315
  try {
2291
- for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
2292
- var order = _step19.value;
2316
+ for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
2317
+ var order = _step21.value;
2293
2318
  if (!this.isPendingSyncOrder(order)) continue;
2294
2319
  var matchIndex = this.findOrderIndexByIdentity(merged, order);
2295
2320
  if (matchIndex >= 0) {
@@ -2300,9 +2325,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2300
2325
  merged.push(order);
2301
2326
  }
2302
2327
  } catch (err) {
2303
- _iterator19.e(err);
2328
+ _iterator21.e(err);
2304
2329
  } finally {
2305
- _iterator19.f();
2330
+ _iterator21.f();
2306
2331
  }
2307
2332
  return this.compactOrderListByIdentity(merged, 'mergeRemoteSnapshotWithPendingOrders').list;
2308
2333
  }
@@ -2396,7 +2421,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2396
2421
  _context20.prev = 12;
2397
2422
  _context20.next = 15;
2398
2423
  return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
2399
- var writeMethod, _iterator20, _step20, order;
2424
+ var writeMethod, _iterator22, _step22, order;
2400
2425
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
2401
2426
  while (1) switch (_context19.prev = _context19.next) {
2402
2427
  case 0:
@@ -2433,15 +2458,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2433
2458
  break;
2434
2459
  }
2435
2460
  writeMethod = 'update';
2436
- _iterator20 = _createForOfIteratorHelper(compactedToWrite);
2461
+ _iterator22 = _createForOfIteratorHelper(compactedToWrite);
2437
2462
  _context19.prev = 17;
2438
- _iterator20.s();
2463
+ _iterator22.s();
2439
2464
  case 19:
2440
- if ((_step20 = _iterator20.n()).done) {
2465
+ if ((_step22 = _iterator22.n()).done) {
2441
2466
  _context19.next = 25;
2442
2467
  break;
2443
2468
  }
2444
- order = _step20.value;
2469
+ order = _step22.value;
2445
2470
  _context19.next = 23;
2446
2471
  return _this20.dbManager.update(INDEXDB_STORE_NAME, order);
2447
2472
  case 23:
@@ -2453,10 +2478,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2453
2478
  case 27:
2454
2479
  _context19.prev = 27;
2455
2480
  _context19.t0 = _context19["catch"](17);
2456
- _iterator20.e(_context19.t0);
2481
+ _iterator22.e(_context19.t0);
2457
2482
  case 30:
2458
2483
  _context19.prev = 30;
2459
- _iterator20.f();
2484
+ _iterator22.f();
2460
2485
  return _context19.finish(30);
2461
2486
  case 33:
2462
2487
  _this20.recordRecentSqliteWrite(source, compactedToWrite);
@@ -2247,6 +2247,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2247
2247
  var _this$otherParams20,
2248
2248
  _paymentRecord$paymen,
2249
2249
  _paymentRecord$create,
2250
+ _ref13,
2251
+ _paymentRecord$origin,
2250
2252
  _this7 = this;
2251
2253
  if (!this.store.order) throw new Error('order 模块未初始化');
2252
2254
  var paymentRecord = payment;
@@ -2268,7 +2270,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2268
2270
  var paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
2269
2271
  var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
2270
2272
  var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
2271
- var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread({}, paymentRecord), {}, {
2273
+ var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
2274
+ var calculatedServiceFee = serviceCharge ? new Decimal((_ref13 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref13 !== void 0 ? _ref13 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
2275
+ var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, paymentRecord), calculatedServiceFee !== undefined ? {
2276
+ service_fee: calculatedServiceFee
2277
+ } : {}), {}, {
2272
2278
  metadata: metadata,
2273
2279
  payment_time: paymentTime,
2274
2280
  created_at: createdAt
@@ -2376,7 +2382,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2376
2382
  key: "initWalletData",
2377
2383
  value: function () {
2378
2384
  var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
2379
- var _params$order_wait_pa, _ref13, _tempOrder$is_price_i;
2385
+ var _params$order_wait_pa, _ref14, _tempOrder$is_price_i;
2380
2386
  var snapshot, tempOrder, amount, walletBusinessData, result;
2381
2387
  return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2382
2388
  while (1) switch (_context24.prev = _context24.next) {
@@ -2419,7 +2425,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2419
2425
  },
2420
2426
  products: this.getWalletProductList(),
2421
2427
  order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
2422
- is_price_include_tax: (_ref13 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref13 !== void 0 ? _ref13 : 1
2428
+ is_price_include_tax: (_ref14 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref14 !== void 0 ? _ref14 : 1
2423
2429
  }, snapshot.identity.orderId ? {
2424
2430
  payment_order_id: String(snapshot.identity.orderId)
2425
2431
  } : {});
@@ -2550,7 +2556,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2550
2556
  key: "sendCustomerPayLink",
2551
2557
  value: (function () {
2552
2558
  var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
2553
- var orderIds, _ref14, _ref15, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
2559
+ var orderIds, _ref15, _ref16, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
2554
2560
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2555
2561
  while (1) switch (_context26.prev = _context26.next) {
2556
2562
  case 0:
@@ -2571,7 +2577,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2571
2577
  });
2572
2578
  case 6:
2573
2579
  submitResult = _context26.sent;
2574
- orderId = (_ref14 = (_ref15 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref15 !== void 0 ? _ref15 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref14 !== void 0 ? _ref14 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
2580
+ orderId = (_ref15 = (_ref16 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref16 !== void 0 ? _ref16 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref15 !== void 0 ? _ref15 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
2575
2581
  if (orderId) {
2576
2582
  _context26.next = 10;
2577
2583
  break;
@@ -2997,14 +3003,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2997
3003
  value: function () {
2998
3004
  var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
2999
3005
  var _this$otherParams22;
3000
- var _ref16,
3001
- _ref16$cover,
3006
+ var _ref17,
3007
+ _ref17$cover,
3002
3008
  cover,
3003
3009
  _args36 = arguments;
3004
3010
  return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3005
3011
  while (1) switch (_context36.prev = _context36.next) {
3006
3012
  case 0:
3007
- _ref16 = _args36.length > 1 && _args36[1] !== undefined ? _args36[1] : {}, _ref16$cover = _ref16.cover, cover = _ref16$cover === void 0 ? false : _ref16$cover;
3013
+ _ref17 = _args36.length > 1 && _args36[1] !== undefined ? _args36[1] : {}, _ref17$cover = _ref17.cover, cover = _ref17$cover === void 0 ? false : _ref17$cover;
3008
3014
  if (cover) {
3009
3015
  this.otherParams = _objectSpread({}, params);
3010
3016
  } else {
@@ -441,7 +441,19 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
441
441
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
442
442
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
443
443
  */
444
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
444
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
445
+ action: "reloadCatalog";
446
+ } | {
447
+ action: "add";
448
+ cacheItem: any;
449
+ } | {
450
+ action: "requiresDetail";
451
+ payload: AddProductRequiresDetailPayload;
452
+ } | {
453
+ action: "requiresBookingEdit";
454
+ cacheItem: any;
455
+ payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
456
+ };
445
457
  /** 规格弹窗 callback 后的第二段决策。 */
446
458
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
447
459
  /**
@@ -805,9 +805,12 @@ var OrderModule = class extends import_BaseModule.BaseModule {
805
805
  return ((_a = result == null ? void 0 : result.data) == null ? void 0 : _a.order_id) ?? (result == null ? void 0 : result.order_id) ?? ((_b = result == null ? void 0 : result.data) == null ? void 0 : _b.id) ?? (result == null ? void 0 : result.id) ?? null;
806
806
  }
807
807
  calculatePaymentEffectiveAmount(payment) {
808
- const amount = new import_decimal.default(payment.amount || 0).minus(new import_decimal.default(payment.service_fee || 0));
808
+ const amount = new import_decimal.default(payment.amount || 0);
809
+ const originAmount = new import_decimal.default(payment.origin_amount ?? payment.amount ?? 0);
810
+ const serviceFee = new import_decimal.default(payment.service_fee || 0);
811
+ const effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
809
812
  const rounding = new import_decimal.default(payment.rounding_amount || 0);
810
- return amount.minus(rounding);
813
+ return effectiveAmount.minus(rounding);
811
814
  }
812
815
  calculatePaymentTotal(payments) {
813
816
  return (0, import_utils.mapPaymentItemsToOrderPayments)(payments, {
@@ -4048,6 +4048,8 @@ var Server = class {
4048
4048
  if (changedOrders.length === 0) {
4049
4049
  return;
4050
4050
  }
4051
+ if (window.isPaymentModalPluginOpen)
4052
+ return;
4051
4053
  for (const [subscriberId, subscriber] of this.salesSearchSubscribers.entries()) {
4052
4054
  try {
4053
4055
  const changedVisibleOrders = changedOrders.filter((order) => {
@@ -193,7 +193,7 @@ export declare class OrderModule extends BaseModule implements Module {
193
193
  private findOrderIndexByIdentity;
194
194
  private getOrderCompletenessScore;
195
195
  private pickPreferredOrder;
196
- private getProductMergeKey;
196
+ private getProductIdentityKeys;
197
197
  private mergeOrderProductLists;
198
198
  private getPaymentMergeKey;
199
199
  private mergeOrderPaymentLists;
@@ -1141,24 +1141,25 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1141
1141
  return right;
1142
1142
  return left;
1143
1143
  }
1144
- getProductMergeKey(product) {
1144
+ getProductIdentityKeys(product) {
1145
1145
  var _a;
1146
1146
  const record = product;
1147
1147
  if (!record)
1148
- return "";
1148
+ return [];
1149
+ const keys = [];
1149
1150
  const metadataUid = (_a = record.metadata) == null ? void 0 : _a.unique_identification_number;
1150
1151
  if (!this.isBlankIdentityValue(metadataUid))
1151
- return `uid:${String(metadataUid)}`;
1152
+ keys.push(`uid:${String(metadataUid)}`);
1152
1153
  const topLevelUid = record.unique_identification_number;
1153
1154
  if (!this.isBlankIdentityValue(topLevelUid))
1154
- return `uid:${String(topLevelUid)}`;
1155
+ keys.push(`uid:${String(topLevelUid)}`);
1155
1156
  const orderDetailId = record.order_detail_id;
1156
1157
  if (!this.isBlankIdentityValue(orderDetailId))
1157
- return `detail:${String(orderDetailId)}`;
1158
+ keys.push(`detail:${String(orderDetailId)}`);
1158
1159
  const bookingUid = record.booking_uid;
1159
1160
  if (!this.isBlankIdentityValue(bookingUid))
1160
- return `booking:${String(bookingUid)}`;
1161
- return "";
1161
+ keys.push(`booking:${String(bookingUid)}`);
1162
+ return keys;
1162
1163
  }
1163
1164
  mergeOrderProductLists(preferred, secondary) {
1164
1165
  const preferredList = Array.isArray(preferred) ? preferred : [];
@@ -1169,16 +1170,17 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1169
1170
  return secondaryList;
1170
1171
  const seenKeys = /* @__PURE__ */ new Set();
1171
1172
  for (const item of preferredList) {
1172
- const key = this.getProductMergeKey(item);
1173
- if (key)
1173
+ const keys = this.getProductIdentityKeys(item);
1174
+ for (const key of keys)
1174
1175
  seenKeys.add(key);
1175
1176
  }
1176
1177
  const result = [...preferredList];
1177
1178
  for (const item of secondaryList) {
1178
- const key = this.getProductMergeKey(item);
1179
- if (!key || seenKeys.has(key))
1179
+ const keys = this.getProductIdentityKeys(item);
1180
+ if (keys.length === 0 || keys.some((key) => seenKeys.has(key)))
1180
1181
  continue;
1181
- seenKeys.add(key);
1182
+ for (const key of keys)
1183
+ seenKeys.add(key);
1182
1184
  result.push((0, import_lodash_es.cloneDeep)(item));
1183
1185
  }
1184
1186
  return result;
@@ -1465,8 +1465,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1465
1465
  const paymentTimestamp = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
1466
1466
  const paymentTime = paymentRecord.payment_time ?? paymentTimestamp;
1467
1467
  const createdAt = paymentRecord.created_at ?? paymentTimestamp;
1468
+ const serviceCharge = paymentRecord.service_charge && typeof paymentRecord.service_charge === "object" ? paymentRecord.service_charge : null;
1469
+ const calculatedServiceFee = serviceCharge ? new import_decimal.default(paymentRecord.origin_amount ?? paymentRecord.amount ?? 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : void 0;
1468
1470
  const payments = this.store.order.addOrderPayment({
1469
1471
  ...paymentRecord,
1472
+ ...calculatedServiceFee !== void 0 ? { service_fee: calculatedServiceFee } : {},
1470
1473
  metadata,
1471
1474
  payment_time: paymentTime,
1472
1475
  created_at: createdAt
@@ -441,7 +441,19 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
441
441
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
442
442
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
443
443
  */
444
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
444
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
445
+ action: "reloadCatalog";
446
+ } | {
447
+ action: "add";
448
+ cacheItem: any;
449
+ } | {
450
+ action: "requiresDetail";
451
+ payload: AddProductRequiresDetailPayload;
452
+ } | {
453
+ action: "requiresBookingEdit";
454
+ cacheItem: any;
455
+ payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
456
+ };
445
457
  /** 规格弹窗 callback 后的第二段决策。 */
446
458
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
447
459
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.249",
4
+ "version": "2.2.250",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",