@pisell/pisellos 0.0.245 → 0.0.247
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.
- package/dist/modules/Payment/index.js +8 -3
- package/dist/modules/Payment/types.d.ts +4 -0
- package/dist/solution/Checkout/index.js +122 -115
- package/dist/solution/Checkout/types.d.ts +20 -1
- package/dist/solution/Checkout/types.js +1 -0
- package/lib/modules/Payment/index.js +8 -3
- package/lib/modules/Payment/types.d.ts +4 -0
- package/lib/solution/Checkout/index.js +43 -14
- package/lib/solution/Checkout/types.d.ts +20 -1
- package/lib/solution/Checkout/types.js +1 -0
- package/package.json +1 -1
|
@@ -1037,7 +1037,8 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1037
1037
|
this.logInfo('Starting addPaymentItemAsync', {
|
|
1038
1038
|
orderUuid: orderUuid,
|
|
1039
1039
|
paymentAmount: paymentItem.amount,
|
|
1040
|
-
paymentCode: paymentItem.code
|
|
1040
|
+
paymentCode: paymentItem.code,
|
|
1041
|
+
orderPaymentType: paymentItem.order_payment_type
|
|
1041
1042
|
});
|
|
1042
1043
|
_context13.prev = 1;
|
|
1043
1044
|
_context13.next = 4;
|
|
@@ -1063,6 +1064,8 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1063
1064
|
service_charge: paymentItem.service_charge,
|
|
1064
1065
|
status: 'active',
|
|
1065
1066
|
// 新支付项默认为活跃状态
|
|
1067
|
+
order_payment_type: paymentItem.order_payment_type || 'normal',
|
|
1068
|
+
// 默认为正常支付
|
|
1066
1069
|
metadata: {
|
|
1067
1070
|
unique_payment_number: paymentUuid // 设置唯一支付号为支付项的 uuid
|
|
1068
1071
|
}
|
|
@@ -1230,7 +1233,8 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1230
1233
|
return {
|
|
1231
1234
|
code: item.code,
|
|
1232
1235
|
amount: item.amount,
|
|
1233
|
-
voucher_id: item.voucher_id
|
|
1236
|
+
voucher_id: item.voucher_id,
|
|
1237
|
+
order_payment_type: item.order_payment_type
|
|
1234
1238
|
};
|
|
1235
1239
|
})
|
|
1236
1240
|
});
|
|
@@ -1313,7 +1317,8 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1313
1317
|
console.log("[PaymentModule] \u6DFB\u52A0\u4EE3\u91D1\u5238\u652F\u4ED8\u9879:", {
|
|
1314
1318
|
code: _voucherItem.code,
|
|
1315
1319
|
amount: _voucherItem.amount,
|
|
1316
|
-
voucher_id: _voucherItem.voucher_id
|
|
1320
|
+
voucher_id: _voucherItem.voucher_id,
|
|
1321
|
+
order_payment_type: _voucherItem.order_payment_type
|
|
1317
1322
|
});
|
|
1318
1323
|
_context15.next = 38;
|
|
1319
1324
|
return this.addPaymentItemAsync(orderUuid, _voucherItem);
|
|
@@ -123,6 +123,8 @@ export interface PaymentItem {
|
|
|
123
123
|
status?: 'active' | 'voided';
|
|
124
124
|
/** 原始金额(用于记录撤销前的金额) */
|
|
125
125
|
origin_amount?: string;
|
|
126
|
+
/** 订单支付类型 */
|
|
127
|
+
order_payment_type?: 'normal' | 'deposit';
|
|
126
128
|
}
|
|
127
129
|
/**
|
|
128
130
|
* 订单信息
|
|
@@ -218,6 +220,8 @@ export interface PaymentItemInput {
|
|
|
218
220
|
};
|
|
219
221
|
/** 舍入金额 */
|
|
220
222
|
rounding_amount?: string;
|
|
223
|
+
/** 订单支付类型 */
|
|
224
|
+
order_payment_type?: 'normal' | 'deposit';
|
|
221
225
|
}
|
|
222
226
|
/**
|
|
223
227
|
* 推送支付项参数
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -343,7 +342,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
343
342
|
key: "initWalletData",
|
|
344
343
|
value: function () {
|
|
345
344
|
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
346
|
-
var _this$store$currentOr3, _this$store$currentCu;
|
|
345
|
+
var _this$store$currentOr3, _this$store$currentCu, _this$store$currentOr4;
|
|
347
346
|
var amountInfo, walletBusinessData;
|
|
348
347
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
349
348
|
while (1) switch (_context8.prev = _context8.next) {
|
|
@@ -367,6 +366,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
367
366
|
_context8.next = 6;
|
|
368
367
|
return this.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
369
368
|
case 6:
|
|
369
|
+
_context8.next = 8;
|
|
370
|
+
return this.core.effects.emit(CheckoutHooks.OnWalletDataInitialized, {
|
|
371
|
+
orderUuid: (_this$store$currentOr4 = this.store.currentOrder) === null || _this$store$currentOr4 === void 0 ? void 0 : _this$store$currentOr4.uuid,
|
|
372
|
+
customerId: walletBusinessData.customer_id,
|
|
373
|
+
walletBusinessData: {
|
|
374
|
+
customer_id: walletBusinessData.customer_id,
|
|
375
|
+
amountInfo: walletBusinessData.amountInfo,
|
|
376
|
+
order_wait_pay_amount: params === null || params === void 0 ? void 0 : params.order_wait_pay_amount
|
|
377
|
+
},
|
|
378
|
+
timestamp: Date.now()
|
|
379
|
+
});
|
|
380
|
+
case 8:
|
|
370
381
|
case "end":
|
|
371
382
|
return _context8.stop();
|
|
372
383
|
}
|
|
@@ -981,12 +992,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
981
992
|
key: "getCheckoutSummaryAsync",
|
|
982
993
|
value: (function () {
|
|
983
994
|
var _getCheckoutSummaryAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
984
|
-
var _this$store$
|
|
995
|
+
var _this$store$currentOr5, _this$store$currentOr6;
|
|
985
996
|
var totalAmount, paidAmount, remainingAmount;
|
|
986
997
|
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
987
998
|
while (1) switch (_context15.prev = _context15.next) {
|
|
988
999
|
case 0:
|
|
989
|
-
totalAmount = ((_this$store$
|
|
1000
|
+
totalAmount = ((_this$store$currentOr5 = this.store.currentOrder) === null || _this$store$currentOr5 === void 0 ? void 0 : _this$store$currentOr5.total_amount) || '0.00';
|
|
990
1001
|
_context15.next = 3;
|
|
991
1002
|
return this.calculatePaidAmountAsync();
|
|
992
1003
|
case 3:
|
|
@@ -1000,7 +1011,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1000
1011
|
totalAmount: totalAmount,
|
|
1001
1012
|
paidAmount: paidAmount,
|
|
1002
1013
|
remainingAmount: remainingAmount,
|
|
1003
|
-
paymentStatus: ((_this$store$
|
|
1014
|
+
paymentStatus: ((_this$store$currentOr6 = this.store.currentOrder) === null || _this$store$currentOr6 === void 0 ? void 0 : _this$store$currentOr6.payment_status) || PaymentStatus.Processing,
|
|
1004
1015
|
availablePaymentMethods: this.store.paymentMethods
|
|
1005
1016
|
});
|
|
1006
1017
|
case 8:
|
|
@@ -1087,8 +1098,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1087
1098
|
}, {
|
|
1088
1099
|
key: "getOrderOriginalData",
|
|
1089
1100
|
value: function getOrderOriginalData() {
|
|
1090
|
-
var _this$store$
|
|
1091
|
-
return (_this$store$
|
|
1101
|
+
var _this$store$currentOr7;
|
|
1102
|
+
return (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.order_info;
|
|
1092
1103
|
}
|
|
1093
1104
|
|
|
1094
1105
|
/**
|
|
@@ -1649,7 +1660,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1649
1660
|
key: "addPaymentItemAsync",
|
|
1650
1661
|
value: (function () {
|
|
1651
1662
|
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(paymentItem) {
|
|
1652
|
-
var _paymentItem$type, _paymentItem$code, isEftposPayment;
|
|
1663
|
+
var _paymentItem$type, _paymentItem$code, orderPaymentType, paymentItemWithType, isEftposPayment;
|
|
1653
1664
|
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1654
1665
|
while (1) switch (_context25.prev = _context25.next) {
|
|
1655
1666
|
case 0:
|
|
@@ -1660,23 +1671,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1660
1671
|
}
|
|
1661
1672
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法添加支付项');
|
|
1662
1673
|
case 3:
|
|
1674
|
+
// 根据当前订单的定金状态设置订单支付类型
|
|
1675
|
+
orderPaymentType = this.store.currentOrder.is_deposit === 1 ? 'deposit' : 'normal'; // 设置支付项的订单支付类型
|
|
1676
|
+
paymentItemWithType = _objectSpread(_objectSpread({}, paymentItem), {}, {
|
|
1677
|
+
order_payment_type: orderPaymentType
|
|
1678
|
+
});
|
|
1663
1679
|
console.log('[Checkout] 为当前订单添加支付项:', {
|
|
1664
1680
|
orderUuid: this.store.currentOrder.uuid,
|
|
1665
1681
|
paymentItem: {
|
|
1666
|
-
code:
|
|
1667
|
-
name:
|
|
1668
|
-
type:
|
|
1669
|
-
amount:
|
|
1670
|
-
service_charge:
|
|
1671
|
-
rounding_amount:
|
|
1672
|
-
voucher_id:
|
|
1673
|
-
|
|
1682
|
+
code: paymentItemWithType.code,
|
|
1683
|
+
name: paymentItemWithType.name,
|
|
1684
|
+
type: paymentItemWithType.type,
|
|
1685
|
+
amount: paymentItemWithType.amount,
|
|
1686
|
+
service_charge: paymentItemWithType.service_charge,
|
|
1687
|
+
rounding_amount: paymentItemWithType.rounding_amount,
|
|
1688
|
+
voucher_id: paymentItemWithType.voucher_id,
|
|
1689
|
+
order_payment_type: paymentItemWithType.order_payment_type
|
|
1690
|
+
},
|
|
1691
|
+
orderDepositStatus: this.store.currentOrder.is_deposit,
|
|
1692
|
+
calculatedOrderPaymentType: orderPaymentType
|
|
1674
1693
|
});
|
|
1675
1694
|
|
|
1676
1695
|
// 添加支付项到订单
|
|
1677
|
-
_context25.next =
|
|
1678
|
-
return this.payment.addPaymentItemAsync(this.store.currentOrder.uuid,
|
|
1679
|
-
case
|
|
1696
|
+
_context25.next = 8;
|
|
1697
|
+
return this.payment.addPaymentItemAsync(this.store.currentOrder.uuid, paymentItemWithType);
|
|
1698
|
+
case 8:
|
|
1680
1699
|
console.log('[Checkout] 支付项添加成功');
|
|
1681
1700
|
|
|
1682
1701
|
// 检查是否是 EFTPOS 支付,如果是则立即同步订单
|
|
@@ -1688,54 +1707,54 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1688
1707
|
currentOrderSynced: this.store.isOrderSynced
|
|
1689
1708
|
});
|
|
1690
1709
|
if (!isEftposPayment) {
|
|
1691
|
-
_context25.next =
|
|
1710
|
+
_context25.next = 24;
|
|
1692
1711
|
break;
|
|
1693
1712
|
}
|
|
1694
1713
|
console.log('[Checkout] 检测到 EFTPOS 支付,立即同步订单到后端...');
|
|
1695
|
-
_context25.prev =
|
|
1696
|
-
_context25.next =
|
|
1714
|
+
_context25.prev = 13;
|
|
1715
|
+
_context25.next = 16;
|
|
1697
1716
|
return this.syncOrderToBackendWithReturn(true);
|
|
1698
|
-
case
|
|
1717
|
+
case 16:
|
|
1699
1718
|
console.log('[Checkout] EFTPOS 支付后订单同步完成 (已标记为手动同步):', {
|
|
1700
1719
|
订单ID: this.store.currentOrder.order_id,
|
|
1701
1720
|
是否已同步: this.store.isOrderSynced
|
|
1702
1721
|
});
|
|
1703
|
-
_context25.next =
|
|
1722
|
+
_context25.next = 24;
|
|
1704
1723
|
break;
|
|
1705
|
-
case
|
|
1706
|
-
_context25.prev =
|
|
1707
|
-
_context25.t0 = _context25["catch"](
|
|
1724
|
+
case 19:
|
|
1725
|
+
_context25.prev = 19;
|
|
1726
|
+
_context25.t0 = _context25["catch"](13);
|
|
1708
1727
|
console.error('[Checkout] EFTPOS 支付后订单同步失败:', _context25.t0);
|
|
1709
1728
|
// 不抛出错误,避免影响支付流程,但记录错误
|
|
1710
|
-
_context25.next = 22;
|
|
1711
|
-
return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context25.t0 instanceof Error ? _context25.t0.message : String(_context25.t0))), CheckoutErrorType.OrderCreationFailed);
|
|
1712
|
-
case 22:
|
|
1713
1729
|
_context25.next = 24;
|
|
1714
|
-
return this.
|
|
1730
|
+
return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context25.t0 instanceof Error ? _context25.t0.message : String(_context25.t0))), CheckoutErrorType.OrderCreationFailed);
|
|
1715
1731
|
case 24:
|
|
1716
1732
|
_context25.next = 26;
|
|
1733
|
+
return this.updateStateAmountToRemaining();
|
|
1734
|
+
case 26:
|
|
1735
|
+
_context25.next = 28;
|
|
1717
1736
|
return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
|
|
1718
1737
|
orderUuid: this.store.currentOrder.uuid,
|
|
1719
1738
|
paymentMethodCode: paymentItem.code,
|
|
1720
1739
|
amount: String(paymentItem.amount),
|
|
1721
1740
|
timestamp: Date.now()
|
|
1722
1741
|
});
|
|
1723
|
-
case 26:
|
|
1724
|
-
_context25.next = 34;
|
|
1725
|
-
break;
|
|
1726
1742
|
case 28:
|
|
1727
|
-
_context25.
|
|
1743
|
+
_context25.next = 36;
|
|
1744
|
+
break;
|
|
1745
|
+
case 30:
|
|
1746
|
+
_context25.prev = 30;
|
|
1728
1747
|
_context25.t1 = _context25["catch"](0);
|
|
1729
1748
|
console.error('[Checkout] 添加支付项失败:', _context25.t1);
|
|
1730
|
-
_context25.next =
|
|
1749
|
+
_context25.next = 35;
|
|
1731
1750
|
return this.handleError(_context25.t1, CheckoutErrorType.PaymentFailed);
|
|
1732
|
-
case
|
|
1751
|
+
case 35:
|
|
1733
1752
|
throw _context25.t1;
|
|
1734
|
-
case
|
|
1753
|
+
case 36:
|
|
1735
1754
|
case "end":
|
|
1736
1755
|
return _context25.stop();
|
|
1737
1756
|
}
|
|
1738
|
-
}, _callee25, this, [[0,
|
|
1757
|
+
}, _callee25, this, [[0, 30], [13, 19]]);
|
|
1739
1758
|
}));
|
|
1740
1759
|
function addPaymentItemAsync(_x16) {
|
|
1741
1760
|
return _addPaymentItemAsync.apply(this, arguments);
|
|
@@ -1870,7 +1889,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1870
1889
|
key: "updateVoucherPaymentItemsAsync",
|
|
1871
1890
|
value: (function () {
|
|
1872
1891
|
var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(voucherPaymentItems) {
|
|
1873
|
-
var
|
|
1892
|
+
var orderPaymentType, voucherPaymentItemsWithType, currentOrderId, isCurrentOrderReal, updatedOrder, voucherItems;
|
|
1874
1893
|
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1875
1894
|
while (1) switch (_context27.prev = _context27.next) {
|
|
1876
1895
|
case 0:
|
|
@@ -1887,47 +1906,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1887
1906
|
voucherPaymentItems: voucherPaymentItems
|
|
1888
1907
|
});
|
|
1889
1908
|
|
|
1890
|
-
//
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
break;
|
|
1911
|
-
case 15:
|
|
1912
|
-
_context27.prev = 15;
|
|
1913
|
-
_context27.t0 = _context27["catch"](5);
|
|
1914
|
-
_iterator.e(_context27.t0);
|
|
1915
|
-
case 18:
|
|
1916
|
-
_context27.prev = 18;
|
|
1917
|
-
_iterator.f();
|
|
1918
|
-
return _context27.finish(18);
|
|
1919
|
-
case 21:
|
|
1920
|
-
_context27.next = 23;
|
|
1921
|
-
return this.payment.updateVoucherPaymentItemsAsync(this.store.currentOrder.uuid, voucherPaymentItems);
|
|
1922
|
-
case 23:
|
|
1909
|
+
// 根据当前订单的定金状态设置订单支付类型
|
|
1910
|
+
orderPaymentType = this.store.currentOrder.is_deposit === 1 ? 'deposit' : 'normal'; // 验证所有支付项都包含 voucher_id,并设置 order_payment_type
|
|
1911
|
+
voucherPaymentItemsWithType = voucherPaymentItems.map(function (item) {
|
|
1912
|
+
if (!item.voucher_id) {
|
|
1913
|
+
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u7F3A\u5C11 voucher_id: ".concat(JSON.stringify(item)));
|
|
1914
|
+
}
|
|
1915
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
1916
|
+
order_payment_type: orderPaymentType
|
|
1917
|
+
});
|
|
1918
|
+
});
|
|
1919
|
+
console.log('[Checkout] 代金券支付项订单支付类型设置:', {
|
|
1920
|
+
orderDepositStatus: this.store.currentOrder.is_deposit,
|
|
1921
|
+
calculatedOrderPaymentType: orderPaymentType,
|
|
1922
|
+
itemsCount: voucherPaymentItemsWithType.length
|
|
1923
|
+
});
|
|
1924
|
+
|
|
1925
|
+
// 调用 Payment 模块的批量更新方法
|
|
1926
|
+
_context27.next = 9;
|
|
1927
|
+
return this.payment.updateVoucherPaymentItemsAsync(this.store.currentOrder.uuid, voucherPaymentItemsWithType);
|
|
1928
|
+
case 9:
|
|
1923
1929
|
console.log('[Checkout] Payment模块批量更新完成');
|
|
1924
1930
|
|
|
1925
1931
|
// 重新从Payment模块获取最新的订单数据,确保支付项同步
|
|
1926
1932
|
currentOrderId = this.store.currentOrder.order_id; // 保存当前的订单ID
|
|
1927
1933
|
isCurrentOrderReal = currentOrderId && !this.isVirtualOrderId(currentOrderId);
|
|
1928
|
-
_context27.next =
|
|
1934
|
+
_context27.next = 14;
|
|
1929
1935
|
return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
|
|
1930
|
-
case
|
|
1936
|
+
case 14:
|
|
1931
1937
|
updatedOrder = _context27.sent;
|
|
1932
1938
|
if (updatedOrder) {
|
|
1933
1939
|
// 如果当前订单ID是真实ID,但获取到的订单ID是虚拟ID,需要保护真实ID
|
|
@@ -1959,10 +1965,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1959
1965
|
}
|
|
1960
1966
|
|
|
1961
1967
|
// 更新 stateAmount 为剩余未支付金额
|
|
1962
|
-
_context27.next =
|
|
1968
|
+
_context27.next = 18;
|
|
1963
1969
|
return this.updateStateAmountToRemaining();
|
|
1964
|
-
case
|
|
1965
|
-
_context27.next =
|
|
1970
|
+
case 18:
|
|
1971
|
+
_context27.next = 20;
|
|
1966
1972
|
return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
|
|
1967
1973
|
orderUuid: this.store.currentOrder.uuid,
|
|
1968
1974
|
paymentMethodCode: 'VOUCHER_BATCH',
|
|
@@ -1971,23 +1977,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1971
1977
|
}, 0).toFixed(2),
|
|
1972
1978
|
timestamp: Date.now()
|
|
1973
1979
|
});
|
|
1974
|
-
case
|
|
1980
|
+
case 20:
|
|
1975
1981
|
console.log('[Checkout] 代金券支付项批量更新成功');
|
|
1976
|
-
_context27.next =
|
|
1982
|
+
_context27.next = 29;
|
|
1977
1983
|
break;
|
|
1978
|
-
case
|
|
1979
|
-
_context27.prev =
|
|
1980
|
-
_context27.
|
|
1981
|
-
console.error('[Checkout] 批量更新代金券支付项失败:', _context27.
|
|
1982
|
-
_context27.next =
|
|
1983
|
-
return this.handleError(_context27.
|
|
1984
|
-
case
|
|
1985
|
-
throw _context27.
|
|
1986
|
-
case
|
|
1984
|
+
case 23:
|
|
1985
|
+
_context27.prev = 23;
|
|
1986
|
+
_context27.t0 = _context27["catch"](0);
|
|
1987
|
+
console.error('[Checkout] 批量更新代金券支付项失败:', _context27.t0);
|
|
1988
|
+
_context27.next = 28;
|
|
1989
|
+
return this.handleError(_context27.t0, CheckoutErrorType.PaymentFailed);
|
|
1990
|
+
case 28:
|
|
1991
|
+
throw _context27.t0;
|
|
1992
|
+
case 29:
|
|
1987
1993
|
case "end":
|
|
1988
1994
|
return _context27.stop();
|
|
1989
1995
|
}
|
|
1990
|
-
}, _callee27, this, [[0,
|
|
1996
|
+
}, _callee27, this, [[0, 23]]);
|
|
1991
1997
|
}));
|
|
1992
1998
|
function updateVoucherPaymentItemsAsync(_x18) {
|
|
1993
1999
|
return _updateVoucherPaymentItemsAsync.apply(this, arguments);
|
|
@@ -2250,7 +2256,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2250
2256
|
key: "manualSyncOrderAsync",
|
|
2251
2257
|
value: (function () {
|
|
2252
2258
|
var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
2253
|
-
var orderUuid, oldOrderId, realOrderId, finalOrderId, finalIsVirtual, _this$store$
|
|
2259
|
+
var orderUuid, oldOrderId, realOrderId, finalOrderId, finalIsVirtual, _this$store$currentOr8, errorMessage;
|
|
2254
2260
|
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2255
2261
|
while (1) switch (_context31.prev = _context31.next) {
|
|
2256
2262
|
case 0:
|
|
@@ -2326,7 +2332,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2326
2332
|
return _context31.abrupt("return", {
|
|
2327
2333
|
success: false,
|
|
2328
2334
|
message: "\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(errorMessage),
|
|
2329
|
-
orderUuid: (_this$store$
|
|
2335
|
+
orderUuid: (_this$store$currentOr8 = this.store.currentOrder) === null || _this$store$currentOr8 === void 0 ? void 0 : _this$store$currentOr8.uuid
|
|
2330
2336
|
});
|
|
2331
2337
|
case 32:
|
|
2332
2338
|
case "end":
|
|
@@ -2403,15 +2409,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2403
2409
|
key: "cancelCurrentOrderAsync",
|
|
2404
2410
|
value: (function () {
|
|
2405
2411
|
var _cancelCurrentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(cancelReason) {
|
|
2406
|
-
var _this$store$
|
|
2412
|
+
var _this$store$currentOr9, _this$store$currentOr10, currentOrderUuid, currentOrderId, isOrderSynced, errorMessage;
|
|
2407
2413
|
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2408
2414
|
while (1) switch (_context32.prev = _context32.next) {
|
|
2409
2415
|
case 0:
|
|
2410
2416
|
_context32.prev = 0;
|
|
2411
2417
|
console.log('[Checkout] 开始取消当前本地订单:', {
|
|
2412
2418
|
hasCurrentOrder: !!this.store.currentOrder,
|
|
2413
|
-
orderUuid: (_this$store$
|
|
2414
|
-
orderId: (_this$store$
|
|
2419
|
+
orderUuid: (_this$store$currentOr9 = this.store.currentOrder) === null || _this$store$currentOr9 === void 0 ? void 0 : _this$store$currentOr9.uuid,
|
|
2420
|
+
orderId: (_this$store$currentOr10 = this.store.currentOrder) === null || _this$store$currentOr10 === void 0 ? void 0 : _this$store$currentOr10.order_id,
|
|
2415
2421
|
isOrderSynced: this.store.isOrderSynced,
|
|
2416
2422
|
cancelReason: cancelReason
|
|
2417
2423
|
});
|
|
@@ -2525,7 +2531,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2525
2531
|
key: "saveForLaterPaymentAsync",
|
|
2526
2532
|
value: (function () {
|
|
2527
2533
|
var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
2528
|
-
var orderUuid, currentOrderId, allPaymentItems, filteredPaymentItems, voucherItems, realOrderId, finalOrderId, _this$store$
|
|
2534
|
+
var orderUuid, currentOrderId, allPaymentItems, filteredPaymentItems, voucherItems, realOrderId, finalOrderId, _this$store$currentOr11, errorMessage;
|
|
2529
2535
|
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2530
2536
|
while (1) switch (_context33.prev = _context33.next) {
|
|
2531
2537
|
case 0:
|
|
@@ -2615,7 +2621,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2615
2621
|
return _context33.abrupt("return", {
|
|
2616
2622
|
success: false,
|
|
2617
2623
|
message: "\u8BA2\u5355\u4FDD\u5B58\u5931\u8D25: ".concat(errorMessage),
|
|
2618
|
-
orderUuid: (_this$store$
|
|
2624
|
+
orderUuid: (_this$store$currentOr11 = this.store.currentOrder) === null || _this$store$currentOr11 === void 0 ? void 0 : _this$store$currentOr11.uuid
|
|
2619
2625
|
});
|
|
2620
2626
|
case 26:
|
|
2621
2627
|
case "end":
|
|
@@ -2666,14 +2672,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2666
2672
|
key: "updateShopDiscountAsync",
|
|
2667
2673
|
value: (function () {
|
|
2668
2674
|
var _updateShopDiscountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(discountAmount) {
|
|
2669
|
-
var _this$store$
|
|
2675
|
+
var _this$store$currentOr12, _this$store$currentOr13, oldDiscount, shopDiscountItem, updatedAmountInfo;
|
|
2670
2676
|
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2671
2677
|
while (1) switch (_context34.prev = _context34.next) {
|
|
2672
2678
|
case 0:
|
|
2673
2679
|
_context34.prev = 0;
|
|
2674
2680
|
oldDiscount = this.getShopDiscount();
|
|
2675
2681
|
console.log('[Checkout] 更新商店折扣:', {
|
|
2676
|
-
orderUuid: (_this$store$
|
|
2682
|
+
orderUuid: (_this$store$currentOr12 = this.store.currentOrder) === null || _this$store$currentOr12 === void 0 ? void 0 : _this$store$currentOr12.uuid,
|
|
2677
2683
|
oldDiscount: oldDiscount,
|
|
2678
2684
|
newDiscount: discountAmount
|
|
2679
2685
|
});
|
|
@@ -2723,7 +2729,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2723
2729
|
case 8:
|
|
2724
2730
|
_context34.next = 10;
|
|
2725
2731
|
return this.core.effects.emit(CheckoutHooks.OnShopDiscountChanged, {
|
|
2726
|
-
orderUuid: (_this$store$
|
|
2732
|
+
orderUuid: (_this$store$currentOr13 = this.store.currentOrder) === null || _this$store$currentOr13 === void 0 ? void 0 : _this$store$currentOr13.uuid,
|
|
2727
2733
|
oldDiscount: oldDiscount,
|
|
2728
2734
|
newDiscount: discountAmount,
|
|
2729
2735
|
timestamp: Date.now()
|
|
@@ -2764,7 +2770,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2764
2770
|
key: "updateOrderNoteAsync",
|
|
2765
2771
|
value: (function () {
|
|
2766
2772
|
var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(note) {
|
|
2767
|
-
var _this$store$
|
|
2773
|
+
var _this$store$currentOr14, _this$store$currentOr15, oldNote, orderInPayment;
|
|
2768
2774
|
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2769
2775
|
while (1) switch (_context35.prev = _context35.next) {
|
|
2770
2776
|
case 0:
|
|
@@ -2776,7 +2782,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2776
2782
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有本地订单数据,无法更新备注');
|
|
2777
2783
|
case 3:
|
|
2778
2784
|
console.log('[Checkout] 更新订单备注:', {
|
|
2779
|
-
orderUuid: (_this$store$
|
|
2785
|
+
orderUuid: (_this$store$currentOr14 = this.store.currentOrder) === null || _this$store$currentOr14 === void 0 ? void 0 : _this$store$currentOr14.uuid,
|
|
2780
2786
|
oldNote: this.store.localOrderData.shop_note,
|
|
2781
2787
|
newNote: note
|
|
2782
2788
|
});
|
|
@@ -2809,7 +2815,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2809
2815
|
case 17:
|
|
2810
2816
|
_context35.next = 19;
|
|
2811
2817
|
return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
|
|
2812
|
-
orderUuid: (_this$store$
|
|
2818
|
+
orderUuid: (_this$store$currentOr15 = this.store.currentOrder) === null || _this$store$currentOr15 === void 0 ? void 0 : _this$store$currentOr15.uuid,
|
|
2813
2819
|
oldNote: oldNote,
|
|
2814
2820
|
newNote: note,
|
|
2815
2821
|
timestamp: Date.now()
|
|
@@ -2949,7 +2955,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2949
2955
|
key: "handlePaymentSuccess",
|
|
2950
2956
|
value: (function () {
|
|
2951
2957
|
var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(data) {
|
|
2952
|
-
var _this$store$
|
|
2958
|
+
var _this$store$currentOr16;
|
|
2953
2959
|
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
2954
2960
|
while (1) switch (_context39.prev = _context39.next) {
|
|
2955
2961
|
case 0:
|
|
@@ -2963,7 +2969,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2963
2969
|
return this.core.effects.emit(CheckoutHooks.OnPaymentSuccess, {
|
|
2964
2970
|
orderUuid: data.orderUuid,
|
|
2965
2971
|
paymentMethodCode: '',
|
|
2966
|
-
amount: ((_this$store$
|
|
2972
|
+
amount: ((_this$store$currentOr16 = this.store.currentOrder) === null || _this$store$currentOr16 === void 0 ? void 0 : _this$store$currentOr16.total_amount) || '0',
|
|
2967
2973
|
timestamp: data.timestamp
|
|
2968
2974
|
});
|
|
2969
2975
|
case 6:
|
|
@@ -2988,7 +2994,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2988
2994
|
key: "handlePaymentError",
|
|
2989
2995
|
value: (function () {
|
|
2990
2996
|
var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(data) {
|
|
2991
|
-
var _this$store$
|
|
2997
|
+
var _this$store$currentOr17;
|
|
2992
2998
|
var error;
|
|
2993
2999
|
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
2994
3000
|
while (1) switch (_context40.prev = _context40.next) {
|
|
@@ -3001,7 +3007,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3001
3007
|
return this.core.effects.emit(CheckoutHooks.OnPaymentFailed, {
|
|
3002
3008
|
orderUuid: data.orderUuid,
|
|
3003
3009
|
paymentMethodCode: '',
|
|
3004
|
-
amount: ((_this$store$
|
|
3010
|
+
amount: ((_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.total_amount) || '0',
|
|
3005
3011
|
timestamp: data.timestamp
|
|
3006
3012
|
});
|
|
3007
3013
|
case 5:
|
|
@@ -3320,7 +3326,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3320
3326
|
key: "updateBalanceDueAmount",
|
|
3321
3327
|
value: (function () {
|
|
3322
3328
|
var _updateBalanceDueAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
|
|
3323
|
-
var _this$store$
|
|
3329
|
+
var _this$store$currentOr18, remainingAmount, currentBalanceDueAmount;
|
|
3324
3330
|
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
3325
3331
|
while (1) switch (_context44.prev = _context44.next) {
|
|
3326
3332
|
case 0:
|
|
@@ -3334,7 +3340,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3334
3340
|
calculatedRemainingAmount: remainingAmount,
|
|
3335
3341
|
currentBalanceDueAmount: currentBalanceDueAmount,
|
|
3336
3342
|
needsUpdate: remainingAmount !== currentBalanceDueAmount,
|
|
3337
|
-
orderUuid: (_this$store$
|
|
3343
|
+
orderUuid: (_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.uuid
|
|
3338
3344
|
});
|
|
3339
3345
|
|
|
3340
3346
|
// 只有当剩余金额与当前 balanceDueAmount 不同时才更新
|
|
@@ -3389,7 +3395,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3389
3395
|
key: "updateStateAmountToRemaining",
|
|
3390
3396
|
value: (function () {
|
|
3391
3397
|
var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
|
|
3392
|
-
var _this$store$
|
|
3398
|
+
var _this$store$currentOr19, remainingAmount, currentStateAmount;
|
|
3393
3399
|
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
3394
3400
|
while (1) switch (_context45.prev = _context45.next) {
|
|
3395
3401
|
case 0:
|
|
@@ -3403,7 +3409,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3403
3409
|
calculatedRemainingAmount: remainingAmount,
|
|
3404
3410
|
currentStateAmount: currentStateAmount,
|
|
3405
3411
|
needsUpdate: remainingAmount !== currentStateAmount,
|
|
3406
|
-
orderUuid: (_this$store$
|
|
3412
|
+
orderUuid: (_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.uuid
|
|
3407
3413
|
});
|
|
3408
3414
|
|
|
3409
3415
|
// 只有当剩余金额与当前 stateAmount 不同时才更新
|
|
@@ -3646,7 +3652,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3646
3652
|
key: "syncOrderToBackendWithReturn",
|
|
3647
3653
|
value: (function () {
|
|
3648
3654
|
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
|
|
3649
|
-
var _this$store$currentCu2, _this$store$
|
|
3655
|
+
var _this$store$currentCu2, _this$store$currentOr20, _this$store$currentOr21, _checkoutResponse3, _checkoutResponse4, _checkoutResponse5, _checkoutResponse6, _checkoutResponse7, _checkoutResponse8;
|
|
3650
3656
|
var isManual,
|
|
3651
3657
|
customPaymentItems,
|
|
3652
3658
|
syncType,
|
|
@@ -3752,7 +3758,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3752
3758
|
code: p.code,
|
|
3753
3759
|
amount: p.amount,
|
|
3754
3760
|
uniquePaymentNumber: (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.unique_payment_number,
|
|
3755
|
-
voucherId: p.voucher_id
|
|
3761
|
+
voucherId: p.voucher_id,
|
|
3762
|
+
orderPaymentType: p.order_payment_type
|
|
3756
3763
|
};
|
|
3757
3764
|
})
|
|
3758
3765
|
});
|
|
@@ -3776,8 +3783,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3776
3783
|
currency_code: this.otherParams.currency_code,
|
|
3777
3784
|
currency_symbol: this.otherParams.currency_symbol,
|
|
3778
3785
|
currency_format: this.otherParams.currency_format,
|
|
3779
|
-
is_deposit: ((_this$store$
|
|
3780
|
-
deposit_amount: ((_this$store$
|
|
3786
|
+
is_deposit: ((_this$store$currentOr20 = this.store.currentOrder) === null || _this$store$currentOr20 === void 0 ? void 0 : _this$store$currentOr20.is_deposit) || 0,
|
|
3787
|
+
deposit_amount: ((_this$store$currentOr21 = this.store.currentOrder) === null || _this$store$currentOr21 === void 0 ? void 0 : _this$store$currentOr21.deposit_amount) || '0.00',
|
|
3781
3788
|
// surcharge_fee: this.otherParams.surcharge_fee,
|
|
3782
3789
|
// surcharges: ,
|
|
3783
3790
|
note: this.store.localOrderData.shop_note
|
|
@@ -403,7 +403,9 @@ export declare enum CheckoutHooks {
|
|
|
403
403
|
/** 下单接口请求开始 */
|
|
404
404
|
OnOrderSubmitStart = "checkout:onOrderSubmitStart",
|
|
405
405
|
/** 下单接口请求完成 */
|
|
406
|
-
OnOrderSubmitEnd = "checkout:onOrderSubmitEnd"
|
|
406
|
+
OnOrderSubmitEnd = "checkout:onOrderSubmitEnd",
|
|
407
|
+
/** 钱包数据初始化完成 */
|
|
408
|
+
OnWalletDataInitialized = "checkout:onWalletDataInitialized"
|
|
407
409
|
}
|
|
408
410
|
/**
|
|
409
411
|
* 结账状态数据
|
|
@@ -897,4 +899,21 @@ export interface CheckoutEventData {
|
|
|
897
899
|
duration?: number;
|
|
898
900
|
timestamp: number;
|
|
899
901
|
};
|
|
902
|
+
/** 钱包数据初始化完成事件 */
|
|
903
|
+
walletDataInitialized: {
|
|
904
|
+
/** 订单UUID */
|
|
905
|
+
orderUuid?: string;
|
|
906
|
+
/** 客户ID */
|
|
907
|
+
customerId?: number;
|
|
908
|
+
/** 钱包业务数据 */
|
|
909
|
+
walletBusinessData: {
|
|
910
|
+
customer_id?: number;
|
|
911
|
+
amountInfo: {
|
|
912
|
+
totalAmount: string;
|
|
913
|
+
subTotal: string;
|
|
914
|
+
};
|
|
915
|
+
order_wait_pay_amount?: number;
|
|
916
|
+
};
|
|
917
|
+
timestamp: number;
|
|
918
|
+
};
|
|
900
919
|
}
|
|
@@ -123,6 +123,7 @@ export var CheckoutHooks = /*#__PURE__*/function (CheckoutHooks) {
|
|
|
123
123
|
CheckoutHooks["OnOrderCleared"] = "checkout:onOrderCleared";
|
|
124
124
|
CheckoutHooks["OnOrderSubmitStart"] = "checkout:onOrderSubmitStart";
|
|
125
125
|
CheckoutHooks["OnOrderSubmitEnd"] = "checkout:onOrderSubmitEnd";
|
|
126
|
+
CheckoutHooks["OnWalletDataInitialized"] = "checkout:onWalletDataInitialized";
|
|
126
127
|
return CheckoutHooks;
|
|
127
128
|
}({});
|
|
128
129
|
|
|
@@ -508,7 +508,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
508
508
|
this.logInfo("Starting addPaymentItemAsync", {
|
|
509
509
|
orderUuid,
|
|
510
510
|
paymentAmount: paymentItem.amount,
|
|
511
|
-
paymentCode: paymentItem.code
|
|
511
|
+
paymentCode: paymentItem.code,
|
|
512
|
+
orderPaymentType: paymentItem.order_payment_type
|
|
512
513
|
});
|
|
513
514
|
try {
|
|
514
515
|
const order = await this.getPaymentOrderByUuidAsync(orderUuid);
|
|
@@ -528,6 +529,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
528
529
|
service_charge: paymentItem.service_charge,
|
|
529
530
|
status: "active",
|
|
530
531
|
// 新支付项默认为活跃状态
|
|
532
|
+
order_payment_type: paymentItem.order_payment_type || "normal",
|
|
533
|
+
// 默认为正常支付
|
|
531
534
|
metadata: {
|
|
532
535
|
unique_payment_number: paymentUuid
|
|
533
536
|
// 设置唯一支付号为支付项的 uuid
|
|
@@ -622,7 +625,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
622
625
|
voucherItems: voucherPaymentItems.map((item) => ({
|
|
623
626
|
code: item.code,
|
|
624
627
|
amount: item.amount,
|
|
625
|
-
voucher_id: item.voucher_id
|
|
628
|
+
voucher_id: item.voucher_id,
|
|
629
|
+
order_payment_type: item.order_payment_type
|
|
626
630
|
}))
|
|
627
631
|
});
|
|
628
632
|
try {
|
|
@@ -658,7 +662,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
658
662
|
console.log(`[PaymentModule] 添加代金券支付项:`, {
|
|
659
663
|
code: voucherItem.code,
|
|
660
664
|
amount: voucherItem.amount,
|
|
661
|
-
voucher_id: voucherItem.voucher_id
|
|
665
|
+
voucher_id: voucherItem.voucher_id,
|
|
666
|
+
order_payment_type: voucherItem.order_payment_type
|
|
662
667
|
});
|
|
663
668
|
await this.addPaymentItemAsync(orderUuid, voucherItem);
|
|
664
669
|
}
|
|
@@ -123,6 +123,8 @@ export interface PaymentItem {
|
|
|
123
123
|
status?: 'active' | 'voided';
|
|
124
124
|
/** 原始金额(用于记录撤销前的金额) */
|
|
125
125
|
origin_amount?: string;
|
|
126
|
+
/** 订单支付类型 */
|
|
127
|
+
order_payment_type?: 'normal' | 'deposit';
|
|
126
128
|
}
|
|
127
129
|
/**
|
|
128
130
|
* 订单信息
|
|
@@ -218,6 +220,8 @@ export interface PaymentItemInput {
|
|
|
218
220
|
};
|
|
219
221
|
/** 舍入金额 */
|
|
220
222
|
rounding_amount?: string;
|
|
223
|
+
/** 订单支付类型 */
|
|
224
|
+
order_payment_type?: 'normal' | 'deposit';
|
|
221
225
|
}
|
|
222
226
|
/**
|
|
223
227
|
* 推送支付项参数
|
|
@@ -164,7 +164,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
164
164
|
return [...productList, ...relationProducts];
|
|
165
165
|
}
|
|
166
166
|
async initWalletData(params) {
|
|
167
|
-
var _a, _b, _c;
|
|
167
|
+
var _a, _b, _c, _d;
|
|
168
168
|
const amountInfo = (_b = (_a = this.store.currentOrder) == null ? void 0 : _a.order_info) == null ? void 0 : _b.amount_breakdown;
|
|
169
169
|
if (!amountInfo) {
|
|
170
170
|
return;
|
|
@@ -181,6 +181,16 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
181
181
|
await this.payment.wallet.initializeWalletDataFromBusinessAsync(
|
|
182
182
|
walletBusinessData
|
|
183
183
|
);
|
|
184
|
+
await this.core.effects.emit(import_types.CheckoutHooks.OnWalletDataInitialized, {
|
|
185
|
+
orderUuid: (_d = this.store.currentOrder) == null ? void 0 : _d.uuid,
|
|
186
|
+
customerId: walletBusinessData.customer_id,
|
|
187
|
+
walletBusinessData: {
|
|
188
|
+
customer_id: walletBusinessData.customer_id,
|
|
189
|
+
amountInfo: walletBusinessData.amountInfo,
|
|
190
|
+
order_wait_pay_amount: params == null ? void 0 : params.order_wait_pay_amount
|
|
191
|
+
},
|
|
192
|
+
timestamp: Date.now()
|
|
193
|
+
});
|
|
184
194
|
}
|
|
185
195
|
/**
|
|
186
196
|
* 创建本地订单 (前端模拟下单流程)
|
|
@@ -929,21 +939,29 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
929
939
|
"未找到当前订单,无法添加支付项"
|
|
930
940
|
);
|
|
931
941
|
}
|
|
942
|
+
const orderPaymentType = this.store.currentOrder.is_deposit === 1 ? "deposit" : "normal";
|
|
943
|
+
const paymentItemWithType = {
|
|
944
|
+
...paymentItem,
|
|
945
|
+
order_payment_type: orderPaymentType
|
|
946
|
+
};
|
|
932
947
|
console.log("[Checkout] 为当前订单添加支付项:", {
|
|
933
948
|
orderUuid: this.store.currentOrder.uuid,
|
|
934
949
|
paymentItem: {
|
|
935
|
-
code:
|
|
936
|
-
name:
|
|
937
|
-
type:
|
|
938
|
-
amount:
|
|
939
|
-
service_charge:
|
|
940
|
-
rounding_amount:
|
|
941
|
-
voucher_id:
|
|
942
|
-
|
|
950
|
+
code: paymentItemWithType.code,
|
|
951
|
+
name: paymentItemWithType.name,
|
|
952
|
+
type: paymentItemWithType.type,
|
|
953
|
+
amount: paymentItemWithType.amount,
|
|
954
|
+
service_charge: paymentItemWithType.service_charge,
|
|
955
|
+
rounding_amount: paymentItemWithType.rounding_amount,
|
|
956
|
+
voucher_id: paymentItemWithType.voucher_id,
|
|
957
|
+
order_payment_type: paymentItemWithType.order_payment_type
|
|
958
|
+
},
|
|
959
|
+
orderDepositStatus: this.store.currentOrder.is_deposit,
|
|
960
|
+
calculatedOrderPaymentType: orderPaymentType
|
|
943
961
|
});
|
|
944
962
|
await this.payment.addPaymentItemAsync(
|
|
945
963
|
this.store.currentOrder.uuid,
|
|
946
|
-
|
|
964
|
+
paymentItemWithType
|
|
947
965
|
);
|
|
948
966
|
console.log("[Checkout] 支付项添加成功");
|
|
949
967
|
const isEftposPayment = ((_a = paymentItem.type) == null ? void 0 : _a.toLowerCase()) === "eftpos" || ((_b = paymentItem.code) == null ? void 0 : _b.toUpperCase().includes("EFTPOS"));
|
|
@@ -1086,17 +1104,27 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1086
1104
|
newVoucherCount: voucherPaymentItems.length,
|
|
1087
1105
|
voucherPaymentItems
|
|
1088
1106
|
});
|
|
1089
|
-
|
|
1107
|
+
const orderPaymentType = this.store.currentOrder.is_deposit === 1 ? "deposit" : "normal";
|
|
1108
|
+
const voucherPaymentItemsWithType = voucherPaymentItems.map((item) => {
|
|
1090
1109
|
if (!item.voucher_id) {
|
|
1091
1110
|
throw (0, import_utils.createCheckoutError)(
|
|
1092
1111
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1093
1112
|
`代金券支付项缺少 voucher_id: ${JSON.stringify(item)}`
|
|
1094
1113
|
);
|
|
1095
1114
|
}
|
|
1096
|
-
|
|
1115
|
+
return {
|
|
1116
|
+
...item,
|
|
1117
|
+
order_payment_type: orderPaymentType
|
|
1118
|
+
};
|
|
1119
|
+
});
|
|
1120
|
+
console.log("[Checkout] 代金券支付项订单支付类型设置:", {
|
|
1121
|
+
orderDepositStatus: this.store.currentOrder.is_deposit,
|
|
1122
|
+
calculatedOrderPaymentType: orderPaymentType,
|
|
1123
|
+
itemsCount: voucherPaymentItemsWithType.length
|
|
1124
|
+
});
|
|
1097
1125
|
await this.payment.updateVoucherPaymentItemsAsync(
|
|
1098
1126
|
this.store.currentOrder.uuid,
|
|
1099
|
-
|
|
1127
|
+
voucherPaymentItemsWithType
|
|
1100
1128
|
);
|
|
1101
1129
|
console.log("[Checkout] Payment模块批量更新完成");
|
|
1102
1130
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
@@ -2232,7 +2260,8 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2232
2260
|
code: p.code,
|
|
2233
2261
|
amount: p.amount,
|
|
2234
2262
|
uniquePaymentNumber: (_a2 = p.metadata) == null ? void 0 : _a2.unique_payment_number,
|
|
2235
|
-
voucherId: p.voucher_id
|
|
2263
|
+
voucherId: p.voucher_id,
|
|
2264
|
+
orderPaymentType: p.order_payment_type
|
|
2236
2265
|
};
|
|
2237
2266
|
})
|
|
2238
2267
|
});
|
|
@@ -403,7 +403,9 @@ export declare enum CheckoutHooks {
|
|
|
403
403
|
/** 下单接口请求开始 */
|
|
404
404
|
OnOrderSubmitStart = "checkout:onOrderSubmitStart",
|
|
405
405
|
/** 下单接口请求完成 */
|
|
406
|
-
OnOrderSubmitEnd = "checkout:onOrderSubmitEnd"
|
|
406
|
+
OnOrderSubmitEnd = "checkout:onOrderSubmitEnd",
|
|
407
|
+
/** 钱包数据初始化完成 */
|
|
408
|
+
OnWalletDataInitialized = "checkout:onWalletDataInitialized"
|
|
407
409
|
}
|
|
408
410
|
/**
|
|
409
411
|
* 结账状态数据
|
|
@@ -897,4 +899,21 @@ export interface CheckoutEventData {
|
|
|
897
899
|
duration?: number;
|
|
898
900
|
timestamp: number;
|
|
899
901
|
};
|
|
902
|
+
/** 钱包数据初始化完成事件 */
|
|
903
|
+
walletDataInitialized: {
|
|
904
|
+
/** 订单UUID */
|
|
905
|
+
orderUuid?: string;
|
|
906
|
+
/** 客户ID */
|
|
907
|
+
customerId?: number;
|
|
908
|
+
/** 钱包业务数据 */
|
|
909
|
+
walletBusinessData: {
|
|
910
|
+
customer_id?: number;
|
|
911
|
+
amountInfo: {
|
|
912
|
+
totalAmount: string;
|
|
913
|
+
subTotal: string;
|
|
914
|
+
};
|
|
915
|
+
order_wait_pay_amount?: number;
|
|
916
|
+
};
|
|
917
|
+
timestamp: number;
|
|
918
|
+
};
|
|
900
919
|
}
|
|
@@ -75,6 +75,7 @@ var CheckoutHooks = /* @__PURE__ */ ((CheckoutHooks2) => {
|
|
|
75
75
|
CheckoutHooks2["OnOrderCleared"] = "checkout:onOrderCleared";
|
|
76
76
|
CheckoutHooks2["OnOrderSubmitStart"] = "checkout:onOrderSubmitStart";
|
|
77
77
|
CheckoutHooks2["OnOrderSubmitEnd"] = "checkout:onOrderSubmitEnd";
|
|
78
|
+
CheckoutHooks2["OnWalletDataInitialized"] = "checkout:onWalletDataInitialized";
|
|
78
79
|
return CheckoutHooks2;
|
|
79
80
|
})(CheckoutHooks || {});
|
|
80
81
|
// Annotate the CommonJS export names for ESM import in node:
|