吴树波 1 день назад
Родитель
Сommit
1cdf6f1fda

+ 28 - 11
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -802,17 +802,34 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
         String noRegisterMsg = "由于您还未完成注册,请联系伴学助手完成注册即可观看!";
         String noRegisterMsg = "由于您还未完成注册,请联系伴学助手完成注册即可观看!";
         //非独属链接提示
         //非独属链接提示
         String noMemberMsg = "此链接已被绑定,请联系伴学助手领取您的专属链接,专属链接请勿分享哦!";
         String noMemberMsg = "此链接已被绑定,请联系伴学助手领取您的专属链接,专属链接请勿分享哦!";
-//        try {
-//            new Thread(() -> {
-//                try {
-//                    rocketMQTemplate.syncSend("repeat-upload", JSON.toJSONString(RepeatUploadVo.builder().type(1).fsUserId(param.getUserId()).build()));
-//                }catch (Exception e){
-//                    logger.error("看课重粉提交mq失败", e);
-//                }
-//            }).start();
-//        }catch (Exception e){
-//            logger.error("看课重粉提交mq失败", e);
-//        }
+        try {
+            new Thread(() -> {
+                log.info("自动重粉判断开始!");
+                try {
+                    QwExternalContact qwExternalContact = qwExternalContactMapper.selectById(param.getQwExternalId());
+                    if(fsUser.getIsRepeat() == 1){
+                        List<QwExternalContact> noRepeatList = qwExternalContactMapper.selectList(new QueryWrapper<QwExternalContact>().eq("fs_user_id", param.getUserId()).eq("is_repeat", 0));
+                        noRepeatList.add(qwExternalContact);
+                        noRepeatList.forEach(e -> e.setIsRepeat(1));
+                        qwExternalContactService.updateBatchById(noRepeatList);
+                        return;
+                    }
+                    Long userId = param.getUserId();
+                    List<QwExternalContact> qwExternalContactList = qwExternalContactMapper.selectQwExternalContactByFsUserId(userId);
+                    if(qwExternalContactList.size() > 1){
+                        qwExternalContactList.add(qwExternalContact);
+                        qwExternalContactList.forEach(e -> e.setIsRepeat(1));
+                        qwExternalContactService.updateBatchById(qwExternalContactList);
+                        fsUser.setIsRepeat(1);
+                        fsUserMapper.updateFsUser(fsUser);
+                    }
+                }catch (Exception e){
+                    log.error("看课重粉判断失败", e);
+                }
+            }).start();
+        }catch (Exception e){
+            log.error("看课重粉提交mq失败", e);
+        }
 
 
         String json = configService.selectConfigByKey("course.config");
         String json = configService.selectConfigByKey("course.config");
         CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
         CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);

+ 1 - 0
fs-service/src/main/java/com/fs/his/domain/FsUser.java

@@ -207,6 +207,7 @@ public class FsUser extends BaseEntity
 
 
     /** 推广上级用户ID */
     /** 推广上级用户ID */
     private Long spreadUserId;
     private Long spreadUserId;
+    private Integer isRepeat;
 
 
     /** app登录后不为null(表示是否下载app) */
     /** app登录后不为null(表示是否下载app) */
     private String historyApp;
     private String historyApp;

+ 0 - 103
fs-service/src/main/java/com/fs/qw/service/impl/QwExternalContactServiceImpl.java

@@ -2161,36 +2161,6 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
 
 
     }
     }
 
 
