Authored by qinchao

身份证号隐藏处理

... ... @@ -8,6 +8,7 @@ import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.resp.SellerResp;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.constant.CertPhotoEnum;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.StoredSellerMapper;
import com.yohoufo.dal.order.SuperEntrySellerMapper;
... ... @@ -140,8 +141,30 @@ public class StoreSellerServiceImpl implements IStoredSellerService {
sellerResp.setZhiMaCertWithPhoto(isZhiMaCertWithPhoto);//新的芝麻认证状态(带身份证图片)
//把已认证的信息带回去,给app
if(zhiMaCert!=null){
sellerResp.setCertName(zhiMaCert.getCertName());
sellerResp.setCertNo(zhiMaCert.getCertNo());
//mask处理,姓名只显示最后一个字,身份证号只显示3位******2位
if(StringUtils.isBlank(zhiMaCert.getCertName())||StringUtils.isBlank(zhiMaCert.getCertNo())){
throw new UfoServiceException(400,"芝麻认证信息数据异常");
}
StringBuilder maskCertName=new StringBuilder();
StringBuilder maskCertNo=new StringBuilder();
String name=zhiMaCert.getCertName();
for(int i=0;i<name.length();i++){
if(i==name.length()-1){
maskCertName.append(name.substring(i,i+1));
}else{
maskCertName.append("*");
}
}
String no=zhiMaCert.getCertNo();
for(int i=0;i<no.length();i++){
if(i<3||i>=16){
maskCertNo.append(no.substring(i,i+1));
}else{
maskCertNo.append("*");
}
}
sellerResp.setCertName(maskCertName.toString());
sellerResp.setCertNo(maskCertNo.toString());
}else{
sellerResp.setCertName(StringUtils.EMPTY);
sellerResp.setCertNo(StringUtils.EMPTY);
... ...
... ... @@ -168,13 +168,22 @@ public class RealNameAuthorizeController {
throw new GatewayException(400, "uid不能为空!");
}
if ( StringUtils.isEmpty(reqVO.getCertNo())|| StringUtils.isEmpty(reqVO.getCertName())){
throw new GatewayException(400, "身份证号、姓名不能为空!");
}
//是否存在芝麻认证信息
ZhiMaCert zhiMaCert =realNameAuthorizeService.getValidZhiMaCert(reqVO.getUid());
if(zhiMaCert!=null){
//前端传过来的是mask的身份证号,用数据库的替换
reqVO.setCertName(zhiMaCert.getCertName());
reqVO.setCertNo(zhiMaCert.getCertNo());
logger.info("realNameAuthorize.zhiMaCertWithPhotoCheckInit reset mask ,zhiMaCert {} ,new reqVO is {}", zhiMaCert ,reqVO);
}else{
if ( StringUtils.isEmpty(reqVO.getCertNo())|| StringUtils.isEmpty(reqVO.getCertName())){
throw new GatewayException(400, "身份证号、姓名不能为空!");
}
//身份证格式校验IDCardUtils
if(!IDCardUtils.validate(reqVO.getCertNo())){
throw new GatewayException(400, "身份证号输入不正确!");
//身份证格式校验IDCardUtils
if(!IDCardUtils.validate(reqVO.getCertNo())){
throw new GatewayException(400, "身份证号输入不正确!");
}
}
//身份证图片,必须
... ... @@ -191,7 +200,7 @@ public class RealNameAuthorizeController {
reqVO.setBackImageUrl(yohoCardUrlPre+reqVO.getBackImageUrl());
//调用芝麻,得到回调url
AuthorizeResultRespVO resultVo=realNameAuthorizeService.zhiMaCertWithPhotoInit(reqVO);
AuthorizeResultRespVO resultVo=realNameAuthorizeService.zhiMaCertWithPhotoInit(zhiMaCert,reqVO);
logger.info("realNameAuthorize.zhiMaCertWithPhotoCheckInit result vo {} ",resultVo);
ApiResponse apiResponse=new ApiResponse();
if(resultVo==null){
... ...
... ... @@ -23,7 +23,7 @@ public interface IRealNameAuthorizeService {
ZhiMaCert getValidZhiMaCert(int uid);
AuthorizeResultRespVO zhiMaCertWithPhotoInit(RealNameAuthorizeReqVO reqVO);
AuthorizeResultRespVO zhiMaCertWithPhotoInit(ZhiMaCert zhiMaCert,RealNameAuthorizeReqVO reqVO);
AuthorizeResultRespVO zhiMaCertInit(RealNameAuthorizeReqVO reqVO);
... ...
... ... @@ -469,11 +469,11 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
}
@Override
public AuthorizeResultRespVO zhiMaCertWithPhotoInit(RealNameAuthorizeReqVO reqVO){
public AuthorizeResultRespVO zhiMaCertWithPhotoInit(ZhiMaCert zhiMaCert,RealNameAuthorizeReqVO reqVO){
logger.info("real name zhiMaCertWithPhotoInit reqVO {}", reqVO);
boolean justCheckPhoto = false;
int uid = reqVO.getUid();
ZhiMaCert zhiMaCert = this.getValidZhiMaCert(uid);
if(zhiMaCert!=null){
if(zhiMaCert.getValidPhoto()!=null&&CertPhotoEnum.valid.getStatus()==zhiMaCert.getValidPhoto()){
//已经有照片了,并且照片已经认证过了
... ...