|
@@ -151,13 +151,6 @@ class SerialNumberView(View):
|
|
|
if serial_number[9:10]:
|
|
|
p2p_type = serial_number[9:10]
|
|
|
|
|
|
- # redis加锁,防止同一个序列号重复绑定
|
|
|
- redisObj = RedisObject()
|
|
|
- isLock = redisObj.CONN.setnx(serial + 'do_attach_uid', 1)
|
|
|
- redisObj.CONN.expire(serial + 'do_attach_uid', 60)
|
|
|
- if not isLock:
|
|
|
- return response.json(5)
|
|
|
-
|
|
|
try:
|
|
|
if not country_id:
|
|
|
# 设备模拟国外环境测试
|
|
@@ -180,6 +173,13 @@ class SerialNumberView(View):
|
|
|
if company_serial.status == 0: # 该序列号未绑定企业
|
|
|
return response.json(173)
|
|
|
elif company_serial.status == 1: # 绑定uid
|
|
|
+ # redis加锁,防止同一个序列号重复绑定
|
|
|
+ key = serial + 'do_attach_uid'
|
|
|
+ redisObj = RedisObject()
|
|
|
+ isLock = redisObj.CONN.setnx(key, 1)
|
|
|
+ redisObj.CONN.expire(key, 60)
|
|
|
+ if not isLock:
|
|
|
+ return response.json(5)
|
|
|
with transaction.atomic():
|
|
|
count = 0
|
|
|
while count < 3:
|
|
@@ -244,6 +244,7 @@ class SerialNumberView(View):
|
|
|
assert update_success
|
|
|
except AssertionError:
|
|
|
return response.json(378)
|
|
|
+ redisObj.del_data(key=key)
|
|
|
return response.json(0, res)
|
|
|
return response.json(5)
|
|
|
elif company_serial.status == 2: # 返回uid
|