|
|
|
@ -2,6 +2,7 @@ package com.elink.esua.epdc.service.impl; |
|
|
|
|
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; |
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaUniformMessage; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
|
import com.elink.esua.epdc.commons.tools.redis.RedisKeys; |
|
|
|
@ -205,17 +206,26 @@ public class MessageServiceImpl implements MessageService { |
|
|
|
}else{ |
|
|
|
throw new RenException("消息推送类型错误!"); |
|
|
|
} |
|
|
|
|
|
|
|
if(formDto.getUserList() == null || formDto.getUserList().size() == 0){ |
|
|
|
log.info("获取成员失败!"); |
|
|
|
return new Result().error("获取成员失败!"); |
|
|
|
} |
|
|
|
// 获取openID
|
|
|
|
Result<UserWorkAndAnalyOpenIdDTO> userIdsResult = adminFeignClient.userRelationWorkAndAnalyOpenId(); |
|
|
|
Result<UserWorkAndAnalyOpenIdDTO> userIdsResult = adminFeignClient.userRelationWorkAndAnalyOpenId(formDto); |
|
|
|
log.info("开始推送:"+userIdsResult.toString()); |
|
|
|
if(userIdsResult == null || userIdsResult.getData() == null){ |
|
|
|
log.info("获取openid失败!"); |
|
|
|
return new Result().error("获取openid失败!"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 调用获取openid接口
|
|
|
|
UserWorkAndAnalyOpenIdDTO userWorkAndAnalyOpenIdDTO = userIdsResult.getData(); |
|
|
|
List<String> analyOpenIdList = userWorkAndAnalyOpenIdDTO.getAnalyOpenIds(); |
|
|
|
List<String> workOpenIdList = userWorkAndAnalyOpenIdDTO.getWorkOpenIds(); |
|
|
|
log.info("开始推送数量数据端:"+analyOpenIdList.size()); |
|
|
|
log.info("开始推送数量工作端:"+workOpenIdList.size()); |
|
|
|
|
|
|
|
if (null != analyOpenIdList && analyOpenIdList.size() > 0) { |
|
|
|
// 获取access_token
|
|
|
|
@ -264,6 +274,7 @@ public class MessageServiceImpl implements MessageService { |
|
|
|
lang, |
|
|
|
page); |
|
|
|
System.out.println("接收者【" + openId + "】,发送结果【" + resultMsg + "】"); |
|
|
|
log.info("接收者【" + openId + "】,发送结果【" + resultMsg + "】"); |
|
|
|
//解析返回信息
|
|
|
|
Map map = JSONObject.parseObject(resultMsg, Map.class); |
|
|
|
if (Integer.parseInt(map.get("errcode").toString()) == 0) { |
|
|
|
@ -311,11 +322,12 @@ public class MessageServiceImpl implements MessageService { |
|
|
|
jsonObject.put("touser",openId); |
|
|
|
jsonObject.put("template_id",template_id); |
|
|
|
jsonObject.put("miniprogram_state",miniprogram_state); |
|
|
|
jsonObject.put("data",m); |
|
|
|
|
|
|
|
jsonObject.put("data",JSON.parseObject(JSON.toJSONString(m))); |
|
|
|
jsonObject.put("lang",lang); |
|
|
|
jsonObject.put("page",page); |
|
|
|
String parmStr = jsonObject.toJSONString(); |
|
|
|
|
|
|
|
log.error("传输内容"+parmStr); |
|
|
|
String sr = HttpRequest.sendPost(url,parmStr); |
|
|
|
return sr; |
|
|
|
} |
|
|
|
@ -331,6 +343,7 @@ public class MessageServiceImpl implements MessageService { |
|
|
|
public String getAccess_token(String appid, String appsecret) { |
|
|
|
// 获取access_token
|
|
|
|
String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential" + "&appid=" + appid + "&secret=" + appsecret; |
|
|
|
log.error("testtest"); |
|
|
|
String sr = HttpRequest.sendPost(url,""); |
|
|
|
|
|
|
|
JSONObject json = JSONObject.parseObject(sr); |
|
|
|
|