feat(fulfillment): 支持手动同步斗鱼外部单协作
This commit is contained in:
@@ -11,12 +11,15 @@ from ..database import get_db
|
||||
from ..deps import require_permission
|
||||
from ..models import User
|
||||
from ..schemas import (
|
||||
PlatformFulfillmentCollabSyncRequest,
|
||||
PlatformFulfillmentCompleteRequest,
|
||||
PlatformFulfillmentMappingUpsert,
|
||||
PlatformFulfillmentReasonRequest,
|
||||
PlatformFulfillmentSettingsUpdate,
|
||||
)
|
||||
from ..services import douyu_collab_service
|
||||
from ..services.audit_service import record_audit
|
||||
from ..services.douyu_collab_events import collab_events
|
||||
from ..services.platform_fulfillment import service
|
||||
|
||||
router = APIRouter(prefix="/api/platform-fulfillment", tags=["直播账号履约"])
|
||||
@@ -95,6 +98,26 @@ def sync_tasks(
|
||||
return result
|
||||
|
||||
|
||||
@router.post("/tasks/sync-collab")
|
||||
def sync_tasks_to_douyu_collab(
|
||||
req: PlatformFulfillmentCollabSyncRequest,
|
||||
db: Session = Depends(get_db),
|
||||
current: User = Depends(require_permission("platform_fulfillment:use")),
|
||||
) -> dict[str, Any]:
|
||||
result = douyu_collab_service.sync_platform_fulfillment_orders(
|
||||
db,
|
||||
current,
|
||||
task_ids=req.task_ids,
|
||||
)
|
||||
if result["created"] or result["updated"]:
|
||||
collab_events.publish(
|
||||
scope="orders",
|
||||
action="order.sync_from_platform_fulfillment",
|
||||
actor_id=int(current.id),
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
@router.get("/tasks/{task_id}")
|
||||
def get_task(
|
||||
task_id: int,
|
||||
|
||||
Reference in New Issue
Block a user