feat(fulfillment): 增加签名 Webhook 事务 Outbox
- 新增直播履约状态事务 Outbox 与签名投递 worker - 增加 order_site 状态回传、重试和低频对账兜底 - 补充 Outbox、签名校验与集成接口测试
This commit is contained in:
@@ -188,6 +188,17 @@ class DouyuBatchRunnerCore:
|
||||
}
|
||||
asyncio.run_coroutine_threadsafe(self.log_queue.put(event), self.loop)
|
||||
|
||||
def _sync_platform_fulfillment(self, db: Session, task: DouyuTask) -> None:
|
||||
"""绑定/确认任务完成后立即刷新履约投影并写 Outbox。"""
|
||||
try:
|
||||
from .platform_fulfillment.service import sync_task_from_binding_runner
|
||||
|
||||
sync_task_from_binding_runner(db, douyu_task_id=int(task.id))
|
||||
except Exception: # noqa: BLE001 - 履约投影失败不能覆盖任务执行结果
|
||||
logger.exception(
|
||||
"[douyu] 同步直播账号履约状态失败: task_id={}", task.id
|
||||
)
|
||||
|
||||
def _mark_task(
|
||||
self,
|
||||
db: Session,
|
||||
@@ -203,6 +214,7 @@ class DouyuBatchRunnerCore:
|
||||
task.finished_at = datetime.now(UTC)
|
||||
db.commit()
|
||||
self._push_task_event(task)
|
||||
self._sync_platform_fulfillment(db, task)
|
||||
|
||||
def _update_task_progress(
|
||||
self,
|
||||
@@ -218,6 +230,7 @@ class DouyuBatchRunnerCore:
|
||||
task.result = result
|
||||
db.commit()
|
||||
self._push_task_event(task)
|
||||
self._sync_platform_fulfillment(db, task)
|
||||
|
||||
def _upsert_goods(self, db: Session, goods: list[dict]) -> None:
|
||||
upsert_goods_snapshot(db, goods)
|
||||
|
||||
Reference in New Issue
Block a user