@pisell/pisellos 2.3.25 → 2.3.26

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.
@@ -1,9 +0,0 @@
1
- // 导出评估器
2
- export { PromotionEvaluator } from "./evaluator";
3
-
4
- // 导出适配器
5
- export { PromotionAdapter } from "./adapter";
6
- export { default } from "./adapter";
7
-
8
- // 导出策略配置示例常量
9
- export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
@@ -155,6 +155,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
155
155
  private extractOrderIdFromSubmitResult;
156
156
  private calculatePaymentEffectiveAmount;
157
157
  private calculatePaymentTotal;
158
+ private calculateOrderPaidPaymentTotal;
158
159
  private getDepositAmount;
159
160
  private normalizeDepositAmount;
160
161
  private getLastOrderDepositSnapshot;
@@ -183,6 +184,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
183
184
  private calculatePaidPaymentSummary;
184
185
  private calculatePaymentServiceFee;
185
186
  private calculatePaymentGapAmount;
187
+ private calculatePaymentOrderAmount;
186
188
  private calculatePaymentRoundingAmount;
187
189
  private formatSummaryMetadataMoney;
188
190
  private syncSummaryProductMetadata;
@@ -465,7 +467,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
465
467
  generateIdempotencyToken(): string;
466
468
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
467
469
  createOrder(params: CommitOrderParams['query']): {
468
- type: "appointment_booking" | "virtual";
470
+ type: "virtual" | "appointment_booking";
469
471
  platform: string;
470
472
  sales_channel: string;
471
473
  order_sales_channel: string;
@@ -1346,6 +1346,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1346
1346
  return sum.plus(_this4.calculatePaymentEffectiveAmount(payment));
1347
1347
  }, new Decimal(0));
1348
1348
  }
