@ -19,8 +19,6 @@ import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils ;
import com.epmet.commons.tools.exception.RenException ;
import com.epmet.commons.tools.feign.ResultDataResolver ;
import com.epmet.commons.tools.redis.RedisKeys ;
import com.epmet.commons.tools.redis.RedisUtils ;
import com.epmet.commons.tools.redis.common.CustomerDingDingRedis ;
import com.epmet.commons.tools.redis.common.bean.DingMiniInfoCache ;
import com.epmet.commons.tools.security.dto.GovTokenDto ;
@ -91,8 +89,6 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
@Autowired
private LoginUserUtil loginUserUtil ;
@Autowired
private RedisUtils redisUtils ;
@Autowired
private DingTalkClientToken dingTalkClientToken ;
@Autowired
private DingTalkClientUser dingTalkClientUser ;
@ -648,42 +644,11 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
result . getMsg ( ) ) ) ;
return new ArrayList < > ( ) ;
}
//临时解决方案
private static final List < StaffOrgsResultDTO > resultTemp = new ArrayList < > ( ) ;
static {
StaffOrgsResultDTO t = new StaffOrgsResultDTO ( ) ;
t . setRootAgencyId ( "53613e1c5de6ed473467f0159a10b135" ) ;
t . setRootAgencyName ( "平阴县" ) ;
t . setCustomerId ( "6f203e30de1a65aab7e69c058826cd80" ) ;
t . setCustomerName ( "平音" ) ;
resultTemp . add ( t ) ;
}
@Override
public List < StaffOrgsResultDTO > getMyOrgByAccount ( ThirdStaffOrgByAccountFormDTO formDTO ) {
String appId = formDTO . getAppId ( ) ;
String userAccount = formDTO . getUserAccount ( ) ;
String password = formDTO . getPassword ( ) ;
//{"code":0,"msg":"success","internalMsg":"","data":[{"rootAgencyId":"53613e1c5de6ed473467f0159a10b135","rootAgencyName":"平阴县","customerId":"6f203e30de1a65aab7e69c058826cd80","customerName":"平音"}]}
if ( "wx2b75d556ba867750" . equals ( appId ) ) {
if ( "18700011111" . equals ( userAccount ) ) {
if ( ! "Py02222" . equals ( password ) ) {
throw new RenException ( EpmetErrorCode . PASSWORD_ERROR . getCode ( ) ) ;
}
//String result = "[{\"rootAgencyId\":\"53613e1c5de6ed473467f0159a10b135\",\"rootAgencyName\":\"平阴县\",\"customerId\":\"6f203e30de1a65aab7e69c058826cd80\",\"customerName\":\"平音\"}]";
return resultTemp ;
}
if ( userAccount . startsWith ( "187000111" ) ) {
throw new EpmetException ( EpmetErrorCode . GOV_STAFF_ACCOUNT_NOT_EXISTS . getCode ( ) ) ;
}
}
//{"isNovice":false,"mobile":"","userAccount":"18700011111","password":"Py011111","appId":"wx2b75d556ba867750"}
logger . info ( "getMyOrgByAccountService at :{}" , System . currentTimeMillis ( ) ) ;
long start = System . currentTimeMillis ( ) ;
//0.根据appId查询对应客户Id
PaCustomerDTO customer = this . getCustomerInfo ( formDTO . getAppId ( ) ) ;
logger . info ( "getMyOrgByAccountService getCustomerInfo cost:{}" , System . currentTimeMillis ( ) - start ) ;
start = System . currentTimeMillis ( ) ;
//7.28 上边根据appId只能锁定一条客户id,后边的批量循环操作暂不做调整,还是使用之前的代码 sun
//1、根据手机号查询到用户信息
ThirdCustomerStaffByAccountFormDTO dto = new ThirdCustomerStaffByAccountFormDTO ( ) ;
@ -694,31 +659,30 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
logger . warn ( String . format ( "账户密码登录异常,账户[%s],code[%s],msg[%s]" , formDTO . getUserAccount ( ) , customerStaffResult . getCode ( ) , customerStaffResult . getMsg ( ) ) ) ;
throw new RenException ( customerStaffResult . getCode ( ) ) ;
}
logger . info ( "getMyOrgByAccountService getCustsomerStaffByIdAndAccount cost:{}" , System . currentTimeMillis ( ) - start ) ;
start = System . currentTimeMillis ( ) ;
//2、密码是否正确
List < CustomerStaffDTO > customerStaffList = customerStaffResult . getData ( ) ;
if ( CollectionUtils . isEmpty ( customerStaffList ) ) {
throw new EpmetException ( EpmetErrorCode . GOV_STAFF_ACCOUNT_NOT_EXISTS . getCode ( ) ) ;
}
//3、查询用户所有的组织信息
List < String > customerIdList = new ArrayList < > ( ) ;
//是否设置过密码
boolean havePasswordFlag = false ;
//密码是否正确
boolean passwordRightFlag = false ;
CustomerStaffDTO customerStaffDTO = customerStaffList . get ( 0 ) ;
for ( CustomerStaffDTO customerStaffDTO : customerStaffList ) {
if ( StringUtils . isNotBlank ( customerStaffDTO . getPassword ( ) ) ) {
havePasswordFlag = true ;
} else {
logger . warn ( String . format ( "当前用户:账户%s,客户Id%s下未设置密码." , formDTO . getUserAccount ( ) , customerStaffDTO . getCustomerId ( ) ) ) ;
continue ;
}
if ( ! PasswordUtils . matches ( formDTO . getPassword ( ) , customerStaffDTO . getPassword ( ) ) ) {
logger . warn ( String . format ( "当前用户:账户%s,客户Id%s密码匹配错误." , formDTO . getUserAccount ( ) , customerStaffDTO . getCustomerId ( ) ) ) ;
if ( StringUtils . isNotBlank ( customerStaffDTO . getPassword ( ) ) ) {
havePasswordFlag = true ;
}
long start2 = System . currentTimeMillis ( ) ;
if ( PasswordUtils . matches ( formDTO . getPassword ( ) , customerStaffDTO . getPassword ( ) ) ) {
passwordRightFlag = true ;
customerIdList . add ( customerStaffDTO . getCustomerId ( ) ) ;
} else {
logger . warn ( String . format ( "当前用户:账户%s,客户Id%s密码匹配正确." , formDTO . getUserAccount ( ) , customerStaffDTO . getCustomerId ( ) ) ) ;
passwordRightFlag = true ;
customerIdList . add ( customerStaffDTO . getCustomerId ( ) ) ;
}
}
logger . info ( "getMyOrgByAccountService PasswordUtils.matches cost:{}" , System . currentTimeMillis ( ) - start2 ) ;
//根据手机号查出来所有用户,密码都为空,表明用户未激活账户,未设置密码
if ( ! havePasswordFlag ) {
logger . warn ( String . format ( "当前账户(%s)下所有账户都未设置密码,请先使用验证码登录激活账户" , formDTO . getUserAccount ( ) ) ) ;
@ -729,27 +693,11 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
logger . warn ( String . format ( "根据当前账户(%s)密码未找到所属组织,密码错误" , formDTO . getUserAccount ( ) ) ) ;
throw new RenException ( EpmetErrorCode . PASSWORD_ERROR . getCode ( ) ) ;
}
logger . info ( "getMyOrgByAccountService checkpassword cost:{}" , System . currentTimeMillis ( ) - start ) ;
start = System . currentTimeMillis ( ) ;
String tempKey = RedisKeys . getCustomerStaffTempKey ( customerStaffDTO . getUserId ( ) ) ;
List < StaffOrgsResultDTO > redisTemp = ( List < StaffOrgsResultDTO > ) redisUtils . get ( tempKey ) ;
if ( redisTemp ! = null ) {
logger . info ( "getMyOrgByAccountService end redis :{}" , System . currentTimeMillis ( ) ) ;
return redisTemp ;
}
logger . info ( "getMyOrgByAccountService getCustomerStaffTempKey cost:{}" , System . currentTimeMillis ( ) - start ) ;
start = System . currentTimeMillis ( ) ;
StaffOrgFormDTO staffOrgFormDTO = new StaffOrgFormDTO ( ) ;
staffOrgFormDTO . setCustomerIdList ( customerIdList ) ;
Result < List < StaffOrgsResultDTO > > result = govOrgOpenFeignClient . getStaffOrgList ( staffOrgFormDTO ) ;
if ( result . success ( ) & & null ! = result . getData ( ) ) {
List < StaffOrgsResultDTO > data = result . getData ( ) ;
logger . info ( "getMyOrgByAccountService getStaffOrgList from db cost:{}" , System . currentTimeMillis ( ) - start ) ;
start = System . currentTimeMillis ( ) ;
redisUtils . set ( tempKey , data ) ;
logger . info ( "getMyOrgByAccountService getCustomerStaffTempKey set redis cost:{}" , System . currentTimeMillis ( ) - start ) ;
logger . info ( "getMyOrgByAccountService end DB :{}" , System . currentTimeMillis ( ) ) ;
return data ;
return result . getData ( ) ;
}
logger . warn ( String . format ( "手机验证码获取组织,调用%s服务失败,入参账户%s,密码%s,返回错误码%s,错误提示信息%s" ,
ServiceConstant . GOV_ORG_SERVER ,
@ -766,11 +714,6 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
* @author zxc
* /
public PaCustomerDTO getCustomerInfo ( String appId ) {
String redisKey = RedisKeys . getThirdCustomerInfoByAppId ( appId ) ;
PaCustomerDTO customer = ( PaCustomerDTO ) redisUtils . get ( redisKey ) ;
if ( customer ! = null & & StringUtils . isNotBlank ( customer . getId ( ) ) ) {
return customer ;
}
JSONObject jsonObject = new JSONObject ( ) ;
String data = HttpClientManager . getInstance ( ) . sendPostByJSON ( AuthHttpUrlConstant . CUSTOMER_MSG_URL + appId , JSON . toJSONString ( jsonObject ) ) . getData ( ) ;
logger . info ( "ThirdLoginServiceImpl.getCustomerInfo:httpclient->url:" + AuthHttpUrlConstant . CUSTOMER_MSG_URL + ",结果->" + data ) ;
@ -786,9 +729,8 @@ public class ThirdLoginServiceImpl implements ThirdLoginService, ResultDataResol
Object PublicCustomerResultDTO = mapToResult . getData ( ) ;
JSONObject json = JSON . parseObject ( PublicCustomerResultDTO . toString ( ) ) ;
Map < String , Object > map = ( Map ) json . get ( "customer" ) ;
customer = ConvertUtils . mapToEntity ( map , PaCustomerDTO . class ) ;
PaCustomerDTO customer = ConvertUtils . mapToEntity ( map , PaCustomerDTO . class ) ;
logger . info ( "小程序登陆third服务获取客户用户信息PaCustomerDTO->" + customer ) ;
redisUtils . set ( redisKey , customer ) ;
return customer ;
}