fix(platform-fulfillment): 允许预售单提前绑定账号
This commit is contained in:
@@ -103,6 +103,8 @@ def _matching_mode() -> str:
|
||||
def _exchange_gate(
|
||||
state: DouyuLiveAccountState,
|
||||
commodity_id: str,
|
||||
*,
|
||||
allow_not_open: bool = False,
|
||||
) -> tuple[str, str, str]:
|
||||
"""把实时商品资格映射为履约可展示的硬门槛。"""
|
||||
if commodity_id in state.limited_ids:
|
||||
@@ -123,6 +125,13 @@ def _exchange_gate(
|
||||
)
|
||||
if availability == AVAILABILITY_AVAILABLE:
|
||||
return "", "", ""
|
||||
if allow_not_open and availability == AVAILABILITY_NOT_OPEN:
|
||||
# 2026-11-22:预售单礼包未开放不阻止提前绑定,兑换阶段继续等待开放。
|
||||
return (
|
||||
"waiting_release",
|
||||
"commodity_not_open",
|
||||
reason or "商品限时兑换尚未开始,可提前绑定角色",
|
||||
)
|
||||
issue_map = {
|
||||
AVAILABILITY_NOT_OPEN: ("commodity_not_open", "商品限时兑换尚未开始"),
|
||||
AVAILABILITY_EXPIRED: ("commodity_expired", "商品限时兑换已经结束"),
|
||||
@@ -2150,6 +2159,7 @@ def allocate_task(db: Session, *, task_id: int, current: User) -> dict[str, Any]
|
||||
candidate_limit = DEFAULT_LIVE_CANDIDATE_LIMIT
|
||||
candidate_limit = max(1, min(candidate_limit, 100))
|
||||
mode = _matching_mode()
|
||||
is_presale = classification.normalize_sale_mode(task.sale_mode) == "presale"
|
||||
capability_candidates = (
|
||||
capability_candidate_accounts(
|
||||
db,
|
||||
@@ -2157,6 +2167,7 @@ def allocate_task(db: Session, *, task_id: int, current: User) -> dict[str, Any]
|
||||
required_points=required_points,
|
||||
commodity_id=task.commodity_id,
|
||||
scope=task.scope or SCOPE_ELITE,
|
||||
allow_not_open=is_presale,
|
||||
)
|
||||
if mode in {"hybrid", "capability"}
|
||||
else []
|
||||
@@ -2195,7 +2206,10 @@ def allocate_task(db: Session, *, task_id: int, current: User) -> dict[str, Any]
|
||||
account_id=int(account.id),
|
||||
commodity_id=task.commodity_id,
|
||||
)
|
||||
reasons = live_state.blocking_reasons(commodity_id=task.commodity_id)
|
||||
reasons = live_state.blocking_reasons(
|
||||
commodity_id=task.commodity_id,
|
||||
allow_not_open=is_presale,
|
||||
)
|
||||
if recent_exchange:
|
||||
reasons.append("365 天内已有该商品兑换事件")
|
||||
|
||||
@@ -2370,7 +2384,9 @@ def allocate_task(db: Session, *, task_id: int, current: User) -> dict[str, Any]
|
||||
required_points=required_points
|
||||
)
|
||||
gate_status, gate_issue, gate_message = _exchange_gate(
|
||||
selected_state, task.commodity_id
|
||||
selected_state,
|
||||
task.commodity_id,
|
||||
allow_not_open=is_presale,
|
||||
)
|
||||
if gate_status:
|
||||
task.exchange_status = gate_status
|
||||
@@ -2948,6 +2964,7 @@ def refresh_exchange_eligibility(
|
||||
]
|
||||
assessments = classify_goods_items(storehome_goods, now=_now())
|
||||
assessment = assessments.get(task.commodity_id)
|
||||
is_presale = classification.normalize_sale_mode(task.sale_mode) == "presale"
|
||||
if task.commodity_id in limited_ids:
|
||||
availability = AVAILABILITY_LIMITED
|
||||
commodity_status = "limited"
|
||||
@@ -2958,6 +2975,17 @@ def refresh_exchange_eligibility(
|
||||
commodity_status = "not_available"
|
||||
issue_code = "commodity_not_offered"
|
||||
commodity_message = "官方商品列表本次未返回该商品,可能已下架"
|
||||
elif (
|
||||
is_presale
|
||||
and assessment is not None
|
||||
and assessment.availability == AVAILABILITY_NOT_OPEN
|
||||
):
|
||||
availability = assessment.availability
|
||||
commodity_status = "waiting_release"
|
||||
issue_code = "commodity_not_open"
|
||||
commodity_message = (
|
||||
assessment.blocking_reason or "商品限时兑换尚未开始,可提前绑定角色"
|
||||
)
|
||||
elif assessment is not None and assessment.availability != AVAILABILITY_AVAILABLE:
|
||||
availability = assessment.availability
|
||||
commodity_status = "not_available"
|
||||
|
||||
Reference in New Issue
Block a user