Browse Source

优化序列号绑定UID接口

zhangdongming 1 year ago
parent
commit
ad64f74d3c
1 changed files with 7 additions and 6 deletions
  1. 7 6
      Controller/SerialNumberController.py

+ 7 - 6
Controller/SerialNumberController.py

@@ -146,12 +146,6 @@ class SerialNumberView(View):
             if company_serial.status == 0:  # 该序列号未绑定企业
                 return response.json(173)
             elif company_serial.status == 1:  # 绑定uid
-                # redis加锁,防止同一个序列号重复绑定
-                key = serial + 'do_attach_uid'
-                is_lock = redisObj.CONN.setnx(key, 1)
-                if not is_lock:
-                    return response.json(5)
-                redisObj.CONN.expire(key, 60)
 
                 # 查询app是否已扫码,未扫码不能进行绑定
                 app_scanned_serial_qs = AppScannedSerial.objects.filter(serial=serial)
@@ -159,6 +153,13 @@ class SerialNumberView(View):
                     LOGGER.info(f'{serial}当前序列号未进行APP扫码')
                     return response.json(5)
 
+                # redis加锁,防止同一个序列号重复绑定
+                key = serial + 'do_attach_uid'
+                is_lock = redisObj.CONN.setnx(key, 1)
+                if not is_lock:
+                    return response.json(5)
+                redisObj.CONN.expire(key, 60)
+
                 # 获取并判断region_id
                 region_id = CommonService.confirm_region_id()
                 if region_id not in REGION_ID_LIST: