修复(履约选号): 按客户QQ/微信、iOS/安卓和角色优先选号
- 候选账号按客户登录方式和系统过滤,避免微信账号接QQ角色 - 客户角色已绑定的账号优先,且不再被未来换绑时间误排除 - 自动选号传入客户资料 - 补充渠道/角色选择测试
This commit is contained in:
@@ -261,6 +261,31 @@ def live_candidate_accounts(
|
||||
return rows
|
||||
|
||||
|
||||
def _customer_channel_filter(
|
||||
customer_platform: str,
|
||||
customer_system: str,
|
||||
):
|
||||
"""客户填写的 QQ/微信、iOS/安卓对应到账号渠道。"""
|
||||
platform = str(customer_platform or "").strip().lower()
|
||||
system = str(customer_system or "").strip().lower()
|
||||
filters = []
|
||||
if platform == "qq":
|
||||
filters.append(
|
||||
or_(Account.game_channel.like("%手Q%"), Account.game_channel.like("%QQ%"))
|
||||
)
|
||||
elif platform == "wechat":
|
||||
filters.append(Account.game_channel.like("%微信%"))
|
||||
if system == "ios":
|
||||
filters.append(
|
||||
or_(Account.game_channel.like("%苹果%"), Account.game_channel.like("%iOS%"))
|
||||
)
|
||||
elif system == "android":
|
||||
filters.append(
|
||||
or_(Account.game_channel.like("%安卓%"), Account.game_channel.like("%android%"))
|
||||
)
|
||||
return and_(*filters) if filters else None
|
||||
|
||||
|
||||
def _capability_candidate_query(
|
||||
db: Session,
|
||||
*,
|
||||
@@ -270,6 +295,9 @@ def _capability_candidate_query(
|
||||
limit: int = 20,
|
||||
now: datetime | None = None,
|
||||
allow_before_open: bool = False,
|
||||
customer_role_name: str = "",
|
||||
customer_platform: str = "",
|
||||
customer_system: str = "",
|
||||
):
|
||||
commodity = commodity_id.strip()
|
||||
if not commodity:
|
||||
@@ -280,6 +308,11 @@ def _capability_candidate_query(
|
||||
moment,
|
||||
allow_before_open=allow_before_open,
|
||||
)
|
||||
channel_filter = _customer_channel_filter(customer_platform, customer_system)
|
||||
role = str(customer_role_name or "").strip()
|
||||
role_filter = role_change_ready_filter(moment)
|
||||
if role:
|
||||
role_filter = or_(role_filter, Account.game_name == role)
|
||||
return (
|
||||
db.query(
|
||||
Account.id.label("account_id"),
|
||||
@@ -315,12 +348,14 @@ def _capability_candidate_query(
|
||||
cookie_present_filter(),
|
||||
valid_ck_filter(),
|
||||
automatable_account_filter(),
|
||||
role_change_ready_filter(moment),
|
||||
role_filter,
|
||||
channel_filter if channel_filter is not None else and_(True),
|
||||
assigned_to_pool_filter(),
|
||||
~active_lease_exists(),
|
||||
~active_collab_order_exists(),
|
||||
)
|
||||
.order_by(
|
||||
case((Account.game_name == role, 0), else_=1) if role else case((True, 0), else_=1),
|
||||
case(
|
||||
(AccountCommodityState.offer_state == OFFER_STATE_ACTIVE, 0),
|
||||
else_=1,
|
||||
@@ -349,6 +384,9 @@ def capability_candidate_rows(
|
||||
limit: int = 20,
|
||||
now: datetime | None = None,
|
||||
allow_before_open: bool = False,
|
||||
customer_role_name: str = "",
|
||||
customer_platform: str = "",
|
||||
customer_system: str = "",
|
||||
) -> list[CapabilityCandidate]:
|
||||
"""读取账号与能力快照;只访问本地数据库,不触发官网请求。"""
|
||||
query = _capability_candidate_query(
|
||||
@@ -359,6 +397,9 @@ def capability_candidate_rows(
|
||||
limit=limit,
|
||||
now=now,
|
||||
allow_before_open=allow_before_open,
|
||||
customer_role_name=customer_role_name,
|
||||
customer_platform=customer_platform,
|
||||
customer_system=customer_system,
|
||||
)
|
||||
if query is None:
|
||||
return []
|
||||
@@ -434,6 +475,9 @@ def capability_candidate_accounts(
|
||||
limit: int = 20,
|
||||
now: datetime | None = None,
|
||||
allow_before_open: bool = False,
|
||||
customer_role_name: str = "",
|
||||
customer_platform: str = "",
|
||||
customer_system: str = "",
|
||||
) -> list[CapabilityAccount]:
|
||||
"""从新鲜的商品能力索引读取候选账号,不产生外部请求。"""
|
||||
return [
|
||||
@@ -446,6 +490,9 @@ def capability_candidate_accounts(
|
||||
limit=limit,
|
||||
now=now,
|
||||
allow_before_open=allow_before_open,
|
||||
customer_role_name=customer_role_name,
|
||||
customer_platform=customer_platform,
|
||||
customer_system=customer_system,
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
@@ -363,6 +363,9 @@ def _allocate_task_from_capability(
|
||||
scope=task.scope or SCOPE_ELITE,
|
||||
now=moment,
|
||||
allow_before_open=is_presale,
|
||||
customer_role_name=task.customer_role_name or "",
|
||||
customer_platform=task.customer_platform or "",
|
||||
customer_system=task.customer_system or "",
|
||||
)
|
||||
recent_exchange_ids: set[int] = set()
|
||||
if capability_candidates:
|
||||
|
||||
Reference in New Issue
Block a user