feat(claim): 支持固定H5订单号领取与订单兑换有效性后台控制
- 数据库新增 099_order_claim_status.sql 迁移,扩展 claim_status、claim_status_reason 等字段 - 后端新增 /claims/h5/:orderNo、UID提交、分销提交接口,保留原有 token 接口双轨兼容 - 增加兑换有效性强拦截:暂停/关闭/退款/取消订单精准阻断并返回友好提示 - 后台新增 POST /admin/orders/:orderId/claim-status 接口与审计日志记录 - 前端管理后台(订单列表、详情页)支持 H5 兑换状态展示、一键复制链接及暂停/关闭/启用弹窗 - 前端领取页面适配 /h5/:orderNo 路由及暂停/关闭等状态的异常展示 - 验证方式:运行前后端类型检查、全量单元测试(后端 674、前端 132)及全量构建编译均通过
This commit is contained in:
@@ -1,11 +1,23 @@
|
||||
import { ExclamationCircleOutlined, LoadingOutlined } from '@ant-design/icons'
|
||||
import {
|
||||
ExclamationCircleOutlined,
|
||||
LoadingOutlined,
|
||||
StopOutlined,
|
||||
WarningOutlined,
|
||||
} from '@ant-design/icons'
|
||||
import { Card, Empty, Spin } from 'antd'
|
||||
import QRCode from 'qrcode'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useParams } from 'react-router'
|
||||
|
||||
import { showError, showSuccess } from '@/lib/feedback'
|
||||
import { fetchClaimDetail, submitAffiliateDashClaim, submitClaimUid } from '@/services/claim'
|
||||
import {
|
||||
fetchClaimDetail,
|
||||
fetchH5ClaimDetail,
|
||||
submitAffiliateDashClaim,
|
||||
submitClaimUid,
|
||||
submitH5AffiliateDashClaim,
|
||||
submitH5ClaimUid,
|
||||
} from '@/services/claim'
|
||||
import type { ClaimDetailData } from '@/types/claim'
|
||||
|
||||
import { AffiliateDashClaimPanel, AffiliateDashResultStep } from './ClaimAffiliateDashSteps'
|
||||
@@ -15,8 +27,13 @@ import { resolveNextPollDelayMs, resolveRolePollDelayMs } from './claim-poll'
|
||||
import { createClaimSnapshot, type ClaimSnapshot } from './claim-snapshot'
|
||||
|
||||
export default function ClaimPage() {
|
||||
const { token: routeToken } = useParams<{ token: string }>()
|
||||
const { token: routeToken, orderNo: routeOrderNo } = useParams<{
|
||||
token?: string
|
||||
orderNo?: string
|
||||
}>()
|
||||
const token = String(routeToken || '').trim()
|
||||
const orderNo = String(routeOrderNo || '').trim()
|
||||
const isH5Mode = Boolean(orderNo)
|
||||
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [submittingUid, setSubmittingUid] = useState(false)
|
||||
@@ -82,7 +99,7 @@ export default function ClaimPage() {
|
||||
|
||||
const loadDetail = useCallback(
|
||||
async (options: { silent?: boolean } = {}) => {
|
||||
if (!token) {
|
||||
if (!token && !orderNo) {
|
||||
setLoading(false)
|
||||
setErrorMessage('领取链接无效,请检查链接是否完整')
|
||||
stopPolling()
|
||||
@@ -95,7 +112,9 @@ export default function ClaimPage() {
|
||||
setErrorMessage('')
|
||||
|
||||
try {
|
||||
const response = await fetchClaimDetail(token)
|
||||
const response = isH5Mode
|
||||
? await fetchH5ClaimDetail(orderNo)
|
||||
: await fetchClaimDetail(token)
|
||||
await applyDetail(response.data)
|
||||
return response.data
|
||||
} catch (error) {
|
||||
@@ -108,7 +127,7 @@ export default function ClaimPage() {
|
||||
}
|
||||
}
|
||||
},
|
||||
[applyDetail, stopPolling, token],
|
||||
[applyDetail, isH5Mode, orderNo, stopPolling, token],
|
||||
)
|
||||
|
||||
const resolveNextPollDelay = useCallback((nextSnapshot: ClaimSnapshot) => {
|
||||
@@ -162,7 +181,9 @@ export default function ClaimPage() {
|
||||
|
||||
setSubmittingUid(true)
|
||||
try {
|
||||
const response = await submitClaimUid(token, uid)
|
||||
const response = isH5Mode
|
||||
? await submitH5ClaimUid(orderNo, uid)
|
||||
: await submitClaimUid(token, uid)
|
||||
await applyDetail(response.data)
|
||||
showSuccess('UID 已提交')
|
||||
} catch (error) {
|
||||
@@ -194,10 +215,15 @@ export default function ClaimPage() {
|
||||
|
||||
setSubmittingSubmit(true)
|
||||
try {
|
||||
const response = await submitAffiliateDashClaim(token, {
|
||||
gameAccount: uid,
|
||||
bindUuid,
|
||||
})
|
||||
const response = isH5Mode
|
||||
? await submitH5AffiliateDashClaim(orderNo, {
|
||||
gameAccount: uid,
|
||||
bindUuid,
|
||||
})
|
||||
: await submitAffiliateDashClaim(token, {
|
||||
gameAccount: uid,
|
||||
bindUuid,
|
||||
})
|
||||
await applyDetail(response.data)
|
||||
showSuccess('发货已提交')
|
||||
} catch (error) {
|
||||
@@ -224,8 +250,24 @@ export default function ClaimPage() {
|
||||
</Card>
|
||||
) : errorMessage ? (
|
||||
<Card className="claim-content-card claim-state-card">
|
||||
<ExclamationCircleOutlined className="claim-large-icon claim-icon-error" />
|
||||
<p>{errorMessage}</p>
|
||||
{errorMessage.includes('暂停') ? (
|
||||
<>
|
||||
<WarningOutlined style={{ fontSize: 48, color: '#faad14' }} />
|
||||
<h3 style={{ marginTop: 16 }}>订单兑换已暂停</h3>
|
||||
<p style={{ color: '#64748b' }}>{errorMessage}</p>
|
||||
</>
|
||||
) : errorMessage.includes('关闭') || errorMessage.includes('退款') ? (
|
||||
<>
|
||||
<StopOutlined style={{ fontSize: 48, color: '#94a3b8' }} />
|
||||
<h3 style={{ marginTop: 16 }}>订单不可兑换</h3>
|
||||
<p style={{ color: '#64748b' }}>{errorMessage}</p>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<ExclamationCircleOutlined className="claim-large-icon claim-icon-error" />
|
||||
<p>{errorMessage}</p>
|
||||
</>
|
||||
)}
|
||||
</Card>
|
||||
) : !detail ? (
|
||||
<Card className="claim-content-card claim-state-card">
|
||||
|
||||
Reference in New Issue
Block a user