|
|
@@ -36,6 +36,8 @@ import com.fs.wxcid.dto.friend.AddContactParam;
|
|
|
import com.fs.wxcid.service.FriendService;
|
|
|
import com.fs.wxcid.vo.AddContactVo;
|
|
|
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.AllArgsConstructor;
|
|
|
@@ -877,7 +879,7 @@ public class WxTaskService {
|
|
|
if (client != null) {
|
|
|
CrmCustomer crmCustomer = crmCustomerService.selectCrmCustomerById(client.getCustomerId());
|
|
|
// 开始申请加微
|
|
|
- WxWorkResponseDTO<String> resp = qwAddWxInvokeIpad(crmCustomer.getMobile(), qwUser.getUid(), qwUser.getServerId());
|
|
|
+ WxWorkResponseDTO<String> resp = qwAddWxInvokeIpad(crmCustomer.getMobile(), qwUser.getUid(),qwUser.getServerId(),qwUser.getVid(),qwUser.getQwUserName());
|
|
|
JSONObject runParam = new JSONObject();
|
|
|
runParam.put("qwId", qwUser.getId());
|
|
|
runParam.put("mobile", crmCustomer.getMobile());
|
|
|
@@ -935,7 +937,7 @@ public class WxTaskService {
|
|
|
try {
|
|
|
//is_add = 2,状态为加微中且是企微类型
|
|
|
List<CompanyWxClient> clients = companyWxClientService.getQwAddWxList(accountIdList, 2);
|
|
|
- log.info("企微申请加微结果查询任务需要查询的数量:{}", clients.size());
|
|
|
+ log.info("企微申请加微结果查询任务需要查询的数量:{}", clients.size());
|
|
|
|
|
|
if (clients.isEmpty()) return;
|
|
|
// 处理每个客户的加微结果
|
|
|
@@ -1010,22 +1012,35 @@ public class WxTaskService {
|
|
|
* @param serverId 服务器id
|
|
|
* @return String 结果
|
|
|
*/
|
|
|
- private WxWorkResponseDTO<String> qwAddWxInvokeIpad(String mobile, String qwUid, Long serverId) {
|
|
|
+ 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);
|
|
|
- wxAddSearchDTO.setVid(null);
|
|
|
- wxAddSearchDTO.setOptionid(null);
|
|
|
- wxAddSearchDTO.setContent(null);
|
|
|
- wxAddSearchDTO.setTicket(null);
|
|
|
+
|
|
|
+ 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={}",
|
|
|
+ log.debug("企微加微接口调用结果: errcode={}, errmsg={}",
|
|
|
response != null ? response.getErrcode() : "null",
|
|
|
response != null ? response.getErrmsg() : "null");
|
|
|
|