Commit ff2be652 by lyhuang

remove the injection of ccService from

parent 9cd546b6
......@@ -42,6 +42,7 @@ import com.ctrip.fun.admin.service.system.UserService;
import com.ctrip.fun.admin.service.tools.CallCenterService;
import com.ctrip.fun.admin.utility.Util;
import com.ctrip.fun.admin.vo.callcenter.AbstractEventHandler;
import com.ctrip.fun.admin.vo.callcenter.RsmwNewStateEvent;
import com.ctrip.fun.common.vo.PagedResponseBean;
import com.ctrip.fun.common.vo.basic.UserExtQuery;
import com.ctrip.fun.common.vo.user.RegisterBean;
......@@ -134,7 +135,26 @@ public class CallCenterController {
// 2)执行命令并返回结果
if(eventHandler!=null){
result = eventHandler.handle(commandJSONObject);
eventHandler.handle(commandJSONObject);
RsmwNewStateEvent eventObj = JSON.toJavaObject(commandJSONObject, RsmwNewStateEvent.class);
String mobileNo = eventObj.getConnectedLineNumber().replaceFirst("^0*", "");
try {
if (StringUtil.isBlank(mobileNo)) {
logger.error("mobile is null in ccdesk!");
throw new CommonException(-02, "ccdesk返回客户手机号为空!");
}
String uid = this.queryRegisterUid(mobileNo);
if (StringUtils.isNotBlank(uid)) {
return String.format("redirect:/system/user/%s/detailByUid", uid);
} else {
return "/tools/validCode";
}
} catch (CommonException e) {
return "error";
}
}else{
result = "event=" + event + ", event字段有误,没有找到对应的eventHandler";
logger.warn("event=" + event + ", event字段有误,没有找到对应的eventHandler");
......@@ -145,8 +165,6 @@ public class CallCenterController {
return e.getMessage();
}
return result;
}
......
......@@ -12,19 +12,11 @@ import org.springframework.stereotype.Controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ctrip.fun.admin.exception.CommonException;
import com.ctrip.fun.admin.service.system.UserService;
import com.ctrip.fun.admin.service.tools.CallCenterService;
import com.ctrip.fun.admin.utility.SpringSecurityUtil;
import com.ctrip.fun.admin.vo.callcenter.AbstractEventHandler;
import com.ctrip.fun.admin.vo.callcenter.RsmwNewStateEvent;
import com.ctrip.fun.common.vo.PagedResponseBean;
import com.ctrip.fun.common.vo.basic.UserExtQuery;
import com.ctrip.fun.common.vo.user.UserBean;
import com.ctrip.fun.common.vo.user.UserExtBean;
import com.ctrip.fun.common.vo.user.UserQuery;
......@@ -62,11 +54,6 @@ public class NewStateEventHandler extends AbstractEventHandler {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private CallCenterService ccService;
private UserService userService;
@Override
......@@ -90,31 +77,11 @@ public class NewStateEventHandler extends AbstractEventHandler {
// UserDetails user = (UserDetails)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String username = SpringSecurityUtil.getCurrentUserName();
NewStateWebSocket.unicast(username,mobileNo);
try {
if (StringUtil.isBlank(mobileNo)) {
logger.error("mobile is null in ccdesk!");
throw new CommonException(-02, "ccdesk返回客户手机号为空!");
}
String uid = this.queryRegisterUid(mobileNo);
if (StringUtils.isNotBlank(uid)) {
return String.format("redirect:/system/user/%s/detailByUid", uid);
} else {
return "/tools/validCode";
}
} catch (CommonException e) {
return "error";
}
/*
// 调rsmw接口,查询绑定关系,拿到aid,也就时websocket里的clientId
RsmwServer rsmwServer = ApplicationHelper.getApplicationContext().getBean("rsmwServer", RsmwServer.class);
AgentSipPhoneBindInfoResponse agentSipPhoneBindInfoResponse = rsmwServer.getBindInfo(null, sipPeerName);
......@@ -241,47 +208,4 @@ public class NewStateEventHandler extends AbstractEventHandler {
return "";
}
private String queryRegisterUid(String mobileNo) throws CommonException {
String uid = null;
UserExtQuery query = new UserExtQuery();
query.setMobile(mobileNo);
query.setPagerOffset(0);
query.setSortField("registerTime");
PagedResponseBean<UserExtBean> response = userService.list("", query);
Collection<UserExtBean> users = response.getResult();
if (CollectionUtils.isNotEmpty(users)) {
List<UserExtBean> list = (List) users;
UserExtBean user = list.get(0);
uid = user.getUid();
} else {
// 查询携程注册信息
UserQuery memberRequest = new UserQuery();
memberRequest.setUid(mobileNo);
UserBean memberResponse = ccService.getMemberInfo("", memberRequest);
// getMemberInfo接口会将携程用户同步为爱玩用户
if (StringUtils.isNotBlank(memberResponse.getUid())) {
uid = memberResponse.getUid();
}
}
return uid;
}
public CallCenterService getCcService() {
return ccService;
}
public UserService getUserService() {
return userService;
}
public void setCcService(CallCenterService ccService) {
this.ccService = ccService;
}
public void setUserService(UserService userService) {
this.userService = userService;
}
}
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 sign in to comment