|
@@ -66,6 +66,7 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpInfo> implements WxCorpInfoService {
|
|
|
+
|
|
|
public static String URL_SEND_WXCORP_MSG = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=ACCESS_TOKEN";
|
|
|
//获取临时素材url
|
|
|
public static String URL_GET_MEDIA = "https://qyapi.weixin.qq.com/cgi-bin/media/get?access_token=ACCESS_TOKEN&media_id=MEDIA_ID";
|
|
@@ -82,6 +83,11 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
|
|
|
public static final String GET_USER_INFO_WITHDP = "https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=ACCESS_TOKEN&department_id=DEPARTMENT_ID";
|
|
|
|
|
|
+ public static final int TEXT_CARD_MSG_BUSTRIP_WAITING_AUDIT = 0;//出差待审核
|
|
|
+ public static final int TEXT_CARD_MSG_BUSTRIP_AGREE = 1;//出差审核通过
|
|
|
+ public static final int TEXT_CARD_MSG_BUSTRIP_DENY = 2;//出差审核驳回
|
|
|
+ public static final int TEXT_CARD_MSG_REPORT_DENY = 10;//日报驳回
|
|
|
+ public static final int TEXT_CARD_MSG_REPORT_AGREE = 11; //日报审核通过
|
|
|
|
|
|
@Value("${suitId}")
|
|
|
private String suitId;
|
|
@@ -236,7 +242,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
return resultUrl;
|
|
|
}
|
|
|
@Override
|
|
|
- public void sendWXCorpMsg(WxCorpInfo corpInfo, String corpUserid, String msg) {
|
|
|
+ public void sendWXCorpMsg(WxCorpInfo corpInfo, String corpUserid, String msg, String pageRouter, Integer msgType) {
|
|
|
try {
|
|
|
if (isDev) return;
|
|
|
log.info("发送企业微信消息===" + corpUserid);
|
|
@@ -247,12 +253,26 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
JSONObject reqParam = new JSONObject();
|
|
|
reqParam.put("touser", corpUserid);
|
|
|
- reqParam.put("msgtype", "text");
|
|
|
+ reqParam.put("msgtype", "textcard");
|
|
|
reqParam.put("enable_id_trans", 1);
|
|
|
reqParam.put("agentid", corpInfo.getAgentid());
|
|
|
- JSONObject contentJson = new JSONObject();
|
|
|
- contentJson.put("content", msg);
|
|
|
- reqParam.put("text", contentJson);
|
|
|
+ JSONObject cardJson = new JSONObject();
|
|
|
+ String title = "";
|
|
|
+ String jumpUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(pageRouter)) {
|
|
|
+ title = "通知";
|
|
|
+ jumpUrl = jumpUrl.replace("STATE", "0");
|
|
|
+ } else {
|
|
|
+ jumpUrl = jumpUrl.replace("STATE", pageRouter);
|
|
|
+ if ("awayOffice".equals(pageRouter)) {
|
|
|
+ //出差
|
|
|
+ title = "出差通知";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cardJson.put("title", title);
|
|
|
+ cardJson.put("description", msg);
|
|
|
+ reqParam.put("textcard", cardJson);
|
|
|
|
|
|
HttpEntity<String> requestEntity = new HttpEntity<String>(reqParam.toJSONString(), headers);
|
|
|
ResponseEntity<String> responseEntity = this.restTemplate.exchange(url,
|