Forráskód Böngészése

Merge branch '20251119-wyp-weCom' into test

wangyunpeng 1 hónapja
szülő
commit
24e065ddc0

+ 3 - 2
api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/wecom/thirdpart/ext/ThirdPartWeComVideoMapperExt.java

@@ -19,9 +19,10 @@ public interface ThirdPartWeComVideoMapperExt {
                                         @Param("oldStatus") Integer oldStatus,
                                         @Param("now") Long now);
 
-    List<ContentPlatformVideo> getVideoMinScoreList(@Param("videoMinScore") Double videoMinScore,
+    List<ContentPlatformVideo> getVideoMinScoreList(@Param("dt") String dt,
+                                                    @Param("videoMinScore") Double videoMinScore,
                                                     @Param("roomId") String roomId,
                                                     @Param("offset") int offset,
-                                                    @Param("limit") int limit,
+                                                    @Param("pageSize") int pageSize,
                                                     @Param("sort") String sort);
 }

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

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import com.tzld.piaoquan.api.common.enums.wecom.ConfigTaskContentTypeEnum;
 import com.tzld.piaoquan.api.common.enums.wecom.MsgSendStatusEnum;
+import com.tzld.piaoquan.api.common.enums.wecom.ThirdPartWeComStaffStatusEnum;
 import com.tzld.piaoquan.api.component.VideoApiService;
 import com.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformPlanMapperExt;
 import com.tzld.piaoquan.api.dao.mapper.wecom.thirdpart.ThirdPartWeComMsgMapper;
@@ -114,6 +115,15 @@ public class WeComSendMsgJob {
                     List<ThirdPartWeComRoomConfigTaskContent> taskContentList = weComThirdPartyRoomService.getRoomConfigTaskContents(configTaskIds);
                     Map<String, List<ThirdPartWeComRoomConfigTaskContent>> taskContentMap = taskContentList.stream()
                             .collect(Collectors.groupingBy(ThirdPartWeComRoomConfigTaskContent::getTaskId));
+                    ThirdPartWeComStaff pushStaff = getSendStaff(roomConfig);
+                    if (Objects.isNull(pushStaff)) {
+                        LarkRobotUtil.sendWeComThirdPartMessage(
+                                "【账号发送群消息,推送账号获取失败通知】\n" +
+                                        "账号名称:" + staff.getName() + "\n" +
+                                        "账号VID:" + staff.getThirdStaffId() + "\n" +
+                                        "群名称:" + room.getName());
+                        return;
+                    }
                     for (ThirdPartWeComRoomConfigTask configTask : taskList) {
                         List<String> timeList = getRoomSendTime(room, roomConfig, configTask);
                         if (timeList.contains(time)) {
@@ -126,20 +136,20 @@ public class WeComSendMsgJob {
                             for (ThirdPartWeComRoomConfigTaskContent configTaskContent : contentList) {
                                 if (ConfigTaskContentTypeEnum.TEXT.getVal() == configTaskContent.getType()) {
                                     // build发送体
-                                    SendTextMsgRequest request = buildSendTextMsgRequest(configTaskContent.getContent(), staff, room);
+                                    SendTextMsgRequest request = buildSendTextMsgRequest(configTaskContent.getContent(), pushStaff, room);
                                     // 发送消息
-                                    CommonResponse<SendTextMsgResponse> response = weComThirdPartyService.sendTextMsg(staff, room, request);
+                                    CommonResponse<SendTextMsgResponse> response = weComThirdPartyService.sendTextMsg(pushStaff, room, request);
                                     // 存储消息
-                                    saveTextWeComMsg(staff.getId(), configTaskContent.getContent(), request, response);
+                                    saveTextWeComMsg(pushStaff.getId(), configTaskContent.getContent(), request, response);
                                 } else if (ConfigTaskContentTypeEnum.MINI_PROGRAM.getVal() == configTaskContent.getType()) {
                                     List<CgiReplyBucketData> cgiReplyBucketDataList = getCgiReplyBucketData(room.getThirdRoomId(), staff, roomConfig, configTaskContent);
                                     for (CgiReplyBucketData cgiReplyBucketData : cgiReplyBucketDataList) {
                                         // build发送体
-                                        SendAppMsgRequest request = buildSendAppMsgRequest(cgiReplyBucketData, staff, room);
+                                        SendAppMsgRequest request = buildSendAppMsgRequest(cgiReplyBucketData, pushStaff, room);
                                         // 发送消息
-                                        CommonResponse<SendAppMsgResponse> response = weComThirdPartyService.sendAppMsg(staff, room, request);
+                                        CommonResponse<SendAppMsgResponse> response = weComThirdPartyService.sendAppMsg(pushStaff, room, request);
                                         // 存储消息
-                                        saveAppWeComMsg(staff.getId(), cgiReplyBucketData.getMiniVideoId(), request, response);
+                                        saveAppWeComMsg(pushStaff.getId(), cgiReplyBucketData.getMiniVideoId(), request, response);
                                     }
                                 }
                             }
@@ -151,6 +161,24 @@ public class WeComSendMsgJob {
         return ReturnT.SUCCESS;
     }
 
+    private ThirdPartWeComStaff getSendStaff(ThirdPartWeComRoomConfig roomConfig) {
+        List<ThirdPartWeComStaff> pushStaffList = weComThirdPartyRoomService.getRoomConfigPushList(Collections.singletonList(roomConfig));
+        Map<Long, ThirdPartWeComStaff> pushStaffMap = pushStaffList.stream()
+                .collect(Collectors.toMap(ThirdPartWeComStaff::getThirdStaffId, Function.identity()));
+        ThirdPartWeComStaff pushStaff = pushStaffMap.get(roomConfig.getPrimaryThirdStaffId());
+        if (Objects.isNull(pushStaff) || pushStaff.getStatus() != ThirdPartWeComStaffStatusEnum.NORMAL.getVal()) {
+            if (Objects.nonNull(roomConfig.getSecondThirdStaffId())) {
+                pushStaff = pushStaffMap.get(roomConfig.getSecondThirdStaffId());
+                if (Objects.isNull(pushStaff) || pushStaff.getStatus() != ThirdPartWeComStaffStatusEnum.NORMAL.getVal()) {
+                    pushStaff = null;
+                }
+            } else {
+                pushStaff = null;
+            }
+        }
+        return pushStaff;
+    }
+
     private List<String> getRoomSendTime(ThirdPartWeComRoom room,
                                          ThirdPartWeComRoomConfig roomConfig,
                                          ThirdPartWeComRoomConfigTask configTask) {
@@ -279,7 +307,8 @@ public class WeComSendMsgJob {
                 break;
             default:
                 // 按平台推荐top选取视频
-                result.addAll(videoMapperExt.getVideoMinScoreList(videoMinScore, roomId, 0, 100, "video.score desc"));
+                String dt = videoMapperExt.getVideoMaxDt();
+                result.addAll(videoMapperExt.getVideoMinScoreList(dt, videoMinScore, roomId, 0, 100, "video.score desc"));
         }
         return result;
     }

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

@@ -46,7 +46,12 @@ public class WeComVideoJob {
             dt = param;
         }
 
-        String sql = String.format("SELECT * FROM loghubods.wecom_cooperation_video_candidate_pool WHERE dt=%s;", dt);
+        String maxDt = videoMapperExt.getVideoMaxDt();
+        if (StringUtils.hasText(maxDt) && maxDt.equals(dt)) {
+            return ReturnT.SUCCESS;
+        }
+        String sql = String.format("SELECT 视频id, 视频品类, 视频标题, 视频播放地址, 分数 " +
+                "FROM loghubods.wecom_cooperation_video_candidate_pool_20251125 WHERE dt=%s;", dt);
         List<Record> dataList = OdpsUtil.getOdpsData(sql);
         Long now = System.currentTimeMillis();
         if (CollectionUtils.isNotEmpty(dataList)) {

+ 3 - 4
api-module/src/main/java/com/tzld/piaoquan/api/service/wecom/thirdparty/WeComThirdPartyRoomService.java

@@ -4,10 +4,7 @@ import com.tzld.piaoquan.api.model.param.wecom.thirdpart.ThirdPartyAccountConfig
 import com.tzld.piaoquan.api.model.param.wecom.thirdpart.ThirdPartyConfigGetParam;
 import com.tzld.piaoquan.api.model.param.wecom.thirdpart.ThirdPartyRoomConfigParam;
 import com.tzld.piaoquan.api.model.param.wecom.thirdpart.ThirdPartyRoomListParam;
-import com.tzld.piaoquan.api.model.po.wecom.thirdpart.ThirdPartWeComRoom;
-import com.tzld.piaoquan.api.model.po.wecom.thirdpart.ThirdPartWeComRoomConfig;
-import com.tzld.piaoquan.api.model.po.wecom.thirdpart.ThirdPartWeComRoomConfigTask;
-import com.tzld.piaoquan.api.model.po.wecom.thirdpart.ThirdPartWeComRoomConfigTaskContent;
+import com.tzld.piaoquan.api.model.po.wecom.thirdpart.*;
 import com.tzld.piaoquan.api.model.vo.IdNameVO;
 import com.tzld.piaoquan.api.model.vo.wecom.thirdpart.ThirdPartyAccountConfigVO;
 import com.tzld.piaoquan.api.model.vo.wecom.thirdpart.ThirdPartyRoomConfigVO;
@@ -24,6 +21,8 @@ public interface WeComThirdPartyRoomService {
 
     ThirdPartyRoomConfigVO getRoomConfig(ThirdPartyConfigGetParam param);
 
+    List<ThirdPartWeComStaff> getRoomConfigPushList(List<ThirdPartWeComRoomConfig> configList);
+
     List<ThirdPartWeComRoomConfigTask> getRoomConfigTasks(List<String> configIds);
 
     List<ThirdPartWeComRoomConfigTaskContent> getRoomConfigTaskContents(List<String> taskIds);

+ 2 - 1
api-module/src/main/java/com/tzld/piaoquan/api/service/wecom/thirdparty/impl/WeComThirdPartyRoomServiceImpl.java

@@ -169,7 +169,8 @@ public class WeComThirdPartyRoomServiceImpl implements WeComThirdPartyRoomServic
         return result;
     }
 
-    private List<ThirdPartWeComStaff> getRoomConfigPushList(List<ThirdPartWeComRoomConfig> configList) {
+    @Override
+    public List<ThirdPartWeComStaff> getRoomConfigPushList(List<ThirdPartWeComRoomConfig> configList) {
         List<Long> thirdStaffIds = new ArrayList<>();
         for (ThirdPartWeComRoomConfig config : configList) {
             if (Objects.nonNull(config.getPrimaryThirdStaffId())) {

+ 1 - 1
api-module/src/main/resources/mapper/wecom/thirdpart/ext/ThirdPartWeComVideoMapperExt.xml

@@ -37,7 +37,7 @@
     <select id="getVideoMinScoreList" resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo">
         select *
         from third_part_we_com_video video
-        where video.dt = #{dt} and video.status = 1 and video.score > #{minScore}
+        where video.dt = #{dt} and video.status = 1
           and video.video_id not in (select video_id from third_part_we_com_msg where send_userid = #{roomId} and video_id is not null)
         order by ${sort}
         limit #{offset}, #{pageSize}