Jelajahi Sumber

社群群发 page channel

wangyunpeng 1 Minggu lalu
induk
melakukan
1b35b446c0

+ 4 - 1
api-module/src/main/java/com/tzld/piaoquan/api/job/wecom/thirdpart/WeComSendMsgJob.java

@@ -73,6 +73,8 @@ public class WeComSendMsgJob {
     private Map<Long, JSONObject> videoSourceStaffConfig;
     @ApolloJsonValue("${send.room.msg.staff.put.scene.config:{}}")
     private Map<Long, String> staffPutSceneConfig;
+    @ApolloJsonValue("${send.room.msg.staff.channel.config:{}}")
+    private Map<Long, String> staffChannelConfig;
     @ApolloJsonValue("${send.room.msg.auto.open.staff:[]}")
     private List<Long> autoOpenStaffList;
     @Value("${send.room.msg.random.time:20}")
@@ -191,7 +193,8 @@ public class WeComSendMsgJob {
             staff.setCarrierId(String.valueOf(thirdPartWeComStaff.getThirdStaffId()));
             staff.setRemark(thirdPartWeComStaff.getName());
             String putScene = staffPutSceneConfig.getOrDefault(thirdPartWeComStaff.getThirdStaffId(), "touliu");
-            String page = messageAttachmentService.getPageNoCache(putScene, staff, video.getVideoId(), "企微", "社群");
+            String pageChannel = staffChannelConfig.getOrDefault(thirdPartWeComStaff.getThirdStaffId(), "tencentqw");
+            String page = messageAttachmentService.getPageNoCache(putScene, pageChannel, staff, video.getVideoId(), "企微", "社群");
 
             CgiReplyBucketData cgiReplyBucketData = new CgiReplyBucketData();
             cgiReplyBucketData.setMiniVideoId(video.getVideoId());

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

@@ -389,16 +389,16 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
     }
 
     @Override
-    public String getPage(Staff staff, Long videoId, String typeOne, String typeTwo) {
+    public String getPage(String putScene, String channel, Staff staff, Long videoId, String typeOne, String typeTwo) {
         try {
             if (staff == null || staff.getCarrierId() == null) {
                 return "";
             }
-            String page = selectPage(videoId, staff.getCarrierId(), typeOne, typeTwo);
+            String page = selectPage(putScene, channel, videoId, staff.getCarrierId(), typeOne, typeTwo);
             if (StringUtils.isNotEmpty(page)) {
                 return page;
             }
-            return insertPage("touliu", staff.getCarrierId(), videoId, staff.getRemark(), typeOne, typeTwo);
+            return insertPage(putScene, channel, staff.getCarrierId(), videoId, staff.getRemark(), typeOne, typeTwo);
         } catch (IOException e) {
             log.error("MessageAttachmentService getPage error", e);
         }
@@ -406,21 +406,21 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
     }
 
     @Override
-    public String getPageNoCache(String putScene, Staff staff, Long videoId, String typeOne, String typeTwo) {
+    public String getPageNoCache(String putScene, String channel, Staff staff, Long videoId, String typeOne, String typeTwo) {
         try {
             if (staff == null || staff.getCarrierId() == null) {
                 return "";
             }
-            return insertPage(putScene, staff.getCarrierId(), videoId, staff.getRemark(), typeOne, typeTwo);
+            return insertPage(putScene, channel, staff.getCarrierId(), videoId, staff.getRemark(), typeOne, typeTwo);
         } catch (IOException e) {
             log.error("MessageAttachmentService getPageNoCache error", e);
         }
         return null;
     }
 
-    private String insertPage(String putScene, String carrierId, Long videoId, String remark, String typeOne, String typeTwo) throws IOException {
+    private String insertPage(String putScene, String channel, String carrierId, Long videoId, String remark, String typeOne, String typeTwo) throws IOException {
         AdPutFlowParam param = new AdPutFlowParam();
-        param.setChannel("tencentqw");
+        param.setChannel(channel);
         param.setPath("pages/category.html");
         param.setPutCarrierId(carrierId);
         param.setPutScene(putScene);
@@ -442,10 +442,10 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
         return data.getString("url");
     }
 
-    public String selectPage(Long videoId, String carrierId, String typeOne, String typeTwo) {
+    public String selectPage(String putScene, String channel, Long videoId, String carrierId, String typeOne, String typeTwo) {
         int totalPage = 1;
         for (int n = 1; n <= totalPage; n++) {
-            String url = getUrl(videoId, n);
+            String url = getUrl(videoId, putScene, channel, n);
             try {
                 String res = httpPoolClient.get(url);
                 JSONObject jsonObject = JSONObject.parseObject(res);
@@ -479,10 +479,8 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
         return null;
     }
 
-    private static String getUrl(Long videoId, int n) {
+    private static String getUrl(Long videoId, String putScene, String channel, int n) {
         String baseUrl = "https://api.piaoquantv.com/ad/put/flow/list/tencent";
-        String putScene = "touliu";
-        String channel = "tencentqw";
         int pageSize = 20;
         return String.format(
                 "%s?videoId=%d&putScene=%s&channel=%s&currentPage=%d&pageSize=%d",

+ 2 - 2
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/MessageAttachmentService.java

@@ -25,9 +25,9 @@ public interface MessageAttachmentService {
 
     String getPicMediaId(String cover, Long corpId, Long miniprogramVideoId);
 
-    String getPage(Staff staff, Long videoId, String typeOne, String typeTwo);
+    String getPage(String putScene, String channel, Staff staff, Long videoId, String typeOne, String typeTwo);
 
-    String getPageNoCache(String putScene, Staff staff, Long videoId, String typeOne, String typeTwo);
+    String getPageNoCache(String putScene, String channel, Staff staff, Long videoId, String typeOne, String typeTwo);
 
     String getPage(String channel, String carrierId, String scene, String putTypeOne, String putTypeTwo, String putTypeThree, Long videoId);
 

+ 1 - 3
offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComMessageDataJob.java

@@ -6,8 +6,6 @@ import com.alibaba.fastjson.JSONObject;
 import com.aliyun.odps.data.Record;
 import com.google.common.collect.Lists;
 import com.tzld.piaoquan.growth.common.common.constant.MessageConstant;
-import com.tzld.piaoquan.growth.common.common.enums.ExceptionCodeEnum;
-import com.tzld.piaoquan.growth.common.common.exception.CustomizeException;
 import com.tzld.piaoquan.growth.common.dao.mapper.*;
 import com.tzld.piaoquan.growth.common.model.bo.*;
 import com.tzld.piaoquan.growth.common.model.po.*;
@@ -552,7 +550,7 @@ public class WeComMessageDataJob {
             if (pageMap.containsKey(key)) {
                 page = pageMap.get(key);
             } else {
-                page = messageAttachmentService.getPage(staff, videoId, "企微", "日常推送");
+                page = messageAttachmentService.getPage("touliu", "tencentqw", staff, videoId, "企微", "日常推送");
                 pageMap.put(key, page);
             }
             if (StringUtils.isEmpty(page)) {