|
@@ -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:
|