|
@@ -84,28 +84,31 @@ class CustomizedPushObject:
|
|
|
else:
|
|
|
app_bundle_id_list = ['com.ansjer.zccloud_ab', 'com.ansjer.customizede']
|
|
|
|
|
|
- gateway_push_qs = GatewayPush.objects.filter(user_id__in=user_id_list, app_bundle_id__in=app_bundle_id_list).\
|
|
|
- values('user_id', 'app_bundle_id', 'push_type', 'token_val')
|
|
|
- for gateway_push in gateway_push_qs:
|
|
|
- push_type = gateway_push['push_type']
|
|
|
- user_id = gateway_push['user_id']
|
|
|
- app_bundle_id = gateway_push['app_bundle_id']
|
|
|
- token_val = gateway_push['token_val']
|
|
|
+ try:
|
|
|
+ gateway_push_qs = GatewayPush.objects.filter(user_id__in=user_id_list, app_bundle_id__in=app_bundle_id_list).\
|
|
|
+ values('user_id', 'app_bundle_id', 'push_type', 'token_val')
|
|
|
+ for gateway_push in gateway_push_qs:
|
|
|
+ push_type = gateway_push['push_type']
|
|
|
+ user_id = gateway_push['user_id']
|
|
|
+ app_bundle_id = gateway_push['app_bundle_id']
|
|
|
+ token_val = gateway_push['token_val']
|
|
|
|
|
|
- push_succeed = cls.push_msg(push_type, app_bundle_id, token_val, n_time, title, msg, icon_link)
|
|
|
+ push_succeed = cls.push_msg(push_type, app_bundle_id, token_val, n_time, title, msg, icon_link)
|
|
|
|
|
|
- # 推送成功,写入系统消息
|
|
|
- if push_succeed:
|
|
|
- sys_msg = msg
|
|
|
- if link:
|
|
|
- sys_msg += '\n' + link
|
|
|
+ # 推送成功,写入系统消息
|
|
|
+ if push_succeed:
|
|
|
+ sys_msg = msg
|
|
|
+ if link:
|
|
|
+ sys_msg += '\n' + link
|
|
|
|
|
|
- SysMsgModel.objects.create(userID_id=user_id, title=title, msg=sys_msg, addTime=n_time, updTime=n_time)
|
|
|
- CUSTOMIZED_PUSH_LOGGER.info('用户{}推送成功'.format(user_id))
|
|
|
- else:
|
|
|
- CUSTOMIZED_PUSH_LOGGER.info('用户{}推送失败,push_type:{}'.format(user_id, push_type))
|
|
|
+ SysMsgModel.objects.create(userID_id=user_id, title=title, msg=sys_msg, addTime=n_time, updTime=n_time)
|
|
|
+ CUSTOMIZED_PUSH_LOGGER.info('用户{}推送成功'.format(user_id))
|
|
|
+ else:
|
|
|
+ CUSTOMIZED_PUSH_LOGGER.info('用户{}推送失败,push_type:{}'.format(user_id, push_type))
|
|
|
|
|
|
- CUSTOMIZED_PUSH_LOGGER.info('customized_push_id:{}推送完成'.format(kwargs['id']))
|
|
|
+ CUSTOMIZED_PUSH_LOGGER.info('customized_push_id:{}推送完成'.format(kwargs['id']))
|
|
|
+ except Exception as e:
|
|
|
+ CUSTOMIZED_PUSH_LOGGER.info('定制化推送异常,error_line:{},error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
@staticmethod
|
|
|
def push_msg(push_type, app_bundle_id, token_val, n_time, title, msg, icon_link):
|
|
@@ -118,37 +121,40 @@ class CustomizedPushObject:
|
|
|
'msg_text': msg,
|
|
|
'n_time': n_time,
|
|
|
}
|
|
|
- # ios
|
|
|
- if push_type == 0:
|
|
|
- push_kwargs['launch_image'] = icon_link
|
|
|
- return PushObject.ios_apns_push(**push_kwargs)
|
|
|
- # gcm
|
|
|
- elif push_type == 1:
|
|
|
- if icon_link is None:
|
|
|
- icon_link = ''
|
|
|
- push_kwargs['image'] = icon_link
|
|
|
- return PushObject.android_fcm_push(**push_kwargs)
|
|
|
- # 极光
|
|
|
- elif push_type == 2:
|
|
|
- push_succeed = PushObject.android_jpush(**push_kwargs)
|
|
|
- # 华为
|
|
|
- elif push_type == 3:
|
|
|
- push_kwargs['image_url'] = icon_link
|
|
|
- huawei_push_object = HuaweiPushObject()
|
|
|
- return huawei_push_object.send_push_notify_message(**push_kwargs)
|
|
|
- # 小米
|
|
|
- elif push_type == 4:
|
|
|
- push_kwargs['channel_id'] = XM_PUSH_CHANNEL_ID['service_reminder']
|
|
|
- return PushObject.android_xmpush(**push_kwargs)
|
|
|
- # vivo
|
|
|
- elif push_type == 5:
|
|
|
- return PushObject.android_vivopush(**push_kwargs)
|
|
|
- # oppo
|
|
|
- elif push_type == 6:
|
|
|
- push_kwargs['channel_id'] = 'VALUE_ADDED'
|
|
|
- return PushObject.android_oppopush(**push_kwargs)
|
|
|
- # 魅族
|
|
|
- elif push_type == 7:
|
|
|
- return PushObject.android_meizupush(**push_kwargs)
|
|
|
- else:
|
|
|
+ try:
|
|
|
+ # ios
|
|
|
+ if push_type == 0:
|
|
|
+ push_kwargs['launch_image'] = icon_link
|
|
|
+ return PushObject.ios_apns_push(**push_kwargs)
|
|
|
+ # gcm
|
|
|
+ elif push_type == 1:
|
|
|
+ if icon_link is None:
|
|
|
+ icon_link = ''
|
|
|
+ push_kwargs['image'] = icon_link
|
|
|
+ return PushObject.android_fcm_push(**push_kwargs)
|
|
|
+ # 极光
|
|
|
+ elif push_type == 2:
|
|
|
+ push_succeed = PushObject.android_jpush(**push_kwargs)
|
|
|
+ # 华为
|
|
|
+ elif push_type == 3:
|
|
|
+ push_kwargs['image_url'] = icon_link
|
|
|
+ huawei_push_object = HuaweiPushObject()
|
|
|
+ return huawei_push_object.send_push_notify_message(**push_kwargs)
|
|
|
+ # 小米
|
|
|
+ elif push_type == 4:
|
|
|
+ push_kwargs['channel_id'] = XM_PUSH_CHANNEL_ID['service_reminder']
|
|
|
+ return PushObject.android_xmpush(**push_kwargs)
|
|
|
+ # vivo
|
|
|
+ elif push_type == 5:
|
|
|
+ return PushObject.android_vivopush(**push_kwargs)
|
|
|
+ # oppo
|
|
|
+ elif push_type == 6:
|
|
|
+ push_kwargs['channel_id'] = 'VALUE_ADDED'
|
|
|
+ return PushObject.android_oppopush(**push_kwargs)
|
|
|
+ # 魅族
|
|
|
+ elif push_type == 7:
|
|
|
+ return PushObject.android_meizupush(**push_kwargs)
|
|
|
+ else:
|
|
|
+ return False
|
|
|
+ except Exception as e:
|
|
|
return False
|