-    //补发好友欢迎语
-//    void sendHookWelcome(QwUser qwUser,SendWelcomeMsgParam sendWelcomeMsgParam,QwExternalContact qwExternalContact){
-//        if (qwUser.getAppKey()!=null&& !qwUser.getAppKey().isEmpty()){
-//            ArrayList<String> msgParamList=new ArrayList<>();
-//            msgParamList.add(sendWelcomeMsgParam.getText().getContent());
-//            sendWelcomeMsgParam.getAttachments().forEach(item->{
-//                if (("link").equals(item.getMsgtype())) {
-//                    msgParamList.add(item.getLink().getUrl());
-//                }
-//            });
-//            if (!msgParamList.isEmpty()){
-//                for (String value : msgParamList) {
-//                    QwHookSendMsgParam sendMsgParam=new QwHookSendMsgParam();
-//                    QwHookSendMsgParam.QwHookSendMsgData sendMsgData=new QwHookSendMsgParam.QwHookSendMsgData();
-//                    sendMsgParam.setType(101003);
-//                    sendMsgData.setMsg(value);
-//                    sendMsgData.setOpenId(qwExternalContact.getExternalUserId());
-//                    sendMsgData.setSyncKey("1");
-//                    sendMsgParam.setData(sendMsgData);
-//                    SendHookAIParam sendAIParam = new SendHookAIParam();
-//                    sendAIParam.setCmd("aiReplyMsg");
-//                    sendAIParam.setData(JSONUtil.toJsonStr(sendMsgParam));
-//                    sendAIParam.setKey(qwUser.getAppKey());
-//                    logger.info("补欢迎语:" + qwExternalContact.getExternalUserId()+":"+value);
-//                    redisTemplate.opsForList().leftPush("AiMsg:"+qwUser.getAppKey(), JSON.toJSONString(sendAIParam));
-//                }
-//            }
-//        }
-//    }
-
     SendWelcomeMsgParam  welcomeMsg(String content,List<SendWelcomeMsgParam.Attachment> attachments,QwUser qwUser,String corpId,Long id){
     SendWelcomeMsgParam  welcomeMsg(String content,List<SendWelcomeMsgParam.Attachment> attachments,QwUser qwUser,String corpId,Long id){
         SendWelcomeMsgParam sendWelcomeMsgParam = new SendWelcomeMsgParam();
         SendWelcomeMsgParam sendWelcomeMsgParam = new SendWelcomeMsgParam();
         TextMessage textMessage = new TextMessage();
         TextMessage textMessage = new TextMessage();
@@ -2253,14 +2223,6 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
     @Override
     @Override
     public void insertQwExternalContactByExternalUserId(String externalUserID, String userID, Long companyId, String corpId, String state, String welcomeCode, QwUser qwUser) throws ParseException {
     public void insertQwExternalContactByExternalUserId(String externalUserID, String userID, Long companyId, String corpId, String state, String welcomeCode, QwUser qwUser) throws ParseException {
 
 
-
-//        String qwApiExternal=redisCache.getCacheObject("qwApiExternal:"+userID+":"+corpId+":"+externalUserID);
-//        if (!StringUtil.strIsNullOrEmpty(qwApiExternal)){
-//            return;
-//        }else {
-//            redisCache.setCacheObject("qwApiExternal:"+userID+":"+corpId+":"+externalUserID ,"1",10, TimeUnit.MINUTES);
-//        }
-
         // 获取当前日期(只包含年月日)
         // 获取当前日期(只包含年月日)
         LocalDate currentDate = LocalDate.now();
         LocalDate currentDate = LocalDate.now();
         // 获取当前系统时间 (HH:mm)
         // 获取当前系统时间 (HH:mm)
@@ -2280,22 +2242,6 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
         qwExternalContact.setExternalUserId(externalUserID); // 设置外部联系人ID
         qwExternalContact.setExternalUserId(externalUserID); // 设置外部联系人ID
         qwExternalContact.setCorpId(corpId);
         qwExternalContact.setCorpId(corpId);
         qwExternalContact.setCreateTime(new Date());
         qwExternalContact.setCreateTime(new Date());
-        //重粉问题
-        try {
-            new Thread(() -> {
-                try {
-                    Thread.sleep(3000);
-                } catch (InterruptedException e) {
-                    logger.error("添加等待时长错误", e);
-                }
-                rocketMQTemplate.syncSend("repeat-upload", JSON.toJSONString(RepeatUploadVo.builder().type(0).externalUserId(externalUserID).build()));
-            }).start();
-        }catch (Exception e){
-            logger.error("重粉提交mq失败", e);
-        }
-
-
-
         //先入一次库
         //先入一次库
         if (isNewQwExternalContact) {
         if (isNewQwExternalContact) {
             qwExternalContact.setName("待同步客户");
             qwExternalContact.setName("待同步客户");
@@ -2306,56 +2252,7 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
         } else {
         } else {
             qwExternalContactMapper.updateQwExternalContact(qwExternalContact);
             qwExternalContactMapper.updateQwExternalContact(qwExternalContact);
         }
         }
-
         QwExternalContact contact=qwExternalContact;
         QwExternalContact contact=qwExternalContact;
-
-//        if (state != null && state != "") {
-//            String s = "way:" + corpId + ":";
-//            if (state.contains(s)) {
-//                if (welcomeCode != null && welcomeCode != "") {
-//                    String substring = state.substring(state.indexOf(s) + s.length());
-//                    QwContactWay qwContactWay = qwContactWayMapper.selectQwContactWayById(Long.parseLong(substring));
-//                    logger.info("qwContactWay:"+qwContactWay);
-//                    if (qwContactWay != null) {
-//                        isWay = true;
-//                        wayId = qwContactWay;
-//                        if (qwContactWay.getIsWelcome() != null && qwContactWay.getIsWelcome() == 1) {
-//                            Boolean isClose = true;
-//                            if (wayId.getIsSpanWelcome() == 1) {
-//                                ExternalContact externalContact = externalContactResult.getExternal_contact();
-//                                String name = externalContact.getName();
-//                                String closeWelcomeWord = wayId.getCloseWelcomeWord();
-//                                if (closeWelcomeWord != null && closeWelcomeWord.length() > 0) {
-//                                    List<String> strings = JSON.parseArray(closeWelcomeWord, String.class);
-//                                    for (String string : strings) {
-//                                        if (name.contains(string)) {
-//                                            isClose = false;
-//                                            break;
-//                                        }
-//                                    }
-//                                }
-//                            }
-//                            if (qwContactWay.getIsWelcome() == 1 && isClose) {
-//                                isSend = qwContactWayService.sendWelcomeMsg(qwContactWay, corpId, welcomeCode,qwUser,contact.getId());
-//                            }
-//                        }
-//                        if (qwContactWay.getUserType() == 1 && qwContactWay.getIsUserLimit() == 1) {
-//                            QwContactWayUser qwContactWayUser = qwContactWayUserMapper.selectQwContactWayUserByUserIdAndCompanyId(userID, corpId);
-//                            if (qwContactWayUser != null) {
-//                                qwContactWayUser.setDayCount(qwContactWayUser.getDayCount() - 1);
-//                                qwContactWayUserMapper.updateQwContactWayUser(qwContactWayUser);
-//                                if (qwContactWayUser.getDayCount() <= 0) {
-//                                    //超过限制
-//                                    qwContactWayService.updateQwContactWayBYLimit(qwContactWayUser.getWayId());
-//                                }
-//
-//                            }
-//                        }
-//                    }
-//                }
-//            }
-//        }
-
         if (welcomeCode != null && !welcomeCode.isEmpty()) {
         if (welcomeCode != null && !welcomeCode.isEmpty()) {
             // 查询成员的欢迎语以及欢迎图片
             // 查询成员的欢迎语以及欢迎图片
             log.info("qw_user_id:{},external_id:{}: 查询欢迎语开始", qwUser.getId(), externalUserID);
             log.info("qw_user_id:{},external_id:{}: 查询欢迎语开始", qwUser.getId(), externalUserID);

+ 1 - 0
fs-service/src/main/resources/mapper/his/FsUserMapper.xml

@@ -732,6 +732,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
             <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
             <if test="appId != null">app_id = #{appId},</if>
             <if test="appId != null">app_id = #{appId},</if>
             <if test="appOpenId != null">app_open_id = #{appOpenId},</if>
             <if test="appOpenId != null">app_open_id = #{appOpenId},</if>
+            <if test="isRepeat != null">is_repeat = #{isRepeat},</if>
             <if test="appleKey != null">apple_key = #{appleKey},</if>
             <if test="appleKey != null">apple_key = #{appleKey},</if>
             <if test="newcomerCouponType != null">newcomer_coupon_type = #{newcomerCouponType},</if>
             <if test="newcomerCouponType != null">newcomer_coupon_type = #{newcomerCouponType},</if>
             <if test="newcomerProfileDone != null">newcomer_profile_done = #{newcomerProfileDone},</if>
             <if test="newcomerProfileDone != null">newcomer_profile_done = #{newcomerProfileDone},</if>

+ 1 - 1
fs-service/src/main/resources/mapper/qw/QwExternalContactMapper.xml

@@ -629,7 +629,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
         </foreach>
     </select>
     </select>
     <select id="selectQwExternalContactByFsUserId" resultType="com.fs.qw.domain.QwExternalContact">
     <select id="selectQwExternalContactByFsUserId" resultType="com.fs.qw.domain.QwExternalContact">
-        <include refid="selectQwExternalContactVo"/>
+        select * from qw_external_contact
         where fs_user_id = #{userId}
         where fs_user_id = #{userId}
     </select>
     </select>
     <select id="selectFsUserCourseComplaintRecordByUserId" resultType="com.fs.qw.vo.QwExternalContactComplaintVO">
     <select id="selectFsUserCourseComplaintRecordByUserId" resultType="com.fs.qw.vo.QwExternalContactComplaintVO">