Commit 744d8372 authored by jay's avatar jay

im统一信息接口添加

parent 092128a1
......@@ -2,6 +2,7 @@ package com.house365.ws.interfaces.rest;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Strings;
import com.house365.beans.entity.DepartmentEntity;
import com.house365.beans.entity.KefuEntity;
import com.house365.beans.entity.UserEntity;
import com.house365.beans.entity.UserMessageEntity;
......@@ -11,6 +12,7 @@ import com.house365.rest.exception.ServiceRunException;
import com.house365.rest.parameter.House365RestObject;
import com.house365.rest.parameter.House365RestResponse;
import com.house365.web.util.MemoryPropertyPlaceholderConfigurer;
import com.house365.ws.dao.mapper.DepartMapper;
import com.house365.ws.dao.mapper.KefuMapper;
import com.house365.ws.dao.mapper.UserMapper;
import com.house365.ws.dao.mapper.UserMessageMapper;
......@@ -44,6 +46,8 @@ public class GetImUserInfoImpl implements IGetImUserInfo {
private UserMessageMapper messageMapper;
@Autowired
private KefuMapper kefumapper;
@Autowired
private DepartMapper departMapper;
@Override
public Object exectue(Parameter parameter) throws ServiceRunException {
......@@ -103,45 +107,63 @@ public class GetImUserInfoImpl implements IGetImUserInfo {
data.setEntity(putMap);
}
} else {
//非南京情况下,先判断是否直卖楼盘,非直卖楼盘;直卖楼盘调用淘房汇接口,有客服id取客服id,没有取accid,非直卖楼盘直接去新房房博士id
if (StringUtils.isBlank(projectId) || StringUtils.isBlank(channel)) {
response.setResult(ReturnAppResult.APP_FAIL.getResultCode());
response.setMsg("接口参数不全");
return JSONObject.fromObject(response).toString();
}
String accId;
KefuEntity kefuEntity = kefumapper.getKefuInfo(city);
if (null != kefuEntity && "1".equals(kefuEntity.getSetKefu())) {
accId = kefuEntity.getKefuAccid();
//查询各个城市的新房客服
String accId = "";
List<NameValuePair> param = new ArrayList<>();
param.add(new BasicNameValuePair("serviceCode", "TaoFangHui"));
param.add(new BasicNameValuePair("serviceName", "getBindInfo"));
param.add(new BasicNameValuePair("city", city));
param.add(new BasicNameValuePair("projectId", projectId));
param.add(new BasicNameValuePair("channel", channel));
String result = HttpClientUtil.doGet(MemoryPropertyPlaceholderConfigurer.getContextProperty("tangfanghui.server.url"), param, 4000, null);
//根据条件查不到楼盘信息的情况下 即非直卖楼盘
if ("".equals(result)) {
//非直卖楼盘,查询各个城市的新房客服
Map<String, Object> searchMap = new HashMap<>(10);
searchMap.put("descripition", city);
List<DepartmentEntity> deptList = departMapper.queryByConditions(searchMap);
if (CollectionUtils.isNotEmpty(deptList)) {
DepartmentEntity entity = deptList.get(0);
String urlPath = entity.getUrlPath();
searchMap.put("deptUrlPath", urlPath);
searchMap.put("identityType", 3);
List<UserEntity> userList = userMapper.queryByConditions(searchMap);
if (CollectionUtils.isNotEmpty(userList)) {
accId = userList.get(0).getAccId();
}
}
} else {
//判断是否直卖楼盘
//调用淘房汇绑定直销人员list
List<NameValuePair> param = new ArrayList<>();
param.add(new BasicNameValuePair("serviceCode", "TaoFangHui"));
param.add(new BasicNameValuePair("serviceName", "getBindInfo"));
param.add(new BasicNameValuePair("city", city));
param.add(new BasicNameValuePair("projectId", projectId));
param.add(new BasicNameValuePair("channel", channel));
String result = HttpClientUtil.doGet(MemoryPropertyPlaceholderConfigurer.getContextProperty("tangfanghui.server.url"), param, 4000, null);
//直卖楼盘去查询城市客服
if (result != null) {
//根据条件查不到楼盘信息的情况下
if ("".equals(result)) {
return null;
}
ObjectMapper objectMapper = new ObjectMapper();
Map<String, Map<String, Map>> webMap = objectMapper.readValue(result, Map.class);
List<Map<String, Object>> list = (List<Map<String, Object>>) webMap.get("data").get("entity").get("list");
if (CollectionUtils.isNotEmpty(list)) {
for (Map<String, Object> l : list) {
int userId = Integer.parseInt(l.get("userId").toString());
KefuEntity kefuEntity = kefumapper.getKefuInfo(city);
if (null != kefuEntity && "1".equals(kefuEntity.getSetKefu())) {
accId = kefuEntity.getKefuAccid();
} else {
ObjectMapper objectMapper = new ObjectMapper();
Map<String, Map<String, Map>> webMap = objectMapper.readValue(result, Map.class);
List<Map<String, Object>> list = (List<Map<String, Object>>) webMap.get("data").get("entity").get("list");
if (CollectionUtils.isNotEmpty(list)) {
int pick = getRandom(list.size());
Map<String, Object> resultMap = list.get(pick);
int userId = Integer.parseInt(resultMap.get("userId").toString());
UserEntity userEntity = userMapper.getById(userId);
accId = userEntity.getAccId();
}
}
}
}
putMap.put("accId", accId);
data.setEntity(putMap);
}
response.setResult(ReturnAppResult.APP_FAIL.getResultCode());
response.setMsg("查询成功");
response.setMsg("查询IM信息成功");
response.setData(data);
} catch (Exception e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment