|
|
@@ -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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 添加链接生成记录
|
|
|
* */
|