fix(fulfillment): 对齐客户确认状态并展示角色接口日志
- 客户页 bindReadyForConfirm 与平台任务 role_ready 对齐 - 详情返回 douyu_role_api_logs 最近 40 条 - 详情页增加角色接口日志诊断表 - 补充客户确认、日志读取回归测试 - 文档记录 11.22 成功 HAR 与角色日志时间线
This commit is contained in:
@@ -17,6 +17,7 @@ from ...models import (
|
||||
AccountLease,
|
||||
DouyuExternalOrder,
|
||||
DouyuGoodsSnapshot,
|
||||
DouyuRoleApiLog,
|
||||
DouyuTask,
|
||||
PlatformCommodityMapping,
|
||||
PlatformFulfillmentEvent,
|
||||
@@ -541,6 +542,14 @@ def get_task_detail(db: Session, task_id: int) -> dict[str, Any]:
|
||||
else {}
|
||||
)
|
||||
bind_task_ids: set[int] = set()
|
||||
if task.bind_task_id:
|
||||
bind_task_ids.add(int(task.bind_task_id))
|
||||
bind_task_ids.update(
|
||||
int(row.id)
|
||||
for row in db.query(DouyuTask.id)
|
||||
.filter(DouyuTask.platform_task_id == int(task.id))
|
||||
.all()
|
||||
)
|
||||
for event in events:
|
||||
detail = event.detail_json or {}
|
||||
raw_id = (
|
||||
@@ -562,8 +571,48 @@ def get_task_detail(db: Session, task_id: int) -> dict[str, Any]:
|
||||
if bind_task_ids
|
||||
else {}
|
||||
)
|
||||
role_logs = (
|
||||
db.query(DouyuRoleApiLog)
|
||||
.filter(DouyuRoleApiLog.task_id.in_(bind_task_ids))
|
||||
.order_by(DouyuRoleApiLog.id.desc())
|
||||
.limit(40)
|
||||
.all()
|
||||
if bind_task_ids
|
||||
else []
|
||||
)
|
||||
return {
|
||||
"task": _task_out(db, task, include_qr=True, include_exchange_task=True),
|
||||
"bindingLogs": [
|
||||
{
|
||||
"id": int(log.id),
|
||||
"taskId": int(log.task_id) if log.task_id else None,
|
||||
"stage": str(log.stage or ""),
|
||||
"source": str(log.source or ""),
|
||||
"actAlias": str(log.act_alias or ""),
|
||||
"apiVersion": str(log.api_version or ""),
|
||||
"roleName": str(log.role_name or ""),
|
||||
"areaName": str(log.area_name or ""),
|
||||
"platName": str(log.plat_name or ""),
|
||||
"bindAct": bool(log.is_bound_act),
|
||||
"bindRole": bool(log.is_bound_role),
|
||||
"needBindAct": bool(log.need_bind_act),
|
||||
"needBindRole": bool(log.need_bind_role),
|
||||
"changeRoleWaitTime": log.change_role_wait_time,
|
||||
"canChangeTime": log.can_change_time,
|
||||
"error": (
|
||||
log.response_json.get("error")
|
||||
if isinstance(log.response_json, dict)
|
||||
else None
|
||||
),
|
||||
"message": (
|
||||
log.response_json.get("msg")
|
||||
if isinstance(log.response_json, dict)
|
||||
else ""
|
||||
),
|
||||
"createdAt": log.created_at,
|
||||
}
|
||||
for log in role_logs
|
||||
],
|
||||
"events": [
|
||||
{
|
||||
"id": event.id,
|
||||
|
||||
@@ -2594,9 +2594,31 @@ export interface PlatformFulfillmentEvent {
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface PlatformFulfillmentBindingLog {
|
||||
id: number;
|
||||
taskId: number | null;
|
||||
stage: string;
|
||||
source: string;
|
||||
actAlias: string;
|
||||
apiVersion: string;
|
||||
roleName: string;
|
||||
areaName: string;
|
||||
platName: string;
|
||||
bindAct: boolean;
|
||||
bindRole: boolean;
|
||||
needBindAct: boolean;
|
||||
needBindRole: boolean;
|
||||
changeRoleWaitTime: number | null;
|
||||
canChangeTime: number | null;
|
||||
error: unknown;
|
||||
message: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface PlatformFulfillmentDetail {
|
||||
task: PlatformFulfillmentTask;
|
||||
events: PlatformFulfillmentEvent[];
|
||||
bindingLogs?: PlatformFulfillmentBindingLog[];
|
||||
}
|
||||
|
||||
export interface PlatformFulfillmentAllocationResult extends PlatformFulfillmentDetail {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Alert, Button, Card, Col, DatePicker, Descriptions, Drawer, Empty, Inpu
|
||||
import { CheckCircleOutlined, CopyOutlined, CreditCardOutlined, DownloadOutlined, GiftOutlined, LinkOutlined, QrcodeOutlined, ReloadOutlined, SettingOutlined, ShoppingOutlined, SyncOutlined, UndoOutlined, UserSwitchOutlined } from '@ant-design/icons';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { douyuApi, platformFulfillmentApi } from '../api/modules';
|
||||
import type { DouyuGoodsItem, DouyuTaskItem, PlatformFulfillmentDetail, PlatformFulfillmentMapping, PlatformFulfillmentSettings, PlatformFulfillmentTask } from '../api/modules';
|
||||
import type { DouyuGoodsItem, DouyuTaskItem, PlatformFulfillmentBindingLog, PlatformFulfillmentDetail, PlatformFulfillmentMapping, PlatformFulfillmentSettings, PlatformFulfillmentTask } from '../api/modules';
|
||||
import ExchangeResultImage from '../components/ExchangeResultImage';
|
||||
import { copyImageToClipboard, fetchExchangeImageBlob, getExchangeImage, isExchangeTask } from '../utils/exchangeImage';
|
||||
import { TASK_STATUS_COLORS, TASK_STATUS_LABELS, taskQrUrl } from './douyu-tasks/config';
|
||||
@@ -1889,6 +1889,49 @@ export default function PlatformFulfillmentPage() {
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<Card size="small" title="角色接口日志(诊断)">
|
||||
{detail?.bindingLogs?.length ? (
|
||||
<Table<PlatformFulfillmentBindingLog>
|
||||
size="small"
|
||||
rowKey="id"
|
||||
pagination={false}
|
||||
dataSource={detail.bindingLogs}
|
||||
scroll={{ x: 980, y: 260 }}
|
||||
columns={[
|
||||
{
|
||||
title: '时间',
|
||||
dataIndex: 'createdAt',
|
||||
width: 150,
|
||||
render: (value: string) => formatTime(value),
|
||||
},
|
||||
{ title: '阶段', dataIndex: 'stage', width: 170 },
|
||||
{ title: '通道', dataIndex: 'actAlias', width: 140 },
|
||||
{ title: '角色', dataIndex: 'roleName', width: 120 },
|
||||
{
|
||||
title: 'bindAct',
|
||||
dataIndex: 'bindAct',
|
||||
width: 76,
|
||||
render: (value: boolean) => (value ? '1' : '0'),
|
||||
},
|
||||
{
|
||||
title: '换绑等待',
|
||||
dataIndex: 'changeRoleWaitTime',
|
||||
width: 96,
|
||||
render: (value: number | null) => value ?? '-',
|
||||
},
|
||||
{
|
||||
title: '结果',
|
||||
dataIndex: 'message',
|
||||
render: (value: string, row: PlatformFulfillmentBindingLog) =>
|
||||
row.error === 0 ? 'OK' : `${String(row.error ?? '')} ${value || ''}`.trim(),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
) : (
|
||||
<Text type="secondary">暂无接口日志</Text>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<Card size="small" title="精英宝典操作">
|
||||
<Space direction="vertical" size={12} style={{ width: '100%' }}>
|
||||
<Text type="secondary">
|
||||
|
||||
Reference in New Issue
Block a user