浏览代码

手动发课红包限制

吴树波 14 小时之前
父节点
当前提交
4281d29589

+ 3 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -1104,6 +1104,9 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             if (user.getStatus()==0){
                 return R.error("会员被停用,无权限,请联系客服!");
             }
+            if (!isNewWxMerchant && StringUtils.isEmpty(user.getUnionId())){
+                return R.error("会员信息有误,无法领取红包,请联系客服!");
+            }
             FsCourseWatchLog watchLog = new FsCourseWatchLog();
 
             // 根据链接类型判断是否已发放奖励

+ 27 - 0
fs-service/src/main/java/com/fs/ipad/IpadSendUtils.java

@@ -34,6 +34,7 @@ public class IpadSendUtils {
     private final RedisCacheT<String> redisCache;
     private final RedisCache redisCacheUrl;
     private final String FILE_KEY = "ipad:upload:";
+    private final String USER_KEY = "ipad:userid:";
 
     /**
      * 发送卡片消息
@@ -200,6 +201,14 @@ public class IpadSendUtils {
         if(vo.isRoom()){
             return chatIds(vo);
         }
+        try {
+            String idStr = redisCache.getCacheObject(USER_KEY + vo.getExId());
+            if(StringUtils.isNotEmpty(idStr)){
+                return Long.parseLong(idStr);
+            }
+        }catch (Exception e){
+            log.error("获取外部联系人ID失败", e);
+        }
         WxWorkUserId2VidDTO wxWorkUserId2VidDTO = new WxWorkUserId2VidDTO();
         wxWorkUserId2VidDTO.setOpenid(Collections.singletonList(vo.getExId()));
         wxWorkUserId2VidDTO.setCorpid(vo.getCorpId());
@@ -211,6 +220,11 @@ public class IpadSendUtils {
             log.error("未找到用户数据,基础数据:{},请求数据:{},返回数据:{}", vo, JSON.toJSONString(wxWorkUserId2VidDTO), JSON.toJSONString(WxWorkVid2UserIdRespDTO));
             throw new BaseException("未找到用户:" + vo.getId());
         }
+        try {
+            redisCache.setCacheObject(USER_KEY + vo.getExId(), data.get(0).getUser_id().toString());
+        }catch (Exception e){
+            log.error("存储获外部联系人ID失败", e);
+        }
         return data.get(0).getUser_id();
     }
 
@@ -220,6 +234,14 @@ public class IpadSendUtils {
      * @return 返回的userid
      */
     private Long chatIds(BaseVo vo){
+        try {
+            String idStr = redisCache.getCacheObject(USER_KEY + vo.getExId());
+            if(StringUtils.isNotEmpty(idStr)){
+                return Long.parseLong(idStr);
+            }
+        }catch (Exception e){
+            log.error("获取群ID失败", e);
+        }
         WxWorkChatIdToRoomIdDTO tdo = new WxWorkChatIdToRoomIdDTO();
         tdo.setChatid(vo.getExId());
         tdo.setCorpid(vo.getCorpId());
@@ -233,6 +255,11 @@ public class IpadSendUtils {
             log.error("未找到群聊数据,请求数据:{},返回数据:{}", JSON.toJSONString(tdo), JSON.toJSONString(result));
             throw new BaseException("未找到群聊:" + vo.getId());
         }
+        try {
+            redisCache.setCacheObject(USER_KEY + vo.getExId(), data.getRoom_id().toString());
+        }catch (Exception e){
+            log.error("存储群ID失败", e);
+        }
         return data.getRoom_id();
     }