perf(fulfillment): Webhook 新订单即时选号

This commit is contained in:
yml
2026-11-23 14:09:04 +08:00
parent 05a7a56c4e
commit 11c2a0dba7
4 changed files with 123 additions and 12 deletions
+7 -3
View File
@@ -99,10 +99,14 @@ def sync_tasks(
current: User = Depends(require_permission("platform_fulfillment:use")),
) -> dict[str, Any]:
result = service.sync_pending_tasks(db, limit=limit)
if result.get("taskIds"):
from ..services.platform_fulfillment.auto_allocator import wake_auto_allocator
from ..services.platform_fulfillment.auto_allocator import (
run_immediate_allocation,
)
wake_auto_allocator(result["taskIds"])
result["immediateAllocation"] = run_immediate_allocation(
db,
task_ids=result.get("taskIds", []),
)
record_audit(
db,
current,
@@ -107,8 +107,15 @@ async def sync_order_event(
result = service.sync_order_item_ids(db, item_ids, commit=False)
inbox.processed_at = datetime.now(UTC)
db.commit()
auto_allocator.wake_auto_allocator(result.get("taskIds", []))
return {**result, "duplicate": False}
task_ids = [
int(task_id) for task_id in result.get("taskIds", []) if str(task_id).isdigit()
]
immediate = auto_allocator.run_immediate_allocation(db, task_ids=task_ids)
return {
**result,
"duplicate": False,
"immediateAllocation": immediate,
}
@router.post(