Explorar o código

邮箱获取修改

liupeng %!s(int64=4) %!d(string=hai) anos
pai
achega
e344560f7c

+ 11 - 15
code/sapparent/sapservice/src/main/java/org/fouram/core/plugin/weixin/cp/util/WXCpUserUtil.java

@@ -44,22 +44,18 @@ public class WXCpUserUtil {
 
 	public static String createOrUpdate(String userId, String name, Long[] firstWxDepartIdList,
 			Long[] secondWxDepartIdList, Long[] thirdWxDepartIdList, Long[] fourthWxDepartIdList, String position,
-			String mobile, String gender, String email, String telephone, String firstOrgName) {
+			String mobile, String gender, String email, String telephone, String firstOrgName) throws WxErrorException {
 		WxCpUser user = getByIdOrEmail(userId, email);
-		try {
-			if (user == null) {
-				user = getUser(userId, name, firstWxDepartIdList, secondWxDepartIdList, thirdWxDepartIdList,
-						fourthWxDepartIdList, position, mobile, gender, email, telephone, firstOrgName);
-				userService.create(user);
-			} else {
-				user = getUser(user.getUserId(), name, firstWxDepartIdList, secondWxDepartIdList, thirdWxDepartIdList,
-						fourthWxDepartIdList, position, mobile, gender, email, telephone, firstOrgName);
-				userService.update(user);
-			}
-			return SapUserResultEnum.SUCCESS.getCode();
-		} catch (WxErrorException e) {
-			return e.getMessage();
-		}
+		if (user == null) {
+			user = getUser(userId, name, firstWxDepartIdList, secondWxDepartIdList, thirdWxDepartIdList,
+					fourthWxDepartIdList, position, mobile, gender, email, telephone, firstOrgName);
+			userService.create(user);
+		} else {
+			user = getUser(user.getUserId(), name, firstWxDepartIdList, secondWxDepartIdList, thirdWxDepartIdList,
+					fourthWxDepartIdList, position, mobile, gender, email, telephone, firstOrgName);
+			userService.update(user);
+		}
+		return SapUserResultEnum.SUCCESS.getCode();
 	}
 
 	private static WxCpUser getUser(String userId, String name, Long[] firstWxDepartIdList, Long[] secondWxDepartIdList,

+ 8 - 0
code/sapparent/sapservice/src/main/java/org/fouram/entity/SapUser.java

@@ -4,6 +4,7 @@ import java.io.Serializable;
 import java.util.Date;
 import java.util.List;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.ibatis.type.Alias;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -87,6 +88,13 @@ public class SapUser implements Serializable {
 	private String wxFullDepart;
 
 	private List<List<SapOrg>> departList;
+	
+	public String getRealEmail() {
+		if(StringUtils.isNotBlank(username) && username.contains("@")) {
+			return username;
+		}
+		return formatEmail;
+	}
 
 	public String getFullOrgName() {
 		StringBuffer sb = new StringBuffer(firstOrgName);

+ 1 - 1
code/sapparent/sapservice/src/main/java/org/fouram/service/SapUserService.java

@@ -289,7 +289,7 @@ public class SapUserService extends BaseService {
 		}
 		return WXCpUserUtil.createOrUpdate(personId, primarySapUser.getName(), firstWxDepartIdList,
 				secondWxDepartIdList, thirdWxDepartIdList, fourthWxDepartIdList, primarySapUser.getSapPosition(),
-				formatMobile, primarySapUser.getGender(), primarySapUser.getUsername(),
+				formatMobile, primarySapUser.getGender(), primarySapUser.getRealEmail(),
 				primarySapUser.getFormatBusinessPhone(), primarySapUser.getFirstOrgName());
 	}