瀏覽代碼

优化序列号绑定UID接口

zhangdongming 1 年之前
父節點
當前提交
f1b3fd6822
共有 1 個文件被更改,包括 7 次插入6 次删除
  1. 7 6
      Controller/SerialNumberController.py

+ 7 - 6
Controller/SerialNumberController.py

@@ -144,12 +144,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)
@@ -157,6 +151,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: