Browse Source

同步修改环信账号

wanghui 8 years ago
parent
commit
b37d0af57d

+ 38 - 6
src/main/java/com/goafanti/app/controller/AppApiController.java

@@ -1,23 +1,29 @@
 package com.goafanti.app.controller;
 
 import java.lang.reflect.InvocationTargetException;
+import java.util.List;
 
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.alibaba.fastjson.JSONObject;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.BaseApiController;
+import com.goafanti.common.model.JpushEasemobAccount;
 import com.goafanti.common.model.MessageFromSystem;
 import com.goafanti.common.model.User;
 import com.goafanti.common.utils.DateUtils;
 import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.easemob.EasemobUtils;
+import com.goafanti.easemob.bo.EasemobInfo;
 import com.goafanti.message.bo.MessageListBo;
 import com.goafanti.message.service.MessageService;
 import com.goafanti.user.service.UserService;
@@ -29,7 +35,8 @@ public class AppApiController extends BaseApiController {
 	private UserService userServiceImpl;
 	@Autowired
 	private MessageService messageServiceImpl;
-	
+	@Autowired
+	private EasemobUtils   easemobUtils;
 	@RequestMapping(value = "/uploadImg",method = RequestMethod.POST)
 	public Result uploadAvatar(HttpServletRequest req){
 		Result res = new Result();
@@ -46,12 +53,37 @@ public class AppApiController extends BaseApiController {
 	@RequestMapping(value = "/updateUser",method = RequestMethod.POST)
 	public Result updateUser(User u){
 		Result res = new Result();
-		if(null != u){
-			u.setId(TokenManager.getUserId());
-			userServiceImpl.updateByPrimaryKeySelective(u);
-		}else{
-			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR));
+		if(StringUtils.isBlank(u.getNickname())){
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"用户昵称不能为空"));
+			return res;
+		}
+		List<User> checkData = userServiceImpl.checkExistUser(null, null, null, null, AFTConstants.USER_SOURCE_REGISTER,
+				u.getNickname());
+		boolean exist = false;
+		boolean needChange = false;
+		if (null != checkData && checkData.size() > 0) {
+			for (User item : checkData) {
+				if (!item.getId().equals(TokenManager.getUserId()))
+					exist = true;
+			}
+		} else {
+			needChange = true;
+		}
+		if (exist) {
+			res.getError().add(buildError(ErrorConstants.USER_NICKNAME_EXIST));
+			return res;
+		} else if (needChange) { // 修改环信昵称
+			JpushEasemobAccount jea = messageServiceImpl.selectSynAccByUid(TokenManager.getUserId());
+			if (null != jea && StringUtils.isNotBlank(jea.getEasemobName())) {
+				JSONObject resultObj = new JSONObject();
+				resultObj.put("username", jea.getEasemobName());
+				resultObj.put("nickname", u.getNickname());
+				easemobUtils.sendLater(
+						new EasemobInfo().uri("/users/").data(resultObj.toJSONString()).method(HttpMethod.POST));
+			}
 		}
+		u.setId(TokenManager.getUserId());
+		userServiceImpl.updateByPrimaryKeySelective(u);
 		return res;
 	}
 	

+ 2 - 0
src/main/java/com/goafanti/common/constant/ErrorConstants.java

@@ -115,4 +115,6 @@ public class ErrorConstants {
 	public static final String AT_LEAST_A_BUSINESS					= "AT_LEAST_A_BUSINESS";
 	
 	public static final String	SON_ALREADY_EXIST					= "SON_ALREADY_EXIST";
+	
+	public static final String USER_NICKNAME_EXIST					= "USER_NICKNAME_EXIST";
 }

+ 7 - 0
src/main/java/com/goafanti/common/dao/JpushEasemobAccountMapper.java

