fix(semi-auto): 扫码后主动提交换绑并透出虎牙失败原因
This commit is contained in:
@@ -731,7 +731,7 @@ export default function AdminSemiAutoTasksPage() {
|
||||
<Text
|
||||
type={
|
||||
event.detail.rebindUnchanged === true ||
|
||||
Number(event.detail.rebindCooldownDays || 0) > 0
|
||||
event.detail.rebindConfirmState === 'rejected'
|
||||
? 'warning'
|
||||
: 'secondary'
|
||||
}
|
||||
@@ -745,6 +745,12 @@ export default function AdminSemiAutoTasksPage() {
|
||||
: ''}
|
||||
</Text>
|
||||
) : null}
|
||||
{event.eventType === 'binding_status_changed' &&
|
||||
event.detail?.rebindConfirmMessage ? (
|
||||
<Text type="secondary">
|
||||
虎牙返回:{String(event.detail.rebindConfirmMessage)}
|
||||
</Text>
|
||||
) : null}
|
||||
</Space>
|
||||
),
|
||||
}))}
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
startCustomerBinding,
|
||||
startCustomerLogin,
|
||||
startCustomerWeiboQrLogin,
|
||||
submitCustomerRebind,
|
||||
verifyCustomerHuyaSmsChallenge,
|
||||
type CustomerHuyaChallengeSolution,
|
||||
type CustomerHuyaSmsChallenge,
|
||||
@@ -306,6 +307,8 @@ export default function CustomerFulfillmentPage() {
|
||||
if (!bindingInfo?.comparison) return
|
||||
// 换绑后仍是原角色时只展示失败原因,不能自动弹出确认框。
|
||||
if (bindingInfo.rebindUnchanged) return
|
||||
// 平台角色与已填资料不一致时先引导同步资料,不能直接弹确认框。
|
||||
if (bindingInfo.comparison.verdict === 'mismatch') return
|
||||
const key = `${selectedTask.id}:${bindingInfo.bindGameRoleId || ''}`
|
||||
if (autoOpenedRoleRef.current === key) return
|
||||
autoOpenedRoleRef.current = key
|
||||
@@ -504,7 +507,18 @@ export default function CustomerFulfillmentPage() {
|
||||
if (nextTask.bindingStatus === 'role_ready') {
|
||||
if (nextBinding?.rebindUnchanged) {
|
||||
setBindingConfirmOpen(false)
|
||||
message.warning(nextBinding.message || '换绑未生效,请查看下方原因')
|
||||
if (nextBinding.rebindConfirmState === 'rejected') {
|
||||
message.error(nextBinding.message || '虎牙未接受本次换绑')
|
||||
} else {
|
||||
message.warning(nextBinding.message || '换绑未生效,请查看下方原因')
|
||||
}
|
||||
return
|
||||
}
|
||||
if (nextBinding?.comparison?.verdict === 'mismatch') {
|
||||
setBindingConfirmOpen(false)
|
||||
message.warning(
|
||||
nextBinding.comparison.message || '平台角色与已填资料不一致,请先同步资料',
|
||||
)
|
||||
return
|
||||
}
|
||||
setBindingConfirmOpen(true)
|
||||
@@ -519,7 +533,11 @@ export default function CustomerFulfillmentPage() {
|
||||
if (openConfirm) setBindingConfirmOpen(false)
|
||||
const detail = nextBinding?.message || ''
|
||||
if (nextTask.bindingStatus === 'scanned') {
|
||||
message.info(detail || '已扫码,正在等待虎牙平台换绑生效,请稍后再点击刷新')
|
||||
if (nextBinding?.rebindConfirmState === 'accepted') {
|
||||
message.info('虎牙已受理换绑,正在等待角色生效')
|
||||
return
|
||||
}
|
||||
message.info(detail || '已扫码,请选好角色后点「已选好角色,提交换绑」')
|
||||
return
|
||||
}
|
||||
if (nextTask.bindingStatus === 'qr_pending') {
|
||||
@@ -548,6 +566,69 @@ export default function CustomerFulfillmentPage() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmitRebind() {
|
||||
if (!selectedTask) return
|
||||
setBindingLoading(true)
|
||||
try {
|
||||
const response = await submitCustomerRebind(orderNo, selectedTask.id)
|
||||
const nextTask = response.data.task
|
||||
const nextBinding = response.data.binding
|
||||
setTasks((current) => current.map((task) => (task.id === nextTask.id ? nextTask : task)))
|
||||
if (nextBinding) setBindingInfo(nextBinding)
|
||||
setBindingConfirmOpen(false)
|
||||
if (nextBinding?.rebindUnchanged || nextBinding?.rebindConfirmState === 'rejected') {
|
||||
message.error(nextBinding.message || '虎牙未接受本次换绑')
|
||||
return
|
||||
}
|
||||
if (nextTask.bindingStatus === 'role_ready') {
|
||||
message.success('换绑已生效,请核对角色后确认绑定')
|
||||
return
|
||||
}
|
||||
message.info('已向虎牙提交换绑,正在等待角色生效')
|
||||
} catch (error) {
|
||||
if (isHuyaSessionExpired(error)) {
|
||||
setBindingSessionExpired(true)
|
||||
setBindingConfirmOpen(false)
|
||||
message.warning('虎牙登录会话已过期,请重新登录')
|
||||
return
|
||||
}
|
||||
message.error(error instanceof Error ? error.message : '提交换绑失败')
|
||||
} finally {
|
||||
setBindingLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSyncBindingProfile() {
|
||||
if (!selectedTask) return
|
||||
const comparison = bindingInfo?.comparison
|
||||
if (!comparison) return
|
||||
const roleName = comparison.boundRoleName
|
||||
const roleId = comparison.boundRoleId
|
||||
const serverZone = comparison.boundZone
|
||||
if (!roleName || !roleId || !/^\d+$/.test(roleId) || !serverZone) {
|
||||
message.warning('平台角色信息不完整,请点「修改资料」手动填写')
|
||||
return
|
||||
}
|
||||
setProfileSaving(true)
|
||||
try {
|
||||
const response = await saveCustomerTaskProfile(orderNo, selectedTask.id, {
|
||||
roleName,
|
||||
roleId,
|
||||
serverZone,
|
||||
})
|
||||
setTasks((current) =>
|
||||
current.map((task) => (task.id === response.data.task.id ? response.data.task : task)),
|
||||
)
|
||||
const bindingResponse = await pollCustomerBinding(orderNo, selectedTask.id)
|
||||
if (bindingResponse.data.binding) setBindingInfo(bindingResponse.data.binding)
|
||||
message.success('资料已按平台角色同步,请核对后确认绑定')
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '同步角色资料失败')
|
||||
} finally {
|
||||
setProfileSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleConfirmBinding() {
|
||||
if (!selectedTask) return
|
||||
setBindingLoading(true)
|
||||
@@ -646,10 +727,16 @@ export default function CustomerFulfillmentPage() {
|
||||
})()
|
||||
const bindingRoleName = bindingInfo?.bindGameRole || selectedTask?.bindGameRole || ''
|
||||
const rebindUnchanged = bindingInfo?.rebindUnchanged === true
|
||||
const rebindCooldownDays = Number(bindingInfo?.rebindCooldownDays || 0)
|
||||
const rebindConfirmState = bindingInfo?.rebindConfirmState || 'idle'
|
||||
const rebindRejected = rebindConfirmState === 'rejected'
|
||||
const rebindAccepted = rebindConfirmState === 'accepted'
|
||||
const nextRebindText = bindingInfo?.nextRebindAt
|
||||
? formatAdminDateTime(bindingInfo.nextRebindAt)
|
||||
: ''
|
||||
const comparisonMismatch =
|
||||
selectedTask?.bindingStatus === 'role_ready' &&
|
||||
!rebindUnchanged &&
|
||||
bindingComparison?.verdict === 'mismatch'
|
||||
const showProfileForm = showBindingStage && profileEditing
|
||||
const bindingCustomerReady = Boolean(
|
||||
bindingComparison?.customerRoleId || bindingComparison?.customerRoleName,
|
||||
@@ -990,7 +1077,11 @@ export default function CustomerFulfillmentPage() {
|
||||
|
||||
{!bindingSessionExpired ? (
|
||||
rebindUnchanged ? (
|
||||
<div className="customer-binding-alert is-warning">换绑未生效,请查看下方原因</div>
|
||||
<div className="customer-binding-alert is-warning">
|
||||
{rebindRejected
|
||||
? '虎牙未接受本次换绑,请查看下方原因'
|
||||
: '换绑未生效,请查看下方原因'}
|
||||
</div>
|
||||
) : selectedTask?.bindingStatus === 'role_ready' ? (
|
||||
<div className="customer-binding-alert is-info">已识别绑定角色,请核对后确认</div>
|
||||
) : selectedTask?.bindingStatus === 'confirmed' || bindingRoleId ? (
|
||||
@@ -1072,13 +1163,16 @@ export default function CustomerFulfillmentPage() {
|
||||
<p className="customer-binding-qr-hint">请使用微信APP扫码进行游戏角色绑定</p>
|
||||
<p className="customer-binding-qr-tip">
|
||||
{selectedTask?.bindingStatus === 'scanned'
|
||||
? '请在微信中完成角色绑定确认,再点击下方按钮进入下一步'
|
||||
: '扫码后请在微信确认框中核对目标角色;本活动 7 天内只能换绑 1 次'}
|
||||
? rebindAccepted
|
||||
? '已向虎牙提交换绑,正在等待角色生效,请稍候刷新。'
|
||||
: bindingInfo?.rebindRequested
|
||||
? '扫码后请在虎牙弹窗中选中目标角色;选好后点下方「已选好角色,提交换绑」。'
|
||||
: '请在微信中完成角色绑定确认,再点击下方按钮进入下一步。'
|
||||
: '扫码后请在微信确认框中核对目标角色。'}
|
||||
</p>
|
||||
{rebindCooldownDays > 0 ? (
|
||||
{nextRebindText ? (
|
||||
<p className="customer-binding-qr-tip">
|
||||
平台提示:预计下次可换绑
|
||||
{nextRebindText ? ` ${nextRebindText}` : '需等待 7 天'};本次扫码可能不会生效。
|
||||
本次换绑成功后,下次可换绑:{nextRebindText}。
|
||||
</p>
|
||||
) : null}
|
||||
<p className="customer-binding-qr-countdown">
|
||||
@@ -1094,15 +1188,29 @@ export default function CustomerFulfillmentPage() {
|
||||
刷新二维码
|
||||
</Button>
|
||||
</div>
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-next"
|
||||
loading={bindingLoading}
|
||||
onClick={() => void handlePollBindingNow()}
|
||||
>
|
||||
已扫码绑定,点击进入下一步
|
||||
</Button>
|
||||
{selectedTask?.bindingStatus === 'scanned' &&
|
||||
bindingInfo?.rebindRequested &&
|
||||
!rebindAccepted ? (
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-next"
|
||||
loading={bindingLoading}
|
||||
onClick={() => void handleSubmitRebind()}
|
||||
>
|
||||
已选好角色,提交换绑
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-next"
|
||||
loading={bindingLoading}
|
||||
onClick={() => void handlePollBindingNow()}
|
||||
>
|
||||
{rebindAccepted ? '刷新绑定状态' : '已扫码绑定,点击进入下一步'}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
@@ -1140,24 +1248,21 @@ export default function CustomerFulfillmentPage() {
|
||||
<Space direction="vertical" size={12} style={{ width: '100%' }}>
|
||||
{rebindUnchanged ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
type={rebindRejected ? 'error' : 'warning'}
|
||||
showIcon
|
||||
message="换绑未生效"
|
||||
message={rebindRejected ? '虎牙未接受本次换绑' : '换绑未生效'}
|
||||
description={
|
||||
<Space direction="vertical" size={2}>
|
||||
<span>
|
||||
扫码已完成,但平台仍返回原绑定角色:
|
||||
平台仍返回原绑定角色:
|
||||
{bindingRoleName || '未识别到角色'}
|
||||
</span>
|
||||
{rebindCooldownDays > 0 ? (
|
||||
<span>
|
||||
原因:本活动 7 天内只能换绑 1 次
|
||||
{nextRebindText ? `,预计下次可换绑:${nextRebindText}` : ''}。
|
||||
</span>
|
||||
{bindingInfo?.rebindConfirmMessage ? (
|
||||
<span>虎牙原因:{bindingInfo.rebindConfirmMessage}</span>
|
||||
) : nextRebindText ? (
|
||||
<span>预计下次可换绑:{nextRebindText}。</span>
|
||||
) : (
|
||||
<span>
|
||||
请在微信确认框中核对目标角色后重新换绑;如持续失败请联系客服。
|
||||
</span>
|
||||
<span>请核对虎牙弹窗中选中的目标角色后重新提交。</span>
|
||||
)}
|
||||
</Space>
|
||||
}
|
||||
@@ -1172,6 +1277,28 @@ export default function CustomerFulfillmentPage() {
|
||||
.join(' · ')}
|
||||
/>
|
||||
)}
|
||||
{comparisonMismatch && bindingComparison ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="平台识别的角色与已填资料不一致"
|
||||
description={
|
||||
<Space direction="vertical" size={2}>
|
||||
<span>
|
||||
平台角色:{bindingComparison.boundZone || '区服未知'} ·{' '}
|
||||
{bindingComparison.boundRoleName || '角色未知'}(ID{' '}
|
||||
{bindingComparison.boundRoleId || '未知'})
|
||||
</span>
|
||||
<span>
|
||||
已填资料:{bindingComparison.customerZone || '区服未填'} ·{' '}
|
||||
{bindingComparison.customerRoleName || '角色未填'}(ID{' '}
|
||||
{bindingComparison.customerRoleId || '未填'})
|
||||
</span>
|
||||
<span>三项一致后才能提交确认;可一键同步平台角色。</span>
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
{!bindingPendingUid && !rebindUnchanged ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
@@ -1187,9 +1314,9 @@ export default function CustomerFulfillmentPage() {
|
||||
size="large"
|
||||
className="customer-binding-confirm"
|
||||
loading={bindingLoading}
|
||||
onClick={() => void handleRefreshBinding(true)}
|
||||
onClick={() => void handleSubmitRebind()}
|
||||
>
|
||||
重新扫码换绑
|
||||
重新提交换绑
|
||||
</Button>
|
||||
<Button
|
||||
block
|
||||
@@ -1197,9 +1324,31 @@ export default function CustomerFulfillmentPage() {
|
||||
className="customer-binding-rebind"
|
||||
icon={<ReloadOutlined />}
|
||||
loading={bindingLoading}
|
||||
onClick={() => void handlePollBindingNow()}
|
||||
onClick={() => void handleRefreshBinding(true)}
|
||||
>
|
||||
刷新绑定状态
|
||||
重新扫码换绑
|
||||
</Button>
|
||||
</div>
|
||||
) : comparisonMismatch ? (
|
||||
<div className="customer-binding-role-actions">
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-confirm"
|
||||
loading={profileSaving}
|
||||
onClick={() => void handleSyncBindingProfile()}
|
||||
>
|
||||
同步平台角色并继续
|
||||
</Button>
|
||||
<Button
|
||||
block
|
||||
size="large"
|
||||
className="customer-binding-rebind"
|
||||
icon={<ExclamationCircleOutlined />}
|
||||
loading={bindingLoading}
|
||||
onClick={() => void handleRefreshBinding(true)}
|
||||
>
|
||||
角色不对,重新扫码换绑
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
|
||||
@@ -66,6 +66,13 @@ export function confirmCustomerBinding(orderNo: string, taskId: number) {
|
||||
)
|
||||
}
|
||||
|
||||
export function submitCustomerRebind(orderNo: string, taskId: number) {
|
||||
return apiPost<{ task: CustomerSemiAutoTask; binding: CustomerBindingInfo }>(
|
||||
`/api/v1/customer-fulfillment/${encodeURIComponent(orderNo)}/tasks/${taskId}/binding/rebind`,
|
||||
{},
|
||||
)
|
||||
}
|
||||
|
||||
type CustomerHuyaChallengeBase = {
|
||||
image: string
|
||||
width: number
|
||||
|
||||
@@ -2,8 +2,10 @@ export type CustomerBindingComparison = {
|
||||
verdict: 'match' | 'mismatch' | 'unknown'
|
||||
customerRoleName: string
|
||||
customerRoleId: string
|
||||
customerZone: string
|
||||
boundRoleName: string
|
||||
boundRoleId: string
|
||||
boundZone: string
|
||||
message: string
|
||||
}
|
||||
|
||||
@@ -58,6 +60,8 @@ export type CustomerBindingInfo = {
|
||||
hasExistingBinding: boolean
|
||||
rebindRequested: boolean
|
||||
rebindUnchanged: boolean
|
||||
rebindConfirmState: 'idle' | 'submitting' | 'accepted' | 'rejected'
|
||||
rebindConfirmMessage: string
|
||||
rebindCooldownDays: number
|
||||
nextRebindAt: string
|
||||
platformChangeBindDay?: number
|
||||
|
||||
Reference in New Issue
Block a user