Ver Fonte

Merge branch 'dev-xym-fix4' into test

xueyiming há 2 meses atrás
pai
commit
1fe207c6ca

+ 8 - 3
api-module/src/main/java/com/tzld/piaoquan/api/controller/TencentWeComController.java

@@ -22,6 +22,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.util.Base64;
 import java.util.Map;
 import java.util.UUID;
 
@@ -242,7 +243,9 @@ public class TencentWeComController {
         File file = new File(filePath);
         // 将MultipartFile的内容传输到File中
         multipartFile.transferTo(file);
-        log.info("sendPostFile url={}", url);
+        byte[] decodedBytes = Base64.getDecoder().decode(url);
+        String originalString = new String(decodedBytes);
+        log.info("sendPostFile url={}", originalString);
         String post = httpPoolClient.post(url, file);
         Files.delete(Paths.get(filePath));
         return post;
@@ -250,7 +253,9 @@ public class TencentWeComController {
 
     @GetMapping("/send/get")
     public String sendGet(@RequestParam String url) throws IOException {
-        log.info("sendGet url={}", url);
-        return httpPoolClient.get(url);
+        byte[] decodedBytes = Base64.getDecoder().decode(url);
+        String originalString = new String(decodedBytes);
+        log.info("sendGet url={}", originalString);
+        return httpPoolClient.get(originalString);
     }
 }

+ 6 - 1
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/MessageServiceImpl.java

@@ -96,7 +96,12 @@ public class MessageServiceImpl implements MessageService {
             String accessToken = weComAccessTokenService.getWeComAccessToken(corpId);
             String url = POST_WE_COM_SEND_WELCOME_MSG
                     + "?access_token=" + accessToken;
-            String s = httpPoolClient.post(url, jsonObject.toJSONString());
+            String s;
+            if (corpId == 1L) {
+                s = httpPoolClient.post(url, jsonObject.toJSONString());
+            } else {
+                s = weComSendService.sendPost(url, jsonObject.toJSONString());
+            }
             JSONObject res = JSONObject.parseObject(s);
             log.info("sendAutoReplyMessage res={}", res);
             Integer code = res.getInteger("errcode");

+ 15 - 5
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/WeComSendServiceImpl.java

@@ -5,6 +5,8 @@ import com.tzld.piaoquan.growth.common.component.HttpPoolClient;
 import com.tzld.piaoquan.growth.common.model.vo.SendRequestParam;
 import com.tzld.piaoquan.growth.common.service.WeComSendService;
 import com.tzld.piaoquan.growth.common.utils.LarkRobotUtil;
+import lombok.extern.slf4j.Slf4j;
+import lombok.val;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -12,7 +14,9 @@ import org.springframework.stereotype.Service;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Base64;
 
+@Slf4j
 @Service
 public class WeComSendServiceImpl implements WeComSendService {
 
@@ -33,7 +37,9 @@ public class WeComSendServiceImpl implements WeComSendService {
         SendRequestParam sendRequestParam = new SendRequestParam();
         sendRequestParam.setUrl(url);
         sendRequestParam.setParam(param);
-        return httpPoolClient.post(sendUrl, JSON.toJSONString(sendRequestParam));
+        String res = httpPoolClient.post(sendUrl, JSON.toJSONString(sendRequestParam));
+        log.info("sendPost res={}", res);
+        return res;
     }
 
     @Override
@@ -43,8 +49,10 @@ public class WeComSendServiceImpl implements WeComSendService {
             return null;
         }
         String sendUrl = "http://" + sendRequestIp + "/wecom/server/send/get";
-        sendUrl += "?url=" + url;
-        return httpPoolClient.get(sendUrl);
+        sendUrl += "?url=" + Base64.getEncoder().encodeToString(url.getBytes());
+        String res = httpPoolClient.get(sendUrl);
+        log.info("sendGet res={}", res);
+        return res;
     }
 
     @Override
@@ -54,7 +62,9 @@ public class WeComSendServiceImpl implements WeComSendService {
             return null;
         }
         String sendUrl = "http://" + sendRequestIp + "/wecom/server/send/post/file";
-        sendUrl += "?url=" + url;
-        return httpPoolClient.post(sendUrl, file);
+        sendUrl += "?url=" + Base64.getEncoder().encodeToString(url.getBytes());
+        String res = httpPoolClient.post(sendUrl, file);
+        log.info("sendPostFile res={}", res);
+        return res;
     }
 }

+ 10 - 1
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/WeComUserServiceImpl.java

@@ -13,6 +13,7 @@ import com.tzld.piaoquan.growth.common.model.po.*;
 import com.tzld.piaoquan.growth.common.model.vo.UserTagParam;
 import com.tzld.piaoquan.growth.common.model.vo.WeComUserVo;
 import com.tzld.piaoquan.growth.common.service.WeComAccessTokenService;
+import com.tzld.piaoquan.growth.common.service.WeComSendService;
 import com.tzld.piaoquan.growth.common.service.WeComUserService;
 import com.tzld.piaoquan.growth.common.utils.DateUtil;
 import com.tzld.piaoquan.growth.common.utils.LarkRobotUtil;
@@ -63,6 +64,9 @@ public class WeComUserServiceImpl implements WeComUserService {
     @Value("${needFilterTagIdConfig:[]}")
     private String needFilterTagIdConfig;
 
+    @Autowired
+    private WeComSendService weComSendService;
+
 
     @Override
     public void addStaffWithUser(String externalUserId, String carrierId, Long corpId) {
@@ -233,7 +237,12 @@ public class WeComUserServiceImpl implements WeComUserService {
         try {
             String weComAccessToken = weComAccessTokenService.getWeComAccessToken(corpId);
             String url = String.format(GET_WE_COM_EXTERNAL_CONTACT_GET + "?access_token=%s&external_userid=%s", weComAccessToken, externalUserId);
-            String res = httpPoolClient.get(url);
+            String res;
+            if (corpId == 1L) {
+                res = httpPoolClient.get(url);
+            } else {
+                res = weComSendService.sendGet(url);
+            }
             JSONObject jsonObject = JSONObject.parseObject(res);
             Integer errcode = jsonObject.getInteger("errcode");
             if (errcode == 0) {