feat(fulfillment): 增加工作台状态事件同步

This commit is contained in:
yml
2026-11-18 10:59:20 +08:00
parent 3a8f12ae43
commit 00c4a268c2
10 changed files with 262 additions and 10 deletions
@@ -2,6 +2,7 @@
from __future__ import annotations
import logging
from typing import Any
from fastapi import APIRouter, Depends, Query
@@ -20,6 +21,7 @@ from ..services.audit_service import record_audit
from ..services.platform_fulfillment import service
router = APIRouter(prefix="/api/platform-fulfillment", tags=["直播账号履约"])
logger = logging.getLogger(__name__)
@router.get("/settings")
@@ -63,6 +65,10 @@ def list_tasks(
current: User = Depends(require_permission("platform_fulfillment:view")),
) -> dict[str, Any]:
del current
try:
service.sync_pending_tasks_if_due(db, limit=100)
except Exception as exc: # noqa: BLE001
logger.warning("自动同步待履约订单失败,继续返回本地任务: %s", exc)
return service.list_tasks(
db,
status=status,
@@ -97,6 +103,7 @@ def get_task(
current: User = Depends(require_permission("platform_fulfillment:view")),
) -> dict[str, Any]:
del current
service.refresh_binding(db, task_id=task_id)
return service.get_task_detail(db, task_id)