fix: 二次迁移名额可列表展示,保存后跳转用户页
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -358,10 +358,16 @@ class ClubMigrateAdminView(APIView):
|
||||
from_uid = (request.data.get('from_uid') or '').strip()
|
||||
if not plan_id or not from_uid:
|
||||
return Response({'code': 400, 'msg': '缺少 plan_id/from_uid'})
|
||||
plan = ClubMigratePlan.query.filter(plan_id=plan_id).first()
|
||||
if not plan:
|
||||
return Response({'code': 404, 'msg': '计划不存在'})
|
||||
try:
|
||||
extra = int(request.data.get('max_extra_times') or 1)
|
||||
except (TypeError, ValueError):
|
||||
return Response({'code': 400, 'msg': 'max_extra_times 无效'})
|
||||
user_info = migrate_svc.lookup_migrate_user_brief(from_uid)
|
||||
if not user_info.get('exists'):
|
||||
return Response({'code': 404, 'msg': f'用户不存在:{from_uid}'})
|
||||
row, _ = ClubMigrateUserQuota.query.get_or_create(
|
||||
plan_id=plan_id,
|
||||
from_uid=from_uid,
|
||||
@@ -374,10 +380,27 @@ class ClubMigrateAdminView(APIView):
|
||||
return Response({
|
||||
'code': 0,
|
||||
'msg': '已设置二次名额',
|
||||
'data': migrate_svc.serialize_user_quota(row, plan=plan, user_info=user_info),
|
||||
})
|
||||
|
||||
if action == 'list_quota':
|
||||
plan_id = (request.data.get('plan_id') or '').strip()
|
||||
if not plan_id:
|
||||
return Response({'code': 400, 'msg': '缺少 plan_id'})
|
||||
plan = ClubMigratePlan.query.filter(plan_id=plan_id).first()
|
||||
if not plan:
|
||||
return Response({'code': 404, 'msg': '计划不存在'})
|
||||
rows = list(
|
||||
ClubMigrateUserQuota.query.filter(plan_id=plan_id).order_by('-id')[:200]
|
||||
)
|
||||
return Response({
|
||||
'code': 0,
|
||||
'msg': 'ok',
|
||||
'data': {
|
||||
'plan_id': plan_id,
|
||||
'from_uid': from_uid,
|
||||
'max_extra_times': row.max_extra_times,
|
||||
'list': [
|
||||
migrate_svc.serialize_user_quota(r, plan=plan)
|
||||
for r in rows
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user