|
@@ -100,6 +100,9 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
@Value(value = "${configEnv.isDev}")
|
|
|
private boolean isDev;
|
|
|
|
|
|
+ @Value(value = "${configEnv.isPrivateDeploy}")
|
|
|
+ private boolean isPrivateDeploy;
|
|
|
+
|
|
|
@Autowired
|
|
|
RestTemplate restTemplate;
|
|
|
|
|
@@ -276,17 +279,25 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
try {
|
|
|
if (isDev) return;
|
|
|
String accessToken = getCorpAccessToken(corpInfo);
|
|
|
- String url = URL_SEND_WXCORP_MSG.replaceAll("ACCESS_TOKEN", accessToken);
|
|
|
+ String url=URL_SEND_WXCORP_MSG.replaceAll("ACCESS_TOKEN", accessToken);
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
JSONObject reqParam = new JSONObject();
|
|
|
- reqParam.put("touser", corpUserid);
|
|
|
- reqParam.put("toparty", "");
|
|
|
- reqParam.put("totag", "");
|
|
|
- reqParam.put("msgtype", "template_msg");
|
|
|
- reqParam.put("agentid", corpInfo.getAgentid());
|
|
|
- reqParam.put("template_msg", msg);
|
|
|
-
|
|
|
+ if(isPrivateDeploy){
|
|
|
+ reqParam.put("touser", corpUserid);
|
|
|
+ reqParam.put("toparty", "");
|
|
|
+ reqParam.put("totag", "");
|
|
|
+ reqParam.put("msgtype", "text");
|
|
|
+ reqParam.put("agentid", corpInfo.getAgentid());
|
|
|
+ reqParam.put("text", msg);
|
|
|
+ }else {
|
|
|
+ reqParam.put("touser", corpUserid);
|
|
|
+ reqParam.put("toparty", "");
|
|
|
+ reqParam.put("totag", "");
|
|
|
+ reqParam.put("msgtype", "template_msg");
|
|
|
+ reqParam.put("agentid", corpInfo.getAgentid());
|
|
|
+ reqParam.put("template_msg", msg);
|
|
|
+ }
|
|
|
HttpEntity<String> requestEntity = new HttpEntity<String>(reqParam.toJSONString(), headers);
|
|
|
ResponseEntity<String> responseEntity = this.restTemplate.exchange(url,
|
|
|
HttpMethod.POST, requestEntity, String.class);
|
|
@@ -303,7 +314,6 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
|
|
|
} else {
|
|
|
System.err.println("发送失败:" + responseEntity.getStatusCode() + ", " + responseEntity.getBody());
|
|
|
}
|
|
|
-
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|