记得上下班打卡 | git大法好,push需谨慎

Commit 879050b3 authored by 张国柄's avatar 张国柄

实名逻辑JAVA替换PHP.API调用;

parent fbbdee24
...@@ -4,10 +4,10 @@ import org.springframework.util.LinkedMultiValueMap; ...@@ -4,10 +4,10 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
public class IdentityUtils { public class IdentityUtils {
private String aliThirdUrl = "https://1.api.apistore.cn/idcard3"; private static String aliThirdUrl = "https://1.api.apistore.cn/idcard3";
private String aliThirdAppCode = "cc29fa8cb494468289dec09df46922b5"; private static String aliThirdAppCode = "cc29fa8cb494468289dec09df46922b5";
public String aliThird(String realName,String cardNo){ public static String aliThird(String realName,String cardNo){
MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("realName",realName); params.add("realName",realName);
params.add("cardNo",cardNo); params.add("cardNo",cardNo);
......
package com.liquidnet.service.adam.service.impl; package com.liquidnet.service.adam.service.impl;
import com.fasterxml.jackson.databind.JsonNode;
import com.liquidnet.common.exception.LiquidnetServiceException; import com.liquidnet.common.exception.LiquidnetServiceException;
import com.liquidnet.common.mq.constant.MQConst; import com.liquidnet.common.mq.constant.MQConst;
import com.liquidnet.commons.lang.util.*; import com.liquidnet.commons.lang.util.*;
...@@ -270,24 +271,31 @@ public class AdamEntersServiceImpl implements IAdamEntersService { ...@@ -270,24 +271,31 @@ public class AdamEntersServiceImpl implements IAdamEntersService {
} }
private void identityHandler(String currentUid, String name, String idCard) { private void identityHandler(String currentUid, String name, String idCard) {
String respStr = null; // String respStr = null;
try { // try {
LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); // LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("realName", name); // paramsMap.add("realName", name);
paramsMap.add("cardNo", idCard); // paramsMap.add("cardNo", idCard);
//
long s = System.currentTimeMillis(); // long s = System.currentTimeMillis();
respStr = HttpUtil.postToPhpApi(env.getProperty("liquidnet.url-service.url") + PHP_API_REAL_NAME, paramsMap); // respStr = HttpUtil.postToPhpApi(env.getProperty("liquidnet.url-service.url") + PHP_API_REAL_NAME, paramsMap);
log.debug("#PHP.API耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#PHP.API耗时:{}ms", System.currentTimeMillis() - s);
log.debug("###PHP.API[{}].RESP:{}", PHP_API_REAL_NAME, respStr); // log.debug("###PHP.API[{}].RESP:{}", PHP_API_REAL_NAME, respStr);
Map respMap = JsonUtils.fromJson(respStr, Map.class); // Map respMap = JsonUtils.fromJson(respStr, Map.class);
if (CollectionUtils.isEmpty(respMap) || !StringUtils.equalsIgnoreCase("OK", (String) respMap.get("message"))) { // if (CollectionUtils.isEmpty(respMap) || !StringUtils.equalsIgnoreCase("OK", (String) respMap.get("message"))) {
log.warn("PHP.API实名认证失败[uid:{},name:{},idCard:{},respStr:{}]", currentUid, name, idCard, respStr); // log.warn("PHP.API实名认证失败[uid:{},name:{},idCard:{},respStr:{}]", currentUid, name, idCard, respStr);
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102"); // ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage()); // throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
} // }
} catch (Exception e) { // } catch (Exception e) {
log.error("PHP.API实名认证异常[uid:{},name:{},idCard:{},respStr:{}]", currentUid, name, idCard, respStr, e); // log.error("PHP.API实名认证异常[uid:{},name:{},idCard:{},respStr:{}]", currentUid, name, idCard, respStr, e);
// ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
// throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
// }
String respStr = IdentityUtils.aliThird(name, idCard);
JsonNode respJNode = JsonUtils.fromJson(respStr, JsonNode.class);
if (null == respJNode || !"0".equals(respJNode.get("error_code").asText())) {
log.info("###实名认证失败[{}]", respStr);
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102"); ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage()); throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
} }
......
package com.liquidnet.service.adam.service.impl; package com.liquidnet.service.adam.service.impl;
import com.fasterxml.jackson.databind.JsonNode;
import com.liquidnet.common.cache.redisson.util.RedisLockUtil; import com.liquidnet.common.cache.redisson.util.RedisLockUtil;
import com.liquidnet.common.exception.LiquidnetServiceException; import com.liquidnet.common.exception.LiquidnetServiceException;
import com.liquidnet.common.mq.constant.MQConst; import com.liquidnet.common.mq.constant.MQConst;
import com.liquidnet.commons.lang.util.HttpUtil; import com.liquidnet.commons.lang.util.*;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.commons.lang.util.SensitizeUtil;
import com.liquidnet.service.adam.constant.AdamRedisConst; import com.liquidnet.service.adam.constant.AdamRedisConst;
import com.liquidnet.service.adam.dto.AdamThirdPartParam; import com.liquidnet.service.adam.dto.AdamThirdPartParam;
import com.liquidnet.service.adam.dto.vo.*; import com.liquidnet.service.adam.dto.vo.*;
...@@ -367,23 +365,30 @@ public class AdamUserServiceImpl implements IAdamUserService { ...@@ -367,23 +365,30 @@ public class AdamUserServiceImpl implements IAdamUserService {
vo = adamRdmService.getRealInfoVoByUid(uid); vo = adamRdmService.getRealInfoVoByUid(uid);
if (null == vo) { if (null == vo) {
if (!adamRdmService.isCertification(1, idCard, name)) { if (!adamRdmService.isCertification(1, idCard, name)) {
String respStr = null; // String respStr = null;
try { // try {
LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); // LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("realName", name); // paramsMap.add("realName", name);
paramsMap.add("cardNo", idCard); // paramsMap.add("cardNo", idCard);
long s = System.currentTimeMillis(); // long s = System.currentTimeMillis();
respStr = HttpUtil.postToPhpApi(env.getProperty("liquidnet.url-service.url") + PHP_API_REAL_NAME, paramsMap); // respStr = HttpUtil.postToPhpApi(env.getProperty("liquidnet.url-service.url") + PHP_API_REAL_NAME, paramsMap);
log.debug("#PHP.API耗时:{}ms", System.currentTimeMillis() - s); // log.debug("#PHP.API耗时:{}ms", System.currentTimeMillis() - s);
log.debug("###PHP.API[{}].RESP:{}", PHP_API_REAL_NAME, respStr); // log.debug("###PHP.API[{}].RESP:{}", PHP_API_REAL_NAME, respStr);
Map respMap = JsonUtils.fromJson(respStr, Map.class); // Map respMap = JsonUtils.fromJson(respStr, Map.class);
if (CollectionUtils.isEmpty(respMap) || !StringUtils.equalsIgnoreCase("OK", (String) respMap.get("message"))) { // if (CollectionUtils.isEmpty(respMap) || !StringUtils.equalsIgnoreCase("OK", (String) respMap.get("message"))) {
log.warn("PHP.API实名认证失败[uid:{},name:{},idCard:{},respStr:{}]", uid, name, idCard, respStr); // log.warn("PHP.API实名认证失败[uid:{},name:{},idCard:{},respStr:{}]", uid, name, idCard, respStr);
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102"); // ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage()); // throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
} // }
} catch (Exception e) { // } catch (Exception e) {
log.error("PHP.API实名认证异常[uid:{},name:{},idCard:{},respStr:{}]", uid, name, idCard, respStr, e); // log.error("PHP.API实名认证异常[uid:{},name:{},idCard:{},respStr:{}]", uid, name, idCard, respStr, e);
// ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
// throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
// }
String respStr = IdentityUtils.aliThird(name, idCard);
JsonNode respJNode = JsonUtils.fromJson(respStr, JsonNode.class);
if (null == respJNode || !"0".equals(respJNode.get("error_code").asText())) {
log.info("###实名认证失败[{}]", respStr);
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102"); ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("10102");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage()); throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment