feat(fulfillment): 增加 Clean Cutover,历史任务隔离到人工入口
- 新增 flow_version,存量任务回填 1,Cutover 后新任务写 2 - 迁移设置 clean_flow_started_at,按订单支付/创建时间判定 - 自动选号只处理 clean 任务 - 工作台新增历史任务 Tab,历史列表不受订单起算时间限制 - 历史任务不参与自动重试和预售台账同步 - 补充流程边界测试和计划文档
This commit is contained in:
@@ -21,6 +21,8 @@ from ..douyu_account_state import DouyuLiveAccountState
|
||||
|
||||
TARGET_PLATFORM = "douyu"
|
||||
SCOPE_ELITE = "elite"
|
||||
FLOW_VERSION_LEGACY = 1
|
||||
FLOW_VERSION_CLEAN = 2
|
||||
BINDING_COOLDOWN_ISSUES = frozenset({"account_role_cooldown", "customer_role_cooldown"})
|
||||
ACTIVE_STATUSES = {
|
||||
"ready",
|
||||
@@ -148,6 +150,33 @@ def _order_match_started_at(db: Session) -> datetime | None:
|
||||
return row.order_match_started_at if row is not None else None
|
||||
|
||||
|
||||
def _clean_flow_started_at(db: Session) -> datetime | None:
|
||||
row = (
|
||||
db.query(PlatformFulfillmentSetting)
|
||||
.filter(PlatformFulfillmentSetting.id == 1)
|
||||
.first()
|
||||
)
|
||||
return row.clean_flow_started_at if row is not None else None
|
||||
|
||||
|
||||
def _flow_version_for_order(
|
||||
db: Session,
|
||||
*,
|
||||
paid_at: datetime | None,
|
||||
created_at: datetime | None,
|
||||
) -> int:
|
||||
"""按订单支付/创建时间划分 legacy/clean,避免旧订单补建任务混入新流程。"""
|
||||
cutoff = _clean_flow_started_at(db)
|
||||
basis = paid_at or created_at
|
||||
if cutoff is None or basis is None:
|
||||
return FLOW_VERSION_CLEAN
|
||||
if cutoff.tzinfo is None:
|
||||
cutoff = cutoff.replace(tzinfo=UTC)
|
||||
if basis.tzinfo is None:
|
||||
basis = basis.replace(tzinfo=UTC)
|
||||
return FLOW_VERSION_LEGACY if basis < cutoff else FLOW_VERSION_CLEAN
|
||||
|
||||
|
||||
def _apply_order_match_cutoff(
|
||||
query,
|
||||
match_started_at: datetime | None,
|
||||
|
||||
Reference in New Issue
Block a user