Commit 970e0414 authored by hanfeng's avatar hanfeng

修改实名认证

parent caf1d086
...@@ -53,9 +53,9 @@ public class AppUserManageDTO { ...@@ -53,9 +53,9 @@ public class AppUserManageDTO {
private Integer source; private Integer source;
/** /**
* * 接收前台时间范围
*/ */
private String registrationDate; private String[] registrationDate;
} }
...@@ -18,7 +18,9 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -18,7 +18,9 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
/**
* 实名认证
*/
@RestController @RestController
@RequestMapping("certif") @RequestMapping("certif")
@Slf4j @Slf4j
......
...@@ -18,15 +18,14 @@ import org.apache.commons.lang.StringUtils; ...@@ -18,15 +18,14 @@ import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.StatusLine; import org.apache.http.StatusLine;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.apache.poi.ss.usermodel.DateUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.Map;
@Service @Service
...@@ -266,8 +265,8 @@ public class CertificationService { ...@@ -266,8 +265,8 @@ public class CertificationService {
//正面进行解析 //正面进行解析
String front = imageParse(idInformation.getFrontUrl(), frontParameter); String front = imageParse(idInformation.getFrontUrl(), frontParameter);
String back = imageParse(idInformation.getBackUrl(), backParameter); String back = imageParse(idInformation.getBackUrl(), backParameter);
log.info("----解析front========="+front); log.info("----解析front=========" + front);
log.info("----解析back========="+back); log.info("----解析back=========" + back);
if (StringUtils.isBlank(front) || StringUtils.isBlank(back)) { if (StringUtils.isBlank(front) || StringUtils.isBlank(back)) {
return ObjectRestResponse.createDefaultFail(); return ObjectRestResponse.createDefaultFail();
} }
...@@ -282,7 +281,7 @@ public class CertificationService { ...@@ -282,7 +281,7 @@ public class CertificationService {
|| MapUtil.isEmpty(backMap) || MapUtil.isEmpty(backMap)
|| !(backMap.get(imageRet).equals(imageResultCode)) || !(backMap.get(imageRet).equals(imageResultCode))
){ ) {
return ObjectRestResponse.createDefaultFail(); return ObjectRestResponse.createDefaultFail();
} }
...@@ -292,7 +291,7 @@ public class CertificationService { ...@@ -292,7 +291,7 @@ public class CertificationService {
Map backData = (Map) backMap.get(dataNam); Map backData = (Map) backMap.get(dataNam);
if (MapUtil.isEmpty(backData)||MapUtil.isEmpty(frontData)){ if (MapUtil.isEmpty(backData) || MapUtil.isEmpty(frontData)) {
return ObjectRestResponse.createDefaultFail(); return ObjectRestResponse.createDefaultFail();
} }
...@@ -312,7 +311,7 @@ public class CertificationService { ...@@ -312,7 +311,7 @@ public class CertificationService {
ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "证件号不一致"); ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "证件号不一致");
} }
//map携带身份证和姓名进行认证 //map携带身份证和姓名进行认证
Map<String, String> authMap = new HashMap<>(); Map<String, String> authMap = new HashMap<>();
authMap.put(idCardName, (String) frontData.get(numberName)); authMap.put(idCardName, (String) frontData.get(numberName));
...@@ -320,13 +319,13 @@ public class CertificationService { ...@@ -320,13 +319,13 @@ public class CertificationService {
//3.调用接口进行认证 //3.调用接口进行认证
String result = certificate(authMap); String result = certificate(authMap);
log.info("----认证结果result========="+result); log.info("----认证结果result=========" + result);
//认证返回的参数是否为空 //认证返回的参数是否为空
if (!StringUtils.isBlank(result)) { if (!StringUtils.isBlank(result)) {
Map<String, Object> map = (Map<String, Object>) JSONObject.parse(result); Map<String, Object> map = (Map<String, Object>) JSONObject.parse(result);
log.info("----certifRet========="+certifRet); log.info("----certifRet=========" + certifRet);
if (MapUtil.isNotEmpty(map) || certifResultCode.equals(map.get(certifRet))) { if (MapUtil.isNotEmpty(map) || certifResultCode.equals(map.get(certifRet))) {
//认证成功后存入保存到数据库 //认证成功后存入保存到数据库
...@@ -342,27 +341,35 @@ public class CertificationService { ...@@ -342,27 +341,35 @@ public class CertificationService {
//获得到期时间 //获得到期时间
String endDate = (String) backData.get(expirationDateName); String endDate = (String) backData.get(expirationDateName);
log.info("----获得到期时间endDate========="+endDate); log.info("----获得到期时间endDate=========" + endDate);
if (StringUtils.isBlank(endDate)) { if (StringUtils.isBlank(endDate)) {
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
Date expirationDate = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); if (!Validation.isDate(endDate)) {
formatter.setLenient(false); Date date = new Date();
Date expirationDate = null; Calendar c = Calendar.getInstance();
try { c.setTime(date);
expirationDate = formatter.parse(endDate); c.add(Calendar.YEAR, 100);
} catch (ParseException e) { expirationDate = c.getTime();
e.printStackTrace(); } else {
return ObjectRestResponse.createDefaultFail(); SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
formatter.setLenient(false);
try {
expirationDate = formatter.parse(endDate);
} catch (ParseException e) {
e.printStackTrace();
return ObjectRestResponse.createDefaultFail();
}
} }
idInformation.setExpirationDate(expirationDate); idInformation.setExpirationDate(expirationDate);
Boolean aBoolean = addIdInformation(idInformation); Boolean aBoolean = addIdInformation(idInformation);
log.info("----请求admin========="+aBoolean); log.info("----请求admin=========" + aBoolean);
if (aBoolean) { if (aBoolean) {
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
...@@ -389,7 +396,7 @@ public class CertificationService { ...@@ -389,7 +396,7 @@ public class CertificationService {
// //
try { try {
log.info("----querys========="+querys); log.info("----querys=========" + querys);
HttpResponse response = CertifHttpUtils.doGet(cHost, cPath, cMethod, headers, querys); HttpResponse response = CertifHttpUtils.doGet(cHost, cPath, cMethod, headers, querys);
StatusLine statusLine = response.getStatusLine(); StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode(); int statusCode = statusLine.getStatusCode();
...@@ -439,7 +446,7 @@ public class CertificationService { ...@@ -439,7 +446,7 @@ public class CertificationService {
StatusLine statusLine = response.getStatusLine(); StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode(); int statusCode = statusLine.getStatusCode();
log.info("----statusCode========="+querys); log.info("----statusCode=========" + querys);
/** /**
* 状态码: 200 正常;400 URL无效;401 appCode错误; 403 次数用完; 500 API网管错误 * 状态码: 200 正常;400 URL无效;401 appCode错误; 403 次数用完; 500 API网管错误
*/ */
...@@ -462,7 +469,7 @@ public class CertificationService { ...@@ -462,7 +469,7 @@ public class CertificationService {
//认证通过保存到数据库当中 //认证通过保存到数据库当中
public Boolean addIdInformation(IdInformation idInformation) { public Boolean addIdInformation(IdInformation idInformation) {
log.info("----idInformation========="+idInformation); log.info("----idInformation=========" + idInformation);
//保存认证信息 //保存认证信息
try { try {
...@@ -474,7 +481,7 @@ public class CertificationService { ...@@ -474,7 +481,7 @@ public class CertificationService {
//认证成功后修改用户,用户认证状态 //认证成功后修改用户,用户认证状态
ObjectRestResponse authentication = userFeign.authentication(idInformation.getUserLonginId(), idInformation.getName(),idInformation.getIdNumber(), 1); ObjectRestResponse authentication = userFeign.authentication(idInformation.getUserLonginId(), idInformation.getName(), idInformation.getIdNumber(), 1);
return authentication.getRel(); return authentication.getRel();
} }
......
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