|
@@ -12,7 +12,9 @@ import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -54,14 +56,14 @@ import com.fs.his.mapper.*;
|
|
|
import com.fs.his.param.FindUserByParam;
|
|
import com.fs.his.param.FindUserByParam;
|
|
|
import com.fs.his.param.FsUserAddIntegralTemplateParam;
|
|
import com.fs.his.param.FsUserAddIntegralTemplateParam;
|
|
|
import com.fs.his.param.FsUserParam;
|
|
import com.fs.his.param.FsUserParam;
|
|
|
-import com.fs.his.service.IFsUserIntegralLogsService;
|
|
|
|
|
-import com.fs.his.service.IFsUserProjectTagService;
|
|
|
|
|
-import com.fs.his.service.IFsUserWxService;
|
|
|
|
|
|
|
+import com.fs.his.service.*;
|
|
|
import com.fs.his.vo.FsUserVO;
|
|
import com.fs.his.vo.FsUserVO;
|
|
|
import com.fs.his.vo.FsUserExportListVO;
|
|
import com.fs.his.vo.FsUserExportListVO;
|
|
|
import com.fs.his.vo.FsUserFollowDoctorVO;
|
|
import com.fs.his.vo.FsUserFollowDoctorVO;
|
|
|
import com.fs.his.vo.UserVo;
|
|
import com.fs.his.vo.UserVo;
|
|
|
|
|
+import com.fs.im.config.IMConfig;
|
|
|
import com.fs.im.config.ImTypeConfig;
|
|
import com.fs.im.config.ImTypeConfig;
|
|
|
|
|
+import com.fs.im.dto.OpenImResponseDTO;
|
|
|
import com.fs.im.service.OpenIMService;
|
|
import com.fs.im.service.OpenIMService;
|
|
|
import com.fs.hisStore.domain.FsStoreOrderScrm;
|
|
import com.fs.hisStore.domain.FsStoreOrderScrm;
|
|
|
import com.fs.hisStore.domain.FsUserBillScrm;
|
|
import com.fs.hisStore.domain.FsUserBillScrm;
|
|
@@ -71,7 +73,9 @@ import com.fs.hisStore.mapper.FsStoreOrderScrmMapper;
|
|
|
import com.fs.hisStore.service.IFsUserBillScrmService;
|
|
import com.fs.hisStore.service.IFsUserBillScrmService;
|
|
|
import com.fs.hisStore.vo.FsCompanyUserListQueryVO;
|
|
import com.fs.hisStore.vo.FsCompanyUserListQueryVO;
|
|
|
import com.fs.qw.cache.IQwExternalContactCacheService;
|
|
import com.fs.qw.cache.IQwExternalContactCacheService;
|
|
|
|
|
+import com.fs.qw.domain.QwExternalContact;
|
|
|
import com.fs.qw.dto.FsUserTransferParamDTO;
|
|
import com.fs.qw.dto.FsUserTransferParamDTO;
|
|
|
|
|
+import com.fs.qw.mapper.QwExternalContactMapper;
|
|
|
import com.fs.qw.param.QwFsUserParam;
|
|
import com.fs.qw.param.QwFsUserParam;
|
|
|
import com.fs.qw.vo.QwFsUserVO;
|
|
import com.fs.qw.vo.QwFsUserVO;
|
|
|
import com.fs.store.domain.FsUserCourseCount;
|
|
import com.fs.store.domain.FsUserCourseCount;
|
|
@@ -90,12 +94,13 @@ import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.http.util.Asserts;
|
|
import org.apache.http.util.Asserts;
|
|
|
|
|
+import org.json.JSONArray;
|
|
|
|
|
+import org.json.JSONObject;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
-import com.fs.his.service.IFsUserService;
|
|
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
@@ -181,6 +186,11 @@ public class FsUserServiceImpl implements IFsUserService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IFsUserWxService fsUserWxService;
|
|
private IFsUserWxService fsUserWxService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private QwExternalContactMapper qwExternalContactMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IFsImFriendshipService fsImFriendshipService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询用户
|
|
* 查询用户
|
|
@@ -1396,4 +1406,78 @@ public class FsUserServiceImpl implements IFsUserService {
|
|
|
|
|
|
|
|
return new PageInfo<>(fsUserPageListVOS);
|
|
return new PageInfo<>(fsUserPageListVOS);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public R addUserAndSaleFriend(FsUser user, Long compayUserId, Long externalUserId) {
|
|
|
|
|
+ //获取IM的管理员Token
|
|
|
|
|
+ String adminToken = openIMService.getAdminToken();
|
|
|
|
|
+ String userId = "U" + user.getUserId().toString();
|
|
|
|
|
+ String compayUserIdValue = "C" + compayUserId.toString();
|
|
|
|
|
+
|
|
|
|
|
+ //验证销售是否存在
|
|
|
|
|
+ CompanyUser companyUser = companyUserMapper.selectCompanyUserById(compayUserId);
|
|
|
|
|
+ if (companyUser == null) {
|
|
|
|
|
+ return R.error("操作失败,销售不存在!");
|
|
|
|
|
+ }
|
|
|
|
|
+ //验证外部联系人是否绑定用户
|
|
|
|
|
+ QwExternalContact externalContact = qwExternalContactMapper.selectQwExternalContactById(externalUserId);
|
|
|
|
|
+ if(externalContact == null){
|
|
|
|
|
+ return R.error("操作失败,外部联系人不存在!");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isNotEmpty(adminToken)) {
|
|
|
|
|
+ //判断是否注册过
|
|
|
|
|
+ ArrayList<String> userIds = new ArrayList<>();
|
|
|
|
|
+ userIds.add(userId);
|
|
|
|
|
+ JSONObject requestBody = new JSONObject().put("checkUserIDs", userIds);
|
|
|
|
|
+ String body = HttpRequest.post(IMConfig.URL+"/user/account_check")
|
|
|
|
|
+ .header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
|
|
+ .header("token", adminToken)
|
|
|
|
|
+ .body(requestBody.toString())
|
|
|
|
|
+ .execute()
|
|
|
|
|
+ .body();
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject(body);
|
|
|
|
|
+ JSONArray results = jsonObject.getJSONObject("data").getJSONArray("results");
|
|
|
|
|
+ if (results != null && results.length() > 0) {
|
|
|
|
|
+ JSONObject resultObj = results.getJSONObject(0);
|
|
|
|
|
+ int accountStatus = resultObj.getInt("accountStatus");
|
|
|
|
|
+ //未注册进行用户注册
|
|
|
|
|
+ if (accountStatus==0){
|
|
|
|
|
+ ArrayList<Object> users = new ArrayList<>();
|
|
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
|
|
+ map.put("userID",userId);
|
|
|
|
|
+ map.put("nickname",user.getNickName());
|
|
|
|
|
+ map.put("faceURL",user.getAvatar());
|
|
|
|
|
+ users.add(map);
|
|
|
|
|
+ requestBody = new JSONObject();
|
|
|
|
|
+ requestBody.put("users", users);
|
|
|
|
|
+ String registerBody = HttpRequest.post(IMConfig.URL+"/user/user_register")
|
|
|
|
|
+ .header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
|
|
+ .header("token", adminToken).body(requestBody.toString()).execute().body();
|
|
|
|
|
+ OpenImResponseDTO registerDTO = JSON.parseObject(registerBody,OpenImResponseDTO.class);
|
|
|
|
|
+ if(registerDTO.getErrCode() != 0){
|
|
|
|
|
+ logger.error("用户注册失败------》:{}",compayUserId+"--"+JSON.toJSONString(registerDTO));
|
|
|
|
|
+ return R.error("用户注册IM失败,请联系管理员!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //添加用户与销售的关系链路
|
|
|
|
|
+ List<String> friendUserIDs = Arrays.asList(userId);
|
|
|
|
|
+ OpenImResponseDTO openImResponseDTO = openIMService.importFriend(compayUserIdValue, friendUserIDs);
|
|
|
|
|
+ if(openImResponseDTO != null && openImResponseDTO.getErrCode() != 0){
|
|
|
|
|
+ logger.error("系链路绑定失败------》:{}",compayUserId+"--"+JSON.toJSONString(openImResponseDTO));
|
|
|
|
|
+ return R.error("操作失败,销售与好友关系链路绑定失败!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(externalContact.getFsUserId() == null){
|
|
|
|
|
+ //绑定外部联系人
|
|
|
|
|
+ externalContact.setFsUserId(user.getUserId());
|
|
|
|
|
+ qwExternalContactMapper.updateQwExternalContact(externalContact);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ logger.error("获取IMTOKEN失败------》:{}",compayUserId);
|
|
|
|
|
+ return R.error("获取IMTOKEN失败,请联系管理员!");
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.ok();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|