Răsfoiți Sursa

增加在添加代理商时需要添加电话号码的逻辑

linhaohong 1 an în urmă
părinte
comite
7d5be5a135
1 a modificat fișierele cu 4 adăugiri și 2 ștergeri
  1. 4 2
      AdminController/UserManageController.py

+ 4 - 2
AdminController/UserManageController.py

@@ -419,6 +419,7 @@ class UserManagement(View):
         agent_name = request_dict.get('agent_name', None)
         card_no = request_dict.get('card_no', "")
         card_address = request_dict.get('card_address', "")
+        phone = request_dict.get('phone', "")
 
         # 校验用户名,邮箱,密码是否符合规则
         dataValid = DataValid()
@@ -451,6 +452,8 @@ class UserManagement(View):
                     role_qs = Role.objects.filter(roleName=roleName)  # 账号角色
                     device_user_qs[0].role.set(role_qs)
             else:  # 添加用户
+                if isAgent and not all([agent_company_name, agent_name, phone]):
+                    return response.json(444)
                 # 查询邮箱是否已注册
                 if Device_User.objects.filter(userEmail=userEmail).exists():
                     return response.json(103)
@@ -463,13 +466,12 @@ class UserManagement(View):
                     "userEmail": userEmail,
                     "password": password,
                     "userID": new_userID,
+                    "phone": phone,
                     "is_active": True,
                     "user_isValid": True,
                 }
                 Device_User.objects.create(**user_data).role.set(role_qs)
                 if isAgent:
-                    if not all([agent_company_name, agent_name]):
-                        return response.json(444)
                     agent_customer_info = AgentCustomerInfo.objects.create(user_id=new_userID, company_name=agent_company_name, status=1, created_time=int(time.time()),
                                                      updated_time=int(time.time()), created_by=userID, updated_by=userID)
                     AgentCustomerCard.objects.create(ac_id=agent_customer_info.id, name=username, card_no=card_no, card_address=card_address, status=1,