|
@@ -6,6 +6,7 @@
|
|
|
@Email : zhangdongming@asj6.wecom.work
|
|
|
@Software: PyCharm
|
|
|
"""
|
|
|
+import re
|
|
|
import time
|
|
|
import json
|
|
|
from decimal import Decimal
|
|
@@ -17,7 +18,7 @@ from django.core.paginator import Paginator
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
|
from AgentModel.models import AgentCustomerInfo, AgentCustomerCard, AgentCustomerPackage, AgentCloudServicePackage, \
|
|
|
- AgentDeviceOrder, AgentAccountWithdraw, AgentDevice, AgentAccount
|
|
|
+ AgentDeviceOrder, AgentAccountWithdraw, AgentDevice, AgentAccount, ApplyAgent
|
|
|
from Model.models import UnicomCombo, Store_Meal, Device_User
|
|
|
|
|
|
from Object.ResponseObject import ResponseObject
|
|
@@ -908,4 +909,32 @@ class AgentCustomerView(View):
|
|
|
return response.json(0)
|
|
|
|
|
|
except Exception as e:
|
|
|
- return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+
|
|
|
+ def apply_agent(self, request_dict, response):
|
|
|
+ """
|
|
|
+ 代理申请
|
|
|
+ @param request_dict: 请求参数
|
|
|
+ @param request_dict name: 名字
|
|
|
+ @param request_dict phone: 电话
|
|
|
+ @param request_dict regin: 地区
|
|
|
+ @param request_dict remark: 备注
|
|
|
+ @param response: 响应对象
|
|
|
+ @return:
|
|
|
+ """
|
|
|
+ name = request_dict.get('name', None)
|
|
|
+ phone = request_dict.get('phone', None)
|
|
|
+ regin = request_dict.get('regin', None)
|
|
|
+ remark = request_dict.get('remark', "")
|
|
|
+ if not all([name, phone, regin]):
|
|
|
+ return response.json(444)
|
|
|
+
|
|
|
+ # 去除非数字字符
|
|
|
+ clean_phone = re.sub(r'\D', '', phone)
|
|
|
+
|
|
|
+ if ApplyAgent.objects.filter(phone=clean_phone).exists():
|
|
|
+ return response.json(174, 'Phone number already exists')
|
|
|
+
|
|
|
+ ApplyAgent.objects.create(name=name, phone=clean_phone, regin=regin, remark=remark)
|
|
|
+
|
|
|
+ return response.json(0, '申请已提交')
|