瀏覽代碼

新增接口-身份证有效期核验

15810770710@163.com 3 年之前
父節點
當前提交
3aadd7fa49

+ 29 - 0
src/main/java/info/aspirecn/iov/sjjh/supplier10000027/action/ChannelAction.java

@@ -193,4 +193,33 @@ public class ChannelAction {
         request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
         return responseObject;
     }
+
+    @ApiOperation(value = "身份证有效性验证")
+    @PostMapping(value = "/validateIdentityInfoValidity.do")
+    public ChannelTypeHandleResponseObject validateIdentityInfoValidity(
+            @ApiParam(value = "通道ID") @RequestHeader(name = "channelId") String channelId,
+            @ApiParam(value = "超时时间,单位:毫秒", example = "10000") @RequestParam(name = "outTime") int outTime,
+            @ApiParam(value = "请求参数JSON串") @RequestParam(name = "customBody") String customBody) {
+        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
+                .getRequest();
+        //调用service
+        ChannelTypeHandleResponseObject responseObject = service.validateIdentityInfoValidity(request, customBody, outTime);
+
+        //把接口参数、调用结果和是否收费放入访问日志中
+        if (responseObject.getCode() != Constant.SUCCESS) {
+            request.setAttribute(SjjhConstant.LOG_ERROR_PARA, Constant.CHANNEL_LOG_ERROR_CODE);
+        } else {
+            request.setAttribute(SjjhConstant.LOG_ERROR_PARA, Constant.CHANNEL_LOG_SUCCESS_CODE);
+        }
+        request.setAttribute(SjjhConstant.LOG_FEE_PARA, responseObject.getIsCharge());
+
+        try {
+            request.setAttribute(Constant.CHANNEL_LOG_QUERY, Base64.encodeBase64String(customBody.getBytes(SjjhConstant.PARA_ENCODE)));
+        } catch (UnsupportedEncodingException e) {
+            ErrorUtils.captureException(e);
+        }
+
+        request.setAttribute(Constant.CHANNEL_TYPE_KEY, Constant.CHANNEL_TYPE_SYNC);
+        return responseObject;
+    }
 }

+ 9 - 0
src/main/java/info/aspirecn/iov/sjjh/supplier10000027/service/ChannelService.java

@@ -54,4 +54,13 @@ public interface ChannelService {
      */
     ChannelTypeHandleResponseObject validateIdentityInfoCommon(HttpServletRequest request, String customBody, int outTime, String decodeType);
 
+    /**
+     * 身份证有效性核验
+     * @param request
+     * @param customBody
+     * @param outTime
+     * @return
+     */
+    ChannelTypeHandleResponseObject validateIdentityInfoValidity(HttpServletRequest request, String customBody, int outTime);
+
 }

+ 82 - 0
src/main/java/info/aspirecn/iov/sjjh/supplier10000027/service/ChannelServiceImpl.java

@@ -75,6 +75,8 @@ public class ChannelServiceImpl implements ChannelService {
     private String bjcaRootTest;
     @Value("${custom.decryptKey}")
     private String decryptKey;
+    @Value("${custom.authMode-0x18}")
+    private String authMode18;
 
     private OkHttpClient okHttpClient = new OkHttpClient.Builder().build();
 
@@ -936,4 +938,84 @@ public class ChannelServiceImpl implements ChannelService {
         }
         return customBody;
     }
