|
@@ -129,11 +129,9 @@ class SerialNumberView(View):
|
|
|
|
|
|
def do_attach_uid(self, request_dict, response, request):
|
|
def do_attach_uid(self, request_dict, response, request):
|
|
serial_number = request_dict.get('serial_number', None)
|
|
serial_number = request_dict.get('serial_number', None)
|
|
- region_id = request_dict.get('region_id', None)
|
|
|
|
company_id = request_dict.get('company_id', None)
|
|
company_id = request_dict.get('company_id', None)
|
|
token = request_dict.get('token', None)
|
|
token = request_dict.get('token', None)
|
|
time_stamp = request_dict.get('time_stamp', None)
|
|
time_stamp = request_dict.get('time_stamp', None)
|
|
- p2p_type = request_dict.get('p2ptype', 1)
|
|
|
|
|
|
|
|
if not all([serial_number, company_id, token, time_stamp]):
|
|
if not all([serial_number, company_id, token, time_stamp]):
|
|
return response.json(444)
|
|
return response.json(444)
|
|
@@ -146,25 +144,11 @@ class SerialNumberView(View):
|
|
serial = serial_number[0:6]
|
|
serial = serial_number[0:6]
|
|
full_serial = serial_number[0:9]
|
|
full_serial = serial_number[0:9]
|
|
|
|
|
|
- if serial_number[9:10]:
|
|
|
|
- p2p_type = serial_number[9:10]
|
|
|
|
-
|
|
|
|
try:
|
|
try:
|
|
- p2p_type = int(p2p_type)
|
|
|
|
- if not region_id:
|
|
|
|
- # 根据配置信息确定region_id
|
|
|
|
- region_id = CommonService.confirm_region_id(request)
|
|
|
|
-
|
|
|
|
- # 尚云: 地区为亚洲分配美洲的uid
|
|
|
|
- if p2p_type == 1 and region_id == 2:
|
|
|
|
- region_id = 3
|
|
|
|
-
|
|
|
|
# 判断序列号是否已和企业关联
|
|
# 判断序列号是否已和企业关联
|
|
company_serial_qs = CompanySerialModel.objects.filter(company__secret=company_id, serial_number=serial)
|
|
company_serial_qs = CompanySerialModel.objects.filter(company__secret=company_id, serial_number=serial)
|
|
if not company_serial_qs.exists():
|
|
if not company_serial_qs.exists():
|
|
return response.json(173)
|
|
return response.json(173)
|
|
-
|
|
|
|
- # 当序列号已关联UID
|
|
|
|
company_serial = company_serial_qs[0]
|
|
company_serial = company_serial_qs[0]
|
|
|
|
|
|
if company_serial.status == 0: # 该序列号未绑定企业
|
|
if company_serial.status == 0: # 该序列号未绑定企业
|
|
@@ -177,6 +161,20 @@ class SerialNumberView(View):
|
|
redisObj.CONN.expire(key, 60)
|
|
redisObj.CONN.expire(key, 60)
|
|
if not isLock:
|
|
if not isLock:
|
|
return response.json(5)
|
|
return response.json(5)
|
|
|
|
+
|
|
|
|
+ region_id = request_dict.get('region_id', None)
|
|
|
|
+ if not region_id:
|
|
|
|
+ # 根据配置信息确定region_id
|
|
|
|
+ region_id = CommonService.confirm_region_id(request)
|
|
|
|
+
|
|
|
|
+ p2p_type = request_dict.get('p2ptype', 1)
|
|
|
|
+ if serial_number[9:10]:
|
|
|
|
+ p2p_type = serial_number[9:10]
|
|
|
|
+ p2p_type = int(p2p_type)
|
|
|
|
+ # 尚云: 地区为亚洲分配美洲的uid
|
|
|
|
+ if p2p_type == 1 and region_id == 2:
|
|
|
|
+ region_id = 3
|
|
|
|
+
|
|
with transaction.atomic():
|
|
with transaction.atomic():
|
|
count = 0
|
|
count = 0
|
|
while count < 3:
|
|
while count < 3:
|