fix: 二次迁移名额可列表展示,保存后跳转用户页
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1110,3 +1110,50 @@ def serialize_token(token_row: ClubMigrateToken) -> dict:
|
||||
'expire_at': token_row.expire_at.isoformat() if token_row.expire_at else '',
|
||||
'asset_snapshot': token_row.asset_snapshot or {},
|
||||
}
|
||||
|
||||
|
||||
def lookup_migrate_user_brief(uid: str) -> dict:
|
||||
"""后台二次名额:校验用户并返回简要资料。"""
|
||||
uid = str(uid or '').strip()
|
||||
user = _load_user(uid)
|
||||
if not user:
|
||||
return {'exists': False, 'from_uid': uid, 'nicheng': '', 'phone': ''}
|
||||
nicheng = ''
|
||||
try:
|
||||
ds = getattr(user, 'DashouProfile', None)
|
||||
if ds and getattr(ds, 'nicheng', None):
|
||||
nicheng = str(ds.nicheng)
|
||||
except Exception:
|
||||
pass
|
||||
if not nicheng:
|
||||
nicheng = str(getattr(user, 'UserName', '') or getattr(user, 'Phone', '') or '')
|
||||
return {
|
||||
'exists': True,
|
||||
'from_uid': uid,
|
||||
'nicheng': nicheng,
|
||||
'phone': str(getattr(user, 'Phone', '') or ''),
|
||||
'club_id': str(getattr(user, 'ClubID', '') or ''),
|
||||
}
|
||||
|
||||
|
||||
def serialize_user_quota(row: ClubMigrateUserQuota, plan: Optional[ClubMigratePlan] = None, user_info: Optional[dict] = None) -> dict:
|
||||
plan = plan or ClubMigratePlan.query.filter(plan_id=row.plan_id).first()
|
||||
info = user_info if user_info is not None else lookup_migrate_user_brief(row.from_uid)
|
||||
used = success_count(row.plan_id, row.from_uid)
|
||||
allowed = max_allowed_success(plan, row.from_uid) if plan else (1 + int(row.max_extra_times or 0))
|
||||
return {
|
||||
'plan_id': row.plan_id,
|
||||
'from_uid': row.from_uid,
|
||||
'max_extra_times': int(row.max_extra_times or 0),
|
||||
'reason': row.reason or '',
|
||||
'updated_by': row.updated_by or '',
|
||||
'created_at': row.CreateTime.isoformat() if row.CreateTime else '',
|
||||
'updated_at': row.UpdateTime.isoformat() if row.UpdateTime else '',
|
||||
'nicheng': info.get('nicheng') or '',
|
||||
'phone': info.get('phone') or '',
|
||||
'user_club_id': info.get('club_id') or '',
|
||||
'success_count': used,
|
||||
'max_allowed': allowed,
|
||||
'remaining': max(0, int(allowed) - int(used)),
|
||||
'can_migrate_again': used < allowed,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user