+
+    @Override
+    public ChannelTypeHandleResponseObject validateIdentityInfoValidity(HttpServletRequest request, String customBody, int outTime) {
+        ChannelTypeHandleResponseObject ret = new ChannelTypeHandleResponseObject();
+        ret.setIsCharge(Constant.INTERFACE_QUERY_NO_FEE);
+        String upstreamCode = Constant.LOG_UPSTREAM_DEFAULT_RESPONSE_CODE;
+        String returnType = request.getHeader(Constant.CUSTOMER_RETURN_TYPE_PARA);
+
+        if (StringUtils.isBlank(returnType)) {
+            returnType = Constant.CUSTOMER_RETURN_ZW;
+        }
+        if (outTime <= 0) {
+            outTime = Constant.HTTPCLIENT_CONNECTTIMEOUT;
+        }
+
+        log.info("validateIdentityInfoValidity---customBody={},outTime={}", customBody, outTime);
+
+        try {
+           /* BASE64Decoder decoder = new BASE64Decoder();
+            customBody = new String(decoder.decodeBuffer(customBody));
+            log.info("BASE64解码后customBody === " + customBody);*/
+            ValidIdentityInfoJsonResolveObject jsonResolveObject = objectMapper.readValue(customBody,
+                    ValidIdentityInfoJsonResolveObject.class);
+            // 参数校验
+            if (!validateCompositeIdentityParams(ret, returnType, jsonResolveObject)) {
+                ret.setCode(Constant.SUCCESS);
+                request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
+                return ret;
+            }
+
+            // 申请
+            ApplyResponseObject apply = dataSignature(authMode18, outTime);
+            if (apply == null || !apply.getBizPackage().getSuccess().equals("true")) {
+                // 申请失败,返回查询错误
+                if (Constant.CUSTOMER_RETURN_ZW.equals(returnType)) {
+                    ret.setResultCode(Constant.OTHER_ERROR_CODE);
+                } else {
+                    ret.setResultCode(Constant.JK_RETURN_CODE_OTHER_ERROR);
+                }
+                ret.setResultBody(Constant.OTHER_ERROR);
+                ret.setResultDesc(Constant.OTHER_ERROR);
+                ret.setCode(Constant.SUCCESS);
+                request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
+                log.info("validateIdentityInfoValidity---apply失败");
+                return ret;
+            }
+
+            // 设置请求参数
+            DataRequestObject requestObject = getRequestObject(jsonResolveObject, authMode18, apply.getBizPackage().getBusinessSerialNumber(), "");
+            log.info("supplier10000027.validateIdentityInfoValidity接口requestObject={}", requestObject);
+            // 发起业务请求
+            String responseContext = callService(requestUrl, JSONObject.toJSONString(requestObject), outTime);
+            log.info("请求上游");
+            log.info("supplier10000027.validateIdentityInfoValidity接口responseContext={}", responseContext);
+            DataResponseObject responseObject = objectMapper.readValue(responseContext, DataResponseObject.class);
+            log.info("supplier10000027.validateIdentityInfoValidity接口responseObject={}", responseObject);
+
+            if (responseObject != null && responseObject.getBizPackage().getSuccess().equals("true")) {
+                ret.setCode(Constant.SUCCESS);
+                setIdentityInfoResponse(ret, returnType, responseObject.getBizPackage().getAuthResult());
+                if (ret.getResultCode() == Constant.JK_RETURN_CODE_1174 || ret.getResultCode() == Constant.ZW_RETURN_CODE_114) {
+                    ret.setResultBody(responseObject.getBizPackage().getAuthResultRetainData());
+                }
+                upstreamCode = responseObject.getBizPackage().getAuthResult();
+            } else {
+                ret.setCode(Constant.FAIL);
+            }
+        } catch (SocketTimeoutException ste) {
+            ErrorUtils.captureException(ste);
+            log.info("supplier10000027.validateIdentityInfoValidity接口SocketTimeoutException={}", ste);
+            ret.setCode(Constant.REQUEST_TIMEOUT);
+        } catch (Exception ioe) {
+            ErrorUtils.captureException(ioe);
+            log.info("supplier10000027.validateIdentityInfoValidity接口Exception={}", ioe);
+            ret.setCode(Constant.FAIL);
+        }
+        //上游返回码
+        request.setAttribute(Constant.LOG_UPSTREAM_RESPONSE_CODE, upstreamCode);
+        return ret;
+    }
 }

+ 16 - 0
src/main/java/info/aspirecn/iov/sjjh/supplier10000027/vo/ValidIdentityInfoJsonResolveObject.java

@@ -0,0 +1,16 @@
+package info.aspirecn.iov.sjjh.supplier10000027.vo;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+import lombok.ToString;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author xusonglin
+ * @version V1.0
+ **/
+@Data
+@ToString(callSuper = true)
+public class ValidIdentityInfoJsonResolveObject  extends CompositeIdentityInfoJsonResolveObject{
+}