Эх сурвалжийг харах

推送刷新手机token和推送类型

peng 2 жил өмнө
parent
commit
3480684d99

+ 28 - 15
Controller/DetectControllerV2.py

@@ -159,21 +159,34 @@ class DetectControllerViewV2(View):
 
             # 初始化UidPushModel推送表
             if electricity_status:
-                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)
+                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)
                 return response.json(0)
 
             if status == 0:

+ 1 - 1
Controller/SerialNumberController.py

@@ -702,7 +702,7 @@ class SerialNumberView(View):
     @staticmethod
     def get_domain(request_dict, response):
         """
-        获取域名
+        设备获取域名
         @param request_dict: 请求参数
         @param response: 响应对象
         @request_dict serial_number: 序列号

+ 3 - 2
Controller/UserController.py

@@ -2143,10 +2143,11 @@ class v3LoginView(TemplateView):
         if all([app_bundle_id, app_type, push_type, token_val, m_code, tz]):
             gateway_push_qs = GatewayPush.objects.filter(user_id=userID, m_code=m_code)
             if gateway_push_qs.exists():
-                gateway_push_qs.update(token_val=token_val, logout=False)
+                gateway_push_qs.update(token_val=token_val, push_type=push_type, logout=False)
             else:
                 GatewayPush.objects.create(user_id=userID, app_bundle_id=app_bundle_id, app_type=app_type,
                                            push_type=push_type, token_val=token_val, m_code=m_code, lang=lang, tz=tz)
+            UidPushModel.objects.filter(userID=userID, m_code=m_code).update(token_val=token_val, push_type=push_type)
 
         now_time = datetime.datetime.utcnow().replace(tzinfo=utc).astimezone(utc)
         region_country = users['region_country']
@@ -2402,7 +2403,7 @@ class InitInfoView(View):
             gateway_push_qs = GatewayPush.objects.filter(user_id=user_id, m_code=m_code)
             if gateway_push_qs.exists():
                 if gateway_push_qs.first().token_val != token_val:
-                    gateway_push_qs.update(token_val=token_val, logout=False)
+                    gateway_push_qs.update(token_val=token_val, push_type=push_type, logout=False)
             else:
                 GatewayPush.objects.create(user_id=user_id, app_bundle_id=app_bundle_id, app_type=app_type,
                                            push_type=push_type, token_val=token_val, m_code=m_code, lang=lang, tz=tz)