1349
+ }, {
1350
+ key: "calculateOrderPaidPaymentTotal",
1351
+ value: function calculateOrderPaidPaymentTotal(payments) {
1352
+ var _this5 = this;
1353
+ return mapPaymentItemsToOrderPayments(payments, {
1354
+ includeVoided: false
1355
+ }).reduce(function (sum, payment) {
1356
+ if (!isPaidPaymentRecord(payment)) return sum;
1357
+ return sum.plus(_this5.calculatePaymentGapAmount(payment));
1358
+ }, new Decimal(0));
1359
+ }
1349
1360
  }, {
1350
1361
  key: "getDepositAmount",
1351
1362
  value: function getDepositAmount(tempOrder, summary) {
@@ -1446,7 +1457,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1446
1457
  var summary = this.store.summary || createEmptySummary();
1447
1458
  var paymentList = payments || tempOrder.payments || [];
1448
1459
  var refundAmount = this.getSummaryRefundAmount(summary);
1449
- var netPaidAmount = Decimal.max(this.calculatePaymentTotal(paymentList).minus(refundAmount), 0);
1460
+ var netPaidAmount = Decimal.max(this.calculateOrderPaidPaymentTotal(paymentList).minus(refundAmount), 0);
1450
1461
  var depositAmount = this.getDepositAmount(tempOrder, summary);
1451
1462
  var orderExpectedAmount = this.getOrderExpectedAmount(summary);
1452
1463
  var isDepositFullyPaid = this.isDepositCovered({
@@ -1468,17 +1479,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1468
1479
  }, {
1469
1480
  key: "calculateDepositPaidAmount",
1470
1481
  value: function calculateDepositPaidAmount(payments) {
1471
- var _this5 = this;
1482
+ var _this6 = this;
1472
1483
  return (payments || []).reduce(function (sum, payment) {
1473
1484
  var paymentRecord = payment;
1474
1485
  if (!isPaidPaymentRecord(paymentRecord)) return sum;
1475
1486
  var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
1476
1487
  if (!isDepositPayment) return sum;
1477
- if (paymentRecord.origin_amount !== undefined && paymentRecord.origin_amount !== null && paymentRecord.origin_amount !== '') {
1478
- return sum.plus(_this5.calculatePaymentGapAmount(paymentRecord));
1479
- }
1480
- var rounding = new Decimal(paymentRecord.rounding_amount || 0);
1481
- return sum.plus(new Decimal(paymentRecord.amount || 0).minus(rounding));
1488
+ return sum.plus(_this6.calculatePaymentGapAmount(paymentRecord));
1482
1489
  }, new Decimal(0));
1483
1490
  }
1484
1491
  }, {
@@ -1515,8 +1522,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1515
1522
  value: function updateTempOrderPaymentStatus(tempOrder, options) {
1516
1523
  var summary = (options === null || options === void 0 ? void 0 : options.summary) || this.store.summary || createEmptySummary();
1517
1524
  var paymentTotal = this.calculatePaymentTotal(tempOrder.payments || []);
1525
+ var orderPaymentTotal = this.calculateOrderPaidPaymentTotal(tempOrder.payments || []);
1518
1526
  var refundAmount = this.getSummaryRefundAmount(summary);
1519
- var netPaymentTotal = Decimal.max(paymentTotal.minus(refundAmount), 0);
1527
+ var netPaymentTotal = Decimal.max(orderPaymentTotal.minus(refundAmount), 0);
1520
1528
  var targetAmount = this.calculatePaymentTargetAmount(tempOrder, summary, netPaymentTotal);
1521
1529
  if (this.shouldKeepPaymentStatusAfterAmountRecalc(tempOrder.payment_status, {
1522
1530
  netPaymentTotal: netPaymentTotal,
@@ -1582,7 +1590,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1582
1590
  key: "capVoucherPaymentsByRemainingAmount",
1583
1591
  value: function capVoucherPaymentsByRemainingAmount(params) {
1584
1592
  var targetAmount = this.getPaymentTargetAmount();
1585
- var nonVoucherTotal = this.calculatePaymentTotal(params.nonVoucherPayments);
1593
+ var nonVoucherTotal = this.calculateOrderPaidPaymentTotal(params.nonVoucherPayments);
1586
1594
  if (targetAmount.lte(0)) return [];
1587
1595
  var remainingAmount = Decimal.max(targetAmount.minus(nonVoucherTotal), 0);
1588
1596
  var cappedVouchers = [];
@@ -1619,16 +1627,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1619
1627
  }, {
1620
1628
  key: "calculatePaidPaymentSummary",
1621
1629
  value: function calculatePaidPaymentSummary(payments) {
1622
- var _this6 = this;
1630
+ var _this7 = this;
1623
1631
  return (payments || []).reduce(function (summary, payment) {
1624
1632
  var paymentRecord = payment;
1625
1633
  if (!isPaidPaymentRecord(paymentRecord)) return summary;
1626
1634
  return {
1627
1635
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
1628
- orderPaidAmount: summary.orderPaidAmount.plus(paymentRecord.origin_amount || 0),
1629
- gapPaidAmount: summary.gapPaidAmount.plus(_this6.calculatePaymentGapAmount(paymentRecord)),
1630
- payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this6.calculatePaymentServiceFee(paymentRecord)),
1631
- roundingAmount: summary.roundingAmount.plus(_this6.calculatePaymentRoundingAmount(paymentRecord))
1636
+ orderPaidAmount: summary.orderPaidAmount.plus(_this7.calculatePaymentOrderAmount(paymentRecord)),
1637
+ gapPaidAmount: summary.gapPaidAmount.plus(_this7.calculatePaymentGapAmount(paymentRecord)),
1638
+ payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this7.calculatePaymentServiceFee(paymentRecord)),
1639
+ roundingAmount: summary.roundingAmount.plus(_this7.calculatePaymentRoundingAmount(paymentRecord))
1632
1640
  };
1633
1641
  }, {
1634
1642
  customerPaidAmount: new Decimal(0),
@@ -1652,11 +1660,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1652
1660
  }, {
1653
1661
  key: "calculatePaymentGapAmount",
1654
1662
  value: function calculatePaymentGapAmount(payment) {
1655
- if (payment.origin_amount === undefined || payment.origin_amount === null || payment.origin_amount === '') {
1656
- return new Decimal(0);
1663
+ if (payment.origin_amount !== undefined && payment.origin_amount !== null && payment.origin_amount !== '') {
1664
+ var _rounding = new Decimal(payment.rounding_amount || 0);
1665
+ return new Decimal(payment.origin_amount || 0).minus(_rounding);
1657
1666
  }
1658
1667
  var rounding = new Decimal(payment.rounding_amount || 0);
1659
- return new Decimal(payment.origin_amount || 0).minus(rounding);
1668
+ var amount = new Decimal(payment.amount || 0);
1669
+ var serviceFee = this.calculatePaymentServiceFee(payment);
1670
+ if (serviceFee.lte(0)) return amount.minus(rounding);
1671
+ if (!hasSyncedOrderPaymentRecord(payment)) return new Decimal(0);
1672
+ return Decimal.max(amount.minus(serviceFee), 0).minus(rounding);
1673
+ }
1674
+ }, {
1675
+ key: "calculatePaymentOrderAmount",
1676
+ value: function calculatePaymentOrderAmount(payment) {
1677
+ if (payment.origin_amount !== undefined && payment.origin_amount !== null && payment.origin_amount !== '') {
1678
+ return new Decimal(payment.origin_amount || 0);
1679
+ }
1680
+ var amount = new Decimal(payment.amount || 0);
1681
+ var serviceFee = this.calculatePaymentServiceFee(payment);
1682
+ if (serviceFee.lte(0)) return amount;
1683
+ if (!hasSyncedOrderPaymentRecord(payment)) return new Decimal(0);
1684
+ return Decimal.max(amount.minus(serviceFee), 0);
1660
1685
  }
1661
1686
  }, {
1662
1687
  key: "calculatePaymentRoundingAmount",
@@ -1813,15 +1838,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1813
1838
  }, {
1814
1839
  key: "normalizeFingerprintValue",
1815
1840
  value: function normalizeFingerprintValue(value) {
1816
- var _this7 = this;
1841
+ var _this8 = this;
1817
1842
  if (Array.isArray(value)) {
1818
1843
  return value.map(function (item) {
1819
- return _this7.normalizeFingerprintValue(item);
1844
+ return _this8.normalizeFingerprintValue(item);
1820
1845
  });
1821
1846
  }
1822
1847
  if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
1823
1848
  return Object.keys(value).sort().reduce(function (result, key) {
1824
- result[key] = _this7.normalizeFingerprintValue(value[key]);
1849
+ result[key] = _this8.normalizeFingerprintValue(value[key]);
1825
1850
  return result;
1826
1851
  }, {});
1827
1852
  }
@@ -1836,7 +1861,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1836
1861
  _sku$barcode,
1837
1862
  _ref20,
1838
1863
  _sku$variant_id,
1839
- _this8 = this;
1864
+ _this9 = this;
1840
1865
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
1841
1866
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
1842
1867
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -1870,7 +1895,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1870
1895
  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,
1871
1896
  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,
1872
1897
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
1873
- 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)
1898
+ add_price: _this9.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)
1874
1899
  };
1875
1900
  })
1876
1901
  }),
@@ -1880,8 +1905,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1880
1905
  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,
1881
1906
  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,
1882
1907
  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),
1883
- price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
1884
- bundle_selling_price: _this8.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
1908
+ price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
1909
+ bundle_selling_price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
1885
1910
  price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
1886
1911
  price_type_ext: (_bundle$price_type_ex = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : ''
1887
1912
  };
@@ -1891,7 +1916,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1891
1916
  return {
1892
1917
  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 : '',
1893
1918
  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,
1894
- amount: _this8.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1919
+ amount: _this9.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1895
1920
  };
1896
1921
  }))
1897
1922
  };
@@ -1899,9 +1924,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1899
1924
  }, {
1900
1925
  key: "buildOrderProductsFingerprint",
1901
1926
  value: function buildOrderProductsFingerprint(products) {
1902
- var _this9 = this;
1927
+ var _this10 = this;
1903
1928
  var items = (products || []).map(function (product) {
1904
- return _this9.buildProductFingerprintItem(product);
1929
+ return _this10.buildProductFingerprintItem(product);
1905
1930
  });
1906
1931
  items.sort(function (left, right) {
1907
1932
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -1923,7 +1948,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1923
1948
  _sku$barcode2,
1924
1949
  _ref30,
1925
1950
  _sku$variant_id2,
1926
- _this10 = this;
1951
+ _this11 = this;
1927
1952
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
1928
1953
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
1929
1954
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -1954,7 +1979,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1954
1979
  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,
1955
1980
  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,
1956
1981
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
1957
- 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)
1982
+ add_price: _this11.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)
1958
1983
  };
1959
1984
  })
1960
1985
  }),
@@ -1968,14 +1993,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1968
1993
  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),
1969
1994
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
1970
1995
  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 : '',
1971
- option: _this10.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
1996
+ option: _this11.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
1972
1997
  var _ref38, _option$id3, _option$option_group_5, _ref39, _option$option_group_6, _option$num3, _option$add_price3;
1973
1998
  return {
1974
1999
  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,
1975
2000
  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,
1976
2001
  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,
1977
2002
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
1978
- 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)
2003
+ add_price: _this11.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)
1979
2004
  };
1980
2005
  }))
1981
2006
  };
@@ -1985,7 +2010,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1985
2010
  return {
1986
2011
  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 : '',
1987
2012
  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,
1988
- amount: _this10.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2013
+ amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
1989
2014
  };
1990
2015
  }))
1991
2016
  };
@@ -1993,9 +2018,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1993
2018
  }, {
1994
2019
  key: "buildOrderProductsStructuralFingerprint",
1995
2020
  value: function buildOrderProductsStructuralFingerprint(products) {
1996
- var _this11 = this;
2021
+ var _this12 = this;
1997
2022
  var items = (products || []).map(function (product) {
1998
- return _this11.buildProductStructuralFingerprintItem(product);
2023
+ return _this12.buildProductStructuralFingerprintItem(product);
1999
2024
  });
2000
2025
  items.sort(function (left, right) {
2001
2026
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2095,7 +2120,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2095
2120
  tempOrder.surcharge_fee = summary.surcharge_fee || tempOrder.surcharge_fee;
2096
2121
  tempOrder.deposit_amount = summary.deposit_amount || '0.00';
2097
2122
  tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
2123
+ var previousSummary = this.store.summary;
2098
2124
  this.store.summary = summary;
2125
+ this.updateTempOrderPaymentStatus(tempOrder, {
2126
+ previousSummary: previousSummary,
2127
+ summary: summary
2128
+ });
2099
2129
  return summary;
2100
2130
  }
2101
2131
  }, {
@@ -2418,9 +2448,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2418
2448
  }, {
2419
2449
  key: "sanitizeTempOrderProducts",
2420
2450
  value: function sanitizeTempOrderProducts(tempOrder) {
2421
- var _this12 = this;
2451
+ var _this13 = this;
2422
2452
  tempOrder.products = (tempOrder.products || []).map(function (product) {
2423
- return _this12.sanitizeOrderProductForTempOrder(product);
2453
+ return _this13.sanitizeOrderProductForTempOrder(product);
2424
2454
  });
2425
2455
  }
2426
2456
  }, {
@@ -2523,7 +2553,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2523
2553
  }, {
2524
2554
  key: "syncLinkedBookingHoldersToProducts",
2525
2555
  value: function syncLinkedBookingHoldersToProducts(tempOrder) {
2526
- var _this13 = this;
2556
+ var _this14 = this;
2527
2557
  var bookings = tempOrder.bookings || [];
2528
2558
  var products = tempOrder.products || [];
2529
2559
  if (!bookings.length || !products.length) return;
@@ -2548,7 +2578,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2548
2578
  var bookingUid = product.booking_uid || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
2549
2579
  var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
2550
2580
  if (linkedBooking) {
2551
- _this13.setProductHolderFromBooking(product, linkedBooking);
2581
+ _this14.setProductHolderFromBooking(product, linkedBooking);
2552
2582
  }
2553
2583
  });
2554
2584
  }
@@ -2676,9 +2706,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2676
2706
  }, {
2677
2707
  key: "findBookingIndexByUniqueIdentificationNumber",
2678
2708
  value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
2679
- var _this14 = this;
2709
+ var _this15 = this;
2680
2710
  return (tempOrder.bookings || []).findIndex(function (booking) {
2681
- return _this14.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
2711
+ return _this15.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
2682
2712
  });
2683
2713
  }
2684
2714
  }, {
@@ -2686,12 +2716,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2686
2716
  value: function removeLinkedBookingsForProduct(tempOrder, product) {
2687
2717
  var _product$metadata7,
2688
2718
  _product$metadata8,
2689
- _this15 = this;
2719
+ _this16 = this;
2690
2720
  var productUid = (product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
2691
2721
  var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.booking_uid);
2692
2722
  if (!productUid && !bookingUid) return;
2693
2723
  tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
2694
- var currentBookingUid = _this15.getBookingUniqueIdentificationNumber(booking);
2724
+ var currentBookingUid = _this16.getBookingUniqueIdentificationNumber(booking);
2695
2725
  if (bookingUid && currentBookingUid === String(bookingUid)) return false;
2696
2726
  if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
2697
2727
  return true;
@@ -3024,15 +3054,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3024
3054
  }, {
3025
3055
  key: "productHasCustomerBoundDiscount",
3026
3056
  value: function productHasCustomerBoundDiscount(product) {
3027
- var _this16 = this;
3057
+ var _this17 = this;
3028
3058
  if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
3029
- return _this16.isCustomerBoundDiscount(discount);
3059
+ return _this17.isCustomerBoundDiscount(discount);
3030
3060
  })) {
3031
3061
  return true;
3032
3062
  }
3033
3063
  return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
3034
3064
  return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
3035
- return _this16.isCustomerBoundDiscount(discount);
3065
+ return _this17.isCustomerBoundDiscount(discount);
3036
3066
  });
3037
3067
  });
3038
3068
  }
