This commit is contained in:
@@ -216,7 +216,7 @@
|
|||||||
}
|
}
|
||||||
ElMessage.warning('资金概况已被其他操作更新,已刷新最新版本;请确认后重新提交')
|
ElMessage.warning('资金概况已被其他操作更新,已刷新最新版本;请确认后重新提交')
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error(normalizeApiError(error).message)
|
console.error('实际信用额度调整失败:', error)
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
submitting.value = false
|
submitting.value = false
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { normalizeApiError } from '@/utils/business/apiError'
|
|
||||||
import type { AgentRechargeStatus } from '@/types/api'
|
import type { AgentRechargeStatus } from '@/types/api'
|
||||||
|
|
||||||
export const ONLINE_RECHARGE_TERMINAL_STATUSES: AgentRechargeStatus[] = [3, 4, 5, 6]
|
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 => {
|
export const amountYuanToFen = (amount: number): number => {
|
||||||
return Math.round(amount * 100)
|
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 type { SearchFormItem } from '@/types'
|
||||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||||
import { formatDateTime } from '@/utils/business/format'
|
import { formatDateTime } from '@/utils/business/format'
|
||||||
import { normalizeApiError } from '@/utils/business/apiError'
|
|
||||||
import {
|
import {
|
||||||
getApprovalStatusText,
|
getApprovalStatusText,
|
||||||
getCurrentApproverSummaryText,
|
getCurrentApproverSummaryText,
|
||||||
@@ -326,8 +325,7 @@
|
|||||||
import {
|
import {
|
||||||
amountYuanToFen,
|
amountYuanToFen,
|
||||||
createOnlineRechargeRequestId,
|
createOnlineRechargeRequestId,
|
||||||
isOnlineRechargeTerminal,
|
isOnlineRechargeTerminal
|
||||||
shouldRetryOnlineCreate
|
|
||||||
} from './agentRechargeOnline'
|
} from './agentRechargeOnline'
|
||||||
|
|
||||||
defineOptions({ name: 'AgentRechargeList' })
|
defineOptions({ name: 'AgentRechargeList' })
|
||||||
@@ -368,7 +366,6 @@
|
|||||||
const paymentStatusLoading = ref(false)
|
const paymentStatusLoading = ref(false)
|
||||||
const qrContent = ref('')
|
const qrContent = ref('')
|
||||||
const onlineRequestId = ref<string | null>(null)
|
const onlineRequestId = ref<string | null>(null)
|
||||||
const onlineCreateRetried = ref(false)
|
|
||||||
const paymentStatusTimer = ref<ReturnType<typeof setInterval> | null>(null)
|
const paymentStatusTimer = ref<ReturnType<typeof setInterval> | null>(null)
|
||||||
const paymentMethodsBounds = reactive({
|
const paymentMethodsBounds = reactive({
|
||||||
min_amount: 10000,
|
min_amount: 10000,
|
||||||
@@ -546,6 +543,7 @@
|
|||||||
})
|
})
|
||||||
const createSubmitDisabled = computed(
|
const createSubmitDisabled = computed(
|
||||||
() =>
|
() =>
|
||||||
|
createLoading.value ||
|
||||||
voucherUploading.value ||
|
voucherUploading.value ||
|
||||||
paymentMethodsLoading.value ||
|
paymentMethodsLoading.value ||
|
||||||
(createMode.value === 'online' && onlinePaymentMethods.value.length === 0)
|
(createMode.value === 'online' && onlinePaymentMethods.value.length === 0)
|
||||||
@@ -973,7 +971,6 @@
|
|||||||
createForm.payment_voucher_key = []
|
createForm.payment_voucher_key = []
|
||||||
createForm.remark = ''
|
createForm.remark = ''
|
||||||
onlineRequestId.value = null
|
onlineRequestId.value = null
|
||||||
onlineCreateRetried.value = false
|
|
||||||
voucherUploading.value = false
|
voucherUploading.value = false
|
||||||
uploadRef.value?.clearFiles(false)
|
uploadRef.value?.clearFiles(false)
|
||||||
}
|
}
|
||||||
@@ -1007,6 +1004,8 @@
|
|||||||
|
|
||||||
// 创建充值订单
|
// 创建充值订单
|
||||||
const handleCreateRecharge = async () => {
|
const handleCreateRecharge = async () => {
|
||||||
|
if (createLoading.value) return
|
||||||
|
|
||||||
const formRef = createFormRef.value
|
const formRef = createFormRef.value
|
||||||
if (!formRef) return
|
if (!formRef) return
|
||||||
if (voucherUploading.value) {
|
if (voucherUploading.value) {
|
||||||
@@ -1014,11 +1013,11 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const valid = await formRef.validate().catch(() => false)
|
|
||||||
if (!valid || createForm.amount == null || !createForm.payment_method) return
|
|
||||||
|
|
||||||
createLoading.value = true
|
createLoading.value = true
|
||||||
try {
|
try {
|
||||||
|
const valid = await formRef.validate().catch(() => false)
|
||||||
|
if (!valid || createForm.amount == null || !createForm.payment_method) return
|
||||||
|
|
||||||
if (createMode.value === 'online') {
|
if (createMode.value === 'online') {
|
||||||
await handleOnlineRechargeCreate(createForm.amount, createForm.payment_method)
|
await handleOnlineRechargeCreate(createForm.amount, createForm.payment_method)
|
||||||
return
|
return
|
||||||
@@ -1067,7 +1066,6 @@
|
|||||||
|
|
||||||
const requestId = onlineRequestId.value || createOnlineRechargeRequestId()
|
const requestId = onlineRequestId.value || createOnlineRechargeRequestId()
|
||||||
onlineRequestId.value = requestId
|
onlineRequestId.value = requestId
|
||||||
onlineCreateRetried.value = false
|
|
||||||
|
|
||||||
const request: CreateAgentRechargeRequest = {
|
const request: CreateAgentRechargeRequest = {
|
||||||
amount: amountYuanToFen(amountYuan),
|
amount: amountYuanToFen(amountYuan),
|
||||||
@@ -1075,45 +1073,28 @@
|
|||||||
request_id: requestId
|
request_id: requestId
|
||||||
}
|
}
|
||||||
|
|
||||||
let attempt = 0
|
try {
|
||||||
while (attempt < 2) {
|
const res = await AgentRechargeService.createAgentRecharge(request)
|
||||||
try {
|
if (res.code !== 0) {
|
||||||
const res = await AgentRechargeService.createAgentRecharge(request)
|
ElMessage.error(res.msg || '在线充值创建失败')
|
||||||
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('在线充值请求结果未知,请勿重复提交;可关闭后刷新列表确认')
|
|
||||||
}
|
|
||||||
onlineRequestId.value = null
|
onlineRequestId.value = null
|
||||||
return
|
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
|
type SystemConfigModule
|
||||||
} from '@/types/api/systemConfig'
|
} from '@/types/api/systemConfig'
|
||||||
import { formatDateTime } from '@/utils/business/format'
|
import { formatDateTime } from '@/utils/business/format'
|
||||||
import { normalizeApiError } from '@/utils/business/apiError'
|
|
||||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||||
import { JULY_PERMISSIONS } from '@/config/constants'
|
import { JULY_PERMISSIONS } from '@/config/constants'
|
||||||
import { useAuth } from '@/composables/useAuth'
|
import { useAuth } from '@/composables/useAuth'
|
||||||
@@ -367,7 +366,6 @@
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('更新系统配置失败:', error)
|
console.error('更新系统配置失败:', error)
|
||||||
ElMessage.error(normalizeApiError(error).message)
|
|
||||||
} finally {
|
} finally {
|
||||||
submitLoading.value = false
|
submitLoading.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user