商家首页图标key分离、商家改昵称接口、抢单列表sj_avatar
This commit is contained in:
@@ -1072,8 +1072,10 @@ class ShangJiaXinXiView(APIView):
|
||||
|
||||
# ------------------- 1. 从 UserShangjia 获取基础字段 -------------------
|
||||
response_data = {
|
||||
'nicheng': shangjia.nicheng or '',
|
||||
'sjzhzhuangtai': shangjia.zhuangtai, # 商家账号状态
|
||||
'fadanzong': shangjia.fabu, # 发单总量(累计)
|
||||
'fabu': shangjia.fabu,
|
||||
'tuikuanzong': shangjia.tuikuan, # 退款总量(累计)
|
||||
'sjyue': float(shangjia.yue), # 商家余额
|
||||
# 'riliushui' 和 'yueliushui' 将从统计表计算,不再使用原字段
|
||||
@@ -1143,6 +1145,36 @@ class ShangJiaXinXiView(APIView):
|
||||
|
||||
|
||||
|
||||
class ShangjiaNichengGengxinView(APIView):
|
||||
"""商家老板修改昵称 POST /yonghu/shangjiagxnc"""
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def post(self, request):
|
||||
from merchant_ops.services.authz import is_merchant_owner
|
||||
|
||||
if not is_merchant_owner(request.user):
|
||||
return Response({'code': 403, 'msg': '仅商家老板可修改昵称', 'data': None}, status=status.HTTP_200_OK)
|
||||
|
||||
nicheng = (request.data.get('nicheng') or '').strip()
|
||||
if not nicheng:
|
||||
return Response({'code': 400, 'msg': '昵称不能为空', 'data': None}, status=status.HTTP_200_OK)
|
||||
if len(nicheng) > 20:
|
||||
return Response({'code': 400, 'msg': '昵称不能超过20字', 'data': None}, status=status.HTTP_200_OK)
|
||||
|
||||
try:
|
||||
shangjia = request.user.ShopProfile
|
||||
except ObjectDoesNotExist:
|
||||
return Response({'code': 4001, 'msg': '商家资料不存在', 'data': None}, status=status.HTTP_200_OK)
|
||||
|
||||
if UserShangjia.query.filter(nicheng=nicheng).exclude(user=request.user).exists():
|
||||
return Response({'code': 400, 'msg': '该昵称已被使用', 'data': None}, status=status.HTTP_200_OK)
|
||||
|
||||
shangjia.nicheng = nicheng
|
||||
shangjia.save(update_fields=['nicheng', 'UpdateTime'])
|
||||
|
||||
return Response({'code': 200, 'msg': '昵称已更新', 'data': {'nicheng': nicheng}}, status=status.HTTP_200_OK)
|
||||
|
||||
|
||||
class BossBiaoshiView(APIView):
|
||||
"""
|
||||
获取用户的GoEasy标识 - 极简实现
|
||||
|
||||
Reference in New Issue
Block a user