refactor(fulfillment): 移除飞飞/乐玩通道,仅保留 affiliate_dash
新单只路由 affiliate_dash(未命中走 manual_dispatch);历史飞飞/乐玩任务保留只读 stub,避免订单重同步失败。同步清理 cloudtentacles 调度、Admin 写路径与相关 env。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,21 +4,16 @@ import QRCode from 'qrcode'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useParams } from 'react-router'
|
||||
|
||||
import { isFeedbackDismissed, showConfirm, showError, showSuccess } from '@/lib/feedback'
|
||||
import { showError, showSuccess } from '@/lib/feedback'
|
||||
import {
|
||||
confirmKuaishouCloudClaimRole,
|
||||
fetchClaimDetail,
|
||||
rebindKuaishouCloudClaimRole,
|
||||
redeemKuaishouCloudClaim,
|
||||
submitAffiliateDashClaim,
|
||||
submitClaimUid,
|
||||
} from '@/services/claim'
|
||||
import type { ClaimDetailData } from '@/types/claim'
|
||||
|
||||
import { AffiliateDashClaimPanel, AffiliateDashResultStep } from './ClaimAffiliateDashSteps'
|
||||
import { FeifeiClaimPanel, FeifeiResultStep } from './ClaimFeifeiSteps'
|
||||
import { ClaimHeaderCard } from './ClaimHeaderCard'
|
||||
import { ClaimResultStep, KuaishouCloudClaimSteps } from './ClaimLewanSteps'
|
||||
import { ClaimUidStep } from './ClaimUidStep'
|
||||
import { resolveNextPollDelayMs, resolveRolePollDelayMs } from './claim-poll'
|
||||
import { createClaimSnapshot, type ClaimSnapshot } from './claim-snapshot'
|
||||
@@ -30,10 +25,6 @@ export default function ClaimPage() {
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [submittingUid, setSubmittingUid] = useState(false)
|
||||
const [uidInput, setUidInput] = useState('')
|
||||
const [refreshingRole, setRefreshingRole] = useState(false)
|
||||
const [confirmingRole, setConfirmingRole] = useState(false)
|
||||
const [rebindingRole, setRebindingRole] = useState(false)
|
||||
const [redeeming, setRedeeming] = useState(false)
|
||||
const [submittingSubmit, setSubmittingSubmit] = useState(false)
|
||||
const [errorMessage, setErrorMessage] = useState('')
|
||||
const [detail, setDetail] = useState<ClaimDetailData | null>(null)
|
||||
@@ -42,10 +33,7 @@ export default function ClaimPage() {
|
||||
const pollTimerRef = useRef(0)
|
||||
const rolePollBaselineRef = useRef({ roleKey: '', at: 0 })
|
||||
|
||||
const snapshot = useMemo(
|
||||
() => createClaimSnapshot(detail, { rebindingRole }),
|
||||
[detail, rebindingRole],
|
||||
)
|
||||
const snapshot = useMemo(() => createClaimSnapshot(detail), [detail])
|
||||
|
||||
const stopPolling = useCallback(() => {
|
||||
if (pollTimerRef.current) {
|
||||
@@ -83,13 +71,7 @@ export default function ClaimPage() {
|
||||
if (expectedUid) {
|
||||
setUidInput(expectedUid)
|
||||
}
|
||||
await generateQRCode(
|
||||
String(
|
||||
nextDetail.kuaishouCloudFulfillment?.binding.bindUrl ||
|
||||
nextDetail.affiliateDash?.bindUrl ||
|
||||
'',
|
||||
).trim(),
|
||||
)
|
||||
await generateQRCode(String(nextDetail.affiliateDash?.bindUrl || '').trim())
|
||||
},
|
||||
[generateQRCode],
|
||||
)
|
||||
@@ -145,6 +127,9 @@ export default function ClaimPage() {
|
||||
|
||||
useEffect(() => {
|
||||
stopPolling()
|
||||
if (snapshot.channelOffline) {
|
||||
return undefined
|
||||
}
|
||||
const delay = resolveNextPollDelay(snapshot)
|
||||
if (!delay) {
|
||||
return undefined
|
||||
@@ -161,7 +146,6 @@ export default function ClaimPage() {
|
||||
}, [loadDetail, resolveNextPollDelay, snapshot, stopPolling])
|
||||
|
||||
async function handleSubmitUid() {
|
||||
// 防并发:提交中忽略重复触发(按钮 loading + 回车 Enter 都可能连续触发)
|
||||
if (submittingUid) {
|
||||
return
|
||||
}
|
||||
@@ -219,139 +203,6 @@ export default function ClaimPage() {
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshRole() {
|
||||
setRefreshingRole(true)
|
||||
try {
|
||||
const nextDetail = await loadDetail({ silent: true })
|
||||
const nextSnapshot = createClaimSnapshot(nextDetail, { rebindingRole })
|
||||
|
||||
if (nextSnapshot.isUidMatched) {
|
||||
showSuccess('角色信息已匹配,可确认兑换')
|
||||
} else if (nextSnapshot.roleId) {
|
||||
showError(
|
||||
`当前绑定角色 ID(${nextSnapshot.roleId})与填写 UID(${nextSnapshot.expectedUid || '-'})不一致`,
|
||||
)
|
||||
} else if (nextDetail) {
|
||||
showError(
|
||||
nextSnapshot.flow?.role.errorMessage ||
|
||||
'暂时还没有识别到角色信息,请完成绑定后稍等片刻再试',
|
||||
)
|
||||
}
|
||||
} finally {
|
||||
setRefreshingRole(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmRole() {
|
||||
setConfirmingRole(true)
|
||||
try {
|
||||
const response = await confirmKuaishouCloudClaimRole(token)
|
||||
await applyDetail(response.data)
|
||||
showSuccess('角色已确认,进入下一步')
|
||||
} catch (error) {
|
||||
showError(error instanceof Error ? error.message : '确认角色失败')
|
||||
} finally {
|
||||
setConfirmingRole(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmRedeem() {
|
||||
try {
|
||||
await showConfirm('兑换后不可取消,也不可退货。请确认 UID 与商品信息完全正确。', '确认兑换', {
|
||||
okText: '确认兑换',
|
||||
okButtonProps: { danger: true },
|
||||
})
|
||||
} catch (error) {
|
||||
if (!isFeedbackDismissed(error)) {
|
||||
showError('确认弹窗已关闭')
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
setRedeeming(true)
|
||||
try {
|
||||
const response = await redeemKuaishouCloudClaim(token)
|
||||
await applyDetail(response.data)
|
||||
showSuccess('兑换请求已提交')
|
||||
} catch (error) {
|
||||
showError(error instanceof Error ? error.message : '兑换失败')
|
||||
} finally {
|
||||
setRedeeming(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function rebindRole() {
|
||||
try {
|
||||
await showConfirm(
|
||||
'换绑后当前绑定链接会失效,系统会退还当前虚拟号并生成新的绑定二维码。请使用你填写的 UID 对应角色重新绑定。',
|
||||
'确认换绑角色',
|
||||
{
|
||||
okText: '确认换绑',
|
||||
okButtonProps: { danger: true },
|
||||
},
|
||||
)
|
||||
} catch (error) {
|
||||
if (!isFeedbackDismissed(error)) {
|
||||
showError('确认弹窗已关闭')
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
setRebindingRole(true)
|
||||
try {
|
||||
const response = await rebindKuaishouCloudClaimRole(token)
|
||||
await applyDetail(response.data)
|
||||
showSuccess('新的绑定二维码已生成,请重新绑定角色')
|
||||
} catch (error) {
|
||||
showError(error instanceof Error ? error.message : '换绑角色失败')
|
||||
} finally {
|
||||
setRebindingRole(false)
|
||||
}
|
||||
}
|
||||
|
||||
function openBindUrl(useCurrentPage = false) {
|
||||
const bindUrl = String(
|
||||
snapshot.flow?.binding.bindUrl || snapshot.affiliateDash?.bindUrl || '',
|
||||
).trim()
|
||||
if (!bindUrl) {
|
||||
showError('绑定链接还没准备好,请稍后刷新')
|
||||
return
|
||||
}
|
||||
|
||||
if (useCurrentPage) {
|
||||
window.location.assign(bindUrl)
|
||||
return
|
||||
}
|
||||
|
||||
window.open(bindUrl, '_blank', 'noopener,noreferrer')
|
||||
}
|
||||
|
||||
function openFeifeiUrl(useCurrentPage = false) {
|
||||
const url = String(
|
||||
snapshot.feifei?.h5UrlWithUid ||
|
||||
snapshot.feifei?.h5.rechargeUrl ||
|
||||
snapshot.feifei?.h5.entryUrl ||
|
||||
'',
|
||||
).trim()
|
||||
|
||||
if (!snapshot.hasExpectedUid) {
|
||||
showError('请先填写游戏 UID')
|
||||
return
|
||||
}
|
||||
|
||||
if (!url) {
|
||||
showError('领取链接还没准备好,请稍后刷新')
|
||||
return
|
||||
}
|
||||
|
||||
if (useCurrentPage) {
|
||||
window.location.assign(url)
|
||||
return
|
||||
}
|
||||
|
||||
window.open(url, '_blank', 'noopener,noreferrer')
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="claim-page">
|
||||
<ClaimHeaderCard
|
||||
@@ -376,6 +227,11 @@ export default function ClaimPage() {
|
||||
<Card className="claim-content-card claim-state-card">
|
||||
<Empty description="流程数据不完整,请联系客服处理" />
|
||||
</Card>
|
||||
) : snapshot.channelOffline ? (
|
||||
<Card className="claim-content-card claim-state-card">
|
||||
<ExclamationCircleOutlined className="claim-large-icon claim-icon-error" />
|
||||
<p>{snapshot.channelOfflineMessage || '该履约渠道已下线,无法继续领取'}</p>
|
||||
</Card>
|
||||
) : snapshot.currentStep === 1 ? (
|
||||
<ClaimUidStep
|
||||
uidInput={uidInput}
|
||||
@@ -383,14 +239,8 @@ export default function ClaimPage() {
|
||||
onChange={setUidInput}
|
||||
onSubmit={() => void handleSubmitUid()}
|
||||
/>
|
||||
) : snapshot.hasRedeemResult ? (
|
||||
snapshot.isFeifeiFlow ? (
|
||||
<FeifeiResultStep snapshot={snapshot} />
|
||||
) : snapshot.isAffiliateDashFlow ? (
|
||||
<AffiliateDashResultStep snapshot={snapshot} />
|
||||
) : (
|
||||
<ClaimResultStep snapshot={snapshot} />
|
||||
)
|
||||
) : snapshot.hasRedeemResult && snapshot.isAffiliateDashFlow ? (
|
||||
<AffiliateDashResultStep snapshot={snapshot} />
|
||||
) : snapshot.isAffiliateDashFlow && snapshot.affiliateDash ? (
|
||||
<AffiliateDashClaimPanel
|
||||
affiliateDash={snapshot.affiliateDash}
|
||||
@@ -404,40 +254,9 @@ export default function ClaimPage() {
|
||||
onResubmitUid={() => void handleSubmitUid()}
|
||||
onSubmit={() => void handleSubmitAffiliateDash()}
|
||||
/>
|
||||
) : snapshot.isFeifeiFlow && snapshot.feifei ? (
|
||||
<FeifeiClaimPanel
|
||||
feifei={snapshot.feifei}
|
||||
expectedUid={snapshot.expectedUid}
|
||||
order={snapshot.order}
|
||||
product={snapshot.product}
|
||||
taskLastError={snapshot.task?.lastError}
|
||||
onOpen={() => openFeifeiUrl(false)}
|
||||
uidInput={uidInput}
|
||||
submittingUid={submittingUid}
|
||||
onUidChange={setUidInput}
|
||||
onResubmitUid={() => void handleSubmitUid()}
|
||||
/>
|
||||
) : snapshot.flow ? (
|
||||
<KuaishouCloudClaimSteps
|
||||
snapshot={snapshot}
|
||||
qrCodeDataUrl={qrCodeDataUrl}
|
||||
refreshingRole={refreshingRole}
|
||||
confirmingRole={confirmingRole}
|
||||
rebindingRole={rebindingRole}
|
||||
redeeming={redeeming}
|
||||
onOpenBindUrl={openBindUrl}
|
||||
onRefreshRole={refreshRole}
|
||||
onRebindRole={rebindRole}
|
||||
onConfirmRole={confirmRole}
|
||||
onConfirmRedeem={confirmRedeem}
|
||||
uidInput={uidInput}
|
||||
submittingUid={submittingUid}
|
||||
onUidChange={setUidInput}
|
||||
onResubmitUid={() => void handleSubmitUid()}
|
||||
/>
|
||||
) : (
|
||||
<Card className="claim-content-card claim-state-card">
|
||||
<Empty description="流程数据不完整,请联系客服处理" />
|
||||
<Empty description="当前领取流程不可用,请联系客服处理" />
|
||||
</Card>
|
||||
)}
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user