Prechádzať zdrojové kódy

获客链接新增Ipad加好友接口

cgp 4 dní pred
rodič
commit
5c56123c25

+ 31 - 0
fs-company/src/main/java/com/fs/company/controller/qw/QwAcquisitionLinkInfoController.java

@@ -4,6 +4,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
 
 import com.fs.common.exception.CustomException;
 import com.fs.common.utils.ServletUtils;
@@ -14,9 +15,11 @@ import com.fs.framework.service.TokenService;
 import com.fs.his.dto.SendResultDetailDTO;
 import com.fs.qw.bo.SendMsgLogBo;
 import com.fs.qw.dto.BatchAddAcquisitionLinkDTO;
+import com.fs.qw.dto.IpadBlindAddDto;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.checkerframework.checker.units.qual.A;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -271,6 +274,34 @@ public class QwAcquisitionLinkInfoController extends BaseController
             return AjaxResult.error("服务器内部错误: " + e.getMessage());
         }
     }
+
+    /**
+     * iPad获客链接加好友
+     *
+     * @param dto 请求参数
+     * @return 操作结果
+     */
+    @PostMapping("/ipadBlindAdd")
+    public AjaxResult ipadBlindAdd(@Valid @RequestBody IpadBlindAddDto dto) {
+        try {
+            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+            if (loginUser == null || loginUser.getCompany() == null) {
+                throw new CustomException("请登录");
+            }
+            SendMsgLogBo sendMsgLogBo = new SendMsgLogBo();
+            sendMsgLogBo.setCompanyId(loginUser.getCompany().getCompanyId());
+            sendMsgLogBo.setCompanyUserId(loginUser.getCompany().getUserId());
+            validatePhone(dto.getPhone());
+            // 调用业务逻辑
+            qwAcquisitionLinkInfoService.ipadBlindAdd(dto, sendMsgLogBo);
+            return AjaxResult.success("添加成功");
+
+        } catch (Exception e) {
+            log.error("iPad盲加失败", e);
+            return AjaxResult.error(e.getMessage());
+        }
+    }
+
     /**
      * 校验电话
      */

+ 9 - 5
fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserInformationCollectionServiceImpl.java

@@ -295,7 +295,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
         fsUserInformationCollection.setUserConfirm2(0);
         fsUserInformationCollection.setUserConfirm(0);
         fsUserInformationCollection.setDoctorConfirm(0);
-        fsUserInformationCollection.setFillFlag(0);//填写标识 0:未填写
+        fsUserInformationCollection.setFillFlag(param.getFillFlag());//填写标识 0:未填写
         fsUserInformationCollection.setStatus(1);
         fsUserInformationCollection.setUpdateTime(DateUtils.getNowDate());
         fsUserInformationCollection.setRemark(param.getRemark());
@@ -1309,6 +1309,12 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
         map.setUserId(param.getUserId());
         map.setId(param.getCollectionId());
         if (fsUserInformationCollectionMapper.updateFsUserInformationCollection(map) > 0) {
+            //更新信息采集进度表里面的用户id
+            FsUserInformationCollectionSchedule schedule = scheduleMapper.selectCollectionScheduleRunningByCollectionId(param.getCollectionId());
+            if (schedule != null&&schedule.getUserId()==null){
+                schedule.setUserId(param.getUserId());
+                scheduleMapper.updateFsUserInformationCollectionSchedule(schedule);
+            }
             return R.ok();
         }
         return R.error("绑定失败");
@@ -1400,10 +1406,8 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
             });
         }
 
-        if (StringUtils.isNotBlank(param.getSource())&&param.getSource().equals("pc")) {
-            // pc端特殊处理
-            fsUserInformationCollection.setFillFlag(param.getFillFlag());
-        }
+
+        fsUserInformationCollection.setFillFlag(param.getFillFlag());
         fsUserInformationCollection.setJsonInfo(JSON.toJSONString(param.getAnswers()));
         fsUserInformationCollection.setUserId(param.getUserId());
         fsUserInformationCollection.setCompanyUserId(param.getCompanyUserId());

+ 35 - 0
fs-service/src/main/java/com/fs/qw/dto/IpadBlindAddDto.java

