Bläddra i källkod

推送开关吐过参数为0不新增数据

peng 2 år sedan
förälder
incheckning
6eec8efb64
1 ändrade filer med 58 tillägg och 57 borttagningar
  1. 58 57
      Controller/DetectControllerV2.py

+ 58 - 57
Controller/DetectControllerV2.py

@@ -159,34 +159,35 @@ class DetectControllerViewV2(View):
 
             # 初始化UidPushModel推送表
             if electricity_status:
-                uid_push_qs = UidPushModel.objects.filter(userID_id=userID, m_code=m_code, uid_set__uid=uid)
-                if uid_push_qs.exists():
-                    uid_push_update_dict = {
-                        'appBundleId': appBundleId,
-                        'app_type': app_type,
-                        'push_type': push_type,
-                        'token_val': token_val,
-                        'updTime': nowTime,
-                        'lang': lang,
-                        'tz': tz
-                    }
-                    uid_push_qs.update(**uid_push_update_dict)
-                else:
-                    uid_push_create_dict = {
-                        'uid_set_id': uid_set_id,
-                        'userID_id': userID,
-                        'appBundleId': appBundleId,
-                        'app_type': app_type,
-                        'push_type': push_type,
-                        'token_val': token_val,
-                        'm_code': m_code,
-                        'addTime': nowTime,
-                        'updTime': nowTime,
-                        'lang': lang,
-                        'tz': tz
-                    }
-                    # 绑定设备推送
-                    UidPushModel.objects.create(**uid_push_create_dict)
+                if m_code != 0 and m_code != '0':
+                    uid_push_qs = UidPushModel.objects.filter(userID_id=userID, m_code=m_code, uid_set__uid=uid)
+                    if uid_push_qs.exists():
+                        uid_push_update_dict = {
+                            'appBundleId': appBundleId,
+                            'app_type': app_type,
+                            'push_type': push_type,
+                            'token_val': token_val,
+                            'updTime': nowTime,
+                            'lang': lang,
+                            'tz': tz
+                        }
+                        uid_push_qs.update(**uid_push_update_dict)
+                    else:
+                        uid_push_create_dict = {
+                            'uid_set_id': uid_set_id,
+                            'userID_id': userID,
+                            'appBundleId': appBundleId,
+                            'app_type': app_type,
+                            'push_type': push_type,
+                            'token_val': token_val,
+                            'm_code': m_code,
+                            'addTime': nowTime,
+                            'updTime': nowTime,
+                            'lang': lang,
+                            'tz': tz
+                        }
+                        # 绑定设备推送
+                        UidPushModel.objects.create(**uid_push_create_dict)
                 if appBundleId == 0 or appBundleId == '0':
                     LOGGER.info('detectV2/changeStatus接口推送数据:{}'.format(request_dict))
                 return response.json(0)
@@ -196,35 +197,35 @@ class DetectControllerViewV2(View):
                 self.do_delete_redis(uid)
                 return response.json(0)
             elif status == 1:
-                uid_push_qs = UidPushModel.objects.filter(userID_id=userID, m_code=m_code, uid_set__uid=uid)
-
-                if uid_push_qs.exists():
-                    uid_push_update_dict = {
-                        'appBundleId': appBundleId,
-                        'app_type': app_type,
-                        'push_type': push_type,
-                        'token_val': token_val,
-                        'updTime': nowTime,
-                        'lang': lang,
-                        'tz': tz
-                    }
-                    uid_push_qs.update(**uid_push_update_dict)
-                else:
-                    uid_push_create_dict = {
-                        'uid_set_id': uid_set_id,
-                        'userID_id': userID,
-                        'appBundleId': appBundleId,
-                        'app_type': app_type,
-                        'push_type': push_type,
-                        'token_val': token_val,
-                        'm_code': m_code,
-                        'addTime': nowTime,
-                        'updTime': nowTime,
-                        'lang': lang,
-                        'tz': tz
-                    }
-                    # 绑定设备推送
-                    UidPushModel.objects.create(**uid_push_create_dict)
+                if m_code != 0 and m_code != '0':
+                    uid_push_qs = UidPushModel.objects.filter(userID_id=userID, m_code=m_code, uid_set__uid=uid)
+                    if uid_push_qs.exists():
+                        uid_push_update_dict = {
+                            'appBundleId': appBundleId,
+                            'app_type': app_type,
+                            'push_type': push_type,
+                            'token_val': token_val,
+                            'updTime': nowTime,
+                            'lang': lang,
+                            'tz': tz
+                        }
+                        uid_push_qs.update(**uid_push_update_dict)
+                    else:
+                        uid_push_create_dict = {
+                            'uid_set_id': uid_set_id,
+                            'userID_id': userID,
+                            'appBundleId': appBundleId,
+                            'app_type': app_type,
+                            'push_type': push_type,
+                            'token_val': token_val,
+                            'm_code': m_code,
+                            'addTime': nowTime,
+                            'updTime': nowTime,
+                            'lang': lang,
+                            'tz': tz
+                        }
+                        # 绑定设备推送
+                        UidPushModel.objects.create(**uid_push_create_dict)
                 if appBundleId == 0 or appBundleId == '0':
                     LOGGER.info('detectV2/changeStatus接口推送数据:{}'.format(request_dict))
                 if interval: