From 2cba0d00dc45998105129a0c26cb546282cd39a8 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 05 六月 2024 13:44:23 +0800
Subject: [PATCH] 随访功能测试:模板、任务、定时发送、公众号发送,流程走通

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/WeChatController.java |   27 +++++++--------------------
 1 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/WeChatController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/WeChatController.java
index ecbc125..d476d32 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/WeChatController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/WeChatController.java
@@ -3,7 +3,9 @@
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.smartor.domain.WeChatSendVo;
+import com.smartor.service.WeChatService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import me.chanjar.weixin.common.exception.WxErrorException;
@@ -42,6 +44,9 @@
     @Value("${appSecret}")
     private String appSecret;
 
+    @Autowired
+    private WeChatService weChatService;
+
 
     /**
      * 鑾峰彇妯℃澘淇℃伅
@@ -73,26 +78,8 @@
      */
     @ApiOperation("寰俊鍏紬鍙蜂俊鎭彂閫�")
     @PostMapping("/sendMessageToFollowers")
-    public Boolean sendMessageToFollowers(@RequestBody WeChatSendVo weChatSendVo) {
-        WxMpService wxMpService;
-        wxMpService = new WxMpServiceImpl();
-        wxMpService.setWxMpConfigStorage(new WxMpInMemoryConfigStorage());
-        WxMpInMemoryConfigStorage wxMpConfigStorage = (WxMpInMemoryConfigStorage) wxMpService.getWxMpConfigStorage();
-        wxMpConfigStorage.setAppId(appid);
-        wxMpConfigStorage.setSecret(appSecret);
-        try {
-            List<String> openIdList = wxMpService.getUserService().userList(null).getOpenids();
-            for (String openId : openIdList) {
-                WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder().toUser(openId).templateId(weChatSendVo.getTemplateId()).url(weChatSendVo.getUrl()).build();
-                for (String key : weChatSendVo.getContent().keySet()) {
-                    templateMessage.addData(new WxMpTemplateData(key, weChatSendVo.getContent().get(key).toString()));
-                }
-                wxMpService.getTemplateMsgService().sendTemplateMsg(templateMessage);
-            }
-        } catch (WxErrorException e) {
-            e.printStackTrace();
-        }
-        return true;
+    public AjaxResult sendMessageToFollowers(@RequestBody WeChatSendVo weChatSendVo) {
+        return toAjax(weChatService.sendMessageToFollowers(weChatSendVo));
     }
 
 

--
Gitblit v1.9.3