@@ -0,0 +1,35 @@
+package com.fs.qw.dto;
+
+import lombok.Data;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+
+/**
+ * iPad盲加请求参数DTO
+ */
+@Data
+public class IpadBlindAddDto {
+    /**
+     * 所在主体id
+     * */
+    private String corpId;
+    /**
+     * 获客链接主键ID
+     */
+    @NotBlank(message = "链接ID不能为空")
+    private Long qwAcquisitionAssistantId;
+    
+    /**
+     * 选中的成员ID(本地数据库ID)
+     */
+    @NotNull(message = "成员ID不能为空")
+    private Long userId;
+    
+    /**
+     * 手机号码
+     */
+    @NotBlank(message = "手机号码不能为空")
+    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号码格式不正确")
+    private String phone;
+}

+ 6 - 0
fs-service/src/main/java/com/fs/qw/service/IQwAcquisitionLinkInfoService.java

@@ -6,6 +6,7 @@ import com.fs.his.dto.SendResultDetailDTO;
 import com.fs.qw.bo.SendMsgLogBo;
 import com.fs.qw.domain.QwAcquisitionLinkInfo;
 import com.fs.qw.dto.BatchAddAcquisitionLinkDTO;
+import com.fs.qw.dto.IpadBlindAddDto;
 
 /**
  * 获客链接-号码链接生成记录Service接口
@@ -95,4 +96,9 @@ public interface IQwAcquisitionLinkInfoService
      * 根据手机号生成单个获客链接
      * */
     String extractLink(Long qwAcquisitionAssistantId, String originalPhone, String originalLink,Long createBy);
+
+    /**
+     * iPad盲加好友
+     * */
+    void ipadBlindAdd(IpadBlindAddDto dto,SendMsgLogBo sendMsgLogBo);
 }

+ 108 - 0
fs-service/src/main/java/com/fs/qw/service/impl/QwAcquisitionLinkInfoServiceImpl.java

@@ -16,10 +16,21 @@ import com.fs.company.service.ICompanySmsTempService;
 import com.fs.his.dto.SendResultDetailDTO;
 import com.fs.qw.bo.SendMsgLogBo;
 import com.fs.qw.domain.QwAcquisitionAssistant;
+import com.fs.qw.domain.QwUser;
 import com.fs.qw.dto.BatchAddAcquisitionLinkDTO;
+import com.fs.qw.dto.IpadBlindAddDto;
 import com.fs.qw.enums.SmsLogType;
 import com.fs.qw.mapper.QwAcquisitionAssistantMapper;
+import com.fs.qw.mapper.QwUserMapper;
+import com.fs.qw.param.QwUserListParam;
+import com.fs.qw.service.IQwUserService;
 import com.fs.qw.utils.UniqueStringUtil;
+import com.fs.qw.vo.QwUserVO;
+import com.fs.wxwork.dto.WxAddSearchDTO;
+import com.fs.wxwork.dto.WxSearchContactDTO;
+import com.fs.wxwork.dto.WxSearchContactResp;
+import com.fs.wxwork.dto.WxWorkResponseDTO;
+import com.fs.wxwork.service.WxWorkService;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -61,6 +72,18 @@ public class QwAcquisitionLinkInfoServiceImpl implements IQwAcquisitionLinkInfoS
     @Autowired
     private QwAcquisitionLinkInfoMapper qwAcquisitionLinkInfoMapper;
 
+    @Autowired
+    private QwAcquisitionLinkInfoServiceImpl self; // 注入自身代理对象
+
+    @Autowired
+    private IQwUserService qwUserService;
+
+    @Autowired
+    private QwUserMapper qwUserMapper;
+
+    @Autowired
+    private  WxWorkService wxWorkService;
+
     //拼接电话号码的链接后缀(这个后面拼接加密后的手机字符串)
     private static final String  LINK_SUFFIX = "?customer_channel=up:";
 
@@ -561,6 +584,91 @@ public class QwAcquisitionLinkInfoServiceImpl implements IQwAcquisitionLinkInfoS
         return LINK_DOMAIN+randomStr;
     }
 
+    @Override
+    public void ipadBlindAdd(IpadBlindAddDto dto,SendMsgLogBo sendMsgLogBo) {
+        //获取QwUser信息
+        QwUser qwUser=qwUserMapper.selectQwUserById(dto.getUserId());
+        if (qwUser==null){
+            log.error( "销售用户不存在,qwUserId:{}",dto.getUserId());
+            throw new CustomException("销售用户不存在");
+        }
+        //判断这个销售的ipad是否在线
+        QwUserListParam queryCondition=new QwUserListParam();
+        queryCondition.setCorpId(dto.getCorpId());
+        queryCondition.setQwUserId(qwUser.getQwUserId());
+        List<QwUserVO> qwUserVOS = qwUserService.selectQwUserListStaffVO(queryCondition);
+        if (qwUserVOS.isEmpty()){
+            throw new CustomException("此主体不存在该销售用户");
+        }
+        if (qwUserVOS.get(0).getIpadStatus()!=0){
+            throw new CustomException("此销售用户ipad已离线,请登录");
+        }
+        try {
+            //调用ipad加好友接口
+            WxWorkResponseDTO<String> response = self.qwAddWxInvokeIpad(dto.getPhone(), qwUser.getUid(),
+                    qwUser.getServerId(),
+                    qwUser.getVid(),
+                    qwUser.getQwUserName());
+            if (response != null && response.getErrcode() == 0) {
+                log.info("ipad获客链接加微成功");
+            }else {
+                log.error("ipad获客链接加微失败,错误码:{},错误信息:{}",response.getErrcode(),response.getErrmsg());
+            }
+        }catch (Exception e){
+            //TODO 如果有异常,暂时只做记录
+            log.error("ipad加微异常",e);
+        }
+
+        //调用发送短信接口
+        self.sendMessageLink(dto.getPhone(),dto.getQwAcquisitionAssistantId(),sendMsgLogBo);
+    }
+
+    /**
+     * 企微加个微调用ipad端
+     * @param mobile  手机号
+     * @param qwUid   企微uid
+     * @param serverId   服务器id
+     * @return String 结果
+     */
+    private WxWorkResponseDTO<String> qwAddWxInvokeIpad(String mobile, String qwUid, Long serverId, String vid, String qwUserName) {
+        if (StringUtils.isBlank(mobile) || StringUtils.isBlank(qwUid) || serverId == null) {
+            log.warn("企微申请加好友任务参数校验失败: mobile={}, qwUid={}, serverId={}", mobile, qwUid, serverId);
+            return null;
+        }
+
+        try {
+            WxAddSearchDTO wxAddSearchDTO = new WxAddSearchDTO();
+            wxAddSearchDTO.setUuid(qwUid);
+            wxAddSearchDTO.setVid(Long.valueOf(vid));
+            wxAddSearchDTO.setPhone(mobile);
+
+            WxSearchContactDTO contactDTO=new WxSearchContactDTO();
+            contactDTO.setUuid(qwUid);
+            contactDTO.setPhoneNumber(mobile);
+
+
+            WxWorkResponseDTO<WxSearchContactResp> respWxWorkResponseDTO = wxWorkService.searchContact(contactDTO, serverId);
+            WxSearchContactResp.UserList user = respWxWorkResponseDTO.getData().getUserList().stream()
+                    .filter(u -> u.getState().equals("2"))
+                    .findFirst()
+                    .orElse(null); // 或者 .orElseThrow(() -> new RuntimeException("未找到指定用户"))
+
+            wxAddSearchDTO.setOptionid(user.getOpenid());
+            wxAddSearchDTO.setTicket(user.getTicket());
+            wxAddSearchDTO.setContent("你好,我是你的专属助手:"+qwUserName+",有什么问题都可以问我哦~");
+
+            WxWorkResponseDTO<String> response = wxWorkService.addSearch(wxAddSearchDTO, serverId);
+            log.debug("企微加微接口调用结果: errcode={}, errmsg={}",
+                    response != null ? response.getErrcode() : "null",
+                    response != null ? response.getErrmsg() : "null");
+
+            return response;
+        } catch (Exception e) {
+            log.error("企微申请加好友任务请求接口异常: mobile={}, qwUid={}, serverId={}", mobile, qwUid, serverId, e);
+            return null;
+        }
+    }
+
     /**
      * 添加链接生成记录
      * */

+ 9 - 0
fs-user-app/src/main/java/com/fs/app/controller/UserInfoCollectionController.java

@@ -141,6 +141,15 @@ public class UserInfoCollectionController extends AppBaseController {
         }
     }
 
+    /**
+     * 查询销售是否具有代填权限
+     * */
+    @GetMapping("/getSalesHasCollectionPermission")
+    public AjaxResult getSalesHasCollectionPermission(){
+        boolean salesProxyFillConfig = userInformationCollectionService.getSalesProxyFillConfig();
+        return AjaxResult.success(salesProxyFillConfig);
+    }
+
 
     /**
      * 对于每条用户信息采集记录,只获取其最新的任务流程