Commit 08d6c093 authored by zuoadmin's avatar zuoadmin

Merge branch 'bug' into 'master'

Bug

See merge request !25
parents 36a8d9ce e3c764bb
...@@ -19,10 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -19,10 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @author : Administrator * @author : Administrator
...@@ -79,6 +76,9 @@ public class MobPushService { ...@@ -79,6 +76,9 @@ public class MobPushService {
request.put("pushNotify", pushNotify); request.put("pushNotify", pushNotify);
Map<String, Object> pushForward = getPushForward(); Map<String, Object> pushForward = getPushForward();
request.put("pushForward", pushForward); request.put("pushForward", pushForward);
//厂商特殊配置
Map<String, Object> pushFactoryExtra = getPushFactoryExtra();
request.put("pushFactoryExtra", pushFactoryExtra);
//groupId: AB分组测试ID //groupId: AB分组测试ID
request.put("groupId", target.getValue()); request.put("groupId", target.getValue());
String body = generalPost(request, pushUrl); String body = generalPost(request, pushUrl);
...@@ -89,6 +89,22 @@ public class MobPushService { ...@@ -89,6 +89,22 @@ public class MobPushService {
return null; return null;
} }
/**
* 厂商特殊渠道配置
*
* @return map
*/
private Map<String, Object> getPushFactoryExtra() {
Map<String, Object> pushFactoryExtra = new HashMap<>();
Map<String, Object> huaweiExtra = new HashMap<>();
huaweiExtra.put("importance", "NORMAL");
pushFactoryExtra.put("huaweiExtra", huaweiExtra);
Map<String, Object> vivoExtra = new HashMap<>();
vivoExtra.put("classification", "1");
pushFactoryExtra.put("vivoExtra", vivoExtra);
return pushFactoryExtra;
}
/** /**
* mob批量推送 * mob批量推送
* *
...@@ -136,6 +152,45 @@ public class MobPushService { ...@@ -136,6 +152,45 @@ public class MobPushService {
return Model.error(); return Model.error();
} }
public boolean getPushInfoById(String workId) {
String reqUrl = "http://api.push.mob.com/v3/stats/getByWorkId";
Map<String, Object> request = new HashMap<>();
//appkey
request.put("appkey", APP_KEY);
request.put("workId", workId);
String body = generalPost(request, reqUrl);
log.error("查询回调结果:{}", body);
if (JSONUtil.isJson(body)) {
JSONObject json = JSONObject.parseObject(body);
if (json.containsKey("status") && json.getInteger("status").equals(200)) {
if (json.containsKey("res")) {
JSONObject res = json.getJSONObject("res");
if (Objects.nonNull(res)) {
if (res.containsKey("android")) {
JSONObject android = res.getJSONObject("android");
if (Objects.nonNull(android)) {
if (android.containsKey("deliverFailNum")) {
Integer deliverFailNum = android.getInteger("deliverFailNum");
return deliverFailNum <= 0;
}
}
} else if (res.containsKey("ios")) {
JSONObject ios = res.getJSONObject("ios");
if (Objects.nonNull(ios)) {
if (ios.containsKey("deliverFailNum")) {
Integer deliverFailNum = ios.getInteger("deliverFailNum");
return deliverFailNum <= 0;
}
}
}
}
}
}
}
return false;
}
private Map<String, Object> getItems(String[] target, String title, String content, Integer pushType) { private Map<String, Object> getItems(String[] target, String title, String content, Integer pushType) {
Map<String, Object> items = new HashMap<>(); Map<String, Object> items = new HashMap<>();
items.put("itemId", IdUtil.fastUUID()); items.put("itemId", IdUtil.fastUUID());
......
...@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; ...@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.weface.common.utils.*; import com.weface.common.utils.*;
import com.weface.component.MenuService; import com.weface.component.MenuService;
import com.weface.component.MobPushService;
import com.weface.config.RedisExpireData; import com.weface.config.RedisExpireData;
import com.weface.entity.MenuTagsEntity; import com.weface.entity.MenuTagsEntity;
import com.weface.entity.PushLogEntity; import com.weface.entity.PushLogEntity;
...@@ -58,35 +59,54 @@ public class UserTagsTask { ...@@ -58,35 +59,54 @@ public class UserTagsTask {
@Autowired @Autowired
private PushLogService pushLogService; private PushLogService pushLogService;
@Autowired
private MobPushService mobPushService;
/** /**
* 查询推送日志时间 * 查询推送日志时间
*/ */
private static final Integer TIME = 1; private static final Integer TIME = 2;
/** /**
* 查询未推送消息成功记录,发送短信通知 * 查询未推送消息成功记录,发送短信通知
*/ */
@Scheduled(cron = "0 0 0/1 * * ? ") @Scheduled(cron = "0 0 0/1 * * ?")
public void sendMessage() { public void sendMessage() {
try { try {
log.error("开始执行短信送任务"); log.error("开始执行短信送任务");
List<PushLogEntity> list = pushLogService.getPushLogByTime(TIME); List<PushLogEntity> list = pushLogService.getPushLogByTime(TIME);
if (!CollectionUtils.isEmpty(list)) { if (!CollectionUtils.isEmpty(list)) {
DES des = DES.getInstanceDes(); DES des = DES.getInstanceDes();
for (PushLogEntity pushLogEntity : list) { for (PushLogEntity pushLogEntity : list) {
String phone = pushLogEntity.getPhone(); String phone = pushLogEntity.getPhone();
if (StringUtils.isNotEmpty(phone)){ if (StringUtils.isEmpty(phone)) {
continue;
}
if (CommonUtil.isBase64(phone)) { if (CommonUtil.isBase64(phone)) {
phone = des.decrypt(phone); phone = des.decrypt(phone);
} }
Integer arriveStatus = pushLogEntity.getArriveStatus();
if (arriveStatus.equals(1001)) {
Integer pushType = pushLogEntity.getPushType();
if (Objects.nonNull(pushType)) {
String pushContent = pushLogEntity.getPushContent(); String pushContent = pushLogEntity.getPushContent();
Integer messageTemplate = pushLogEntity.getMessageTemplate(); Integer messageTemplate = pushLogEntity.getMessageTemplate();
Integer arriveStatus = pushLogEntity.getArriveStatus(); boolean push = false;
if (1001 == arriveStatus) { //毛博推送
if (pushType.equals(2)) {
//查询推送记录是否送到
push = mobPushService.getPushInfoById(pushLogEntity.getTaskId());
//推送已到达
if (push) {
pushLogEntity.setArriveStatus(1002);
pushLogEntity.setUpdateTime(new Date());
pushLogService.updateById(pushLogEntity);
}
}
if (!push) {
boolean b = ShortMsgSend.sendMobileByRegister(pushContent, phone, messageTemplate); boolean b = ShortMsgSend.sendMobileByRegister(pushContent, phone, messageTemplate);
if (b) { if (b) {
log.error("执行短信发送成功"); log.error("执行短信发送成功:{}", phone);
pushLogEntity.setArriveStatus(1003); pushLogEntity.setArriveStatus(1003);
pushLogEntity.setUpdateTime(new Date()); pushLogEntity.setUpdateTime(new Date());
pushLogService.updateById(pushLogEntity); pushLogService.updateById(pushLogEntity);
...@@ -95,6 +115,7 @@ public class UserTagsTask { ...@@ -95,6 +115,7 @@ public class UserTagsTask {
} }
} }
} }
}
} catch (IOException e) { } catch (IOException e) {
log.error("执行短信发送失败:{}", e.getMessage()); log.error("执行短信发送失败:{}", e.getMessage());
e.printStackTrace(); e.printStackTrace();
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<select id="getPushLogByTime" resultMap="pushLogMap"> <select id="getPushLogByTime" resultMap="pushLogMap">
SELECT * SELECT *
FROM tb_push_log FROM tb_push_log
WHERE is_valid = 1 WHERE is_valid = 1 AND phone IS NOT NULL
AND arrive_status = 1001 AND arrive_status = 1001
AND create_time > DATE_SUB( AND create_time > DATE_SUB(
NOW(), NOW(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment