Authored by qinchao

Merge branch 'hotfix-zhimacall0603' into test6.9.6

@@ -24,12 +24,15 @@ public interface IZhiMaCertDao { @@ -24,12 +24,15 @@ public interface IZhiMaCertDao {
24 24
25 ZhiMaCert selectValidByUid(int uid); 25 ZhiMaCert selectValidByUid(int uid);
26 26
  27 + //最近的一条未授权的数据
  28 + ZhiMaCert selectLatestUnAuthorizeByUid(int uid);
  29 +
27 ZhiMaCert selectValidByCertNo(String certNo); 30 ZhiMaCert selectValidByCertNo(String certNo);
28 31
29 //根据业务编号查询 32 //根据业务编号查询
30 ZhiMaCert selectByBizNo(@Param("bizNo")String bizNo); 33 ZhiMaCert selectByBizNo(@Param("bizNo")String bizNo);
31 34
32 - int deleteByUid(int uid); 35 + //int deleteByUid(int uid);
33 36
34 //根据业务编号查询 37 //根据业务编号查询
35 List<ZhiMaCert> selectTopCountValidStatusAndValidPhotoStatus(@Param("validStatus")int validStatus,@Param("validPhoto")int validPhoto,@Param("topCount")int topCount); 38 List<ZhiMaCert> selectTopCountValidStatusAndValidPhotoStatus(@Param("validStatus")int validStatus,@Param("validPhoto")int validPhoto,@Param("topCount")int topCount);
@@ -11,7 +11,7 @@ public class ZhiMaCert { @@ -11,7 +11,7 @@ public class ZhiMaCert {
11 //uid ,索引 11 //uid ,索引
12 private Integer uid; 12 private Integer uid;
13 13
14 - //生效状态:1 生效 ; 0 不生效 14 + //生效状态:'9:未授权(初始值), 1:有效, 0:已失效(删除或者解绑)
15 private Integer validStatus; 15 private Integer validStatus;
16 16
17 //身份证图片已传:1 生效 ;2 生效,但是未实际ocr校验, 0 不生效 17 //身份证图片已传:1 生效 ;2 生效,但是未实际ocr校验, 0 不生效
@@ -33,6 +33,14 @@ @@ -33,6 +33,14 @@
33 order by id desc limit 1 33 order by id desc limit 1
34 </select> 34 </select>
35 35
  36 + <select id="selectLatestUnAuthorizeByUid" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  37 + select
  38 + <include refid="Base_Column_List" />
  39 + from zhima_cert
  40 + where uid = #{uid} and valid_status = 9
  41 + order by id desc limit 1
  42 + </select>
  43 +
36 <select id="selectValidByCertNo" resultMap="BaseResultMap" parameterType="java.lang.String" > 44 <select id="selectValidByCertNo" resultMap="BaseResultMap" parameterType="java.lang.String" >
37 select 45 select
38 <include refid="Base_Column_List" /> 46 <include refid="Base_Column_List" />
@@ -90,11 +98,13 @@ @@ -90,11 +98,13 @@
90 where id = #{id} 98 where id = #{id}
91 </update> 99 </update>
92 100
  101 + <!--
93 <delete id="deleteByUid" parameterType="java.lang.Integer"> 102 <delete id="deleteByUid" parameterType="java.lang.Integer">
94 update zhima_cert 103 update zhima_cert
95 set valid_status = 0 104 set valid_status = 0
96 where uid = #{uid} 105 where uid = #{uid}
97 </delete> 106 </delete>
  107 + -->
98 108
99 <select id="selectTopCountValidStatusAndValidPhotoStatus" resultMap="BaseResultMap"> 109 <select id="selectTopCountValidStatusAndValidPhotoStatus" resultMap="BaseResultMap">
100 select 110 select
@@ -22,7 +22,7 @@ public interface IRealNameAuthorizeService { @@ -22,7 +22,7 @@ public interface IRealNameAuthorizeService {
22 22
23 boolean isValidZhiMaCert(int uid); 23 boolean isValidZhiMaCert(int uid);
24 24
25 - int clearZhiMaCertInfo(Integer uid); 25 + //int clearZhiMaCertInfo(Integer uid);
26 26
27 ZhiMaCert getValidZhiMaCert(int uid); 27 ZhiMaCert getValidZhiMaCert(int uid);
28 28
@@ -48,6 +48,7 @@ import java.text.SimpleDateFormat; @@ -48,6 +48,7 @@ import java.text.SimpleDateFormat;
48 import java.time.LocalDateTime; 48 import java.time.LocalDateTime;
49 import java.time.ZoneOffset; 49 import java.time.ZoneOffset;
50 import java.util.ArrayList; 50 import java.util.ArrayList;
  51 +import java.util.Calendar;
51 import java.util.Date; 52 import java.util.Date;
52 import java.util.List; 53 import java.util.List;
53 import java.util.concurrent.TimeUnit; 54 import java.util.concurrent.TimeUnit;
@@ -299,7 +300,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { @@ -299,7 +300,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
299 /** 300 /**
300 * 清芝麻认证的缓存信息 301 * 清芝麻认证的缓存信息
301 */ 302 */
302 - @Override 303 + /*@Override
303 public int clearZhiMaCertInfo(Integer uid){ 304 public int clearZhiMaCertInfo(Integer uid){
304 logger.info("RealNameAuthorizeServiceImpl clearCacheZhiMaCertInfo uid is {} ", uid); 305 logger.info("RealNameAuthorizeServiceImpl clearCacheZhiMaCertInfo uid is {} ", uid);
305 int result = 0; 306 int result = 0;
@@ -310,7 +311,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { @@ -310,7 +311,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
310 cacheService.delZhiMaCert(uid); 311 cacheService.delZhiMaCert(uid);
311 } 312 }
312 return result; 313 return result;
313 - } 314 + }*/
314 315
315 @Override 316 @Override
316 public ZhiMaCert getValidZhiMaCert(int uid) { 317 public ZhiMaCert getValidZhiMaCert(int uid) {
@@ -328,6 +329,42 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { @@ -328,6 +329,42 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
328 if (zhiMaCert != null) { 329 if (zhiMaCert != null) {
329 //保存到redis 330 //保存到redis
330 cacheService.setZhiMaCert(zhiMaCert); 331 cacheService.setZhiMaCert(zhiMaCert);
  332 + }else{
  333 + //根据uid查询最近一条芝麻认证没通过的数据数据:
  334 + // 如果没有主动请求过&&ocr通过了 ,再根据biz_no获取支付宝结果 ,
  335 + // 最后打个标记,代表已经请求过一次,后续不再请求
  336 + // 暂时不打标志了 ,请求一次时间也不长 ,后续再观察下,看看时间情况
  337 + ZhiMaCert zhiMaCert_check_again = zhiMaCertDao.selectLatestUnAuthorizeByUid(uid);
  338 + Calendar c = Calendar.getInstance();
  339 + c.set(Calendar.HOUR_OF_DAY, 0);
  340 + c.set(Calendar.MINUTE, 0);
  341 + c.set(Calendar.SECOND, 0);
  342 + c.set(Calendar.MILLISECOND, 0);
  343 + Long today_zero=c.getTimeInMillis()/1000;
  344 +
  345 + //当天至少请求过一次实名认证,并且是当天的数据
  346 + //String dayStr = getStringDate("yyyyMMdd");
  347 + //Long count = cacheService.getPhotoCheckCount(dayStr,uid);
  348 + logger.info("getValidZhiMaCert recall zhiMaCertResultQuery enter uid is {} zhiMaCert_check_again {}",uid,zhiMaCert_check_again);
  349 + if(zhiMaCert_check_again!=null&&StringUtils.isNotBlank(zhiMaCert_check_again.getBizNo())
  350 + &&CertPhotoEnum.isValidStatus(zhiMaCert_check_again.getValidPhoto())
  351 + &&zhiMaCert_check_again.getCreateTime()>=today_zero
  352 + ){
  353 + ZhimaCustomerCertificationQueryResponse zhiMaResp=ZhiMaCallUtil.zhiMaResult(zhiMaCert_check_again.getBizNo());
  354 + logger.info("getValidZhiMaCert recall zhiMaCertResultQuery enter result is {},zhiMaCert_check_again {}",JSON.toJSONString(zhiMaResp),zhiMaCert_check_again);
  355 + if(zhiMaResp!=null&&zhiMaResp.isSuccess()&&"true".equals(zhiMaResp.getPassed())){
  356 + //芝麻认证通过
  357 + int updateCount = zhiMaCertDao.updateValidStatusByPrimaryKey(zhiMaCert_check_again.getId());
  358 + logger.info("getValidZhiMaCert recall zhiMaCertResultQuery updateCount {} ,result is {},zhiMaCert_check_again {}",updateCount ,JSON.toJSONString(zhiMaResp),zhiMaCert_check_again);
  359 + if(updateCount>=1){
  360 + zhiMaCert = zhiMaCertDao.selectValidByUid(uid);
  361 + if (zhiMaCert != null) {
  362 + //保存到redis
  363 + cacheService.setZhiMaCert(zhiMaCert);
  364 + }
  365 + }
  366 + }
  367 + }
331 } 368 }
332 return zhiMaCert; 369 return zhiMaCert;
333 } 370 }
@@ -545,7 +582,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService { @@ -545,7 +582,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
545 //存储认证信息 582 //存储认证信息
546 ZhiMaCert zhiMaCert = new ZhiMaCert(); 583 ZhiMaCert zhiMaCert = new ZhiMaCert();
547 zhiMaCert.setUid(reqVO.getUid()); 584 zhiMaCert.setUid(reqVO.getUid());
548 - zhiMaCert.setValidStatus(0);//用户还未授权,暂时未生效 585 + zhiMaCert.setValidStatus(9);//用户还未授权,暂时未生效 ,初始值为9
549 zhiMaCert.setCertName(reqVO.getCertName()); 586 zhiMaCert.setCertName(reqVO.getCertName());
550 zhiMaCert.setCertNo(reqVO.getCertNo()); 587 zhiMaCert.setCertNo(reqVO.getCertNo());
551 zhiMaCert.setCreateTime(nowSecond); 588 zhiMaCert.setCreateTime(nowSecond);