发布(0.4.6): 修复预售兑换记录判定与详情展示并新增工作台强制发放
This commit is contained in:
@@ -13,7 +13,7 @@ from core.douyu import DouyuActivityClient, DouyuActivityError
|
||||
|
||||
from ..models import Account, DouyuEsportsGoodsSnapshot, DouyuGoodsSnapshot, DouyuTask
|
||||
from .account_exchange_sync_service import sync_exchange_records
|
||||
from .binding_ownership import workbench_task_occupation_error
|
||||
from .binding_ownership import role_names_match, workbench_task_occupation_error
|
||||
from .business_events import record_exchange
|
||||
from .douyu_activity_query import (
|
||||
query_activity_goods,
|
||||
@@ -138,9 +138,39 @@ class GoodsMixin:
|
||||
},
|
||||
)
|
||||
|
||||
def _check_goods_occupation(
|
||||
self, db: Session, task: DouyuTask, account: Account
|
||||
) -> str | None:
|
||||
payload = self._task_payload(task)
|
||||
force_occupied = bool(payload.get("force_occupied"))
|
||||
expected_role = str(payload.get("force_expected_role") or "").strip()
|
||||
occupation_error = workbench_task_occupation_error(
|
||||
db,
|
||||
account,
|
||||
task_type=str(task.task_type or "exchange_goods"),
|
||||
handbook_scope=str(task.handbook_scope or ""),
|
||||
platform_task_id=task.platform_task_id,
|
||||
allow_auto_link=False,
|
||||
force_occupied=force_occupied,
|
||||
)
|
||||
if occupation_error:
|
||||
return occupation_error
|
||||
if force_occupied and expected_role:
|
||||
current_role = str(account.game_name or "").strip()
|
||||
if not current_role or not role_names_match(current_role, expected_role):
|
||||
return (
|
||||
f"账号当前绑定角色({current_role or '未获取'})"
|
||||
f"与确认时角色({expected_role})不一致,已取消强制发放"
|
||||
)
|
||||
return None
|
||||
|
||||
def _execute_lock_goods(
|
||||
self, db: Session, task: DouyuTask, account: Account, cookie: str, config: dict
|
||||
):
|
||||
occupation_error = self._check_goods_occupation(db, task, account)
|
||||
if occupation_error:
|
||||
self._mark_task(db, task, "failed", occupation_error)
|
||||
return
|
||||
payload = self._task_payload(task)
|
||||
commodity_id = str(
|
||||
payload.get("commodity_id") or payload.get("commodityId") or ""
|
||||
@@ -192,6 +222,10 @@ class GoodsMixin:
|
||||
cookie: str,
|
||||
config: dict,
|
||||
):
|
||||
occupation_error = self._check_goods_occupation(db, task, account)
|
||||
if occupation_error:
|
||||
self._mark_task(db, task, "failed", occupation_error)
|
||||
return
|
||||
payload = self._task_payload(task)
|
||||
order_id = str(payload.get("order_id") or payload.get("orderId") or "").strip()
|
||||
commodity_id = str(
|
||||
@@ -329,14 +363,7 @@ class GoodsMixin:
|
||||
def _execute_exchange_goods(
|
||||
self, db: Session, task: DouyuTask, account: Account, cookie: str, config: dict
|
||||
):
|
||||
occupation_error = workbench_task_occupation_error(
|
||||
db,
|
||||
account,
|
||||
task_type=str(task.task_type or "exchange_goods"),
|
||||
handbook_scope=str(task.handbook_scope or ""),
|
||||
platform_task_id=task.platform_task_id,
|
||||
allow_auto_link=False,
|
||||
)
|
||||
occupation_error = self._check_goods_occupation(db, task, account)
|
||||
if occupation_error:
|
||||
self._mark_task(db, task, "failed", occupation_error)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user