@pisell/pisellos 2.2.9 → 2.2.11
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.
|
@@ -707,7 +707,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
707
707
|
key: "updateLocalOrderAsync",
|
|
708
708
|
value: (function () {
|
|
709
709
|
var _updateLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
710
|
-
var _params$orderData6, _params$orderData7, _params$cartSummary2, _params$totalInfo5, _params$totalInfo6, _params$totalInfo7, _params$totalInfo8;
|
|
710
|
+
var _params$orderData6, _params$orderData7, _params$cartSummary2, _params$totalInfo5, _params$totalInfo6, _params$totalInfo7, _params$totalInfo8, _this$store$currentOr9, _this$store$currentOr10;
|
|
711
711
|
var validation, amountInfo, customerInfo, allOrders, existingOrder, _updated$payment2, _existingOrder$paymen, _updated$payment, currentTime, formattedExistPayments, _isNeedDeposit, _updated, syncedPayments, _syncedAmount, _totalAmount, _remainingExpectAmount, _depositDiffAmount, totalAmount, activePayments, paidAmount, remaining, _isNeedDeposit2, updated, syncedAmount, remainingExpectAmount, depositDiffAmount, isNeedDeposit, created, _syncedPayments, _syncedAmount2;
|
|
712
712
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
713
713
|
while (1) switch (_context10.prev = _context10.next) {
|
|
@@ -959,7 +959,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
959
959
|
this.store.currentOrder = created;
|
|
960
960
|
|
|
961
961
|
// 🔧 新增: 如果有云端支付项,需要计算正确的待付金额
|
|
962
|
-
if (params.existPayment && params.existPayment.length > 0) {
|
|
962
|
+
if (params.existPayment && params.existPayment.length > 0 || (_this$store$currentOr9 = this.store.currentOrder) !== null && _this$store$currentOr9 !== void 0 && _this$store$currentOr9.order_id && !isVirtualOrderId((_this$store$currentOr10 = this.store.currentOrder) === null || _this$store$currentOr10 === void 0 ? void 0 : _this$store$currentOr10.order_id)) {
|
|
963
963
|
// 标记订单已同步(因为订单和支付项都来自云端)
|
|
964
964
|
this.store.isOrderSynced = true;
|
|
965
965
|
|
|
@@ -1073,8 +1073,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1073
1073
|
}, {
|
|
1074
1074
|
key: "getOrderOriginalData",
|
|
1075
1075
|
value: function getOrderOriginalData() {
|
|
1076
|
-
var _this$store$
|
|
1077
|
-
return (_this$store$
|
|
1076
|
+
var _this$store$currentOr11;
|
|
1077
|
+
return (_this$store$currentOr11 = this.store.currentOrder) === null || _this$store$currentOr11 === void 0 ? void 0 : _this$store$currentOr11.order_info;
|
|
1078
1078
|
}
|
|
1079
1079
|
|
|
1080
1080
|
/**
|
|
@@ -1923,7 +1923,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1923
1923
|
key: "setDepositAmountAsync",
|
|
1924
1924
|
value: (function () {
|
|
1925
1925
|
var _setDepositAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(depositAmount) {
|
|
1926
|
-
var _this$store$
|
|
1926
|
+
var _this$store$currentOr12, _this$store$currentOr13;
|
|
1927
1927
|
var depositValue, formattedDepositAmount, oldDepositAmount, updateParams;
|
|
1928
1928
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1929
1929
|
while (1) switch (_context20.prev = _context20.next) {
|
|
@@ -1931,8 +1931,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1931
1931
|
this.logInfo('setDepositAmountAsync called', {
|
|
1932
1932
|
depositAmount: depositAmount,
|
|
1933
1933
|
hasCurrentOrder: !!this.store.currentOrder,
|
|
1934
|
-
currentOrderId: (_this$store$
|
|
1935
|
-
currentTotalAmount: (_this$store$
|
|
1934
|
+
currentOrderId: (_this$store$currentOr12 = this.store.currentOrder) === null || _this$store$currentOr12 === void 0 ? void 0 : _this$store$currentOr12.order_id,
|
|
1935
|
+
currentTotalAmount: (_this$store$currentOr13 = this.store.currentOrder) === null || _this$store$currentOr13 === void 0 ? void 0 : _this$store$currentOr13.total_amount
|
|
1936
1936
|
});
|
|
1937
1937
|
_context20.prev = 1;
|
|
1938
1938
|
// 验证定金金额格式
|
|
@@ -2052,17 +2052,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2052
2052
|
key: "manualSyncOrderAsync",
|
|
2053
2053
|
value: (function () {
|
|
2054
2054
|
var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
2055
|
-
var _this$store$
|
|
2056
|
-
var _this$store$
|
|
2055
|
+
var _this$store$currentOr14, _this$store$currentOr15, _this$store$currentOr16;
|
|
2056
|
+
var _this$store$currentOr17, orderUuid, oldOrderId, syncResult, finalOrderId, finalIsVirtual, newRes, _this$store$currentOr18, errorMessage;
|
|
2057
2057
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2058
2058
|
while (1) switch (_context21.prev = _context21.next) {
|
|
2059
2059
|
case 0:
|
|
2060
2060
|
console.log('manualSyncOrderAsync called');
|
|
2061
2061
|
this.logInfo('manualSyncOrderAsync called', {
|
|
2062
2062
|
hasCurrentOrder: !!this.store.currentOrder,
|
|
2063
|
-
currentOrderId: (_this$store$
|
|
2064
|
-
orderUuid: (_this$store$
|
|
2065
|
-
totalAmount: (_this$store$
|
|
2063
|
+
currentOrderId: (_this$store$currentOr14 = this.store.currentOrder) === null || _this$store$currentOr14 === void 0 ? void 0 : _this$store$currentOr14.order_id,
|
|
2064
|
+
orderUuid: (_this$store$currentOr15 = this.store.currentOrder) === null || _this$store$currentOr15 === void 0 ? void 0 : _this$store$currentOr15.uuid,
|
|
2065
|
+
totalAmount: (_this$store$currentOr16 = this.store.currentOrder) === null || _this$store$currentOr16 === void 0 ? void 0 : _this$store$currentOr16.total_amount,
|
|
2066
2066
|
isOrderSynced: this.store.isOrderSynced,
|
|
2067
2067
|
isVirtualOrderId: this.store.currentOrder ? isVirtualOrderId(this.store.currentOrder.order_id) : false
|
|
2068
2068
|
});
|
|
@@ -2122,7 +2122,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2122
2122
|
this.logError('[Checkout] 严重警告:返回的订单ID与存储的订单ID不一致!');
|
|
2123
2123
|
}
|
|
2124
2124
|
newRes = _objectSpread(_objectSpread({}, syncResult), {}, {
|
|
2125
|
-
is_deposit: ((_this$store$
|
|
2125
|
+
is_deposit: ((_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.is_deposit) || 0
|
|
2126
2126
|
});
|
|
2127
2127
|
_context21.next = 30;
|
|
2128
2128
|
return this.updateStateAmountToRemaining(false);
|
|
@@ -2136,7 +2136,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2136
2136
|
return _context21.abrupt("return", {
|
|
2137
2137
|
success: false,
|
|
2138
2138
|
message: "\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(errorMessage),
|
|
2139
|
-
orderUuid: (_this$store$
|
|
2139
|
+
orderUuid: (_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.uuid
|
|
2140
2140
|
});
|
|
2141
2141
|
case 38:
|
|
2142
2142
|
case "end":
|
|
@@ -2213,15 +2213,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2213
2213
|
key: "cancelCurrentOrderAsync",
|
|
2214
2214
|
value: (function () {
|
|
2215
2215
|
var _cancelCurrentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(cancelReason) {
|
|
2216
|
-
var _this$store$
|
|
2216
|
+
var _this$store$currentOr19, _this$store$currentOr20, currentOrderUuid, currentOrderId, isOrderSynced, errorMessage;
|
|
2217
2217
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2218
2218
|
while (1) switch (_context22.prev = _context22.next) {
|
|
2219
2219
|
case 0:
|
|
2220
2220
|
_context22.prev = 0;
|
|
2221
2221
|
this.logInfo('开始取消当前本地订单:', {
|
|
2222
2222
|
hasCurrentOrder: !!this.store.currentOrder,
|
|
2223
|
-
orderUuid: (_this$store$
|
|
2224
|
-
orderId: (_this$store$
|
|
2223
|
+
orderUuid: (_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.uuid,
|
|
2224
|
+
orderId: (_this$store$currentOr20 = this.store.currentOrder) === null || _this$store$currentOr20 === void 0 ? void 0 : _this$store$currentOr20.order_id,
|
|
2225
2225
|
isOrderSynced: this.store.isOrderSynced,
|
|
2226
2226
|
cancelReason: cancelReason
|
|
2227
2227
|
});
|
|
@@ -2332,7 +2332,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2332
2332
|
key: "saveForLaterPaymentAsync",
|
|
2333
2333
|
value: (function () {
|
|
2334
2334
|
var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
2335
|
-
var orderUuid, currentOrderId, allPaymentItems, syncResult, _this$store$
|
|
2335
|
+
var orderUuid, currentOrderId, allPaymentItems, syncResult, _this$store$currentOr21, errorMessage;
|
|
2336
2336
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2337
2337
|
while (1) switch (_context23.prev = _context23.next) {
|
|
2338
2338
|
case 0:
|
|
@@ -2386,7 +2386,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2386
2386
|
return _context23.abrupt("return", {
|
|
2387
2387
|
success: false,
|
|
2388
2388
|
message: "\u8BA2\u5355\u4FDD\u5B58\u5931\u8D25: ".concat(errorMessage),
|
|
2389
|
-
orderUuid: (_this$store$
|
|
2389
|
+
orderUuid: (_this$store$currentOr21 = this.store.currentOrder) === null || _this$store$currentOr21 === void 0 ? void 0 : _this$store$currentOr21.uuid
|
|
2390
2390
|
});
|
|
2391
2391
|
case 21:
|
|
2392
2392
|
case "end":
|
|
@@ -2409,7 +2409,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2409
2409
|
key: "updateOrderNoteAsync",
|
|
2410
2410
|
value: (function () {
|
|
2411
2411
|
var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(note) {
|
|
2412
|
-
var _this$store$
|
|
2412
|
+
var _this$store$currentOr22, _this$store$currentOr23, oldNote, orderInPayment;
|
|
2413
2413
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2414
2414
|
while (1) switch (_context24.prev = _context24.next) {
|
|
2415
2415
|
case 0:
|
|
@@ -2421,7 +2421,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2421
2421
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有本地订单数据,无法更新备注');
|
|
2422
2422
|
case 3:
|
|
2423
2423
|
console.log('[Checkout] 更新订单备注:', {
|
|
2424
|
-
orderUuid: (_this$store$
|
|
2424
|
+
orderUuid: (_this$store$currentOr22 = this.store.currentOrder) === null || _this$store$currentOr22 === void 0 ? void 0 : _this$store$currentOr22.uuid,
|
|
2425
2425
|
oldNote: this.store.localOrderData.shop_note,
|
|
2426
2426
|
newNote: note
|
|
2427
2427
|
});
|
|
@@ -2454,7 +2454,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2454
2454
|
case 17:
|
|
2455
2455
|
_context24.next = 19;
|
|
2456
2456
|
return this.core.effects.emit("".concat(this.name, ":onOrderNoteChanged"), {
|
|
2457
|
-
orderUuid: (_this$store$
|
|
2457
|
+
orderUuid: (_this$store$currentOr23 = this.store.currentOrder) === null || _this$store$currentOr23 === void 0 ? void 0 : _this$store$currentOr23.uuid,
|
|
2458
2458
|
oldNote: oldNote,
|
|
2459
2459
|
newNote: note,
|
|
2460
2460
|
timestamp: Date.now()
|
|
@@ -2526,7 +2526,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2526
2526
|
key: "handlePaymentSuccess",
|
|
2527
2527
|
value: (function () {
|
|
2528
2528
|
var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(data) {
|
|
2529
|
-
var _this$store$
|
|
2529
|
+
var _this$store$currentOr24;
|
|
2530
2530
|
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2531
2531
|
while (1) switch (_context26.prev = _context26.next) {
|
|
2532
2532
|
case 0:
|
|
@@ -2537,7 +2537,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2537
2537
|
return this.core.effects.emit("".concat(this.name, ":onPaymentSuccess"), {
|
|
2538
2538
|
orderUuid: data.orderUuid,
|
|
2539
2539
|
paymentMethodCode: '',
|
|
2540
|
-
amount: ((_this$store$
|
|
2540
|
+
amount: ((_this$store$currentOr24 = this.store.currentOrder) === null || _this$store$currentOr24 === void 0 ? void 0 : _this$store$currentOr24.total_amount) || '0',
|
|
2541
2541
|
timestamp: data.timestamp
|
|
2542
2542
|
});
|
|
2543
2543
|
case 4:
|
|
@@ -2562,7 +2562,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2562
2562
|
key: "handlePaymentError",
|
|
2563
2563
|
value: (function () {
|
|
2564
2564
|
var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(data) {
|
|
2565
|
-
var _this$store$
|
|
2565
|
+
var _this$store$currentOr25;
|
|
2566
2566
|
var error;
|
|
2567
2567
|
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2568
2568
|
while (1) switch (_context27.prev = _context27.next) {
|
|
@@ -2575,7 +2575,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2575
2575
|
return this.core.effects.emit("".concat(this.name, ":onPaymentFailed"), {
|
|
2576
2576
|
orderUuid: data.orderUuid,
|
|
2577
2577
|
paymentMethodCode: '',
|
|
2578
|
-
amount: ((_this$store$
|
|
2578
|
+
amount: ((_this$store$currentOr25 = this.store.currentOrder) === null || _this$store$currentOr25 === void 0 ? void 0 : _this$store$currentOr25.total_amount) || '0',
|
|
2579
2579
|
timestamp: data.timestamp
|
|
2580
2580
|
});
|
|
2581
2581
|
case 5:
|
|
@@ -3698,10 +3698,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3698
3698
|
value: (function () {
|
|
3699
3699
|
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
|
|
3700
3700
|
var _this6 = this,
|
|
3701
|
-
_this$store$currentOr24,
|
|
3702
|
-
_this$store$currentOr25,
|
|
3703
|
-
_this$store$currentCu2,
|
|
3704
3701
|
_this$store$currentOr26,
|
|
3702
|
+
_this$store$currentOr27,
|
|
3703
|
+
_this$store$currentCu2,
|
|
3704
|
+
_this$store$currentOr28,
|
|
3705
3705
|
_this$store$localOrde,
|
|
3706
3706
|
_this$store$localOrde2,
|
|
3707
3707
|
_checkoutResponse3,
|
|
@@ -3783,7 +3783,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3783
3783
|
})
|
|
3784
3784
|
});
|
|
3785
3785
|
}); // 确定最终的定金金额:优先使用手动设置的值,否则从支付项中计算
|
|
3786
|
-
manualDepositAmount = ((_this$store$
|
|
3786
|
+
manualDepositAmount = ((_this$store$currentOr26 = this.store.currentOrder) === null || _this$store$currentOr26 === void 0 ? void 0 : _this$store$currentOr26.deposit_amount) || '0.00'; // 优先级逻辑:手动设置的定金金额 > 从支付项计算的金额
|
|
3787
3787
|
manualDepositValue = new Decimal(manualDepositAmount);
|
|
3788
3788
|
if (manualDepositValue.gt(0)) {
|
|
3789
3789
|
// 如果手动设置了定金金额且大于0,使用手动设置的值
|
|
@@ -3843,7 +3843,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3843
3843
|
}),
|
|
3844
3844
|
manualDepositAmount: manualDepositAmount,
|
|
3845
3845
|
finalDepositAmount: finalDepositAmount,
|
|
3846
|
-
isDeposit: ((_this$store$
|
|
3846
|
+
isDeposit: ((_this$store$currentOr27 = this.store.currentOrder) === null || _this$store$currentOr27 === void 0 ? void 0 : _this$store$currentOr27.is_deposit) || 0
|
|
3847
3847
|
});
|
|
3848
3848
|
|
|
3849
3849
|
// 构造订单参数,直接使用 localOrderData 中已处理好的数据
|
|
@@ -3865,7 +3865,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3865
3865
|
currency_code: this.otherParams.currency_code,
|
|
3866
3866
|
currency_symbol: this.otherParams.currency_symbol,
|
|
3867
3867
|
currency_format: this.otherParams.currency_format,
|
|
3868
|
-
is_deposit: ((_this$store$
|
|
3868
|
+
is_deposit: ((_this$store$currentOr28 = this.store.currentOrder) !== null && _this$store$currentOr28 !== void 0 && _this$store$currentOr28.is_deposit || Number(finalDepositAmount) > 0 ? 1 : 0) || 0,
|
|
3869
3869
|
deposit_amount: finalDepositAmount,
|
|
3870
3870
|
// 使用最终确定的定金金额(手动设置优先)
|
|
3871
3871
|
product_tax_fee: this.store.localOrderData.tax_fee,
|
|
@@ -453,7 +453,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
453
453
|
* 会覆盖 order_info 与金额等字段,并重新计算待付金额,最后设置为 currentOrder。
|
|
454
454
|
*/
|
|
455
455
|
async updateLocalOrderAsync(params) {
|
|
456
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
456
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
457
457
|
this.logInfo("updateLocalOrderAsync called", {
|
|
458
458
|
orderId: params.orderId,
|
|
459
459
|
orderDataType: (_a = params.orderData) == null ? void 0 : _a.type,
|
|
@@ -660,7 +660,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
660
660
|
}
|
|
661
661
|
});
|
|
662
662
|
this.store.currentOrder = created;
|
|
663
|
-
if (params.existPayment && params.existPayment.length > 0) {
|
|
663
|
+
if (params.existPayment && params.existPayment.length > 0 || ((_p = this.store.currentOrder) == null ? void 0 : _p.order_id) && !(0, import_utils.isVirtualOrderId)((_q = this.store.currentOrder) == null ? void 0 : _q.order_id)) {
|
|
664
664
|
this.store.isOrderSynced = true;
|
|
665
665
|
const syncedPayments = created.payment.filter((p) => p.isSynced && p.status !== "voided");
|
|
666
666
|
const syncedAmount = syncedPayments.reduce((sum, p) => {
|