feat(fulfillment): 增加账号商品能力索引与生命周期事件

This commit is contained in:
yml
2026-11-18 19:30:59 +08:00
parent dc95d83b32
commit 667634a8df
35 changed files with 3076 additions and 82 deletions
+22
View File
@@ -26,6 +26,7 @@ from ..models import (
from .douyu_goods_service import upsert_goods_snapshot
from .douyu_service import (
DOUYU_CONFIG_FIELDS,
SUPPORTED_DOUYU_TASK_TYPES,
douyu_config_value,
douyu_task_payload,
ensure_douyu_config,
@@ -212,6 +213,27 @@ class DouyuBatchRunnerCore:
if result is not None:
task.result = result
task.finished_at = datetime.now(UTC)
if task.account_id and status in {"success", "failed", "error", "stopped"}:
from .business_events import record_douyu_task_result
account = (
db.query(Account).filter(Account.id == task.account_id).first()
)
if account is not None:
record_douyu_task_result(
db,
account,
task_id=int(task.id),
task_type=str(task.task_type or ""),
task_label=SUPPORTED_DOUYU_TASK_TYPES.get(
str(task.task_type or ""),
str(task.task_type or "斗鱼任务"),
),
scope=str(task.handbook_scope or ""),
status=status,
message=message,
occurred_at=task.finished_at,
)
db.commit()
self._push_task_event(task)
self._sync_platform_fulfillment(db, task)