@pisell/pisellos 0.0.248 → 0.0.249
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.
|
@@ -314,7 +314,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
314
314
|
}[];
|
|
315
315
|
setOtherData(key: string, value: any): void;
|
|
316
316
|
getOtherData(key: string): any;
|
|
317
|
-
getProductTypeById(id: number): Promise<"
|
|
317
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
318
318
|
/**
|
|
319
319
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
320
320
|
*
|
|
@@ -2545,7 +2545,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2545
2545
|
key: "saveForLaterPaymentAsync",
|
|
2546
2546
|
value: (function () {
|
|
2547
2547
|
var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
2548
|
-
var orderUuid, currentOrderId, allPaymentItems,
|
|
2548
|
+
var orderUuid, currentOrderId, allPaymentItems, realOrderId, finalOrderId, _this$store$currentOr11, errorMessage;
|
|
2549
2549
|
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2550
2550
|
while (1) switch (_context33.prev = _context33.next) {
|
|
2551
2551
|
case 0:
|
|
@@ -2572,45 +2572,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2572
2572
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
|
|
2573
2573
|
case 8:
|
|
2574
2574
|
allPaymentItems = _context33.sent;
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
}); // 记录过滤结果
|
|
2579
|
-
voucherItems = allPaymentItems.filter(function (payment) {
|
|
2580
|
-
return payment.voucher_id;
|
|
2581
|
-
});
|
|
2582
|
-
console.log('[Checkout] 支付项过滤结果:', {
|
|
2583
|
-
总支付项: allPaymentItems.length,
|
|
2584
|
-
过滤后支付项: filteredPaymentItems.length,
|
|
2585
|
-
被过滤的代金券项: voucherItems.length,
|
|
2586
|
-
代金券详情: voucherItems.map(function (item) {
|
|
2587
|
-
return {
|
|
2588
|
-
uuid: item.uuid,
|
|
2589
|
-
code: item.code,
|
|
2590
|
-
amount: item.amount,
|
|
2591
|
-
voucherId: item.voucher_id
|
|
2592
|
-
};
|
|
2593
|
-
}),
|
|
2594
|
-
保留的支付项: filteredPaymentItems.map(function (item) {
|
|
2595
|
-
return {
|
|
2596
|
-
uuid: item.uuid,
|
|
2597
|
-
code: item.code,
|
|
2598
|
-
amount: item.amount
|
|
2599
|
-
};
|
|
2600
|
-
})
|
|
2601
|
-
});
|
|
2602
|
-
|
|
2603
|
-
// 调用同步方法,传入过滤后的支付项
|
|
2604
|
-
_context33.next = 14;
|
|
2605
|
-
return this.syncOrderToBackendWithReturn(false, filteredPaymentItems);
|
|
2606
|
-
case 14:
|
|
2575
|
+
_context33.next = 11;
|
|
2576
|
+
return this.syncOrderToBackendWithReturn(false, allPaymentItems);
|
|
2577
|
+
case 11:
|
|
2607
2578
|
realOrderId = _context33.sent;
|
|
2608
2579
|
console.log('[Checkout] 保存订单完成:', {
|
|
2609
2580
|
orderUuid: orderUuid,
|
|
2610
2581
|
oldOrderId: currentOrderId,
|
|
2611
2582
|
realOrderId: realOrderId,
|
|
2612
2583
|
isOrderSynced: this.store.isOrderSynced,
|
|
2613
|
-
filteredPaymentsCount:
|
|
2584
|
+
filteredPaymentsCount: allPaymentItems.length
|
|
2614
2585
|
});
|
|
2615
2586
|
|
|
2616
2587
|
// 验证最终状态
|
|
@@ -2627,8 +2598,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2627
2598
|
orderId: realOrderId,
|
|
2628
2599
|
orderUuid: orderUuid
|
|
2629
2600
|
});
|
|
2630
|
-
case
|
|
2631
|
-
_context33.prev =
|
|
2601
|
+
case 18:
|
|
2602
|
+
_context33.prev = 18;
|
|
2632
2603
|
_context33.t0 = _context33["catch"](0);
|
|
2633
2604
|
console.error('[Checkout] 保存订单失败:', _context33.t0);
|
|
2634
2605
|
errorMessage = _context33.t0 instanceof Error ? _context33.t0.message : '保存失败';
|
|
@@ -2637,11 +2608,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2637
2608
|
message: "\u8BA2\u5355\u4FDD\u5B58\u5931\u8D25: ".concat(errorMessage),
|
|
2638
2609
|
orderUuid: (_this$store$currentOr11 = this.store.currentOrder) === null || _this$store$currentOr11 === void 0 ? void 0 : _this$store$currentOr11.uuid
|
|
2639
2610
|
});
|
|
2640
|
-
case
|
|
2611
|
+
case 23:
|
|
2641
2612
|
case "end":
|
|
2642
2613
|
return _context33.stop();
|
|
2643
2614
|
}
|
|
2644
|
-
}, _callee33, this, [[0,
|
|
2615
|
+
}, _callee33, this, [[0, 18]]);
|
|
2645
2616
|
}));
|
|
2646
2617
|
function saveForLaterPaymentAsync() {
|
|
2647
2618
|
return _saveForLaterPaymentAsync.apply(this, arguments);
|
|
@@ -3681,7 +3652,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3681
3652
|
key: "syncOrderToBackendWithReturn",
|
|
3682
3653
|
value: (function () {
|
|
3683
3654
|
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
|
|
3684
|
-
var
|
|
3655
|
+
var _this4 = this,
|
|
3656
|
+
_processedPaymentItem,
|
|
3657
|
+
_this$store$currentCu2,
|
|
3658
|
+
_this$store$currentOr20,
|
|
3659
|
+
_this$store$currentOr21,
|
|
3660
|
+
_checkoutResponse3,
|
|
3661
|
+
_checkoutResponse4,
|
|
3662
|
+
_checkoutResponse5,
|
|
3663
|
+
_checkoutResponse6,
|
|
3664
|
+
_checkoutResponse7,
|
|
3665
|
+
_checkoutResponse8;
|
|
3685
3666
|
var isManual,
|
|
3686
3667
|
customPaymentItems,
|
|
3687
3668
|
syncType,
|
|
@@ -3691,6 +3672,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3691
3672
|
reason,
|
|
3692
3673
|
operation,
|
|
3693
3674
|
paymentItems,
|
|
3675
|
+
processedPaymentItems,
|
|
3694
3676
|
orderParams,
|
|
3695
3677
|
startTime,
|
|
3696
3678
|
checkoutResponse,
|
|
@@ -3794,12 +3776,35 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3794
3776
|
})
|
|
3795
3777
|
});
|
|
3796
3778
|
|
|
3779
|
+
// 处理支付项数据,确保包含完整的 metadata
|
|
3780
|
+
processedPaymentItems = paymentItems.map(function (item) {
|
|
3781
|
+
var _item$metadata, _item$metadata2;
|
|
3782
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
3783
|
+
metadata: _objectSpread(_objectSpread({}, item.metadata), {}, {
|
|
3784
|
+
rounding_rule: ((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.rounding_rule) || _this4.otherParams.order_rounding_setting,
|
|
3785
|
+
shop_wallet_pass_id: ((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.shop_wallet_pass_id) || _this4.otherParams.shop_wallet_pass_id
|
|
3786
|
+
})
|
|
3787
|
+
});
|
|
3788
|
+
});
|
|
3789
|
+
console.log('[Checkout] 处理后的支付项数据(包含完整metadata):', {
|
|
3790
|
+
originalCount: paymentItems.length,
|
|
3791
|
+
processedCount: processedPaymentItems.length,
|
|
3792
|
+
sampleMetadata: (_processedPaymentItem = processedPaymentItems[0]) === null || _processedPaymentItem === void 0 ? void 0 : _processedPaymentItem.metadata,
|
|
3793
|
+
allPaymentItems: processedPaymentItems.map(function (p) {
|
|
3794
|
+
return {
|
|
3795
|
+
code: p.code,
|
|
3796
|
+
amount: p.amount,
|
|
3797
|
+
metadata: p.metadata
|
|
3798
|
+
};
|
|
3799
|
+
})
|
|
3800
|
+
});
|
|
3801
|
+
|
|
3797
3802
|
// 构造订单参数,直接使用 localOrderData 中已处理好的数据
|
|
3798
3803
|
orderParams = _objectSpread(_objectSpread({}, this.store.localOrderData), {}, {
|
|
3799
3804
|
type: this.store.localOrderData.type,
|
|
3800
3805
|
platform: this.store.localOrderData.platform,
|
|
3801
|
-
payments:
|
|
3802
|
-
//
|
|
3806
|
+
payments: processedPaymentItems,
|
|
3807
|
+
// 使用处理过的支付项数据
|
|
3803
3808
|
customer_id: (_this$store$currentCu2 = this.store.currentCustomer) === null || _this$store$currentCu2 === void 0 ? void 0 : _this$store$currentCu2.customer_id,
|
|
3804
3809
|
// 添加客户ID
|
|
3805
3810
|
is_price_include_tax: this.otherParams.is_price_include_tax,
|
|
@@ -3845,7 +3850,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3845
3850
|
|
|
3846
3851
|
// 发送下单接口请求开始事件
|
|
3847
3852
|
startTime = Date.now();
|
|
3848
|
-
_context47.next =
|
|
3853
|
+
_context47.next = 27;
|
|
3849
3854
|
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitStart, {
|
|
3850
3855
|
orderUuid: this.store.currentOrder.uuid,
|
|
3851
3856
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3853,26 +3858,26 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3853
3858
|
paymentItemCount: paymentItems.length,
|
|
3854
3859
|
timestamp: startTime
|
|
3855
3860
|
});
|
|
3856
|
-
case
|
|
3861
|
+
case 27:
|
|
3857
3862
|
submitSuccess = false;
|
|
3858
|
-
_context47.prev =
|
|
3859
|
-
_context47.next =
|
|
3863
|
+
_context47.prev = 28;
|
|
3864
|
+
_context47.next = 31;
|
|
3860
3865
|
return this.order.createOrderByCheckout(orderParams);
|
|
3861
|
-
case
|
|
3866
|
+
case 31:
|
|
3862
3867
|
checkoutResponse = _context47.sent;
|
|
3863
3868
|
submitSuccess = true;
|
|
3864
3869
|
console.log('[Checkout] 下单接口调用成功');
|
|
3865
|
-
_context47.next =
|
|
3870
|
+
_context47.next = 43;
|
|
3866
3871
|
break;
|
|
3867
|
-
case
|
|
3868
|
-
_context47.prev =
|
|
3869
|
-
_context47.t1 = _context47["catch"](
|
|
3872
|
+
case 36:
|
|
3873
|
+
_context47.prev = 36;
|
|
3874
|
+
_context47.t1 = _context47["catch"](28);
|
|
3870
3875
|
submitSuccess = false;
|
|
3871
3876
|
submitError = _context47.t1 instanceof Error ? _context47.t1.message : String(_context47.t1);
|
|
3872
3877
|
// console.error('[Checkout] 下单接口调用失败:', submitError);
|
|
3873
3878
|
|
|
3874
3879
|
// 发送订单同步失败事件(网络错误或请求失败)
|
|
3875
|
-
_context47.next =
|
|
3880
|
+
_context47.next = 42;
|
|
3876
3881
|
return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
|
|
3877
3882
|
orderUuid: this.store.currentOrder.uuid,
|
|
3878
3883
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3882,11 +3887,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3882
3887
|
duration: Date.now() - startTime,
|
|
3883
3888
|
timestamp: Date.now()
|
|
3884
3889
|
});
|
|
3885
|
-
case
|
|
3890
|
+
case 42:
|
|
3886
3891
|
throw _context47.t1;
|
|
3887
|
-
case
|
|
3888
|
-
_context47.prev =
|
|
3889
|
-
_context47.next =
|
|
3892
|
+
case 43:
|
|
3893
|
+
_context47.prev = 43;
|
|
3894
|
+
_context47.next = 46;
|
|
3890
3895
|
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitEnd, {
|
|
3891
3896
|
success: submitSuccess,
|
|
3892
3897
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -3897,9 +3902,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3897
3902
|
duration: Date.now() - startTime,
|
|
3898
3903
|
timestamp: Date.now()
|
|
3899
3904
|
});
|
|
3900
|
-
case
|
|
3901
|
-
return _context47.finish(
|
|
3902
|
-
case
|
|
3905
|
+
case 46:
|
|
3906
|
+
return _context47.finish(43);
|
|
3907
|
+
case 47:
|
|
3903
3908
|
console.log('[Checkout] 后端返回的响应数据:', {
|
|
3904
3909
|
status: (_checkoutResponse3 = checkoutResponse) === null || _checkoutResponse3 === void 0 ? void 0 : _checkoutResponse3.status,
|
|
3905
3910
|
code: (_checkoutResponse4 = checkoutResponse) === null || _checkoutResponse4 === void 0 ? void 0 : _checkoutResponse4.code,
|
|
@@ -3911,7 +3916,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3911
3916
|
responseStatus = (_checkoutResponse7 = checkoutResponse) === null || _checkoutResponse7 === void 0 ? void 0 : _checkoutResponse7.status;
|
|
3912
3917
|
isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse8 = checkoutResponse) === null || _checkoutResponse8 === void 0 ? void 0 : _checkoutResponse8.code) === 200;
|
|
3913
3918
|
if (isSuccessResponse) {
|
|
3914
|
-
_context47.next =
|
|
3919
|
+
_context47.next = 56;
|
|
3915
3920
|
break;
|
|
3916
3921
|
}
|
|
3917
3922
|
errorMessage = ((_checkoutResponse9 = checkoutResponse) === null || _checkoutResponse9 === void 0 ? void 0 : _checkoutResponse9.message) || '订单同步失败,后端返回非成功状态';
|
|
@@ -3924,7 +3929,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3924
3929
|
});
|
|
3925
3930
|
|
|
3926
3931
|
// 发送订单同步失败事件
|
|
3927
|
-
_context47.next =
|
|
3932
|
+
_context47.next = 55;
|
|
3928
3933
|
return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
|
|
3929
3934
|
orderUuid: this.store.currentOrder.uuid,
|
|
3930
3935
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3935,20 +3940,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3935
3940
|
duration: Date.now() - startTime,
|
|
3936
3941
|
timestamp: Date.now()
|
|
3937
3942
|
});
|
|
3938
|
-
case
|
|
3943
|
+
case 55:
|
|
3939
3944
|
throw new Error(errorMessage);
|
|
3940
|
-
case
|
|
3945
|
+
case 56:
|
|
3941
3946
|
console.log('[Checkout] 响应状态检查通过,开始处理订单数据');
|
|
3942
3947
|
if (!isUpdateOperation) {
|
|
3943
|
-
_context47.next =
|
|
3948
|
+
_context47.next = 62;
|
|
3944
3949
|
break;
|
|
3945
3950
|
}
|
|
3946
3951
|
// 更新操作:使用现有的订单ID
|
|
3947
3952
|
realOrderId = currentOrderId;
|
|
3948
3953
|
console.log("[Checkout] \u8BA2\u5355\u66F4\u65B0\u6210\u529F\uFF0C\u8BA2\u5355ID: ".concat(realOrderId));
|
|
3949
|
-
_context47.next =
|
|
3954
|
+
_context47.next = 83;
|
|
3950
3955
|
break;
|
|
3951
|
-
case
|
|
3956
|
+
case 62:
|
|
3952
3957
|
// 创建操作:从响应中提取新的订单ID
|
|
3953
3958
|
extractedOrderId = (_checkoutResponse12 = checkoutResponse) === null || _checkoutResponse12 === void 0 || (_checkoutResponse12 = _checkoutResponse12.data) === null || _checkoutResponse12 === void 0 ? void 0 : _checkoutResponse12.order_id; // 如果data.order_id不存在,尝试直接从根级获取
|
|
3954
3959
|
if (!extractedOrderId) {
|
|
@@ -3960,11 +3965,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3960
3965
|
extractedOrderId = String(extractedOrderId);
|
|
3961
3966
|
}
|
|
3962
3967
|
if (extractedOrderId) {
|
|
3963
|
-
_context47.next =
|
|
3968
|
+
_context47.next = 67;
|
|
3964
3969
|
break;
|
|
3965
3970
|
}
|
|
3966
3971
|
throw new Error('后端返回的订单信息中未包含订单ID');
|
|
3967
|
-
case
|
|
3972
|
+
case 67:
|
|
3968
3973
|
realOrderId = extractedOrderId;
|
|
3969
3974
|
console.log('[Checkout] 订单创建成功,真实订单ID:', realOrderId);
|
|
3970
3975
|
|
|
@@ -3974,10 +3979,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3974
3979
|
oldOrderId: this.store.currentOrder.order_id,
|
|
3975
3980
|
newOrderId: realOrderId
|
|
3976
3981
|
});
|
|
3977
|
-
_context47.prev =
|
|
3978
|
-
_context47.next =
|
|
3982
|
+
_context47.prev = 70;
|
|
3983
|
+
_context47.next = 73;
|
|
3979
3984
|
return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
|
|
3980
|
-
case
|
|
3985
|
+
case 73:
|
|
3981
3986
|
updatedOrder = _context47.sent;
|
|
3982
3987
|
console.log('[Checkout] Payment模块替换订单ID结果:', {
|
|
3983
3988
|
wasSuccessful: !!updatedOrder,
|
|
@@ -4004,22 +4009,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4004
4009
|
目标ID: realOrderId
|
|
4005
4010
|
});
|
|
4006
4011
|
}
|
|
4007
|
-
_context47.next =
|
|
4012
|
+
_context47.next = 83;
|
|
4008
4013
|
break;
|
|
4009
|
-
case
|
|
4010
|
-
_context47.prev =
|
|
4011
|
-
_context47.t2 = _context47["catch"](
|
|
4014
|
+
case 78:
|
|
4015
|
+
_context47.prev = 78;
|
|
4016
|
+
_context47.t2 = _context47["catch"](70);
|
|
4012
4017
|
console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context47.t2);
|
|
4013
4018
|
|
|
4014
4019
|
// 发生错误时也进行手动替换
|
|
4015
4020
|
this.store.currentOrder.order_id = realOrderId;
|
|
4016
4021
|
console.log('[Checkout] 错误恢复:手动设置订单ID:', realOrderId);
|
|
4017
|
-
case
|
|
4022
|
+
case 83:
|
|
4018
4023
|
// 标记订单已同步
|
|
4019
4024
|
this.store.isOrderSynced = true;
|
|
4020
4025
|
|
|
4021
4026
|
// 触发订单同步完成事件
|
|
4022
|
-
_context47.next =
|
|
4027
|
+
_context47.next = 86;
|
|
4023
4028
|
return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
|
|
4024
4029
|
orderUuid: this.store.currentOrder.uuid,
|
|
4025
4030
|
realOrderId: realOrderId,
|
|
@@ -4028,7 +4033,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4028
4033
|
isManual: isManual,
|
|
4029
4034
|
response: checkoutResponse
|
|
4030
4035
|
});
|
|
4031
|
-
case
|
|
4036
|
+
case 86:
|
|
4032
4037
|
// 验证最终状态
|
|
4033
4038
|
finalOrderId = this.store.currentOrder.order_id;
|
|
4034
4039
|
finalIsVirtual = this.isVirtualOrderId(finalOrderId || '');
|
|
@@ -4046,11 +4051,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4046
4051
|
|
|
4047
4052
|
// 返回真实订单ID
|
|
4048
4053
|
return _context47.abrupt("return", realOrderId);
|
|
4049
|
-
case
|
|
4054
|
+
case 91:
|
|
4050
4055
|
case "end":
|
|
4051
4056
|
return _context47.stop();
|
|
4052
4057
|
}
|
|
4053
|
-
}, _callee47, this, [[
|
|
4058
|
+
}, _callee47, this, [[28, 36, 43, 47], [70, 78]]);
|
|
4054
4059
|
}));
|
|
4055
4060
|
function syncOrderToBackendWithReturn() {
|
|
4056
4061
|
return _syncOrderToBackendWithReturn.apply(this, arguments);
|
|
@@ -314,7 +314,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
314
314
|
}[];
|
|
315
315
|
setOtherData(key: string, value: any): void;
|
|
316
316
|
getOtherData(key: string): any;
|
|
317
|
-
getProductTypeById(id: number): Promise<"
|
|
317
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
318
318
|
/**
|
|
319
319
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
320
320
|
*
|
|
@@ -1566,38 +1566,16 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1566
1566
|
const allPaymentItems = await this.payment.getPaymentItemsAsync(
|
|
1567
1567
|
this.store.currentOrder.uuid
|
|
1568
1568
|
);
|
|
1569
|
-
const filteredPaymentItems = allPaymentItems.filter(
|
|
1570
|
-
(payment) => !payment.voucher_id
|
|
1571
|
-
);
|
|
1572
|
-
const voucherItems = allPaymentItems.filter(
|
|
1573
|
-
(payment) => payment.voucher_id
|
|
1574
|
-
);
|
|
1575
|
-
console.log("[Checkout] 支付项过滤结果:", {
|
|
1576
|
-
总支付项: allPaymentItems.length,
|
|
1577
|
-
过滤后支付项: filteredPaymentItems.length,
|
|
1578
|
-
被过滤的代金券项: voucherItems.length,
|
|
1579
|
-
代金券详情: voucherItems.map((item) => ({
|
|
1580
|
-
uuid: item.uuid,
|
|
1581
|
-
code: item.code,
|
|
1582
|
-
amount: item.amount,
|
|
1583
|
-
voucherId: item.voucher_id
|
|
1584
|
-
})),
|
|
1585
|
-
保留的支付项: filteredPaymentItems.map((item) => ({
|
|
1586
|
-
uuid: item.uuid,
|
|
1587
|
-
code: item.code,
|
|
1588
|
-
amount: item.amount
|
|
1589
|
-
}))
|
|
1590
|
-
});
|
|
1591
1569
|
const realOrderId = await this.syncOrderToBackendWithReturn(
|
|
1592
1570
|
false,
|
|
1593
|
-
|
|
1571
|
+
allPaymentItems
|
|
1594
1572
|
);
|
|
1595
1573
|
console.log("[Checkout] 保存订单完成:", {
|
|
1596
1574
|
orderUuid,
|
|
1597
1575
|
oldOrderId: currentOrderId,
|
|
1598
1576
|
realOrderId,
|
|
1599
1577
|
isOrderSynced: this.store.isOrderSynced,
|
|
1600
|
-
filteredPaymentsCount:
|
|
1578
|
+
filteredPaymentsCount: allPaymentItems.length
|
|
1601
1579
|
});
|
|
1602
1580
|
const finalOrderId = this.store.currentOrder.order_id;
|
|
1603
1581
|
console.log("[Checkout] saveForLaterPaymentAsync 最终状态验证:", {
|
|
@@ -2236,7 +2214,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2236
2214
|
* @returns 后端返回的真实订单ID
|
|
2237
2215
|
*/
|
|
2238
2216
|
async syncOrderToBackendWithReturn(isManual = false, customPaymentItems) {
|
|
2239
|
-
var _a, _b, _c, _d, _e;
|
|
2217
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2240
2218
|
if (!this.store.localOrderData || !this.store.currentOrder) {
|
|
2241
2219
|
throw new Error("缺少必要的订单数据,无法同步到后端");
|
|
2242
2220
|
}
|
|
@@ -2290,13 +2268,34 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2290
2268
|
};
|
|
2291
2269
|
})
|
|
2292
2270
|
});
|
|
2271
|
+
const processedPaymentItems = paymentItems.map((item) => {
|
|
2272
|
+
var _a2, _b2;
|
|
2273
|
+
return {
|
|
2274
|
+
...item,
|
|
2275
|
+
metadata: {
|
|
2276
|
+
...item.metadata,
|
|
2277
|
+
rounding_rule: ((_a2 = item.metadata) == null ? void 0 : _a2.rounding_rule) || this.otherParams.order_rounding_setting,
|
|
2278
|
+
shop_wallet_pass_id: ((_b2 = item.metadata) == null ? void 0 : _b2.shop_wallet_pass_id) || this.otherParams.shop_wallet_pass_id
|
|
2279
|
+
}
|
|
2280
|
+
};
|
|
2281
|
+
});
|
|
2282
|
+
console.log("[Checkout] 处理后的支付项数据(包含完整metadata):", {
|
|
2283
|
+
originalCount: paymentItems.length,
|
|
2284
|
+
processedCount: processedPaymentItems.length,
|
|
2285
|
+
sampleMetadata: (_a = processedPaymentItems[0]) == null ? void 0 : _a.metadata,
|
|
2286
|
+
allPaymentItems: processedPaymentItems.map((p) => ({
|
|
2287
|
+
code: p.code,
|
|
2288
|
+
amount: p.amount,
|
|
2289
|
+
metadata: p.metadata
|
|
2290
|
+
}))
|
|
2291
|
+
});
|
|
2293
2292
|
const orderParams = {
|
|
2294
2293
|
...this.store.localOrderData,
|
|
2295
2294
|
type: this.store.localOrderData.type,
|
|
2296
2295
|
platform: this.store.localOrderData.platform,
|
|
2297
|
-
payments:
|
|
2298
|
-
//
|
|
2299
|
-
customer_id: (
|
|
2296
|
+
payments: processedPaymentItems,
|
|
2297
|
+
// 使用处理过的支付项数据
|
|
2298
|
+
customer_id: (_b = this.store.currentCustomer) == null ? void 0 : _b.customer_id,
|
|
2300
2299
|
// 添加客户ID
|
|
2301
2300
|
is_price_include_tax: this.otherParams.is_price_include_tax,
|
|
2302
2301
|
// core 有
|
|
@@ -2309,8 +2308,8 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2309
2308
|
currency_code: this.otherParams.currency_code,
|
|
2310
2309
|
currency_symbol: this.otherParams.currency_symbol,
|
|
2311
2310
|
currency_format: this.otherParams.currency_format,
|
|
2312
|
-
is_deposit: ((
|
|
2313
|
-
deposit_amount: ((
|
|
2311
|
+
is_deposit: ((_c = this.store.currentOrder) == null ? void 0 : _c.is_deposit) || 0,
|
|
2312
|
+
deposit_amount: ((_d = this.store.currentOrder) == null ? void 0 : _d.deposit_amount) || "0.00",
|
|
2314
2313
|
// surcharge_fee: this.otherParams.surcharge_fee,
|
|
2315
2314
|
// surcharges: ,
|
|
2316
2315
|
note: this.store.localOrderData.shop_note
|
|
@@ -2372,7 +2371,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2372
2371
|
orderUuid: this.store.currentOrder.uuid,
|
|
2373
2372
|
operation: isUpdateOperation ? "update" : "create",
|
|
2374
2373
|
isManual,
|
|
2375
|
-
orderId: submitSuccess ? ((
|
|
2374
|
+
orderId: submitSuccess ? ((_e = checkoutResponse == null ? void 0 : checkoutResponse.data) == null ? void 0 : _e.order_id) || (checkoutResponse == null ? void 0 : checkoutResponse.order_id) : void 0,
|
|
2376
2375
|
error: submitError,
|
|
2377
2376
|
duration: Date.now() - startTime,
|
|
2378
2377
|
timestamp: Date.now()
|
|
@@ -2413,7 +2412,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2413
2412
|
realOrderId = currentOrderId;
|
|
2414
2413
|
console.log(`[Checkout] 订单更新成功,订单ID: ${realOrderId}`);
|
|
2415
2414
|
} else {
|
|
2416
|
-
let extractedOrderId = (
|
|
2415
|
+
let extractedOrderId = (_f = checkoutResponse == null ? void 0 : checkoutResponse.data) == null ? void 0 : _f.order_id;
|
|
2417
2416
|
if (!extractedOrderId) {
|
|
2418
2417
|
extractedOrderId = checkoutResponse == null ? void 0 : checkoutResponse.order_id;
|
|
2419
2418
|
}
|