fix(fulfillment): 优先刷新联合皮肤全资格账号

This commit is contained in:
yml
2026-11-28 21:20:07 +08:00
parent 5d54954762
commit ab49def623
6 changed files with 162 additions and 9 deletions
@@ -31,6 +31,10 @@ from ...platform_fulfillment.account_selector import (
capability_refresh_candidate_accounts,
storehome_refresh_candidate_accounts,
)
from ...platform_fulfillment.policy import (
bundle_requirements_for_commodity,
normalize_allocation_policy,
)
JOB_KEY = "account_capability_refresh"
DEFAULT_BACKFILL_RESERVED_SLOTS = 8
@@ -95,6 +99,27 @@ def _backfill_reserved_slots() -> int:
return DEFAULT_BACKFILL_RESERVED_SLOTS
def _preferred_bundle_groups(
db: Session,
commodity_ids: list[str],
) -> tuple[tuple[str, ...], ...]:
if not commodity_ids:
return ()
row = db.get(PlatformFulfillmentSetting, 1)
policy = normalize_allocation_policy(
row.allocation_policy_json if row is not None else None
)
groups: list[tuple[str, ...]] = []
for commodity_id in commodity_ids:
required, _ = bundle_requirements_for_commodity(policy, commodity_id)
if not required:
continue
group = tuple(dict.fromkeys((commodity_id, *required)))
if group not in groups:
groups.append(group)
return tuple(groups)
def _build_select_query(
db: Session,
job: AutomationJob,
@@ -159,6 +184,8 @@ def _refresh_candidates(
limit=backfill_limit,
now=moment,
exclude_account_ids=tuple(demand_ids),
scope="elite",
preferred_commodity_groups=_preferred_bundle_groups(db, commodity_ids),
)
if backfill_limit > 0
else []