Authored by qinchao

Merge branch 'hotfix-zhimacall0603' into test6.9.6

... ... @@ -24,12 +24,15 @@ public interface IZhiMaCertDao {
ZhiMaCert selectValidByUid(int uid);
//最近的一条未授权的数据
ZhiMaCert selectLatestUnAuthorizeByUid(int uid);
ZhiMaCert selectValidByCertNo(String certNo);
//根据业务编号查询
ZhiMaCert selectByBizNo(@Param("bizNo")String bizNo);
int deleteByUid(int uid);
//int deleteByUid(int uid);
//根据业务编号查询
List<ZhiMaCert> selectTopCountValidStatusAndValidPhotoStatus(@Param("validStatus")int validStatus,@Param("validPhoto")int validPhoto,@Param("topCount")int topCount);
... ...
... ... @@ -11,7 +11,7 @@ public class ZhiMaCert {
//uid ,索引
private Integer uid;
//生效状态:1 生效 ; 0 不生效
//生效状态:'9:未授权(初始值), 1:有效, 0:已失效(删除或者解绑)
private Integer validStatus;
//身份证图片已传:1 生效 ;2 生效,但是未实际ocr校验, 0 不生效
... ...
... ... @@ -33,6 +33,14 @@
order by id desc limit 1
</select>
<select id="selectLatestUnAuthorizeByUid" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from zhima_cert
where uid = #{uid} and valid_status = 9
order by id desc limit 1
</select>
<select id="selectValidByCertNo" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
... ... @@ -90,11 +98,13 @@
where id = #{id}
</update>
<!--
<delete id="deleteByUid" parameterType="java.lang.Integer">
update zhima_cert
set valid_status = 0
where uid = #{uid}
</delete>
-->
<select id="selectTopCountValidStatusAndValidPhotoStatus" resultMap="BaseResultMap">
select
... ...
... ... @@ -22,7 +22,7 @@ public interface IRealNameAuthorizeService {
boolean isValidZhiMaCert(int uid);
int clearZhiMaCertInfo(Integer uid);
//int clearZhiMaCertInfo(Integer uid);
ZhiMaCert getValidZhiMaCert(int uid);
... ...
... ... @@ -48,6 +48,7 @@ import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
... ... @@ -299,7 +300,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
/**
* 清芝麻认证的缓存信息
*/
@Override
/*@Override
public int clearZhiMaCertInfo(Integer uid){
logger.info("RealNameAuthorizeServiceImpl clearCacheZhiMaCertInfo uid is {} ", uid);
int result = 0;
... ... @@ -310,7 +311,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
cacheService.delZhiMaCert(uid);
}
return result;
}
}*/
@Override
public ZhiMaCert getValidZhiMaCert(int uid) {
... ... @@ -328,6 +329,42 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
if (zhiMaCert != null) {
//保存到redis
cacheService.setZhiMaCert(zhiMaCert);
}else{
//根据uid查询最近一条芝麻认证没通过的数据数据:
// 如果没有主动请求过&&ocr通过了 ,再根据biz_no获取支付宝结果 ,
// 最后打个标记,代表已经请求过一次,后续不再请求
// 暂时不打标志了 ,请求一次时间也不长 ,后续再观察下,看看时间情况
ZhiMaCert zhiMaCert_check_again = zhiMaCertDao.selectLatestUnAuthorizeByUid(uid);
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MILLISECOND, 0);
Long today_zero=c.getTimeInMillis()/1000;
//当天至少请求过一次实名认证,并且是当天的数据
//String dayStr = getStringDate("yyyyMMdd");
//Long count = cacheService.getPhotoCheckCount(dayStr,uid);
logger.info("getValidZhiMaCert recall zhiMaCertResultQuery enter uid is {} zhiMaCert_check_again {}",uid,zhiMaCert_check_again);
if(zhiMaCert_check_again!=null&&StringUtils.isNotBlank(zhiMaCert_check_again.getBizNo())
&&CertPhotoEnum.isValidStatus(zhiMaCert_check_again.getValidPhoto())
&&zhiMaCert_check_again.getCreateTime()>=today_zero
){
ZhimaCustomerCertificationQueryResponse zhiMaResp=ZhiMaCallUtil.zhiMaResult(zhiMaCert_check_again.getBizNo());
logger.info("getValidZhiMaCert recall zhiMaCertResultQuery enter result is {},zhiMaCert_check_again {}",JSON.toJSONString(zhiMaResp),zhiMaCert_check_again);
if(zhiMaResp!=null&&zhiMaResp.isSuccess()&&"true".equals(zhiMaResp.getPassed())){
//芝麻认证通过
int updateCount = zhiMaCertDao.updateValidStatusByPrimaryKey(zhiMaCert_check_again.getId());
logger.info("getValidZhiMaCert recall zhiMaCertResultQuery updateCount {} ,result is {},zhiMaCert_check_again {}",updateCount ,JSON.toJSONString(zhiMaResp),zhiMaCert_check_again);
if(updateCount>=1){
zhiMaCert = zhiMaCertDao.selectValidByUid(uid);
if (zhiMaCert != null) {
//保存到redis
cacheService.setZhiMaCert(zhiMaCert);
}
}
}
}
}
return zhiMaCert;
}
... ... @@ -545,7 +582,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
//存储认证信息
ZhiMaCert zhiMaCert = new ZhiMaCert();
zhiMaCert.setUid(reqVO.getUid());
zhiMaCert.setValidStatus(0);//用户还未授权,暂时未生效
zhiMaCert.setValidStatus(9);//用户还未授权,暂时未生效 ,初始值为9
zhiMaCert.setCertName(reqVO.getCertName());
zhiMaCert.setCertNo(reqVO.getCertNo());
zhiMaCert.setCreateTime(nowSecond);
... ...