Jelajahi Sumber

fix: 返回redis认证结果多条

lixuesong 3 tahun lalu
induk
melakukan
4c60eeb71f

+ 5 - 18
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/mq/GigSignCertReceiver.java

@@ -288,28 +288,15 @@ public class GigSignCertReceiver extends BaseRabbiMqHandler<String> {
 		}
 		if (CollUtil.isNotEmpty(resultMap)) {
 			String key = CacheConstants.USER_SIGN_CERT_RESPONSE_KEY + user.getUserId();
-			// key已存在,则追加写入新的渠道的状态
-			String qResult = (String) redisTemplate.opsForValue().get(key);
-			if (JSONUtil.isJsonObj(qResult)) {
-				JSONObject qResultObj = JSONUtil.parseObj(qResult);
-				if (o1Map != null) {
-					qResultObj.set(GigTypeEnum.OLADING.name(), o1Map);
-				}
-				if (o2Map != null) {
-					qResultObj.set(GigTypeEnum.JIN_YUAN.name(), o2Map);
-				}
-				redisTemplate.opsForValue().set(key, JSONUtil.toJsonStr(qResultObj), 1, TimeUnit.MINUTES);
-			} else {
-				redisTemplate.opsForValue().set(key, JSONUtil.toJsonStr(resultMap), 1, TimeUnit.MINUTES);
-			}
-
+			redisTemplate.opsForValue().set(key, JSONUtil.toJsonStr(resultMap), 1, TimeUnit.MINUTES);
 		}
 
-		// 处理同时发起时另一个渠道需要的补发情况 TODO
+		// 处理同时发起时另一个渠道需要的补发情况
 		// 查询redis是否有同时发起的标记
 		String redisKey = CacheConstants.OLADING_SEND_BOTH_CHANNEL + user.getUserId();
 		Object userId = redisTemplate.opsForValue().get(redisKey);
-		if (userId != null) {
+		String certStatus = subjectResult.getStr("certStatus");
+		if (userId != null && OladingCommonRequest.UploadTaxpayerAgreementStatus.SUCCESS.name().equals(certStatus)) {
 			// 如果同一人同时存在海南飞亿、金园数科的渠道,则补发一次(由于阿拉钉同一人不同渠道的回调只有一次,所以这里需要补发)
 			log.info("=============================补发阿拉钉另一渠道MQ4==================================");
 			UserSignCertDTO reCertDTO = new UserSignCertDTO();
@@ -376,12 +363,12 @@ public class GigSignCertReceiver extends BaseRabbiMqHandler<String> {
 			}
 		}
 		// 已认证,则设置回调状态
+		// 此处实际是处理核身视频的回调
 		if (OladingCertStatus.CERT.getCode().equals(String.valueOf(userSub.getCertStatus()))) {
 			updateWrapper.set(SysUserSub::getCallbackStatus, GigCallBackStatus.RETURNED);
 		}
 
 		sysUserSubService.update(updateWrapper);
-		// 如果是核身视频回调,则同步该账号的易联-金园数科渠道认证状态 TODO
 
 		return certStatusMap;
 	}

+ 9 - 56
hnqz-upms/hnqz-upms-biz/src/main/java/com/qunzhixinxi/hnqz/admin/service/gig/impl/GigThirdApiServiceImpl.java

@@ -2,7 +2,6 @@ package com.qunzhixinxi.hnqz.admin.service.gig.impl;
 
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.StrUtil;
-import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -13,7 +12,6 @@ import com.qunzhixinxi.hnqz.admin.entity.WmScorePackage;
 import com.qunzhixinxi.hnqz.admin.entity.WmScorePackageSettleNote;
 import com.qunzhixinxi.hnqz.admin.entity.dto.UserSignCertDTO;
 import com.qunzhixinxi.hnqz.admin.enums.GigCallBackStatus;
-import com.qunzhixinxi.hnqz.admin.enums.GigTypeEnum;
 import com.qunzhixinxi.hnqz.admin.enums.OladingCertStatus;
 import com.qunzhixinxi.hnqz.admin.service.SysUserSubService;
 import com.qunzhixinxi.hnqz.admin.service.WmScorePackageService;
@@ -254,15 +252,12 @@ public class GigThirdApiServiceImpl implements GigThirdApiService {
 
 		Map<String, String> subMap = new HashMap<>();
 		SysUserSub updateUserSub = new SysUserSub();
-		OladingCertStatus currentCertStatus;
 		if (OladingCommonRequest.SignUpStatus.SIGN.equals(signUpCertStatus)) {
 			subMap.put("certStatus", OladingCertStatus.SIGNED.name());
 			updateUserSub.setCertStatus(Integer.valueOf(OladingCertStatus.SIGNED.getCode()));
-			currentCertStatus = OladingCertStatus.SIGNED;
 		} else {
 			subMap.put("certStatus", OladingCertStatus.UN_SIGNED.name());
 			updateUserSub.setCertStatus(Integer.valueOf(OladingCertStatus.UN_SIGNED.getCode()));
-			currentCertStatus = OladingCertStatus.UN_SIGNED;
 		}
 		updateUserSub.setId(userSub.getId());
 		updateUserSub.setUpdateTime(LocalDateTime.now());
@@ -278,16 +273,9 @@ public class GigThirdApiServiceImpl implements GigThirdApiService {
 
 		// 结果放到redis
 		String key = CacheConstants.USER_SIGN_CERT_RESPONSE_KEY + userSub.getUserId();
-		String qResult = (String) redisTemplate.opsForValue().get(key);
-		if (JSONUtil.isJsonObj(qResult)) {
-			JSONObject qResultObj = JSONUtil.parseObj(qResult);
-			qResultObj.set(userSub.getGigType().name(), MapUtil.builder("certStatus", currentCertStatus.name()).build());
-			redisTemplate.opsForValue().set(key, JSONUtil.toJsonStr(qResultObj), 1, TimeUnit.MINUTES);
-		} else {
-			Map<String, Object> result = MapUtil.newHashMap(2);
-			result.put(userSub.getGigType().name(), new HashMap<>(subMap));
-			redisTemplate.opsForValue().set(key, JSONUtil.toJsonStr(result), 1, TimeUnit.MINUTES);
-		}
+		Map<String, Object> result = MapUtil.newHashMap(2);
+		result.put(userSub.getGigType().name(), new HashMap<>(subMap));
+		redisTemplate.opsForValue().set(key, JSONUtil.toJsonStr(result), 1, TimeUnit.MINUTES);
 
 		// 如果成功,则发送证照上传MQ
 		if (OladingCommonRequest.SignUpStatus.SIGN.equals(signUpCertStatus)) {
@@ -296,21 +284,6 @@ public class GigThirdApiServiceImpl implements GigThirdApiService {
 			userSignCertDTO.setUserId(userSub.getUserId());
 			userSignCertDTO.setGigTypeList(Collections.singletonList(userSub.getGigType()));
 			sysUserSignCertService.batchChannelCert(userSignCertDTO);
-
-//			// 查询是否存在另一渠道需要发起(海南飞亿、金园数科其中之一)
-//			SysUserSub secUserSub = sysUserSubService.getOne(Wrappers.<SysUserSub>lambdaQuery()
-//					.eq(SysUserSub::getUserId, userSub.getUserId())
-//					.in(SysUserSub::getGigType, GigTypeEnum.OLADING, GigTypeEnum.JIN_YUAN)
-//					.eq(SysUserSub::getCertStatus, Integer.parseInt(OladingCertStatus.SIGNING.getCode()))
-//					.ne(SysUserSub::getId, userSub.getId()));
-//			if (secUserSub != null) {
-//				// 如果同一人同时存在海南飞亿、金园数科的渠道,则补发一次(由于阿拉钉同一人不同渠道的回调只有一次,所以这里需要补发)
-//				log.info("=============================补发阿拉钉另一渠道MQ1==================================");
-//				UserSignCertDTO reCertDTO = new UserSignCertDTO();
-//				reCertDTO.setUserId(secUserSub.getUserId());
-//				reCertDTO.setGigTypeList(Collections.singletonList(secUserSub.getGigType()));
-//				sysUserSignCertService.batchChannelCert(reCertDTO);
-//			}
 		}
 	}
 
@@ -333,17 +306,14 @@ public class GigThirdApiServiceImpl implements GigThirdApiService {
 		Map<String, String> subMap = new HashMap<>();
 		LambdaUpdateWrapper<SysUserSub> updateUserSubWrapper = Wrappers.lambdaUpdate();
 		updateUserSubWrapper.eq(SysUserSub::getId, userSub.getId());
-		OladingCertStatus currentCertStatus;
 		if (OladingCommonRequest.UploadIdCardImageStatus.IDENTIFY_SUCCESS.equals(uploadIdCertStatus)) {
 			subMap.put("certStatus", OladingCertStatus.SIGNED.name());
 			updateUserSubWrapper.set(SysUserSub::getCertStatus, Integer.valueOf(OladingCertStatus.SIGNED.getCode()));
-			currentCertStatus = OladingCertStatus.SIGNED;
 		} else {
 			subMap.put("certStatus", OladingCertStatus.SIGNED.name());
 			updateUserSubWrapper.set(SysUserSub::getCertStatus, Integer.valueOf(OladingCertStatus.SIGNED.getCode()));
 			updateUserSubWrapper.set(SysUserSub::getIdCardFrontUrl, null);
 			updateUserSubWrapper.set(SysUserSub::getIdCardBackUrl, null);
-			currentCertStatus = OladingCertStatus.SIGNED;
 		}
 		updateUserSubWrapper.set(SysUserSub::getUpdateTime, LocalDateTime.now());
 		updateUserSubWrapper.set(SysUserSub::getUpdateUser, 0);
@@ -358,16 +328,9 @@ public class GigThirdApiServiceImpl implements GigThirdApiService {
 
 		// 结果放到redis
 		String key = CacheConstants.USER_SIGN_CERT_RESPONSE_KEY + userSub.getUserId();
-		String qResult = (String) redisTemplate.opsForValue().get(key);
-		if (JSONUtil.isJsonObj(qResult)) {
-			JSONObject qResultObj = JSONUtil.parseObj(qResult);
-			qResultObj.set(userSub.getGigType().name(), MapUtil.builder("certStatus", currentCertStatus.name()).build());
-			redisTemplate.opsForValue().set(key, JSONUtil.toJsonStr(qResultObj), 1, TimeUnit.MINUTES);
-		} else {
-			Map<String, Object> result = MapUtil.newHashMap(2);
-			result.put(userSub.getGigType().name(), new HashMap<>(subMap));
-			redisTemplate.opsForValue().set(key, JSONUtil.toJsonStr(result), 1, TimeUnit.MINUTES);
-		}
+		Map<String, Object> result = MapUtil.newHashMap(2);
+		result.put(userSub.getGigType().name(), new HashMap<>(subMap));
+		redisTemplate.opsForValue().set(key, JSONUtil.toJsonStr(result), 1, TimeUnit.MINUTES);
 
 		// 如果成功,则发送协议上传MQ
 		if (OladingCommonRequest.UploadIdCardImageStatus.IDENTIFY_SUCCESS.equals(uploadIdCertStatus)) {
@@ -396,17 +359,14 @@ public class GigThirdApiServiceImpl implements GigThirdApiService {
 		}
 
 		Map<String, String> subMap = new HashMap<>();
-		OladingCertStatus currentCertStatus;
 		LambdaUpdateWrapper<SysUserSub> updateUserSubWrapper = Wrappers.lambdaUpdate();
 		updateUserSubWrapper.eq(SysUserSub::getId, userSub.getId());
 		if (OladingCommonRequest.UploadTaxpayerAgreementStatus.SUCCESS.equals(agreementStatus)) {
 			subMap.put("certStatus", OladingCertStatus.CERT.name());
 			updateUserSubWrapper.set(SysUserSub::getCertStatus, Integer.valueOf(OladingCertStatus.CERT.getCode()));
-			currentCertStatus = OladingCertStatus.CERT;
 		} else {
 			subMap.put("certStatus", OladingCertStatus.SIGNED.name());
 			updateUserSubWrapper.set(SysUserSub::getCertStatus, Integer.valueOf(OladingCertStatus.SIGNED.getCode()));
-			currentCertStatus = OladingCertStatus.SIGNED;
 		}
 		updateUserSubWrapper.set(SysUserSub::getUpdateTime, LocalDateTime.now());
 		updateUserSubWrapper.set(SysUserSub::getUpdateUser, 0);
@@ -421,16 +381,9 @@ public class GigThirdApiServiceImpl implements GigThirdApiService {
 
 		// 结果放到redis
 		String key = CacheConstants.USER_SIGN_CERT_RESPONSE_KEY + userSub.getUserId();
-		String qResult = (String) redisTemplate.opsForValue().get(key);
-		if (JSONUtil.isJsonObj(qResult)) {
-			JSONObject qResultObj = JSONUtil.parseObj(qResult);
-			qResultObj.set(userSub.getGigType().name(), MapUtil.builder("certStatus", currentCertStatus.name()).build());
-			redisTemplate.opsForValue().set(key, JSONUtil.toJsonStr(qResultObj), 1, TimeUnit.MINUTES);
-		} else {
-			Map<String, Object> result = MapUtil.newHashMap(2);
-			result.put(userSub.getGigType().name(), new HashMap<>(subMap));
-			redisTemplate.opsForValue().set(key, JSONUtil.toJsonStr(result), 1, TimeUnit.MINUTES);
-		}
+		Map<String, Object> result = MapUtil.newHashMap(2);
+		result.put(userSub.getGigType().name(), new HashMap<>(subMap));
+		redisTemplate.opsForValue().set(key, JSONUtil.toJsonStr(result), 1, TimeUnit.MINUTES);
 
 		if (OladingCommonRequest.UploadTaxpayerAgreementStatus.SUCCESS.equals(agreementStatus)) {
 			// 如果成功,则发送核身视频上传MQ