feat(fulfillment): 增加取消恢复与操作人审计

This commit is contained in:
yml
2026-11-18 21:40:25 +08:00
parent 7a11be3885
commit e90e93d515
9 changed files with 424 additions and 7 deletions
+34 -1
View File
@@ -15,6 +15,7 @@ from ..schemas import (
PlatformFulfillmentCompleteRequest,
PlatformFulfillmentMappingUpsert,
PlatformFulfillmentReasonRequest,
PlatformFulfillmentRestoreRequest,
PlatformFulfillmentSettingsUpdate,
)
from ..services import douyu_collab_service
@@ -343,7 +344,7 @@ def cancel_task(
task_id: int,
req: PlatformFulfillmentReasonRequest,
db: Session = Depends(get_db),
current: User = Depends(require_permission("platform_fulfillment:use")),
current: User = Depends(require_permission("platform_fulfillment:cancel")),
) -> dict[str, Any]:
result = service.cancel_task(
db,
@@ -362,4 +363,36 @@ def cancel_task(
return result
@router.post("/tasks/{task_id}/restore")
def restore_cancelled_task(
task_id: int,
req: PlatformFulfillmentRestoreRequest,
db: Session = Depends(get_db),
current: User = Depends(require_permission("platform_fulfillment:restore")),
) -> dict[str, Any]:
result = service.restore_cancelled_task(
db,
task_id=task_id,
current=current,
reason=req.reason,
)
record_audit(
db,
current,
action="platform_fulfillment:restore",
target=f"platform_fulfillment_task:{task_id}",
detail={"reason": req.reason},
)
db.commit()
collab_events.publish(
scope="orders",
action="order.restore_from_platform_fulfillment",
actor_id=int(current.id),
)
from ..services.platform_fulfillment.auto_allocator import wake_auto_allocator
wake_auto_allocator([task_id])
return result
__all__ = ["router"]