Bläddra i källkod

欢迎语问题处理

yfh 2 dagar sedan
förälder
incheckning
40882dbc13

+ 38 - 18
fs-service/src/main/java/com/fs/qw/service/impl/QwContactWayServiceImpl.java

@@ -6,6 +6,7 @@ import com.fs.common.BeanCopyUtils;
 import com.fs.common.core.domain.R;
 import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
+import com.fs.common.utils.StringUtils;
 import com.fs.course.domain.FsCourseWatchLog;
 import com.fs.course.mapper.FsCourseWatchLogMapper;
 import com.fs.course.param.FsCourseLinkCreateParam;
@@ -371,10 +372,9 @@ public class QwContactWayServiceImpl implements IQwContactWayService
 
     }
 
-    @Override
-    public boolean sendWelcomeMsg(QwContactWay qwContactWay, String corpId, String welcomeCode,QwUser qwUser,Long qwExternalId) {
-
 
+    @Override
+    public boolean sendWelcomeMsg(QwContactWay qwContactWay, String corpId, String welcomeCode, QwUser qwUser, Long qwExternalId) {
         if (qwContactWay.getIsSpanWelcome()==1){
             String welcomeJson = qwContactWay.getWelcomeJson();
             if (welcomeJson!=null&&welcomeJson!=""){
@@ -395,9 +395,7 @@ public class QwContactWayServiceImpl implements IQwContactWayService
 
                             SendWelcomeMsgParam copy = BeanCopyUtils.copy(qwWelcomeJsonFrom, SendWelcomeMsgParam.class);
                             copy.setWelcome_code(welcomeCode);
-
                             QwResult qwResult = qwApiService.sendWelcomeMsg(copy, corpId);
-
                             if (qwResult.getErrcode()==0){
                                 return false;
                             }else {
@@ -411,23 +409,45 @@ public class QwContactWayServiceImpl implements IQwContactWayService
 
 
         }
+
         SendWelcomeMsgParam sendWelcomeMsgParam = new SendWelcomeMsgParam();
         sendWelcomeMsgParam.setWelcome_code(welcomeCode);
-        TextMessage textMessage = new TextMessage();
-        textMessage.setContent(qwContactWay.getTextContent());
-        sendWelcomeMsgParam.setText(textMessage);
-        SendWelcomeMsgParam.Attachment attachment = new SendWelcomeMsgParam.Attachment();
-        SendWelcomeMsgParam.Attachment.ImageAttachment imageAttachment = new SendWelcomeMsgParam.Attachment.ImageAttachment();
-        imageAttachment.setPic_url(qwContactWay.getImagePicUrl());
-        attachment.setMsgtype("image");
-        attachment.setImage(imageAttachment);
-        sendWelcomeMsgParam.setAttachments(Arrays.asList(attachment));
+
+        // 构建文本消息
+        if (StringUtils.isNotBlank(qwContactWay.getTextContent())) {
+            TextMessage textMessage = new TextMessage();
+            textMessage.setContent(qwContactWay.getTextContent());
+            sendWelcomeMsgParam.setText(textMessage);
+        }
+
+        // 构建图片附件 - 修正结构
+        List<SendWelcomeMsgParam.Attachment> attachments = new ArrayList<>();
+
+        if (StringUtils.isNotBlank(qwContactWay.getImagePicUrl())) {
+            SendWelcomeMsgParam.Attachment imageAttachment = new SendWelcomeMsgParam.Attachment();
+            imageAttachment.setMsgtype("image");
+
+            // 创建图片内容对象
+            SendWelcomeMsgParam.Attachment.ImageAttachment imageContent = new SendWelcomeMsgParam.Attachment.ImageAttachment();
+            imageContent.setPic_url(qwContactWay.getImagePicUrl());
+            imageAttachment.setImage(imageContent);
+
+            attachments.add(imageAttachment);
+        }
+
+        if (!attachments.isEmpty()) {
+            sendWelcomeMsgParam.setAttachments(attachments);
+        }
+
+        // 发送请求
         QwResult qwResult = qwApiService.sendWelcomeMsg(sendWelcomeMsgParam, corpId);
-        if (qwResult.getErrcode()==0){
-            return false;
-        }else {
-            return true;
+
+        if ("levent".equals(qwUser.getQwUserId())) {
+            log.debug("发送结果: {}", qwResult);
         }
+
+        // 修正返回值逻辑 - 0表示成功
+        return qwResult.getErrcode() == 0;
     }
 
     public List<QwWelcomeJsonFrom.Attachment> attachmentsTools( List<QwWelcomeJsonFrom.Attachment> attachments,

+ 2 - 3
fs-service/src/main/java/com/fs/qw/service/impl/QwExternalContactServiceImpl.java

@@ -2308,7 +2308,7 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
                                     }
                                 }
                             }
-                            if (qwContactWay.getIsSpanWelcome() == 1 && isClose) {
+                            if (qwContactWay.getIsWelcome() == 1 && isClose) {
                                 isSend = qwContactWayService.sendWelcomeMsg(qwContactWay, corpId, welcomeCode,qwUser,contact.getId());
                             }
                         }
@@ -2347,7 +2347,6 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
                                 LocalTime start = LocalTime.parse(schedule.getStartTime());
                                 LocalTime end = LocalTime.parse(schedule.getEndTime().equals("24:00") ? "23:59:59" : schedule.getEndTime());
                                 if (!now.isBefore(start) && !now.isAfter(end)) {
-
                                     TextMessage textMessage = new TextMessage();
                                     textMessage.setContent(schedule.getWelcomeText());
                                     sendWelcomeMsgParam.setText(textMessage);
@@ -4261,7 +4260,7 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
 
         //客户删除销售-找这个销售的sop任务中所有的营期里有没有这个客户,删了(暂时不要删-这种流失的有些一样能发消息)
 //        sopUserLogsInfoMapper.deleteByQwUserIdAndCorpIdToContactId(userID,corpId, externalUserID);
-        logger.error("客户删除销售-"+"|"+externalUserID+"|"+userID+"|"+corpId);
+//        logger.error("客户删除销售-"+"|"+externalUserID+"|"+userID+"|"+corpId);
 
         QwExternalContact qwExternalContact = qwExternalContactMapper.selectQwExternalContactUserIdAndExternalIdAndCompanyId(externalUserID, userID, corpId);
         if (qwExternalContact != null) {