This commit is contained in:
@@ -216,7 +216,7 @@
|
||||
}
|
||||
ElMessage.warning('资金概况已被其他操作更新,已刷新最新版本;请确认后重新提交')
|
||||
} else {
|
||||
ElMessage.error(normalizeApiError(error).message)
|
||||
console.error('实际信用额度调整失败:', error)
|
||||
}
|
||||
} finally {
|
||||
submitting.value = false
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
|
||||
@@ -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<string | null>(null)
|
||||
const onlineCreateRetried = ref(false)
|
||||
const paymentStatusTimer = ref<ReturnType<typeof setInterval> | 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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user