|
|
package com.yohoufo.user.service.impl;
|
|
|
|
|
|
import com.alipay.api.response.AlipayUserCertifyOpenQueryResponse;
|
|
|
import com.alipay.api.response.ZhimaCustomerCertificationQueryResponse;
|
|
|
import com.yoho.tools.common.beans.ApiResponse;
|
|
|
import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
|
|
|
import com.yohoufo.common.constant.CertPhotoEnum;
|
|
|
import com.yohoufo.common.exception.UfoServiceException;
|
|
|
import com.yohoufo.dal.user.IZhiMaCertDao;
|
|
|
import com.yohoufo.dal.user.model.ZhiMaCert;
|
|
|
import com.yohoufo.user.helper.AlipayCertificationHelper;
|
|
|
import com.yohoufo.user.requestVO.RealNameAuthorizeReqVO;
|
|
|
import com.yohoufo.user.service.ICertificationService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -26,6 +31,7 @@ public class CertificationServiceImpl implements ICertificationService { |
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(CertificationServiceImpl.class);
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
private IZhiMaCertDao zhiMaCertDao;
|
|
|
|
...
|
...
|
@@ -76,6 +82,37 @@ public class CertificationServiceImpl implements ICertificationService { |
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ApiResponse queryUserCertify(RealNameAuthorizeReqVO reqVO) {
|
|
|
try {
|
|
|
logger.info("queryUserCertify: enter. reqVO is {}", reqVO);
|
|
|
//(1) 根据 bizNo 查询认证信息是否存在
|
|
|
ZhiMaCert zhiMaCert = zhiMaCertDao.selectByBizNo(reqVO.getZhiMaBizNo());
|
|
|
if (zhiMaCert == null || StringUtils.isEmpty(zhiMaCert.getBizNo())) {
|
|
|
logger.warn("queryUserCertify: certInfo is null. reqVO is {}", reqVO);
|
|
|
throw new UfoServiceException(400, "未找到身份认证信息!");
|
|
|
}
|
|
|
//(2) 身份认证结果获取(调用支付宝接口)并更新
|
|
|
AlipayUserCertifyOpenQueryResponse response = AlipayCertificationHelper.alipayCertifyResult(zhiMaCert.getBizNo());
|
|
|
logger.info("queryUserCertify: queryUserCert by alipay success. reqVO is {}, certResult is {}", reqVO, response);
|
|
|
if(response.isSuccess() && "T".equals(response.getPassed().get(0))){
|
|
|
int updateCount = zhiMaCertDao.updateValidStatusByPrimaryKey(zhiMaCert.getId());
|
|
|
if(updateCount < 1){
|
|
|
logger.warn("queryUserCertify: update certResult fail. reqVO is {}", reqVO);
|
|
|
throw new UfoServiceException(400, "更新身份认证结果失败!");
|
|
|
}
|
|
|
logger.info("queryUserCertify: userCert pass. reqVO is {}, certResult is {}", reqVO, response);
|
|
|
return new ApiResponse<>(true);
|
|
|
}else{
|
|
|
String errorMsg = response.getSubMsg();//认证不通过可能是出现异常情况
|
|
|
logger.info("queryUserCertify: userCert notPass. reqVO is {}, certResult is {}", reqVO, response);
|
|
|
return new ApiResponse<>(400, StringUtils.isEmpty(errorMsg) ? "身份认证不通过" : errorMsg ,false);
|
|
|
}
|
|
|
}catch(Exception e){
|
|
|
logger.warn("queryUserCertify: error. reqVO is {}, e is {}", reqVO, e);
|
|
|
throw new UfoServiceException(400, "查询身份认证结果失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|