From 93ed3fbd630c6b614e8f7d7788601036458db962 Mon Sep 17 00:00:00 2001 From: luo Date: Thu, 30 Jul 2026 09:51:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=A3=E7=90=86=E5=85=85=E5=80=BC?= =?UTF-8?q?=E6=89=AB=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/ShopCreditLimitDialog.vue | 2 +- .../agent-recharge/agentRechargeOnline.ts | 6 -- src/views/finance/agent-recharge/index.vue | 71 +++++++------------ src/views/settings/system-configs/index.vue | 2 - 4 files changed, 27 insertions(+), 54 deletions(-) diff --git a/src/components/business/ShopCreditLimitDialog.vue b/src/components/business/ShopCreditLimitDialog.vue index 93a9b39..3acacdb 100644 --- a/src/components/business/ShopCreditLimitDialog.vue +++ b/src/components/business/ShopCreditLimitDialog.vue @@ -216,7 +216,7 @@ } ElMessage.warning('资金概况已被其他操作更新,已刷新最新版本;请确认后重新提交') } else { - ElMessage.error(normalizeApiError(error).message) + console.error('实际信用额度调整失败:', error) } } finally { submitting.value = false diff --git a/src/views/finance/agent-recharge/agentRechargeOnline.ts b/src/views/finance/agent-recharge/agentRechargeOnline.ts index efde3b0..1811309 100644 --- a/src/views/finance/agent-recharge/agentRechargeOnline.ts +++ b/src/views/finance/agent-recharge/agentRechargeOnline.ts @@ -1,4 +1,3 @@ -import { normalizeApiError } from '@/utils/business/apiError' import type { AgentRechargeStatus } from '@/types/api' export const ONLINE_RECHARGE_TERMINAL_STATUSES: AgentRechargeStatus[] = [3, 4, 5, 6] @@ -16,8 +15,3 @@ export const createOnlineRechargeRequestId = (): string => { export const amountYuanToFen = (amount: number): number => { return Math.round(amount * 100) } - -export const shouldRetryOnlineCreate = (error: unknown): boolean => { - const kind = normalizeApiError(error).kind - return kind === 'timeout' || kind === 'server' || kind === 'unknown' -} diff --git a/src/views/finance/agent-recharge/index.vue b/src/views/finance/agent-recharge/index.vue index 6625adc..c39b2c9 100644 --- a/src/views/finance/agent-recharge/index.vue +++ b/src/views/finance/agent-recharge/index.vue @@ -309,7 +309,6 @@ import type { SearchFormItem } from '@/types' import { useCheckedColumns } from '@/composables/useCheckedColumns' import { formatDateTime } from '@/utils/business/format' - import { normalizeApiError } from '@/utils/business/apiError' import { getApprovalStatusText, getCurrentApproverSummaryText, @@ -326,8 +325,7 @@ import { amountYuanToFen, createOnlineRechargeRequestId, - isOnlineRechargeTerminal, - shouldRetryOnlineCreate + isOnlineRechargeTerminal } from './agentRechargeOnline' defineOptions({ name: 'AgentRechargeList' }) @@ -368,7 +366,6 @@ const paymentStatusLoading = ref(false) const qrContent = ref('') const onlineRequestId = ref(null) - const onlineCreateRetried = ref(false) const paymentStatusTimer = ref | null>(null) const paymentMethodsBounds = reactive({ min_amount: 10000, @@ -546,6 +543,7 @@ }) const createSubmitDisabled = computed( () => + createLoading.value || voucherUploading.value || paymentMethodsLoading.value || (createMode.value === 'online' && onlinePaymentMethods.value.length === 0) @@ -973,7 +971,6 @@ createForm.payment_voucher_key = [] createForm.remark = '' onlineRequestId.value = null - onlineCreateRetried.value = false voucherUploading.value = false uploadRef.value?.clearFiles(false) } @@ -1007,6 +1004,8 @@ // 创建充值订单 const handleCreateRecharge = async () => { + if (createLoading.value) return + const formRef = createFormRef.value if (!formRef) return if (voucherUploading.value) { @@ -1014,11 +1013,11 @@ return } - const valid = await formRef.validate().catch(() => false) - if (!valid || createForm.amount == null || !createForm.payment_method) return - createLoading.value = true try { + const valid = await formRef.validate().catch(() => false) + if (!valid || createForm.amount == null || !createForm.payment_method) return + if (createMode.value === 'online') { await handleOnlineRechargeCreate(createForm.amount, createForm.payment_method) return @@ -1067,7 +1066,6 @@ const requestId = onlineRequestId.value || createOnlineRechargeRequestId() onlineRequestId.value = requestId - onlineCreateRetried.value = false const request: CreateAgentRechargeRequest = { amount: amountYuanToFen(amountYuan), @@ -1075,45 +1073,28 @@ request_id: requestId } - let attempt = 0 - while (attempt < 2) { - try { - const res = await AgentRechargeService.createAgentRecharge(request) - if (res.code !== 0) { - ElMessage.error(res.msg || '在线充值创建失败') - onlineRequestId.value = null - return - } - - if (!res.data?.qr_content) { - ElMessage.error('支付接口未返回有效二维码,请刷新后重试') - return - } - - onlineQrRecharge.value = res.data - onlinePaymentStatus.value = null - qrContent.value = res.data.qr_content - onlineQrDialogVisible.value = true - createDialogVisible.value = false - onlineRequestId.value = null - await getTableData() - return - } catch (error) { - if (attempt === 0 && shouldRetryOnlineCreate(error)) { - attempt += 1 - onlineCreateRetried.value = true - continue - } - - const normalized = normalizeApiError(error) - if (normalized.kind === 'validation' || normalized.kind === 'conflict') { - ElMessage.error(normalized.message) - } else { - ElMessage.warning('在线充值请求结果未知,请勿重复提交;可关闭后刷新列表确认') - } + try { + const res = await AgentRechargeService.createAgentRecharge(request) + if (res.code !== 0) { + ElMessage.error(res.msg || '在线充值创建失败') onlineRequestId.value = null return } + + if (!res.data?.qr_content) { + ElMessage.error('支付接口未返回有效二维码,请刷新后重试') + return + } + + onlineQrRecharge.value = res.data + onlinePaymentStatus.value = null + qrContent.value = res.data.qr_content + onlineQrDialogVisible.value = true + createDialogVisible.value = false + onlineRequestId.value = null + await getTableData() + } catch { + onlineRequestId.value = null } } diff --git a/src/views/settings/system-configs/index.vue b/src/views/settings/system-configs/index.vue index c0c8f83..dead324 100644 --- a/src/views/settings/system-configs/index.vue +++ b/src/views/settings/system-configs/index.vue @@ -118,7 +118,6 @@ type SystemConfigModule } from '@/types/api/systemConfig' import { formatDateTime } from '@/utils/business/format' - import { normalizeApiError } from '@/utils/business/apiError' import { useCheckedColumns } from '@/composables/useCheckedColumns' import { JULY_PERMISSIONS } from '@/config/constants' import { useAuth } from '@/composables/useAuth' @@ -367,7 +366,6 @@ } } catch (error) { console.error('更新系统配置失败:', error) - ElMessage.error(normalizeApiError(error).message) } finally { submitLoading.value = false }