feat(fulfillment): 增加订单匹配起算时间
This commit is contained in:
@@ -51,18 +51,19 @@ def run_auto_allocation_once(
|
||||
10,
|
||||
3600,
|
||||
)
|
||||
candidates = (
|
||||
db.query(PlatformFulfillmentTask)
|
||||
.filter(
|
||||
PlatformFulfillmentTask.execution_status == "ready",
|
||||
PlatformFulfillmentTask.account_id.is_(None),
|
||||
PlatformFulfillmentTask.commodity_id != "",
|
||||
PlatformFulfillmentTask.updated_at
|
||||
<= moment - timedelta(seconds=retry_seconds),
|
||||
query = db.query(PlatformFulfillmentTask).filter(
|
||||
PlatformFulfillmentTask.execution_status == "ready",
|
||||
PlatformFulfillmentTask.account_id.is_(None),
|
||||
PlatformFulfillmentTask.commodity_id != "",
|
||||
PlatformFulfillmentTask.updated_at <= moment - timedelta(seconds=retry_seconds),
|
||||
)
|
||||
match_started_at = service._order_match_started_at(db)
|
||||
if match_started_at is not None:
|
||||
query = query.filter(
|
||||
PlatformFulfillmentTask.created_at >= match_started_at,
|
||||
)
|
||||
.order_by(PlatformFulfillmentTask.updated_at.asc())
|
||||
.limit(batch_size)
|
||||
.all()
|
||||
candidates = (
|
||||
query.order_by(PlatformFulfillmentTask.updated_at.asc()).limit(batch_size).all()
|
||||
)
|
||||
if not candidates:
|
||||
return {"checked": 0, "allocated": 0, "failed": 0}
|
||||
@@ -84,9 +85,7 @@ def run_auto_allocation_once(
|
||||
except Exception as exc: # noqa: BLE001 - 单个任务异常不能中断整批
|
||||
db.rollback()
|
||||
failed += 1
|
||||
logger.warning(
|
||||
"直播账号履约自动选号失败 task_id={}: {}", task.id, exc
|
||||
)
|
||||
logger.warning("直播账号履约自动选号失败 task_id={}: {}", task.id, exc)
|
||||
return {
|
||||
"checked": len(candidates),
|
||||
"allocated": allocated,
|
||||
|
||||
Reference in New Issue
Block a user