@@ -3041,18 +3071,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3041
3071
  value: function shouldSkipDiscountCalculation(tempOrder) {
3042
3072
  var _this$store$discount17,
3043
3073
  _this$store$discount18,
3044
- _this17 = this;
3074
+ _this18 = this;
3045
3075
  if (this.hasActiveCustomerBoundDiscount) return false;
3046
3076
  var discountList = ((_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || (_this$store$discount18 = _this$store$discount17.getDiscountList) === null || _this$store$discount18 === void 0 ? void 0 : _this$store$discount18.call(_this$store$discount17)) || [];
3047
3077
  if (discountList.length > 0) return false;
3048
3078
  return !(tempOrder.products || []).some(function (product) {
3049
- return _this17.productHasCustomerBoundDiscount(product);
3079
+ return _this18.productHasCustomerBoundDiscount(product);
3050
3080
  });
3051
3081
  }
3052
3082
  }, {
3053
3083
  key: "clearCustomerBoundDiscounts",
3054
3084
  value: function clearCustomerBoundDiscounts(tempOrder) {
3055
- var _this18 = this,
3085
+ var _this19 = this,
3056
3086
  _discountModule$getDi,
3057
3087
  _discountModule$getOr,
3058
3088
  _discountModule$setDi,
@@ -3061,7 +3091,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3061
3091
  var filterDiscountList = function filterDiscountList(discountList) {
3062
3092
  if (!Array.isArray(discountList)) return [];
3063
3093
  return discountList.filter(function (discount) {
3064
- var shouldRemove = _this18.isCustomerBoundDiscount(discount);
3094
+ var shouldRemove = _this19.isCustomerBoundDiscount(discount);
3065
3095
  if (shouldRemove) didRemoveCustomerBoundDiscount = true;
3066
3096
  return !shouldRemove;
3067
3097
  });
@@ -3088,12 +3118,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3088
3118
  var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
3089
3119
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
3090
3120
  var nextDiscounts = currentDiscounts.filter(function (discount) {
3091
- if (_this18.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3092
- return !_this18.isCustomerBoundDiscount(discount);
3121
+ if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3122
+ return !_this19.isCustomerBoundDiscount(discount);
3093
3123
  });
3094
3124
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
3095
- if (_this18.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3096
- return !_this18.isCustomerBoundDiscount(discount);
3125
+ if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3126
+ return !_this19.isCustomerBoundDiscount(discount);
3097
3127
  });
3098
3128
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
3099
3129
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -3261,7 +3291,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3261
3291
  }, {
3262
3292
  key: "addOrderPayment",
3263
3293
  value: function addOrderPayment(payment) {
3264
- var _this19 = this;
3294
+ var _this20 = this;
3265
3295
  this.logInfo('addOrderPayment', {
3266
3296
  payment: payment
3267
3297
  });
@@ -3278,7 +3308,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3278
3308
  void this.recalculateSummary({
3279
3309
  createIfMissing: true
3280
3310
  }).catch(function (error) {
3281
- _this19.logError('recalculate summary after addOrderPayment failed', {
3311
+ _this20.logError('recalculate summary after addOrderPayment failed', {
3282
3312
  error: error instanceof Error ? error.message : String(error)
3283
3313
  });
3284
3314
  });
@@ -3360,7 +3390,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3360
3390
  }, {
3361
3391
  key: "applyPaymentLifecycleChange",
3362
3392
  value: function applyPaymentLifecycleChange(tempOrder, options) {
3363
- var _this20 = this;
3393
+ var _this21 = this;
3364
3394
  this.updateTempOrderPaymentStatus(tempOrder);
3365
3395
  if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
3366
3396
  this.persistTempOrder();
@@ -3370,7 +3400,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3370
3400
  void this.recalculateSummary({
3371
3401
  createIfMissing: true
3372
3402
  }).catch(function (error) {
3373
- _this20.logError("recalculate summary after ".concat(logContext, " failed"), {
3403
+ _this21.logError("recalculate summary after ".concat(logContext, " failed"), {
3374
3404
  error: error instanceof Error ? error.message : String(error)
3375
3405
  });
3376
3406
  });
@@ -3414,7 +3444,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3414
3444
  }, {
3415
3445
  key: "updateVoucherOrderPayments",
3416
3446
  value: function updateVoucherOrderPayments(payments, options) {
3417
- var _this21 = this;
3447
+ var _this22 = this;
3418
3448
  var tempOrder = this.ensureTempOrder();
3419
3449
  var isOrderPaymentType = function isOrderPaymentType(value) {
3420
3450
  return value === 'normal' || value === 'deposit';
@@ -3449,7 +3479,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3449
3479
  });
3450
3480
  };
3451
3481
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
3452
- return _this21.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
3482
+ return _this22.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
3453
3483
  defaultPaid: false
3454
3484
  });
3455
3485
  })).filter(function (payment) {
@@ -3498,7 +3528,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3498
3528
  void this.recalculateSummary({
3499
3529
  createIfMissing: true
3500
3530
  }).catch(function (error) {
3501
- _this21.logError('recalculate summary after updateVoucherOrderPayments failed', {
3531
+ _this22.logError('recalculate summary after updateVoucherOrderPayments failed', {
3502
3532
  error: error instanceof Error ? error.message : String(error)
3503
3533
  });
3504
3534
  });
@@ -3634,7 +3664,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3634
3664
  var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(tempOrder, product, booking) {
3635
3665
  var _booking_uid,
3636
3666
  _metadata,
3637
- _this22 = this;
3667
+ _this23 = this;
3638
3668
  var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
3639
3669
  return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3640
3670
  while (1) switch (_context19.prev = _context19.next) {
@@ -3659,8 +3689,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3659
3689
  hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
3660
3690
  shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid;
3661
3691
  matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
3662
- if (_this22.hasGoodPassDiscount(item)) return false;
3663
- if (_this22.hasOrderProductLineNote(item)) return false;
3692
+ if (_this23.hasGoodPassDiscount(item)) return false;
3693
+ if (_this23.hasOrderProductLineNote(item)) return false;
3664
3694
  if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
3665
3695
  if (item.product_id !== productToAdd.product_id) return false;
3666
3696
  if (item.product_variant_id !== productToAdd.product_variant_id) return false;
@@ -3957,17 +3987,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3957
3987
  }, {
3958
3988
  key: "preservePersistedBundlePriceFields",
3959
3989
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
3960
- var _this23 = this;
3990
+ var _this24 = this;
3961
3991
  if (!Array.isArray(nextBundles)) return nextBundles;
3962
3992
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
3963
3993
  var previousByIdentity = new Map();
3964
3994
  previousBundles.forEach(function (bundle) {
3965
- var identity = _this23.getBundleRuntimeIdentity(bundle);
3995
+ var identity = _this24.getBundleRuntimeIdentity(bundle);
3966
3996
  if (identity) previousByIdentity.set(identity, bundle);
3967
3997
  });
3968
3998
  return nextBundles.map(function (bundle, index) {
3969
3999
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
3970
- var previous = previousByIdentity.get(_this23.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
4000
+ var previous = previousByIdentity.get(_this24.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
3971
4001
  if (!previous || _typeof(previous) !== 'object') return bundle;
3972
4002
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
3973
4003
  cover: previous.cover
@@ -4159,7 +4189,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4159
4189
  key: "updateOrderProducts",
4160
4190
  value: function () {
4161
4191
  var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(paramsList) {
4162
- var _this24 = this;
4192
+ var _this25 = this;
4163
4193
  var tempOrder, reapplyBookingDiscountProductUids;
4164
4194
  return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4165
4195
  while (1) switch (_context23.prev = _context23.next) {
@@ -4172,7 +4202,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4172
4202
  return _context23.abrupt("return", tempOrder.products);
4173
4203
  case 3:
4174
4204
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
4175
- var updatedProductUid = _this24.applyOrderProductUpdateToTempOrder(tempOrder, params);
4205
+ var updatedProductUid = _this25.applyOrderProductUpdateToTempOrder(tempOrder, params);
4176
4206
  // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
4177
4207
  if (params.allow_booking_discount_reapply && updatedProductUid) {
4178
4208
  acc.push(String(updatedProductUid));
@@ -4351,7 +4381,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4351
4381
  key: "removeProductsFromOrder",
4352
4382
  value: (function () {
4353
4383
  var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identities) {
4354
- var _this25 = this;
4384
+ var _this26 = this;
4355
4385
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
4356
4386
  return _regeneratorRuntime().wrap(function _callee24$(_context27) {
4357
4387
  while (1) switch (_context27.prev = _context27.next) {
@@ -4406,7 +4436,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4406
4436
  }
4407
4437
  if (productUid !== undefined && productUid !== null && productUid !== '') {
4408
4438
  bookingsBeforeRemove.forEach(function (booking) {
4409
- var bookingUid = _this25.getBookingUniqueIdentificationNumber(booking);
4439
+ var bookingUid = _this26.getBookingUniqueIdentificationNumber(booking);
4410
4440
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
4411
4441
  linkedBookingUidsToRemove.add(bookingUid);
4412
4442
  }
@@ -4885,10 +4915,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4885
4915
  value: function extractSubmitErrorResponse(error) {
4886
4916
  var _error$response,
4887
4917
  _error$response2,
4888
- _this26 = this;
4918
+ _this27 = this;
4889
4919
  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];
4890
4920
  return candidates.find(function (candidate) {
4891
- return _this26.isSubmitErrorResponse(candidate);
4921
+ return _this27.isSubmitErrorResponse(candidate);
4892
4922
  }) || null;
4893
4923
  }
4894
4924
  }, {
@@ -4917,7 +4947,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4917
4947
  value: function () {
4918
4948
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
4919
4949
  var _params$confirmPendin;
4920
- var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, paidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
4950
+ var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
4921
4951
  return _regeneratorRuntime().wrap(function _callee32$(_context35) {
4922
4952
  while (1) switch (_context35.prev = _context35.next) {
4923
4953
  case 0:
@@ -4926,8 +4956,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4926
4956
  shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
4927
4957
  effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
4928
4958
  completion = this.getPaymentCompletion(effectivePayments);
4929
- paidPaymentTotal = this.calculatePaymentTotal(effectivePayments);
4930
- paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || 'paid' : paidPaymentTotal.gt(0) ? 'partially_paid' : 'payment_processing';
4959
+ orderPaidPaymentTotal = this.calculateOrderPaidPaymentTotal(effectivePayments);
4960
+ paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || 'paid' : orderPaidPaymentTotal.gt(0) ? 'partially_paid' : 'payment_processing';
4931
4961
  tempOrder.payments = effectivePayments;
4932
4962
  tempOrder.payment_status = paymentStatus;
4933
4963
  this.persistTempOrder();
@@ -5562,7 +5592,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5562
5592
  }, {
5563
5593
  key: "normalizeTempOrderForRuntime",
5564
5594
  value: function normalizeTempOrderForRuntime(raw, options) {
5565
- var _this27 = this;
5595
+ var _this28 = this;
5566
5596
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
5567
5597
  // ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
5568
5598
  if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (raw === null || raw === void 0 ? void 0 : raw.id) !== undefined && (raw === null || raw === void 0 ? void 0 : raw.id) !== null) {
@@ -5585,12 +5615,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5585
5615
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
5586
5616
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
5587
5617
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
5588
- return _this27.normalizeHydratedOrderProduct(p, {
5618
+ return _this28.normalizeHydratedOrderProduct(p, {
5589
5619
  makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
5590
5620
  });
5591
5621
  }) : [];
5592
5622
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
5593
- var booking = _this27.normalizeHydratedBookingHolder(b || {});
5623
+ var booking = _this28.normalizeHydratedBookingHolder(b || {});
5594
5624
  return _objectSpread(_objectSpread({}, booking), {}, {
5595
5625
  is_all: normalizeBookingIsAll(booking),
5596
5626
  sub_type: normalizeBookingSubType(booking)
@@ -5759,7 +5789,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5759
5789
  }, {
5760
5790
  key: "normalizeHydratedOrderProduct",
5761
5791
  value: function normalizeHydratedOrderProduct(product, options) {
5762
- var _this28 = this;
5792
+ var _this29 = this;
5763
5793
  var row = _objectSpread({}, product || {});
5764
5794
  if (row.num === undefined && row.product_quantity !== undefined) {
5765
5795
  row.num = row.product_quantity;
@@ -5767,7 +5797,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5767
5797
  var productSku = ensureProductSku(row);
5768
5798
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
5769
5799
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
5770
- return _this28.normalizeHydratedProductOptionItem(optionItem || {});
5800
+ return _this29.normalizeHydratedProductOptionItem(optionItem || {});
5771
5801
  }))
5772
5802
  });
5773
5803
  delete row["product_".concat('option', "_item")];
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 1 | 5 | 3 | 2 | 4 | 6;
314
+ weekNum: 0 | 2 | 1 | 6 | 3 | 4 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -441,19 +441,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
441
441
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
442
442
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
443
443
  */
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
- };
444
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
457
445
  /** 规格弹窗 callback 后的第二段决策。 */
458
446
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
459
447
  /**
@@ -1,49 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/model/strategy/adapter/promotion/index.ts
30
- var promotion_exports = {};
31
- __export(promotion_exports, {
32
- BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
- PromotionAdapter: () => import_adapter.PromotionAdapter,
34
- PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
- X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
- default: () => import_adapter2.default
37
- });
38
- module.exports = __toCommonJS(promotion_exports);
39
- var import_evaluator = require("./evaluator");
40
- var import_adapter = require("./adapter");
41
- var import_adapter2 = __toESM(require("./adapter"));
42
- var import_examples = require("./examples");
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- BUY_X_GET_Y_FREE_STRATEGY,
46
- PromotionAdapter,
47
- PromotionEvaluator,
48
- X_ITEMS_FOR_Y_PRICE_STRATEGY
49
- });
@@ -155,6 +155,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
155
155
  private extractOrderIdFromSubmitResult;
156
156
  private calculatePaymentEffectiveAmount;
157
157
  private calculatePaymentTotal;
158
+ private calculateOrderPaidPaymentTotal;
158
159
  private getDepositAmount;
159
160
  private normalizeDepositAmount;
160
161
  private getLastOrderDepositSnapshot;
@@ -183,6 +184,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
183
184
  private calculatePaidPaymentSummary;
184
185
  private calculatePaymentServiceFee;
185
186
  private calculatePaymentGapAmount;
187
+ private calculatePaymentOrderAmount;
186
188
  private calculatePaymentRoundingAmount;
187
189
  private formatSummaryMetadataMoney;
188
190
  private syncSummaryProductMetadata;
@@ -465,7 +467,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
465
467
  generateIdempotencyToken(): string;
466
468
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
467
469
  createOrder(params: CommitOrderParams['query']): {
468
- type: "appointment_booking" | "virtual";
470
+ type: "virtual" | "appointment_booking";
469
471
  platform: string;
470
472
  sales_channel: string;
471
473
  order_sales_channel: string;
@@ -902,6 +902,15 @@ var OrderModule = class extends import_BaseModule.BaseModule {
902
902
  return sum.plus(this.calculatePaymentEffectiveAmount(payment));
903
903
  }, new import_decimal.default(0));
904
904
  }
905
+ calculateOrderPaidPaymentTotal(payments) {
906
+ return (0, import_utils.mapPaymentItemsToOrderPayments)(payments, {
907
+ includeVoided: false
908
+ }).reduce((sum, payment) => {
909
+ if (!isPaidPaymentRecord(payment))
910
+ return sum;
911
+ return sum.plus(this.calculatePaymentGapAmount(payment));
912
+ }, new import_decimal.default(0));
913
+ }
905
914
  getDepositAmount(tempOrder, summary) {
906
915
  return new import_decimal.default(summary.deposit_amount || tempOrder.deposit_amount || "0.00");
907
916
  }
@@ -992,7 +1001,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
992
1001
  const paymentList = payments || tempOrder.payments || [];
993
1002
  const refundAmount = this.getSummaryRefundAmount(summary);
994
1003
  const netPaidAmount = import_decimal.default.max(
995
- this.calculatePaymentTotal(paymentList).minus(refundAmount),
1004
+ this.calculateOrderPaidPaymentTotal(paymentList).minus(refundAmount),
996
1005
  0
997
1006
  );
998
1007
  const depositAmount = this.getDepositAmount(tempOrder, summary);
@@ -1021,11 +1030,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1021
1030
  const isDepositPayment = paymentRecord.type === "deposit" || paymentRecord.order_payment_type === "deposit";
1022
1031
  if (!isDepositPayment)
1023
1032
  return sum;
1024
- if (paymentRecord.origin_amount !== void 0 && paymentRecord.origin_amount !== null && paymentRecord.origin_amount !== "") {
1025
- return sum.plus(this.calculatePaymentGapAmount(paymentRecord));
1026
- }
1027
- const rounding = new import_decimal.default(paymentRecord.rounding_amount || 0);
1028
- return sum.plus(new import_decimal.default(paymentRecord.amount || 0).minus(rounding));
1033
+ return sum.plus(this.calculatePaymentGapAmount(paymentRecord));
1029
1034
  }, new import_decimal.default(0));
1030
1035
  }
1031
1036
  resolveNextOrderPaymentType(tempOrder) {
@@ -1058,8 +1063,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1058
1063
  updateTempOrderPaymentStatus(tempOrder, options) {
1059
1064
  const summary = (options == null ? void 0 : options.summary) || this.store.summary || (0, import_utils.createEmptySummary)();
1060
1065
  const paymentTotal = this.calculatePaymentTotal(tempOrder.payments || []);
1066
+ const orderPaymentTotal = this.calculateOrderPaidPaymentTotal(tempOrder.payments || []);
1061
1067
  const refundAmount = this.getSummaryRefundAmount(summary);
1062
- const netPaymentTotal = import_decimal.default.max(paymentTotal.minus(refundAmount), 0);
1068
+ const netPaymentTotal = import_decimal.default.max(orderPaymentTotal.minus(refundAmount), 0);
1063
1069
  const targetAmount = this.calculatePaymentTargetAmount(
1064
1070
  tempOrder,
1065
1071
  summary,
@@ -1128,7 +1134,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1128
1134
  }
1129
1135
  capVoucherPaymentsByRemainingAmount(params) {
1130
1136
  const targetAmount = this.getPaymentTargetAmount();
1131
- const nonVoucherTotal = this.calculatePaymentTotal(params.nonVoucherPayments);
1137
+ const nonVoucherTotal = this.calculateOrderPaidPaymentTotal(params.nonVoucherPayments);
1132
1138
  if (targetAmount.lte(0))
1133
1139
  return [];
1134
1140
  let remainingAmount = import_decimal.default.max(
@@ -1171,7 +1177,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1171
1177
  return summary;
1172
1178
  return {
1173
1179
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
1174
- orderPaidAmount: summary.orderPaidAmount.plus(paymentRecord.origin_amount || 0),
1180
+ orderPaidAmount: summary.orderPaidAmount.plus(this.calculatePaymentOrderAmount(paymentRecord)),
1175
1181
  gapPaidAmount: summary.gapPaidAmount.plus(this.calculatePaymentGapAmount(paymentRecord)),
1176
1182
  payServiceChargeAmount: summary.payServiceChargeAmount.plus(this.calculatePaymentServiceFee(paymentRecord)),
1177
1183
  roundingAmount: summary.roundingAmount.plus(this.calculatePaymentRoundingAmount(paymentRecord))
@@ -1196,11 +1202,30 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1196
1202
  return new import_decimal.default(payment.amount || 0).times(percentage).plus(fixedAmount);
1197
1203
  }
1198
1204
  calculatePaymentGapAmount(payment) {
1199
- if (payment.origin_amount === void 0 || payment.origin_amount === null || payment.origin_amount === "") {
1200
- return new import_decimal.default(0);
1205
+ if (payment.origin_amount !== void 0 && payment.origin_amount !== null && payment.origin_amount !== "") {
1206
+ const rounding2 = new import_decimal.default(payment.rounding_amount || 0);
1207
+ return new import_decimal.default(payment.origin_amount || 0).minus(rounding2);
1201
1208
  }
1202
1209
  const rounding = new import_decimal.default(payment.rounding_amount || 0);
1203
- return new import_decimal.default(payment.origin_amount || 0).minus(rounding);
1210
+ const amount = new import_decimal.default(payment.amount || 0);
1211
+ const serviceFee = this.calculatePaymentServiceFee(payment);
1212
+ if (serviceFee.lte(0))
1213
+ return amount.minus(rounding);
1214
+ if (!hasSyncedOrderPaymentRecord(payment))
1215
+ return new import_decimal.default(0);
1216
+ return import_decimal.default.max(amount.minus(serviceFee), 0).minus(rounding);
1217
+ }
1218
+ calculatePaymentOrderAmount(payment) {
1219
+ if (payment.origin_amount !== void 0 && payment.origin_amount !== null && payment.origin_amount !== "") {
1220
+ return new import_decimal.default(payment.origin_amount || 0);
1221
+ }
1222
+ const amount = new import_decimal.default(payment.amount || 0);
1223
+ const serviceFee = this.calculatePaymentServiceFee(payment);
1224
+ if (serviceFee.lte(0))
1225
+ return amount;
1226
+ if (!hasSyncedOrderPaymentRecord(payment))
1227
+ return new import_decimal.default(0);
1228
+ return import_decimal.default.max(amount.minus(serviceFee), 0);
1204
1229
  }
1205
1230
  calculatePaymentRoundingAmount(payment) {
1206
1231
  if (payment.rounding_amount === void 0 || payment.rounding_amount === null || payment.rounding_amount === "") {
@@ -1548,7 +1573,12 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1548
1573
  tempOrder.surcharge_fee = summary.surcharge_fee || tempOrder.surcharge_fee;
1549
1574
  tempOrder.deposit_amount = summary.deposit_amount || "0.00";
1550
1575
  tempOrder.is_deposit = summary.deposit_amount !== "0.00" ? 1 : 0;
1576
+ const previousSummary = this.store.summary;
1551
1577
  this.store.summary = summary;
1578
+ this.updateTempOrderPaymentStatus(tempOrder, {
1579
+ previousSummary,
1580
+ summary
1581
+ });
1552
1582
  return summary;
1553
1583
  }
1554
1584
  clearPersistedAmountFieldsForFullRecalc(products) {
@@ -3659,8 +3689,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
3659
3689
  const shouldConfirmPendingVoucherPayments = params.confirmPendingVoucherPayments ?? params.submitWhenPaid === true;
3660
3690
  const effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
3661
3691
  const completion = this.getPaymentCompletion(effectivePayments);
3662
- const paidPaymentTotal = this.calculatePaymentTotal(effectivePayments);
3663
- const paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || "paid" : paidPaymentTotal.gt(0) ? "partially_paid" : "payment_processing";
3692
+ const orderPaidPaymentTotal = this.calculateOrderPaidPaymentTotal(effectivePayments);
3693
+ const paymentStatus = completion.isOrderFullyPaid ? params.paymentStatus || "paid" : orderPaidPaymentTotal.gt(0) ? "partially_paid" : "payment_processing";
3664
3694
  tempOrder.payments = effectivePayments;
3665
3695
  tempOrder.payment_status = paymentStatus;
3666
3696
  this.persistTempOrder();
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 1 | 5 | 3 | 2 | 4 | 6;
314
+ weekNum: 0 | 2 | 1 | 6 | 3 | 4 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -441,19 +441,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
441
441
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
442
442
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
443
443
  */
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
- };
444
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
457
445
  /** 规格弹窗 callback 后的第二段决策。 */
458
446
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
459
447
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.25",
4
+ "version": "2.3.26",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",