|
|
package com.yohoufo.user.service.impl;
|
|
|
|
|
|
import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
|
|
|
import com.yohoufo.common.utils.UserInfoHiddenHelper;
|
|
|
import com.yohoufo.dal.user.IUserAuthorizeInfoDao;
|
|
|
import com.yohoufo.dal.user.model.UserAuthorizeInfo;
|
|
|
import com.yohoufo.user.cache.CacheService;
|
|
|
import com.yohoufo.user.helper.HideDataUtil;
|
|
|
import com.yohoufo.user.requestVO.RealNameAuthorizeReqVO;
|
|
|
import com.yohoufo.user.service.IRealNameAuthorizeService;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -19,7 +22,7 @@ import java.time.ZoneOffset; |
|
|
*/
|
|
|
@Service("realNameAuthorizeServiceImpl")
|
|
|
public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
|
|
|
private Logger logger = LoggerFactory.getLogger(RealNameAuthorizeServiceImpl.class);
|
|
|
private static final Logger logger = LoggerFactory.getLogger(RealNameAuthorizeServiceImpl.class);
|
|
|
|
|
|
@Autowired
|
|
|
private IUserAuthorizeInfoDao userAuthorizeInfoDao;
|
...
|
...
|
@@ -58,7 +61,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
|
}
|
|
|
|
|
|
//如果不存在,则从数据库获取
|
|
|
authorizeInfo= userAuthorizeInfoDao.selectValidAuthorizeInfoByUid(uid);
|
|
|
authorizeInfo = userAuthorizeInfoDao.selectValidAuthorizeInfoByUid(uid);
|
|
|
logger.info("RealNameAuthorizeServiceImpl getValidAuthorizeInfo uid is {} ,database info is {} ",uid,authorizeInfo);
|
|
|
if(authorizeInfo!=null){
|
|
|
//保存到redis
|
...
|
...
|
@@ -90,6 +93,76 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { |
|
|
cacheService.setUserAuthorizeInfo( userAuthorizeInfo);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void saveAuthorizeInfoNew(RealNameAuthorizeReqVO reqVO) {
|
|
|
|
|
|
logger.info("enter saveAuthorizeInfoNew reqVO = {}", reqVO);
|
|
|
int uid = reqVO.getUid();
|
|
|
String alipayAccount = reqVO.getAlipayAccount();
|
|
|
String certName = reqVO.getCertName();
|
|
|
String alipayUid = reqVO.getAlipayUid();
|
|
|
|
|
|
UserAuthorizeInfo userAuthorizeInfo =new UserAuthorizeInfo();
|
|
|
userAuthorizeInfo.setUid(uid);
|
|
|
userAuthorizeInfo.setValidStatus(1);
|
|
|
userAuthorizeInfo.setAlipayAccount(alipayAccount);
|
|
|
userAuthorizeInfo.setCertName(certName);
|
|
|
userAuthorizeInfo.setAlipayUid(alipayUid);
|
|
|
long create_time = System.currentTimeMillis() /1000;
|
|
|
userAuthorizeInfo.setCreateTime(create_time);
|
|
|
|
|
|
userAuthorizeInfoDao.insertSelective(userAuthorizeInfo);
|
|
|
logger.info("real name saveAuthorizeInfo success ,reqVO= {}", reqVO);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据uid 查询用户绑定的支付宝信息
|
|
|
* 旧版本:没有存alipayId(支付宝userId)
|
|
|
* 新版本:有alipayId
|
|
|
* @param uid
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public AuthorizeResultRespVO queryAuthorizeInfo(Integer uid) {
|
|
|
//获取
|
|
|
UserAuthorizeInfo info = getValidAuthorizeInfo(uid);
|
|
|
//封装结果
|
|
|
AuthorizeResultRespVO result = new AuthorizeResultRespVO();
|
|
|
result.setUid(uid);
|
|
|
if(null == info){//没有实名认证
|
|
|
result.setAuthorizeFlag(false);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
result.setAuthorizeFlag(true);
|
|
|
//支付宝userId
|
|
|
if(StringUtils.isNotBlank( info.getAlipayUid())){
|
|
|
result.setAlipayId(info.getAlipayUid());
|
|
|
}
|
|
|
|
|
|
//支付宝账户信息
|
|
|
if(StringUtils.isNotBlank(info.getAlipayAccount())){
|
|
|
result.setAlipayAccount(info.getAlipayAccount());
|
|
|
//把账号部分信息隐藏
|
|
|
if(HideDataUtil.isEmail(info.getAlipayAccount())){
|
|
|
result.setAlipayMaskAccount(HideDataUtil.hideEmail(info.getAlipayAccount()));
|
|
|
}else if(UserInfoHiddenHelper.isPhone(info.getAlipayAccount())){
|
|
|
result.setAlipayMaskAccount(UserInfoHiddenHelper.hidePhoneNo(info.getAlipayAccount()));
|
|
|
}else if(info.getAlipayAccount().length()>2){
|
|
|
//即不是手机,又不是邮箱,只显示首末位
|
|
|
result.setAlipayMaskAccount(info.getAlipayAccount().substring(0,1) + "****"
|
|
|
+ info.getAlipayAccount().substring(info.getAlipayAccount().length()-1));
|
|
|
}else{
|
|
|
result.setAlipayMaskAccount(info.getAlipayAccount());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
result.setCertName(info.getCertName());
|
|
|
result.setCreateTime(info.getCreateTime());
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
private LocalDateTime getLocalDateTime(){
|
|
|
LocalDateTime now=LocalDateTime.now();
|
...
|
...
|
|