@@ -74,4 +74,11 @@ public interface JpushEasemobAccountMapper {
 	 * @mbg.generated  Thu Dec 21 08:23:35 CST 2017
 	 */
 	int updateByPrimaryKey(JpushEasemobAccount record);
+	
+	/**
+	 * 根据用户查询
+	 * @param uid
+	 * @return
+	 */
+	JpushEasemobAccount selectSynAccByUid(String uid);
 }

+ 10 - 6
src/main/java/com/goafanti/common/dao/UserMapper.java

@@ -173,12 +173,16 @@ public interface UserMapper {
 
 	/**
 	 * 查询用户
-	 * @param uid
-	 * @param identifyName
-	 * @param mobile
-	 * @return
-	 */
-	List<User> checkUser(@Param("id")String id,@Param("identifyName")String identifyName, @Param("mobile")String mobile,@Param("type")Integer type);
+	 * @param id
+	 * @param identifyName 认证用户名
+	 * @param mobile 手机号码
+	 * @param type 用户类型 0-个人 1-单位
+	 * @param source 来源 0-注册 1-录入
+	 * @return 
+	 * @param nickname 昵称
+	 */
+	List<User> checkUser(@Param("id")String id,@Param("identifyName")String identifyName, @Param("mobile")String mobile,
+			@Param("type")Integer type,@Param("source") Integer source,@Param("nickname") String nickname);
 
 
 	List<UserInterestBo> userInterest(String uid);

+ 6 - 0
src/main/java/com/goafanti/common/mapper/JpushEasemobAccountMapper.xml

@@ -330,4 +330,10 @@
       easemob_pass = #{easemobPass,jdbcType=VARCHAR}
     where uuid = #{uuid,jdbcType=VARCHAR}
   </update>
+  <select id="selectSynAccByUid" parameterType="java.lang.String" resultMap="BaseResultMap">
+  	select 
+    <include refid="Base_Column_List" />
+    from jpush_easemob_account
+    where uid = #{uid,jdbcType=VARCHAR}
+  </select>
 </mapper>

+ 2 - 1
src/main/java/com/goafanti/common/mapper/MessageFromSystemMapper.xml

@@ -589,7 +589,8 @@
    
    <select id="listPersonalMessageByPage" resultType="com.goafanti.message.bo.MessageListBo">
 		select
-			b.id as messageId,b.title,date_format(b.create_time,'%Y-%m-%d %H:%I:%S') as createTime,b.subject, b.resource_type as resourceType
+			b.id as messageId,b.title,date_format(b.create_time,'%Y-%m-%d %H:%I:%S') as createTime,b.subject,
+			b.resource_type as resourceType,b.resource_id as resourceId,if(a.read_time is null,0,1) as isRead
 		from
 			message_consumer a left join message_from_system b on
 			a.message_id = b.id

+ 6 - 0
src/main/java/com/goafanti/common/mapper/UserMapper.xml

@@ -1409,6 +1409,12 @@
 		<if test="type != null">
 			and type = #{type,jdbcType=INTEGER}
 		</if>
+		<if test="source != null">
+			and source = #{source,jdbcType=INTEGER}
+		</if>
+		<if test="nickname != null and nickname != ''">
+			and nickname = #{nickname,jdbcType=INTEGER}
+		</if>
 	</select>
 
 	<select id="userInterest" resultType="com.goafanti.user.bo.UserInterestBo">

+ 3 - 3
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -209,7 +209,7 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 		user.setBusinessAudit(AFTConstants.NO);
 		passwordUtil.encryptPassword(user);
 		if(type == UserType.PERSONAL.getCode()){
-			if(userMapper.checkUser("", "", contactMobile, type).size()>0) throw new BusinessException(new Error(ErrorConstants.CUSTOMER_ALREADY_EXIST, name,""));
+			if(userMapper.checkUser("", "", contactMobile, type,null,null).size()>0) throw new BusinessException(new Error(ErrorConstants.CUSTOMER_ALREADY_EXIST, name,""));
 			UserIdentity ui = new UserIdentity();
 			ui.setId(identifyId);
 			ui.setUid(uid);
@@ -548,9 +548,9 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 			}
 			if(StringUtils.isBlank(bo.getUid())){ //是否已经存在
 				if(bo.getCustomerType().equals(AFTConstants.USER_TYPE_PERSONAL)){
-					list = userMapper.checkUser("", "", bo.getMobile(), Integer.parseInt(bo.getCustomerType()));
+					list = userMapper.checkUser("", "", bo.getMobile(), Integer.parseInt(bo.getCustomerType()),null,null);
 				}else if(bo.getCustomerType().equals(AFTConstants.USER_TYPE_ORGANIZATION)){
-					list = userMapper.checkUser("", bo.getIdentifyName(), "", Integer.parseInt(bo.getCustomerType()));
+					list = userMapper.checkUser("", bo.getIdentifyName(), "", Integer.parseInt(bo.getCustomerType()),null,null);
 				}			
 				if (list.size() > 0) {
 					bo.setUid(list.get(0).getId());

+ 211 - 211
src/main/java/com/goafanti/easemob/EasemobUtils.java

@@ -1,211 +1,211 @@
-package com.goafanti.easemob;
-
-import java.io.IOException;
-import java.util.Optional;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.concurrent.FutureCallback;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
-import org.apache.http.impl.nio.client.HttpAsyncClients;
-import org.apache.http.util.EntityUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.HttpMethod;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.goafanti.common.utils.LoggerUtils;
-import com.goafanti.easemob.bo.EasemobInfo;
-import com.goafanti.easemob.queue.EasemobRedisQueue;
-
-public class EasemobUtils implements InitializingBean, DisposableBean {
-	private static final String				UTF_8		= "UTF-8";
-	private static final Logger				logger		= LoggerFactory.getLogger(EasemobUtils.class);
-	private static final Optional<Integer>	UN_AUTH		= Optional.of(401);
-	private static final Optional<Integer>	REACH_LIMIT	= Optional.of(429);
-
-	@Value(value = "${easemob.client.url}")
-	private String							clientUrl;
-	@Value(value = "${easemob.client.id}")
-	private String							clientId;
-	@Value(value = "${easemob.client.secret}")
-	private String							clientSecret;
-
-	private String							token;
-
-	@Autowired
-	private EasemobRedisQueue				jedisQueue;
-
-	private void auth() {
-		JSONObject jo = new JSONObject();
-		jo.put("grant_type", "client_credentials");
-		jo.put("client_id", clientId);
-		jo.put("client_secret", clientSecret);
-		JSONObject res = send(
-				new EasemobInfo().uri("/token").data(jo.toJSONString()).method(HttpMethod.POST).withAuth(false));
-		if (res != null) {
-			token = res.getString("access_token");
-		}
-	}
-
-	private HttpUriRequest buildRequest(EasemobInfo info) {
-		HttpUriRequest req = null;
-		switch (info.getMethod()) {
-		case POST:
-			req = new HttpPost(clientUrl + info.getUri());
-			((HttpPost) req).setEntity(new StringEntity(info.getData(), UTF_8));
-			break;
-		default:
-			req = new HttpGet(clientUrl + info.getUri());
-			break;
-		}
-		if (info.isWithAuth()) {
-			req.addHeader("Authorization", "Bearer " + token);
-		}
-		((HttpRequestBase) req).setConfig(RequestConfig.custom().setConnectTimeout(10000)
-				.setConnectionRequestTimeout(10000).setSocketTimeout(10000).build());
-		req.addHeader("Content-Type", "application/json");
-		return req;
-	}
-
-	public JSONObject send(EasemobInfo info) {
-		HttpUriRequest req = buildRequest(info);
-		CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
-		httpclient.start();
-		LoggerUtils.debug(logger, "SEND: [%s] - [%s]", info.getMethod(), info.getUri());
-		Future<HttpResponse> future = httpclient.execute(req, null);
-		try {
-			HttpResponse response = future.get();
-			Optional<Integer> rescode = getResCode(response);
-			if (info.isWithAuth() && isUnauth(rescode)) {
-				auth();
-			} else if (isReachLimit(rescode)) {
-				LoggerUtils.debug(logger, "Reach Easemob API limitation!");
-			} else {
-				HttpEntity entity = response.getEntity();
-				if (entity != null) {
-					try {
-						String resStr = EntityUtils.toString(entity, UTF_8);
-						return (JSONObject) JSON.parse(resStr);
-					} catch (Exception e) {
-						LoggerUtils.debug(logger, e.getMessage(), e);
-					}
-				}
-			}
-			LoggerUtils.debug(logger, response);
-		} catch (InterruptedException | ExecutionException e) {
-			LoggerUtils.debug(logger, e.getMessage(), e);
-		} finally {
-			try {
-				httpclient.close();
-			} catch (IOException e) {
-			}
-		}
-		return info.getTryCount() > 1 ? null : send(info.tryCount(info.getTryCount() + 1));
-	}
-
-	public void sendLater(EasemobInfo info) {
-		jedisQueue.pushFromTail(info);
-	}
-
-	public void sendAsync(EasemobInfo info) {
-		HttpUriRequest req = buildRequest(info);
-		CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
-		httpclient.start();
-		LoggerUtils.debug(logger, "SEND: [%s] - [%s]", info.getMethod(), info.getUri());
-		httpclient.execute(req, new FutureCallback<HttpResponse>() {
-			@Override
-			public void failed(Exception ex) {
-				sendLater(info.tryCount(info.getTryCount() + 1));
-				close();
-			}
-
-			@Override
-			public void completed(HttpResponse result) {
-				Optional<Integer> rescode = getResCode(result);
-				if (info.isWithAuth() && isUnauth(rescode)) {
-					auth();
-				} else if (isReachLimit(rescode)) {
-					LoggerUtils.debug(logger, "Reach Easemob API limitation!");
-					sendLater(info.tryCount(info.getTryCount() + 1));
-				}
-				LoggerUtils.debug(logger, result);
-				close();
-			}
-
-			@Override
-			public void cancelled() {
-				close();
-				LoggerUtils.debug(logger, "CANCELLED: [%s] - [%s]", req.getMethod(), req.getURI());
-			}
-
-			private void close() {
-				try {
-					httpclient.close();
-				} catch (IOException e) {
-				}
-			}
-		});
-	}
-
-	public void sendMessage(String from, String to, String msg, Object... value) {
-		sendAsync(new EasemobInfo().uri("/messages").data(buildMessage(from, to, null, String.format(msg, value)))
-				.method(HttpMethod.POST));
-	}
-
-	public void sendMessage(String from, String to, Object ext, String msg, Object... value) {
-		sendAsync(new EasemobInfo().uri("/messages").data(buildMessage(from, to, ext, String.format(msg, value)))
-				.method(HttpMethod.POST));
-	}
-
-	private String buildMessage(String from, String to, Object ext, String msg) {
-		JSONObject message = new JSONObject();
-		message.put("type", "txt");
-		message.put("msg", msg);
-		JSONObject jo = new JSONObject();
-		jo.put("target_type", "users");
-		jo.put("target", new String[] { to });
-		jo.put("msg", message);
-		jo.put("from", from);
-		if (ext != null) {
-			jo.put("ext", ext);
-		}
-		return jo.toJSONString();
-	}
-
-	private Optional<Integer> getResCode(HttpResponse response) {
-		return Optional.ofNullable(response).map(res -> res.getStatusLine()).map(sl -> sl.getStatusCode());
-	}
-
-	private boolean isUnauth(Optional<Integer> responseStatus) {
-		return UN_AUTH.equals(responseStatus);
-	}
-
-	private boolean isReachLimit(Optional<Integer> responseStatus) {
-		return REACH_LIMIT.equals(responseStatus);
-	}
-
-	@Override
-	public void destroy() throws Exception {
-		LoggerUtils.debug(logger, "消息系统关闭");
-	}
-
-	@Override
-	public void afterPropertiesSet() throws Exception {
-		auth();
-	}
-
-}
+package com.goafanti.easemob;
+
+import java.io.IOException;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.concurrent.FutureCallback;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
+import org.apache.http.impl.nio.client.HttpAsyncClients;
+import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpMethod;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.goafanti.common.utils.LoggerUtils;
+import com.goafanti.easemob.bo.EasemobInfo;
+import com.goafanti.easemob.queue.EasemobRedisQueue;
+
+public class EasemobUtils implements InitializingBean, DisposableBean {
+	private static final String				UTF_8		= "UTF-8";
+	private static final Logger				logger		= LoggerFactory.getLogger(EasemobUtils.class);
+	private static final Optional<Integer>	UN_AUTH		= Optional.of(401);
+	private static final Optional<Integer>	REACH_LIMIT	= Optional.of(429);
+
+	@Value(value = "${easemob.client.url}")
+	private String							clientUrl;
+	@Value(value = "${easemob.client.id}")
+	private String							clientId;
+	@Value(value = "${easemob.client.secret}")
+	private String							clientSecret;
+
+	private String							token;
+
+	@Autowired
+	private EasemobRedisQueue				jedisQueue;
+
+	private void auth() {
+		JSONObject jo = new JSONObject();
+		jo.put("grant_type", "client_credentials");
+		jo.put("client_id", clientId);
+		jo.put("client_secret", clientSecret);
+		JSONObject res = send(
+				new EasemobInfo().uri("/token").data(jo.toJSONString()).method(HttpMethod.POST).withAuth(false));
+		if (res != null) {
+			token = res.getString("access_token");
+		}
+	}
+
+	private HttpUriRequest buildRequest(EasemobInfo info) {
+		HttpUriRequest req = null;
+		switch (info.getMethod()) {
+		case POST:
+			req = new HttpPost(clientUrl + info.getUri());
+			((HttpPost) req).setEntity(new StringEntity(info.getData(), UTF_8));
+			break;
+		default:
+			req = new HttpGet(clientUrl + info.getUri());
+			break;
+		}
+		if (info.isWithAuth()) {
+			req.addHeader("Authorization", "Bearer " + token);
+		}
+		((HttpRequestBase) req).setConfig(RequestConfig.custom().setConnectTimeout(10000)
+				.setConnectionRequestTimeout(10000).setSocketTimeout(10000).build());
+		req.addHeader("Content-Type", "application/json");
+		return req;
+	}
+
+	public JSONObject send(EasemobInfo info) {
+		HttpUriRequest req = buildRequest(info);
+		CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
+		httpclient.start();
+		LoggerUtils.debug(logger, "SEND: [%s] - [%s]", info.getMethod(), info.getUri());
+		Future<HttpResponse> future = httpclient.execute(req, null);
+		try {
+			HttpResponse response = future.get();
+			Optional<Integer> rescode = getResCode(response);
+			if (info.isWithAuth() && isUnauth(rescode)) {
+				auth();
+			} else if (isReachLimit(rescode)) {
+				LoggerUtils.debug(logger, "Reach Easemob API limitation!");
+			} else {
+				HttpEntity entity = response.getEntity();
+				if (entity != null) {
+					try {
+						String resStr = EntityUtils.toString(entity, UTF_8);
+						return (JSONObject) JSON.parse(resStr);
+					} catch (Exception e) {
+						LoggerUtils.debug(logger, e.getMessage(), e);
+					}
+				}
+			}
+			LoggerUtils.debug(logger, response);
+		} catch (InterruptedException | ExecutionException e) {
+			LoggerUtils.debug(logger, e.getMessage(), e);
+		} finally {
+			try {
+				httpclient.close();
+			} catch (IOException e) {
+			}
+		}
+		return info.getTryCount() > 1 ? null : send(info.tryCount(info.getTryCount() + 1));
+	}
+
+	public void sendLater(EasemobInfo info) {
+		jedisQueue.pushFromTail(info);
+	}
+
+	public void sendAsync(EasemobInfo info) {
+		HttpUriRequest req = buildRequest(info);
+		CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
+		httpclient.start();
+		LoggerUtils.debug(logger, "SEND: [%s] - [%s]", info.getMethod(), info.getUri());
+		httpclient.execute(req, new FutureCallback<HttpResponse>() {
+			@Override
+			public void failed(Exception ex) {
+				sendLater(info.tryCount(info.getTryCount() + 1));
+				close();
+			}
+
+			@Override
+			public void completed(HttpResponse result) {
+				Optional<Integer> rescode = getResCode(result);
+				if (info.isWithAuth() && isUnauth(rescode)) {
+					auth();
+				} else if (isReachLimit(rescode)) {
+					LoggerUtils.debug(logger, "Reach Easemob API limitation!");
+					sendLater(info.tryCount(info.getTryCount() + 1));
+				}
+				LoggerUtils.debug(logger, result);
+				close();
+			}
+
+			@Override
+			public void cancelled() {
+				close();
+				LoggerUtils.debug(logger, "CANCELLED: [%s] - [%s]", req.getMethod(), req.getURI());
+			}
+
+			private void close() {
+				try {
+					httpclient.close();
+				} catch (IOException e) {
+				}
+			}
+		});
+	}
+
+	public void sendMessage(String from, String to, String msg, Object... value) {
+		sendAsync(new EasemobInfo().uri("/messages").data(buildMessage(from, to, null, String.format(msg, value)))
+				.method(HttpMethod.POST));
+	}
+
+	public void sendMessage(String from, String to, Object ext, String msg, Object... value) {
+		sendAsync(new EasemobInfo().uri("/messages").data(buildMessage(from, to, ext, String.format(msg, value)))
+				.method(HttpMethod.POST));
+	}
+
+	private String buildMessage(String from, String to, Object ext, String msg) {
+		JSONObject message = new JSONObject();
+		message.put("type", "txt");
+		message.put("msg", msg);
+		JSONObject jo = new JSONObject();
+		jo.put("target_type", "users");
+		jo.put("target", new String[] { to });
+		jo.put("msg", message);
+		jo.put("from", from);
+		if (ext != null) {
+			jo.put("ext", ext);
+		}
+		return jo.toJSONString();
+	}
+
+	private Optional<Integer> getResCode(HttpResponse response) {
+		return Optional.ofNullable(response).map(res -> res.getStatusLine()).map(sl -> sl.getStatusCode());
+	}
+
+	private boolean isUnauth(Optional<Integer> responseStatus) {
+		return UN_AUTH.equals(responseStatus);
+	}
+
+	private boolean isReachLimit(Optional<Integer> responseStatus) {
+		return REACH_LIMIT.equals(responseStatus);
+	}
+
+	@Override
+	public void destroy() throws Exception {
+		LoggerUtils.debug(logger, "消息系统关闭");
+	}
+
+	@Override
+	public void afterPropertiesSet() throws Exception {
+		auth();
+	}
+
+}

+ 7 - 0
src/main/java/com/goafanti/message/bo/MessageListBo.java

@@ -11,6 +11,7 @@ public class MessageListBo {
 	private String resourceType;
 	private String resourceId;
 	private String isDraft;
+	private String isRead;
 	public String getMessageId() {
 		return messageId;
 	}
@@ -71,4 +72,10 @@ public class MessageListBo {
 	public void setIsDraft(String isDraft) {
 		this.isDraft = isDraft;
 	}
+	public String getIsRead() {
+		return isRead;
+	}
+	public void setIsRead(String isRead) {
+		this.isRead = isRead;
+	}
 }

+ 8 - 0
src/main/java/com/goafanti/message/service/MessageService.java

@@ -5,6 +5,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.goafanti.app.bo.IndexBo;
+import com.goafanti.common.model.JpushEasemobAccount;
 import com.goafanti.common.model.MessageConsumer;
 import com.goafanti.common.model.MessageFromSystem;
 import com.goafanti.common.model.MessageProducer;
@@ -142,4 +143,11 @@ public interface MessageService {
 	 * @return
 	 */
 	MessageFromSystem selectSystemMessageDetail(String messageId);
+	
+	/**
+	 * 查询第三方账号
+	 * @param uid
+	 * @return
+	 */
+	JpushEasemobAccount selectSynAccByUid(String uid);
 }

+ 9 - 0
src/main/java/com/goafanti/message/service/impl/MessageServiceImpl.java

@@ -14,9 +14,11 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import com.goafanti.app.bo.IndexBo;
+import com.goafanti.common.dao.JpushEasemobAccountMapper;
 import com.goafanti.common.dao.MessageFromSystemMapper;
 import com.goafanti.common.dao.MessageProducerMapper;
 import com.goafanti.common.model.Admin;
+import com.goafanti.common.model.JpushEasemobAccount;
 import com.goafanti.common.model.MessageConsumer;
 import com.goafanti.common.model.MessageFromSystem;
 import com.goafanti.common.model.MessageProducer;
@@ -37,6 +39,8 @@ public class MessageServiceImpl  extends BaseMybatisDao<MessageFromSystemMapper>
 	private MessageFromSystemMapper messageFromSystemMapper;
 	@Autowired
 	private MessageProducerMapper messageProducerMapper;
+	@Autowired
+	private JpushEasemobAccountMapper jpushEasemobAccountMapper;
 	@Override
 	public String selectSendUser(Map<Integer, String> selectMap,Integer type) {
 		if(selectMap.containsKey(ConsumerType.CUSTOMER_RETAIL.getTypeCode())){ //客户散户
@@ -318,4 +322,9 @@ public class MessageServiceImpl  extends BaseMybatisDao<MessageFromSystemMapper>
 		}
 		return sourceType;
 	}
+
+	@Override
+	public JpushEasemobAccount selectSynAccByUid(String uid) {
+		return jpushEasemobAccountMapper.selectSynAccByUid(uid);
+	}
 }

+ 2 - 0
src/main/java/com/goafanti/user/service/UserService.java

@@ -62,4 +62,6 @@ public interface UserService {
 	List<UserPartnerDetailBo> findUserPartner();
 
 	UserBasicInfo selectBaseInfo();
+	
+	List<User> checkExistUser(String id,String identifyName, String mobile,Integer type,Integer source,String nickname);
 }

+ 5 - 0
src/main/java/com/goafanti/user/service/impl/UserServiceImpl.java

@@ -361,4 +361,9 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 		return null;
 	}
 
+	@Override
+	public List<User> checkExistUser(String id,String identifyName, String mobile,Integer type,Integer source,String nickname) {
+		return userMapper.checkUser(id, identifyName, mobile, type, source, nickname);
+	}
+
 }

+ 3 - 1
src/main/resources/props/error.properties

@@ -101,4 +101,6 @@ CUSTOMER_ALREADY_EXIST = \u5BA2\u6237\u5DF2\u5B58\u5728
 
 BUSINESS_ALREADY_EXIST = \u9879\u76EE\u5DF2\u5B58\u5728
 
-AT_LEAST_A_BUSINESS = \u81F3\u5C11\u9700\u8981\u586B\u5199\u4E00\u9879\u4E1A\u52A1
+AT_LEAST_A_BUSINESS = \u81F3\u5C11\u9700\u8981\u586B\u5199\u4E00\u9879\u4E1A\u52A1
+
+USER_NICKNAME_EXIST = \u6635\u79F0\u5DF2\u5B58\u5728