|
@@ -132,24 +132,21 @@ class SerialNumberView(View):
|
|
|
company_id = request_dict.get('company_id', None)
|
|
|
token = request_dict.get('token', None)
|
|
|
time_stamp = request_dict.get('time_stamp', None)
|
|
|
- p2ptype = request_dict.get('p2ptype', 1)
|
|
|
+ p2p_type = request_dict.get('p2ptype', 1)
|
|
|
+
|
|
|
if not all([serial_number, company_id, token, time_stamp]):
|
|
|
return response.json(444)
|
|
|
|
|
|
- token = int(CommonService.decode_data(token))
|
|
|
- time_stamp = int(time_stamp)
|
|
|
+ # 时间戳token校验
|
|
|
+ if not CommonService.check_time_stamp_token(token, time_stamp):
|
|
|
+ return response.json(13)
|
|
|
|
|
|
now_time = int(time.time())
|
|
|
- distance = now_time - time_stamp
|
|
|
-
|
|
|
- if token != time_stamp or distance > 60000 or distance < -60000: # 为了全球化时间控制在一天内
|
|
|
- return response.json(404)
|
|
|
-
|
|
|
serial = serial_number[0:6]
|
|
|
full_serial = serial_number[0:9]
|
|
|
|
|
|
if serial_number[9:10]:
|
|
|
- p2ptype = serial_number[9:10]
|
|
|
+ p2p_type = serial_number[9:10]
|
|
|
try:
|
|
|
if not country_id:
|
|
|
ip = CommonService.get_ip_address(request)
|
|
@@ -171,12 +168,16 @@ class SerialNumberView(View):
|
|
|
while count < 3:
|
|
|
# 查询是否存在未绑定序列号的uid
|
|
|
uid_qs = UIDModel.objects.filter(vpg__company_id=company_serial.company.id,
|
|
|
- vpg__region_id=country_id, status=0, p2p_type=p2ptype). \
|
|
|
+ vpg__region_id=country_id, status=0, p2p_type=p2p_type). \
|
|
|
order_by('id')
|
|
|
if not uid_qs.exists():
|
|
|
return response.json(173)
|
|
|
|
|
|
uid = uid_qs[0]
|
|
|
+ # 判断uid是否已绑定过序列号
|
|
|
+ uid_company_serial_qs = UIDCompanySerialModel.objects.filter(uid_id=uid.id)
|
|
|
+ if uid_company_serial_qs.exists():
|
|
|
+ return response.json(174)
|
|
|
|
|
|
result = UIDModel.objects.filter(id=uid.id, status=0).update(status=2, update_time=now_time)
|
|
|
if int(result) <= 0: # 更新失败
|
|
@@ -251,16 +252,10 @@ class SerialNumberView(View):
|
|
|
token = request_dict.get('token', None)
|
|
|
time_stamp = request_dict.get('time_stamp', None)
|
|
|
|
|
|
- if token and time_stamp and serial_number :
|
|
|
-
|
|
|
- token = int(CommonService.decode_data(token))
|
|
|
- time_stamp = int(time_stamp)
|
|
|
-
|
|
|
- now_time = int(time.time())
|
|
|
- distance = now_time - time_stamp
|
|
|
-
|
|
|
- if token != time_stamp or distance > 60000 or distance < -60000: # 为了全球化时间控制在一天内
|
|
|
- return response.json(404)
|
|
|
+ if token and time_stamp and serial_number:
|
|
|
+ # 时间戳token校验
|
|
|
+ if not CommonService.check_time_stamp_token(token, time_stamp):
|
|
|
+ return response.json(13)
|
|
|
|
|
|
mark = serial_number[6:9]
|
|
|
serial = serial_number[0:6]
|
|
@@ -288,15 +283,12 @@ class SerialNumberView(View):
|
|
|
|
|
|
if not all([token, time_stamp, serial_number]):
|
|
|
return response.json(444)
|
|
|
- token = int(CommonService.decode_data(token))
|
|
|
- time_stamp = int(time_stamp)
|
|
|
|
|
|
- now_time = int(time.time())
|
|
|
- distance = now_time - time_stamp
|
|
|
-
|
|
|
- if token != time_stamp or distance > 60000 or distance < -60000: # 为了全球化时间控制在一天内
|
|
|
- return response.json(404)
|
|
|
+ # 时间戳token校验
|
|
|
+ if not CommonService.check_time_stamp_token(token, time_stamp):
|
|
|
+ return response.json(13)
|
|
|
|
|
|
+ now_time = int(time.time())
|
|
|
serial = serial_number[0:6]
|
|
|
uid_serial_qs = UIDCompanySerialModel.objects.filter(company_serial__serial_number=serial)
|
|
|
if not uid_serial_qs.exists():
|