package com.nova.sankuai.domain.api.hengyidai; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.nova.sankuai.domain.api.hengyidai.dto.HyConfirmDto; import com.nova.sankuai.domain.api.hengyidai.dto.HyGetContractsDto; import com.nova.sankuai.domain.api.hengyidai.dto.HyGetRepayUrlDto; import com.nova.sankuai.domain.api.hengyidai.dto.HyGetSignUrlDto; import com.nova.sankuai.domain.api.hengyidai.response.*; import com.nova.sankuai.domain.entity.Customer; import com.nova.sankuai.domain.enums.customerinfo.MonthlyIncomeEnum; import com.nova.sankuai.domain.enums.customerinfo.UseOfLoanEnum; import com.nova.sankuai.domain.enums.yixin.*; import com.nova.sankuai.security.HttpClientUtil; import lombok.Data; import org.apache.commons.lang.StringUtils; import org.apache.http.util.TextUtils; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Map; /** * 恒易贷对接 */ @Data @Component public class HyUtil { @Autowired private HySignUtil hySignUtil; /** * 撞库 * * @param idCardMd5 身份证MD5值 * @return */ public HyResponse checkUser(String idCardMd5, Logger log, String logNumber) { String url = "/checkUser"; JSONObject root = new JSONObject(); //撞库参数,身份证号 MD5 加密 root.put("collidParameter", idCardMd5); //撞库类型 root.put("collidType", 3); try { log.info("日志编号:" + logNumber + "撞库参数 -> {}", root); String request = hySignUtil.buildRequest(root.toJSONString()); log.info("日志编号:" + logNumber + "撞库参数json -> {}", request); String hyResult = HttpClientUtil.getInstance().postJsonData(hySignUtil.getHyPath() + url, request); log.info("日志编号:" + logNumber + "撞库返回 -> {}", hyResult); if (!TextUtils.isEmpty(hyResult)) { HyResponse hyResponse = JSON.parseObject(hyResult, HyResponse.class); if (null != hyResponse.getData()) { HyCollisionLibraryResponse response = JSON.parseObject(hyResponse.getData().toString(), HyCollisionLibraryResponse.class); hyResponse.setData(response); } log.info("日志编号:" + logNumber + "撞库返回结果 -> {}", hyResponse); return hyResponse; } } catch (Exception e) { e.printStackTrace(); log.error("撞库接口异常->:{}", e.getMessage()); } return null; } /** * 进件 * * @param customer * @param log * @param logNumber * @return */ public HyResponse pushPhaseOne(Customer customer, String orderNo, Logger log, String logNumber) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //采集时间 String dateString = formatter.format(customer.getApplyDate()); //orderTime(订单创建时间),(applytim)申请时间 String format = formatter.format(new Date(System.currentTimeMillis())); String url = "/pushPhaseOne"; JSONObject root = new JSONObject(); //进件单号 root.put("orderNo", orderNo); //用户基本信息 JSONObject userBaseInfo = new JSONObject(); //手机号 userBaseInfo.put("mobile", customer.getPhone()); //姓名 userBaseInfo.put("name", customer.getName()); //当前居住地址 userBaseInfo.put("currentAddress", customer.getAddress()); //婚姻状况类型 详见“婚姻类型”枚举 userBaseInfo.put("marriageType", formatHyMarriage(customer.getMaritalStatus())); //受教育程度类型 详见“教育程度类型”枚举 userBaseInfo.put("educationType", formatHyEducation(customer.getEducation())); //住房类型 userBaseInfo.put("houseType", formatHyHouse(customer.getLivest())); //月收入 例如:5000。 必须是具体数值,不能传区间。单位:元。 userBaseInfo.put("inCome", formatMonthly(customer.getMonthlyIncome())); //借款用途 详见“借款用途类型”枚举 userBaseInfo.put("loanUsageType", formatHyLoanUsageType(customer.getUseOfLoan())); root.put("userBaseInfo", userBaseInfo); //身份证信息 JSONObject identityInfo = new JSONObject(); //姓名(OCR 扫描) identityInfo.put("name", customer.getName()); //身 份 证 号(OCR 扫描) identityInfo.put("idNum", customer.getIdCard()); //性别(OCR 扫描) 1为女,2为男 identityInfo.put("sex", "女".equals(customer.getSex()) ? 1 : 2); //民族(OCR 扫描) identityInfo.put("nation", customer.getNation()); //地址(OCR 扫描) identityInfo.put("identityAddress", customer.getIdAddress()); //发 证 机 关(OCR 扫描) identityInfo.put("issueAgency", customer.getSignOrganization()); //有效期(OCR扫描)格式:2012.10.01-2022.10.01或 2017.10.13-长期 if (null != customer.getIdLongTerm() && "1".equals(customer.getIdLongTerm())) { StringBuffer buffer = new StringBuffer(customer.getIdValidDateBegin()); buffer.insert(4, "."); buffer.insert(7, "."); identityInfo.put("periodValidityDate", buffer.toString() + "-长期"); } else { StringBuffer buffer = new StringBuffer(customer.getIdValidDateBegin()); buffer.insert(4, "."); buffer.insert(7, "."); StringBuffer dateEnd = new StringBuffer(customer.getIdValidDateEnd()); dateEnd.insert(4, "."); dateEnd.insert(7, "."); identityInfo.put("periodValidityDate", buffer.toString() + "-" + dateEnd.toString()); } root.put("identityInfo", identityInfo); //借款信息 JSONObject applyInfo = new JSONObject(); //订单创建时间 格式:yyyy-MM-dd HH:mm:ss applyInfo.put("orderTime", format); //申请金额 单位:分 if (customer.getLoanAmount() != null) { applyInfo.put("applyAmount", customer.getLoanAmount() * 100); } else { applyInfo.put("applyAmount", "500000"); } //申请期限 applyInfo.put("applyPeriodNum", customer.getLoanTerm()); //申请期限单位 1:天,2:月,暂时只支持:月 applyInfo.put("applyPeriodNumUnit", 2); root.put("applyInfo", applyInfo); //联系人信息 JSONObject contactsInfo = new JSONObject(); //第 一 联 系 人 名称 contactsInfo.put("contactOneName", customer.getRelationshipName()); //第 一 联 系 人 手机号 contactsInfo.put("contactOneMobile", customer.getRelationshipPhone()); //第 一 联 系 人 类型 详见“联系人一类型”枚举 contactsInfo.put("contactOneType", formatHomeRelation(customer.getRelationship())); //第 二 联 系 人 名称 contactsInfo.put("contactTwoName", customer.getContactName()); //第 二 联 系 人 手机号 contactsInfo.put("contactTwoMobile", customer.getContactPhone()); //第 二 联 系 人 类型 详见“联系人二类型”枚举 contactsInfo.put("contactTwoType", formatFriendRelation(customer.getContactRelation())); root.put("contactsInfo", contactsInfo); //所在公司信息 JSONObject companyInfo = new JSONObject(); //公司名称 companyInfo.put("companyName", customer.getCompanyName()); //公司电话 companyInfo.put("companyTel", customer.getCompanyPhone()); //公司地址 companyInfo.put("companyAddress", customer.getCompanyAddress()); //公司性质类型 详见“公司性质类型”枚举 companyInfo.put("companyNatureType", formatHyCompanyNature(customer.getCompanyNature())); root.put("companyInfo", companyInfo); //设备信息 JSONObject deviceInfo = new JSONObject(); //系统类型 ios 或 android if (StringUtils.isNotEmpty(customer.getOs())) { deviceInfo.put("osType", customer.getOs().toLowerCase()); } //设备品牌 例如:华为 if (StringUtils.isNotEmpty(customer.getDeviceBrand())) { deviceInfo.put("deviceBrand", customer.getDeviceBrand()); } else { deviceInfo.put("deviceBrand", "华为"); } //设备型号 例如: P30 deviceInfo.put("deviceModel", "0000-0000"); //设备号,安 卓 设 备 取imei,IOS 设备取idfa if ("ios".equals(customer.getOs())) { if (null != customer.getIdfa()) deviceInfo.put("imei", customer.getIdfa()); } else { if (null != customer.getImei()) deviceInfo.put("imei", customer.getImei()); } //登录设备 ip deviceInfo.put("ip", customer.getClientIp()); //GSM 设备唯一号IMEI //deviceInfo.put("gsmImei", ""); //CMDA 设备唯一号 MEID //deviceInfo.put("cdmaMeid", ""); //网络类型 //deviceInfo.put("networkType", ""); //运营商 //deviceInfo.put("serviceName", ""); //无线局域网 ip 地址 if (null != customer.getIpAddres()) deviceInfo.put("lanAddress", customer.getIpAddres()); //内存大小 //deviceInfo.put("mem", ""); //数据来源 //deviceInfo.put("dataSource", ); //是否是模拟器 //deviceInfo.put("isSimulator",); root.put("deviceInfo", deviceInfo); //位置信息 JSONObject positionInfo = new JSONObject(); //经度 if (StringUtils.isNotEmpty(customer.getLng())) { positionInfo.put("applyY", customer.getLng()); } else { positionInfo.put("applyY", "0000-0000"); } //纬度 if (StringUtils.isNotEmpty(customer.getLat())) { positionInfo.put("applyX", customer.getLat()); } else { positionInfo.put("applyX", "0000-0000"); } //申请时的位置 示例:省+市+区/县+详细地址,例:江苏省苏州市张家港市**镇*** positionInfo.put("applypos", "0000-0000"); //申请时间 示例:yyyy-MM-dd HH:mm:ss positionInfo.put("applytim", format); root.put("positionInfo", positionInfo); log.info("日志编号:" + logNumber + "进件参数 -> {}", root); //活体信息 JSONObject liveInfo = new JSONObject(); //身份证正面图片 Base64 编码 liveInfo.put("idCardFrontImge", HySignUtil.pictureToBase64(customer.getIdCardFrontPath())); //身份证反面图片 Base64 编码 liveInfo.put("idCardBackImge", HySignUtil.pictureToBase64(customer.getIdCardBackPath())); //人脸图片 Base64 编码 liveInfo.put("faceImge", HySignUtil.pictureToBase64(customer.getFacePhotoPath())); //有源对比得分 liveInfo.put("score", customer.getVerifySimilarity()); //采集时间 格式:yyyy-MM-dd HH:mm:ss liveInfo.put("createTime", dateString); root.put("liveInfo", liveInfo); try { // log.info("日志编号:" + logNumber + "进件参数 -> {}", root); String request = hySignUtil.buildRequest(JSON.toJSONString(root)); // log.info("日志编号:" + logNumber + "进件参数json -> {}", request); String hyResult = HttpClientUtil.getInstance().postJsonData(hySignUtil.getHyPath() + url, request); log.info("日志编号:" + logNumber + "进件返回 -> {}", hyResult); if (!TextUtils.isEmpty(hyResult)) { HyResponse hyResponse = JSON.parseObject(hyResult, HyResponse.class); log.info("日志编号:" + logNumber + "进件返回 -> {}", hyResponse); return hyResponse; } } catch (Exception e) { e.printStackTrace(); log.error("进件接口异常->:{}", e.getMessage()); } return null; } /** * 婚姻状况 * * @param marriage * @return */ private String formatHyMarriage(String marriage) { if (YiXinMaritalStatusEnum.MaritalStatus_6.getCode().equals(marriage)) { //已婚 return "201"; } else if (YiXinMaritalStatusEnum.MaritalStatus_5.getCode().equals(marriage)) { //未婚 return "202"; } else if (YiXinMaritalStatusEnum.MaritalStatus_7.getCode().equals(marriage)) { //离异 return "203"; } else if (YiXinMaritalStatusEnum.MaritalStatus_8.getCode().equals(marriage)) { //丧偶 return "204"; } else { return "202"; } } /** * 教育程度 * * @param eduction * @return */ private String formatHyEducation(String eduction) { /*if (YiXinEducationEnum.JUNIOR_HIGH_SCHOOL.getCode().equals(eduction)) { //初中 return "252"; } else */ if (YiXinEducationEnum.COLLEGE_DEGREE.getCode().equals(eduction)) { //大专 return "254"; } else if (YiXinEducationEnum.HIGH_SCHOOL.getCode().equals(eduction)) { //高中/中专/技校 return "253"; } else if (YiXinEducationEnum.BACHELOR_DEGREE.getCode().equals(eduction)) { //大学本科 return "255"; } /*else if (YiXinEducationEnum.PRIMARY_SCHOOL.getCode().equals(eduction)) { //初中及以下 return "251"; } else if (YiXinEducationEnum.DOCTORAL_CANDIDATE.getCode().equals(eduction)) { //博士 return "257"; }*/ else if (YiXinEducationEnum.MASTER_CANDIDATE.getCode().equals(eduction)) { //硕士 return "256"; } else { return eduction; } } /** * 住房类型 * * @param houseType * @return */ private String formatHyHouse(String houseType) { if (YiXinLivestEnum.LIVEST_1.getCode().equals(houseType)) { //自建房 return "102"; } else if (YiXinLivestEnum.LIVEST_5.getCode().equals(houseType)) { //租房 return "101"; } else if (YiXinLivestEnum.LIVEST_4.getCode().equals(houseType)) { //宿舍 return "105"; } else if (YiXinLivestEnum.LIVEST_3.getCode().equals(houseType)) { //父母同住 return "106"; } else if (YiXinLivestEnum.LIVEST_7.getCode().equals(houseType)) { //其他 return "107"; } else { return "107"; } } private Integer formatMonthly(Integer monthlyIncome) { if (MonthlyIncomeEnum.Income_1W_UNDER.getCode().equals(monthlyIncome)) { return 10000; } else if (MonthlyIncomeEnum.Income_1W_3W.getCode().equals(monthlyIncome)) { return 30000; } else if (MonthlyIncomeEnum.Income_3W_UPPER.getCode().equals(monthlyIncome)) { return 30000; } else { return 10000; } } /** * 借款用途 * * @param loanUsageType * @return */ private String formatHyLoanUsageType(String loanUsageType) { if (UseOfLoanEnum.Loan_7.getCode().equals(loanUsageType) || UseOfLoanEnum.Loan_18.getCode().equals(loanUsageType)) { //装修房屋 return "411"; } else if (UseOfLoanEnum.Loan_8.getCode().equals(loanUsageType)) { //教育支出 return "412"; } else if (UseOfLoanEnum.Loan_25.getCode().equals(loanUsageType)) { //医疗支出 return "413"; } else if (UseOfLoanEnum.Loan_16.getCode().equals(loanUsageType)) { //旅游酒店机票 return "414"; } else if (UseOfLoanEnum.Loan_17.getCode().equals(loanUsageType)) { //购置车辆 return "415"; } else if (UseOfLoanEnum.Loan_9.getCode().equals(loanUsageType) || UseOfLoanEnum.Loan_10.getCode().equals(loanUsageType) || UseOfLoanEnum.Loan_14.getCode().equals(loanUsageType) || UseOfLoanEnum.Loan_15.getCode().equals(loanUsageType) || UseOfLoanEnum.Loan_19.getCode().equals(loanUsageType) || UseOfLoanEnum.Loan_23.getCode().equals(loanUsageType) || UseOfLoanEnum.Loan_24.getCode().equals(loanUsageType)) { //购置家具、家电 return "416"; } else if (UseOfLoanEnum.Loan_11.getCode().equals(loanUsageType)) { //婚庆开销 return "423"; } else { return loanUsageType; } } /** * 公司性质类型 * * @param companyNature * @return */ private String formatHyCompanyNature(String companyNature) { if (YiXinCompanyNatureEnum.Nature_1.getCode().equals(companyNature)) { //事业单位 return "308"; } else if (YiXinCompanyNatureEnum.Nature_4.getCode().equals(companyNature)) { //个体工商户 return "302"; } else if (YiXinCompanyNatureEnum.Nature_2.getCode().equals(companyNature)) { //国企 return "305"; } else if (YiXinCompanyNatureEnum.Nature_3.getCode().equals(companyNature)) { //外商投资企业 return "301"; } else if (YiXinCompanyNatureEnum.Nature_6.getCode().equals(companyNature)) { //其他 return "300"; } else { return "300"; } } /** * 第一联系人类型 * * @param contactType * @return */ private String formatHomeRelation(String contactType) { if (YiXinHomeRelationEnum.PARENTS.getCode().equals(contactType)) { //父母 return "501"; } else if (YiXinHomeRelationEnum.CHILD.getCode().equals(contactType)) { //子女 return "502"; } else if (YiXinHomeRelationEnum.SPOUSE.getCode().equals(contactType)) { //配偶 return "503"; } else { return contactType; } } /** * 第二联系人类型 * * @param contactType * @return */ private String formatFriendRelation(String contactType) { if (YiXinFriendRelationEnum.RELATIVES.getCode().equals(contactType)) { //亲属 return "601"; } else if (YiXinFriendRelationEnum.FRIEND.getCode().equals(contactType)) { //朋友 return "602"; } else if (YiXinFriendRelationEnum.COLLEAGUE.getCode().equals(contactType)) { //同事 return "603"; } else { return "602"; } } /** * 审核结果查询 * 渠道方调用该接口获取平台方审核结果 * * @param orderNo * @param log * @param logNumber * @return */ public HyResponse getAuditResult(String orderNo, Logger log, String logNumber) { String url = "/getAuditResult"; JSONObject root = new JSONObject(); //进件单号 root.put("orderNo", orderNo); try { log.info("日志编号:" + logNumber + "审核结果查询参数 -> {}", root); String request = hySignUtil.buildRequest(JSON.toJSONString(root)); log.info("日志编号:" + logNumber + "审核结果查询参数json -> {}", request); String hyResult = HttpClientUtil.getInstance().postJsonData(hySignUtil.getHyPath() + url, request); log.info("日志编号:" + logNumber + "审核结果查询返回 -> {}", hyResult); if (!TextUtils.isEmpty(hyResult)) { HyResponse hyResponse = JSON.parseObject(hyResult, HyResponse.class); if (null != hyResponse.getData()) { HyGetAuditResultResponse response = JSON.parseObject(hyResponse.getData().toString(), HyGetAuditResultResponse.class); hyResponse.setData(response); } log.info("日志编号:" + logNumber + "审核结果查询返回 -> {}", hyResponse); return hyResponse; } } catch (Exception e) { e.printStackTrace(); log.error("审核结果查询接口异常->:{}", e.getMessage()); } return null; } /** * 订单状态查询 * * @param orderNo * @param log * @param logNumber * @return */ public HyResponse getOrderStatus(String orderNo, Logger log, String logNumber) { String url = "/getOrderStatus"; JSONObject root = new JSONObject(); //进件单号 root.put("orderNo", orderNo); try { log.info("日志编号:" + logNumber + "订单状态查询参数 -> {}", root); String request = hySignUtil.buildRequest(JSON.toJSONString(root)); log.info("日志编号:" + logNumber + "订单状态查询参数json -> {}", request); String hyResult = HttpClientUtil.getInstance().postJsonData(hySignUtil.getHyPath() + url, request); log.info("日志编号:" + logNumber + "订单状态查询返回 -> {}", hyResult); if (!TextUtils.isEmpty(hyResult)) { HyResponse hyResponse = JSON.parseObject(hyResult, HyResponse.class); if (null != hyResponse.getData()) { HyGetOrderStatusResponse response = JSON.parseObject(hyResponse.getData().toString(), HyGetOrderStatusResponse.class); hyResponse.setData(response); } log.info("日志编号:" + logNumber + "订单状态查询返回 -> {}", hyResponse); return hyResponse; } } catch (Exception e) { e.printStackTrace(); log.error("订单状态查询接口异常->:{}", e.getMessage()); } return null; } /** * 绑卡信息查询 * * @param orderNo * @param log * @param logNumber * @return */ public HyResponse getBankInfo(String orderNo, Logger log, String logNumber) { String url = "/getBankInfo"; JSONObject root = new JSONObject(); //进件单号 root.put("orderNo", orderNo); try { log.info("日志编号:" + logNumber + "绑卡信息查询参数 -> {}", root); String request = hySignUtil.buildRequest(JSON.toJSONString(root)); log.info("日志编号:" + logNumber + "绑卡信息查询参数json -> {}", request); String hyResult = HttpClientUtil.getInstance().postJsonData(hySignUtil.getHyPath() + url, request); log.info("日志编号:" + logNumber + "绑卡信息查询返回 -> {}", hyResult); if (!TextUtils.isEmpty(hyResult)) { HyResponse hyResponse = JSON.parseObject(hyResult, HyResponse.class); if (null != hyResponse.getData()) { HyGetBankInfoResponse response = JSON.parseObject(hyResponse.getData().toString(), HyGetBankInfoResponse.class); hyResponse.setData(response); } log.info("日志编号:" + logNumber + "绑卡信息查询返回 -> {}", hyResponse); return hyResponse; } } catch (Exception e) { e.printStackTrace(); log.error("绑卡信息查询接口异常->:{}", e.getMessage()); } return null; } /** * 试算查询 * * @param orderNo * @param log * @param logNumber * @return */ public HyResponse getTrialInfo(String orderNo, Logger log, String logNumber) { String url = "/getTrialInfo"; JSONObject root = new JSONObject(); //进件单号 root.put("orderNo", orderNo); try { log.info("日志编号:" + logNumber + "试算查询参数 -> {}", root); String request = hySignUtil.buildRequest(JSON.toJSONString(root)); log.info("日志编号:" + logNumber + "试算查询参数json -> {}", request); String hyResult = HttpClientUtil.getInstance().postJsonData(hySignUtil.getHyPath() + url, request); log.info("日志编号:" + logNumber + "试算查询返回 -> {}", hyResult); if (!TextUtils.isEmpty(hyResult)) { HyResponse hyResponse = JSON.parseObject(hyResult, HyResponse.class); if (null != hyResponse.getData()) { HyGetTrialInfoResponse response = JSON.parseObject(hyResponse.getData().toString(), HyGetTrialInfoResponse.class); hyResponse.setData(response); } log.info("日志编号:" + logNumber + "试算查询返回 -> {}", hyResponse); return hyResponse; } } catch (Exception e) { e.printStackTrace(); log.error("试算查询接口异常->:{}", e.getMessage()); } return null; } /** * 确认借款 * * @param dto * @param log * @param logNumber * @return */ public HyResponse confirm(HyConfirmDto dto, Logger log, String logNumber) { String url = "/confirm"; JSONObject root = new JSONObject(); root.put("orderNo", dto.getOrderNo()); root.put("applyAmount", dto.getApplyAmount()); root.put("applyPeriodNum", dto.getApplyPeriodNum()); root.put("applyPeriodNumUnit", dto.getApplyPeriodNumUnit()); try { log.info("日志编号:" + logNumber + "确认借款参数 -> {}", root); String request = hySignUtil.buildRequest(JSON.toJSONString(root)); log.info("日志编号:" + logNumber + "确认借款参数json -> {}", request); String hyResult = HttpClientUtil.getInstance().postJsonData(hySignUtil.getHyPath() + url, request); log.info("日志编号:" + logNumber + "确认借款返回 -> {}", hyResult); if (!TextUtils.isEmpty(hyResult)) { HyResponse hyResponse = JSON.parseObject(hyResult, HyResponse.class); log.info("日志编号:" + logNumber + "确认借款返回 -> {}", hyResponse); return hyResponse; } } catch (Exception e) { e.printStackTrace(); log.error("确认借款接口异常->:{}", e.getMessage()); } return null; } /** * 签约 * * @param dto * @param log * @param logNumber * @return */ public HyResponse getSignUrl(HyGetSignUrlDto dto, Logger log, String logNumber) { String url = "/getSignUrl"; JSONObject root = new JSONObject(); root.put("orderNo", dto.getOrderNo()); root.put("returnUrl", dto.getReturnUrl()); try { log.info("日志编号:" + logNumber + "签约参数 -> {}", root); String request = hySignUtil.buildRequest(JSON.toJSONString(root)); log.info("日志编号:" + logNumber + "签约参数json -> {}", request); String hyResult = HttpClientUtil.getInstance().postJsonData(hySignUtil.getHyPath() + url, request); log.info("日志编号:" + logNumber + "签约返回 -> {}", hyResult); if (!TextUtils.isEmpty(hyResult)) { HyResponse hyResponse = JSON.parseObject(hyResult, HyResponse.class); if (null != hyResponse.getData()) { HyGetSignUrlResponse response = JSON.parseObject(hyResponse.getData().toString(), HyGetSignUrlResponse.class); hyResponse.setData(response); } log.info("日志编号:" + logNumber + "签约返回 -> {}", hyResponse); return hyResponse; } } catch (Exception e) { e.printStackTrace(); log.error("签约接口异常->:{}", e.getMessage()); } return null; } /** * 还款 * * @param dto * @param log * @param logNumber * @return */ public HyResponse getRepayUrl(HyGetRepayUrlDto dto, Logger log, String logNumber) { String url = "/getRepayUrl"; JSONObject root = new JSONObject(); root.put("orderNo", dto.getOrderNo()); root.put("returnUrl", dto.getReturnUrl()); try { log.info("日志编号:" + logNumber + "还款参数 -> {}", root); String request = hySignUtil.buildRequest(JSON.toJSONString(root)); log.info("日志编号:" + logNumber + "还款参数json -> {}", request); String hyResult = HttpClientUtil.getInstance().postJsonData(hySignUtil.getHyPath() + url, request); log.info("日志编号:" + logNumber + "还款返回 -> {}", hyResult); if (!TextUtils.isEmpty(hyResult)) { HyResponse hyResponse = JSON.parseObject(hyResult, HyResponse.class); if (null != hyResponse.getData()) { HyGetRepayUrlResponse response = JSON.parseObject(hyResponse.getData().toString(), HyGetRepayUrlResponse.class); hyResponse.setData(response); } log.info("日志编号:" + logNumber + "还款返回 -> {}", hyResponse); return hyResponse; } } catch (Exception e) { e.printStackTrace(); log.error("还款接口异常->:{}", e.getMessage()); } return null; } /** * 还款计划查询 * * @param orderNo * @param log * @param logNumber * @return */ public HyResponse> getRepayPlan(String orderNo, Logger log, String logNumber) { String url = "/getRepayPlan"; JSONObject root = new JSONObject(); root.put("orderNo", orderNo); try { log.info("日志编号:" + logNumber + "还款计划查询参数 -> {}", root); String request = hySignUtil.buildRequest(JSON.toJSONString(root)); log.info("日志编号:" + logNumber + "还款计划查询参数json -> {}", request); String hyResult = HttpClientUtil.getInstance().postJsonData(hySignUtil.getHyPath() + url, request); log.info("日志编号:" + logNumber + "还款计划查询返回 -> {}", hyResult); if (!TextUtils.isEmpty(hyResult)) { HyResponse hyResponse = JSON.parseObject(hyResult, HyResponse.class); if (null != hyResponse.getData()) { List planResponses = JSONArray.parseArray(hyResponse.getData().toString(), HyGetRepayPlanResponse.class); hyResponse.setData(planResponses); } log.info("日志编号:" + logNumber + "还款计划查询返回 -> {}", hyResponse); return hyResponse; } } catch (Exception e) { e.printStackTrace(); log.error("还款计划查询接口异常->:{}", e.getMessage()); } return null; } /** * 协议 * * @param dto * @param log * @param logNumber */ public HyResponse> getContracts(HyGetContractsDto dto, Logger log, String logNumber) { String url = "/getContracts"; JSONObject root = new JSONObject(); root.put("contractTypeList", dto.getContractTypeList()); root.put("orderNo", dto.getOrderNo()); try { log.info("日志编号:" + logNumber + "协议参数 -> {}", root); String request = hySignUtil.buildRequest(JSON.toJSONString(root)); log.info("日志编号:" + logNumber + "协议参数json -> {}", request); String hyResult = HttpClientUtil.getInstance().postJsonData(hySignUtil.getHyPath() + url, request); log.info("日志编号:" + logNumber + "协议查询返回 -> {}", hyResult); if (!TextUtils.isEmpty(hyResult)) { HyResponse hyResponse = JSON.parseObject(hyResult, HyResponse.class); if (null != hyResponse.getData()) { Map map = JSON.parseObject(hyResponse.getData().toString(), Map.class); hyResponse.setData(map); } log.info("日志编号:" + logNumber + "协议查询返回 -> {}", hyResponse); return hyResponse; } } catch (Exception e) { e.printStackTrace(); log.error("协议接口异常->:{}", e.getMessage()); } return null; } }