liupeng 5 роки тому
батько
коміт
000316317b

+ 13 - 5
code/sapparent/sapservice/src/main/java/org/fouram/core/plugin/weixin/cp/util/WXCpMessageUtil.java

@@ -1,13 +1,18 @@
 package org.fouram.core.plugin.weixin.cp.util;
 package org.fouram.core.plugin.weixin.cp.util;
 
 
+import java.util.List;
+
 import org.fouram.core.plugin.weixin.cp.core.WXCpMessage;
 import org.fouram.core.plugin.weixin.cp.core.WXCpMessage;
 import org.fouram.core.util.ConfConfig;
 import org.fouram.core.util.ConfConfig;
 import org.fouram.core.util.LoggerUtil;
 import org.fouram.core.util.LoggerUtil;
 
 
-import me.chanjar.weixin.common.api.WxConsts.XmlMsgType;
+import com.google.common.collect.Lists;
+
+import me.chanjar.weixin.common.api.WxConsts.KefuMsgType;
 import me.chanjar.weixin.common.error.WxErrorException;
 import me.chanjar.weixin.common.error.WxErrorException;
 import me.chanjar.weixin.cp.bean.WxCpMessage;
 import me.chanjar.weixin.cp.bean.WxCpMessage;
 import me.chanjar.weixin.cp.bean.WxCpMessageSendResult;
 import me.chanjar.weixin.cp.bean.WxCpMessageSendResult;
+import me.chanjar.weixin.cp.bean.article.NewArticle;
 
 
 /**
 /**
  * 企业微信用户工具类
  * 企业微信用户工具类
@@ -16,12 +21,15 @@ import me.chanjar.weixin.cp.bean.WxCpMessageSendResult;
  */
  */
 public class WXCpMessageUtil {
 public class WXCpMessageUtil {
 
 
-	public static void sendQuitUserMsg(String content) throws WxErrorException {
+	public static void sendQuitUserMsg(String title) throws WxErrorException {
 		try {
 		try {
 			WxCpMessage message = new WxCpMessage();
 			WxCpMessage message = new WxCpMessage();
 			message.setToUser(ConfConfig.getConfigString("wxCp.massage.toUser"));
 			message.setToUser(ConfConfig.getConfigString("wxCp.massage.toUser"));
-			message.setMsgType(XmlMsgType.TEXT);
-			message.setContent(content);
+			message.setMsgType(KefuMsgType.NEWS);
+			NewArticle article = NewArticle.builder().title(title)
+					.url(ConfConfig.getConfigString("wxCp.massage.quitUserUrl")).build();
+			List<NewArticle> articles = Lists.newArrayList(article);
+			message.setArticles(articles);
 			WxCpMessageSendResult sendResult = WXCpMessage.service.messageSend(message);
 			WxCpMessageSendResult sendResult = WXCpMessage.service.messageSend(message);
 			LoggerUtil.info(sendResult.toString());
 			LoggerUtil.info(sendResult.toString());
 		} catch (WxErrorException e) {
 		} catch (WxErrorException e) {
@@ -30,6 +38,6 @@ public class WXCpMessageUtil {
 	}
 	}
 
 
 	public static void main(String[] args) throws WxErrorException {
 	public static void main(String[] args) throws WxErrorException {
-		sendQuitUserMsg("1111111111222");
+		sendQuitUserMsg("test");
 	}
 	}
 }
 }

+ 1 - 0
code/sapparent/sapservice/src/main/resources/env/develop/config.properties

@@ -6,6 +6,7 @@ wxCp.corpSecret = 0i1jzYxLcriGTXhoatAGYaCFUXshfASbavRScZQxVmI
 wxCp.massage.agentId = 1000003
 wxCp.massage.agentId = 1000003
 wxCp.massage.secret = Sf9mHYuIeAFyqvyoDnTXAH2hlly7kWq6LoIYGCuTZUM
 wxCp.massage.secret = Sf9mHYuIeAFyqvyoDnTXAH2hlly7kWq6LoIYGCuTZUM
 wxCp.massage.toUser = 1000001
 wxCp.massage.toUser = 1000001
+wxCp.massage.quitUserUrl = https://www.baidu.com
 #prod
 #prod
 #wxCp.corpId = ww911e29458d3a46fd
 #wxCp.corpId = ww911e29458d3a46fd
 #wxCp.corpSecret = amUNgH2lo-szEYkLmClZN2jMYcDu0NnXIAtWfW729P4
 #wxCp.corpSecret = amUNgH2lo-szEYkLmClZN2jMYcDu0NnXIAtWfW729P4