|  | @@ -33,7 +33,9 @@ import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import javax.annotation.Resource;
 | 
	
		
			
				|  |  | +import java.util.List;
 | 
	
		
			
				|  |  |  import java.util.Objects;
 | 
	
		
			
				|  |  | +import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
 | 
	
		
			
				|  |  |  import static cn.newfeifan.mall.framework.common.util.servlet.ServletUtils.getClientIP;
 | 
	
	
		
			
				|  | @@ -103,7 +105,7 @@ public class MemberAuthServiceImpl implements MemberAuthService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      @Transactional
 | 
	
		
			
				|  |  | -    public AppAuthLoginRespVO socialLogin(AppAuthSocialLoginReqVO reqVO, String phone, Boolean isFirst, Boolean isRegister) {
 | 
	
		
			
				|  |  | +    public AppAuthLoginRespVO socialRegister(AppAuthSocialRegisterReqVO reqVO, String phone, Boolean isFirst, Boolean isRegister) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 使用 code 授权码,进行登录。然后,获得到绑定的用户编号
 | 
	
	
		
			
				|  | @@ -143,6 +145,52 @@ public class MemberAuthServiceImpl implements MemberAuthService {
 | 
	
		
			
				|  |  |          return createTokenAfterLoginSuccess(user, user.getMobile(), LoginLogTypeEnum.LOGIN_SOCIAL, socialUser.getOpenid());
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public AppAuthLoginRespVO socialLogin(AppAuthSocialLoginReqVO reqVO) {
 | 
	
		
			
				|  |  | +        // 使用 code 授权码,进行登录。然后,获得到绑定的用户编号
 | 
	
		
			
				|  |  | +        SocialUserRespDTO socialUser = socialUserApi.getSocialUserByCode(UserTypeEnum.MEMBER.getValue(), reqVO.getType(),
 | 
	
		
			
				|  |  | +                reqVO.getCode(), reqVO.getState(), true, false);
 | 
	
		
			
				|  |  | +        if (socialUser == null) {
 | 
	
		
			
				|  |  | +            throw exception(AUTH_SOCIAL_USER_NOT_FOUND);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //如果同一个微信绑定了多个用户就返回用户集 供用户选择登录
 | 
	
		
			
				|  |  | +        if(socialUser.getUserIds().size() != 1){
 | 
	
		
			
				|  |  | +            List<MemberUserDO> users = userService.getUserList(socialUser.getUserIds());
 | 
	
		
			
				|  |  | +            List<AppAuthMemberUserRespVO> memberUserRespVOS = users.stream().map(user -> AppAuthMemberUserRespVO
 | 
	
		
			
				|  |  | +                    .builder()
 | 
	
		
			
				|  |  | +                    .username(user.getUsername())
 | 
	
		
			
				|  |  | +                    .avatar(user.getAvatar())
 | 
	
		
			
				|  |  | +                    .build())
 | 
	
		
			
				|  |  | +                    .collect(Collectors.toList());
 | 
	
		
			
				|  |  | +            return AppAuthLoginRespVO.builder().socialUsers(memberUserRespVOS).build();
 | 
	
		
			
				|  |  | +        }else{
 | 
	
		
			
				|  |  | +            //如果只有一个账号那就直接登录
 | 
	
		
			
				|  |  | +            socialUser.setUserId(socialUser.getUserIds().get(0));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        MemberUserDO user = userService.getUser(socialUser.getUserId());
 | 
	
		
			
				|  |  | +        if (user == null) {
 | 
	
		
			
				|  |  | +            throw exception(USER_NOT_EXISTS);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 创建 Token 令牌,记录登录日志
 | 
	
		
			
				|  |  | +        return createTokenAfterLoginSuccess(user, user.getMobile(), LoginLogTypeEnum.LOGIN_SOCIAL, socialUser.getOpenid());
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public AppAuthLoginRespVO selectUsernameLogin(AppAuthSelectUsernameLoginReqVO reqVO) {
 | 
	
		
			
				|  |  | +        MemberUserDO user = userService.selectByUsername(reqVO.getUsername());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //如果微信绑定的账号中没有此账号那就返回报错
 | 
	
		
			
				|  |  | +        Boolean flag = socialUserApi.wxIsBindByUserId(reqVO.getOpenId(), user.getId());
 | 
	
		
			
				|  |  | +        if(!flag){
 | 
	
		
			
				|  |  | +            throw exception(AUTH_SOCIAL_USER_BIND_USER_NOT_FOUND);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return createTokenAfterLoginSuccess(user, user.getMobile(), LoginLogTypeEnum.LOGIN_SOCIAL, reqVO.getOpenId());
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public AppAuthLoginRespVO weixinMiniAppLogin(AppAuthWeixinMiniAppLoginReqVO reqVO) {
 | 
	
		
			
				|  |  |          // 获得对应的手机号信息
 |