package com.nova.sankuai.domain.api.yixin;
|
|
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.util.IdUtil;
|
import com.alibaba.fastjson.JSON;
|
import com.nova.sankuai.domain.api.yixin.dto.*;
|
import com.nova.sankuai.domain.api.yixin.response.*;
|
import com.nova.sankuai.domain.api.yixin.vo.RepayVo;
|
import com.nova.sankuai.domain.entity.Customer;
|
import com.nova.sankuai.domain.enums.capitalInfo.CapitalInfoTypeCodeEnum;
|
import com.nova.sankuai.domain.enums.customerinfo.*;
|
import com.nova.sankuai.domain.enums.yixin.YiXinFriendRelationEnum;
|
import com.nova.sankuai.domain.enums.yixin.YiXinHomeRelationEnum;
|
import com.nova.sankuai.domain.enums.yixin.YiXinLivestEnum;
|
import com.nova.sankuai.security.HttpClientUtil;
|
import io.swagger.annotations.ApiModelProperty;
|
import org.apache.commons.lang.StringUtils;
|
import org.apache.http.util.TextUtils;
|
import org.slf4j.Logger;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.stereotype.Component;
|
|
import java.security.KeyFactory;
|
import java.security.PrivateKey;
|
import java.security.PublicKey;
|
import java.security.interfaces.RSAPublicKey;
|
import java.security.spec.PKCS8EncodedKeySpec;
|
import java.security.spec.X509EncodedKeySpec;
|
import java.util.*;
|
|
/**
|
* 绿地对接
|
*/
|
@Component
|
public class YXUtil {
|
|
@ApiModelProperty(value = "资金方-宜信")
|
public static final String FUNDING_YIXIN = "YIXIN";
|
@ApiModelProperty(value = "资金方-小花钱包")
|
public static final String FUNDING_XHQB = "XHQB";
|
@ApiModelProperty(value = "资金方-洋钱罐对接")
|
public static final String FUNDING_JQTX = "JQTX";
|
@ApiModelProperty(value = "资金方-普融花")
|
public static final String FUNDING_PRH = "JUNHANG";
|
|
@Value("${yixin.path}")
|
private String yxPath;
|
|
@Value("${tengxunyun.suyihua.appId}")
|
private String syhAppId;
|
|
@Value("${tengxunyun.suyihua.secret}")
|
private String syhSecret;
|
|
@Value("${yixin.publickey}")
|
private String yxPubKey;
|
|
@Value("${tengxunyun.jieyidai.appId}")
|
private String jydAppId;
|
|
@Value("${tengxunyun.jieyidai.secret}")
|
private String jydSecret;
|
|
@Value("${tengxunyun.sankuaifenqi.appId}")
|
private String skAppId;
|
|
@Value("${tengxunyun.sankuaifenqi.secret}")
|
private String skSecret;
|
|
@Value("${tengxunyun.jixianghua.appId}")
|
private String jxhAppId;
|
|
@Value("${tengxunyun.jixianghua.secret}")
|
private String jxhSecret;
|
|
@Value("${tengxunyun.weixianghua.appId}")
|
private String wxhAppId;
|
|
@Value("${tengxunyun.weixianghua.secret}")
|
private String wxhSecret;
|
|
@Value("${tengxunyun.kadana.appId}")
|
private String kdnAppId;
|
|
@Value("${tengxunyun.kadana.secret}")
|
private String kdnSecret;
|
|
@Value("${tengxunyun.jxd.appId}")
|
private String jxdAppId;
|
|
@Value("${tengxunyun.jxd.secret}")
|
private String jxdSecret;
|
|
public String getSerialNo() {
|
UUID uuid = UUID.randomUUID();
|
String serialNo = uuid.toString().replace("-", "");
|
return serialNo;
|
}
|
|
public String createRepayApplyNo() {
|
long nextId = IdUtil.getSnowflake().nextId();
|
String serialNo = "XD_LD_" + YXSignUtil.reqSysCode + "_" + nextId;
|
return serialNo;
|
}
|
|
public String getFunding(String code) {
|
String funding;
|
if (CapitalInfoTypeCodeEnum.XIAO_HUA_QIAN_BAO.getCode().equals(code)) {
|
funding = YXUtil.FUNDING_XHQB;
|
} else if (CapitalInfoTypeCodeEnum.JIN_QIAN_TIAN_XIA.getCode().equals(code)) {
|
funding = YXUtil.FUNDING_JQTX;
|
} else if (CapitalInfoTypeCodeEnum.PU_RONG_HUA.getCode().equals(code)) {
|
funding = YXUtil.FUNDING_PRH;
|
} else {
|
funding = YXUtil.FUNDING_YIXIN;
|
}
|
return funding;
|
}
|
|
/**
|
* 2.4.7.还款结果查询接口
|
*
|
* @param funding 资金方代码
|
* @param logNumber 日志编号
|
* @param logger 日志对象
|
*/
|
public YxRepaymentResultResponse yxRepaymentResult(YxRepaymentResultDto dto,
|
String funding, Logger logger, String logNumber) {
|
String url = "/flow/repaymentResult";
|
Map<String, Object> param = new HashMap<>(16);
|
param.put("userId", dto.getUserId());
|
param.put("repayApplyNo", dto.getRepayApplyNo());
|
try {
|
logger.info("日志编号:" + logNumber + "还款结果查询接口参数 -> {}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "还款结果查询接口加密参数 -> {}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
|
// logger.info("日志编号:" + logNumber + "还款结果查询接口加密返回 -> {}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> map = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "还款结果查询接口加密返回 -> {}", map);
|
if (!TextUtils.isEmpty(map.get("params"))) {
|
return JSON.parseObject(map.get("params"), YxRepaymentResultResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
/**
|
* 2.3.1 支持银行列表查询接口
|
*
|
* @param funding 资金方代码
|
* @param logNumber 日志编号
|
* @param logger 日志对象
|
*/
|
public YxGetUsableBankListResponse yxGetUsableBankList(Long userId,
|
String funding, Logger logger, String logNumber) {
|
String url = "/flow/getUsableBankList";
|
Map<String, Object> param = new HashMap<>(16);
|
param.put("userId", userId);
|
try {
|
logger.info("日志编号:" + logNumber + "支持银行列表查询接口参数 -> {}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "支持银行列表查询接口加密参数 -> {}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
|
// logger.info("日志编号:" + logNumber + "支持银行列表查询接口加密返回 -> {}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> map = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "支持银行列表查询接口加密返回 -> {}", map);
|
if (!TextUtils.isEmpty(map.get("params"))) {
|
return JSON.parseObject(map.get("params"), YxGetUsableBankListResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
/**
|
* 2.3.1 绑卡获取验证码参数
|
*
|
* @param logger 日志对象
|
* @param logNumber 日志编号
|
* @param dto 绑卡获取验证码参数Dto
|
* @param funding 资金方代码
|
*/
|
public YxBindBankSmsResponse yxBindBankSms(YxBindBankSmsDto dto,
|
String funding, Logger logger, String logNumber) {
|
String url = "/flow/getBindBankSMS";
|
Map<String, Object> param = new HashMap<>(16);
|
param.put("serialNo", dto.getSerialNo());
|
param.put("fundCode", funding);
|
param.put("scene", dto.getScene());
|
param.put("loanNo", dto.getLoanNo());
|
param.put("creditNo", dto.getCreditNo());
|
param.put("idNo", dto.getIdNo());
|
param.put("custName", dto.getCustName());
|
param.put("phoneNo", dto.getPhoneNo());
|
param.put("userId", dto.getUserId());
|
param.put("custName", dto.getCustName());
|
param.put("bankCardNum", dto.getBankCardNum());
|
param.put("bankCode", dto.getBankCode());
|
|
try {
|
logger.info("日志编号:" + logNumber + "绑卡获取验证码接口参数 -> {}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "绑卡获取验证码加密参数 -> {}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
|
// logger.info("日志编号:" + logNumber + "绑卡获取验证码加密返回 -> {}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> map = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "绑卡获取验证码加密返回 -> {}", map);
|
if (!TextUtils.isEmpty(map.get("params"))) {
|
return JSON.parseObject(map.get("params"), YxBindBankSmsResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
/**
|
* 2.3.2 绑卡验证码提交
|
*
|
* @param funding 资金方代码
|
* @param dto 绑卡验证码提交参数Dto
|
* @param logger 日志对象
|
* @param logNumber 日志编号
|
*/
|
public YxBindBankSubmitResponse yxVerifyBindBankSMS(YxBindBankSubmitDto dto,
|
String funding, Logger logger, String logNumber) {
|
String url = "/flow/verifyBindBankSMS";
|
Map<String, Object> param = new HashMap<>(16);
|
param.put("serialNo", dto.getSerialNo());
|
param.put("fundCode", funding);
|
param.put("scene", dto.getScene());
|
param.put("loanNo", dto.getLoanNo());
|
param.put("creditNo", dto.getCreditNo());
|
param.put("messageNo", dto.getMessageNo());
|
param.put("bankCardNum", dto.getBankCardNum());
|
param.put("verifyCode", dto.getVerifyCode());
|
|
try {
|
logger.info("日志编号:" + logNumber + "绑卡验证码提交接口参数 -> {}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "绑卡验证码提交加密参数 -> {}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
|
// logger.info("日志编号:" + logNumber + "绑卡验证码提交加密返回 -> {}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> map = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "绑卡验证码提交加密返回 -> {}", map);
|
if (!TextUtils.isEmpty(map.get("params"))) {
|
return JSON.parseObject(map.get("params"), YxBindBankSubmitResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
/**
|
* 2.3.3 用户银行卡列表查询接口
|
*
|
* @param logger 日志对象
|
* @param dto 用户银行卡列表查询接口
|
* @param funding 资金方代码
|
* @param logNumber 日志编号
|
*/
|
public YxQueryUserBankListResponse yxQueryUserBankList(YxQueryUserBankListDto dto,
|
String funding, Logger logger, String logNumber) {
|
String url = "/flow/queryUserBankList";
|
Map<String, Object> param = new HashMap<>(16);
|
param.put("userId", dto.getUserId());
|
param.put("loanNo", dto.getLoanNo());
|
try {
|
logger.info("日志编号:" + logNumber + "用户银行卡列表查询接口参数 -> {}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "用户银行卡列表查询加密参数 -> {}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
|
// logger.info("日志编号:" + logNumber + "用户银行卡列表查询返回 -> {}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> map = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "用户银行卡列表查询加密返回 -> {}", map);
|
if (!TextUtils.isEmpty(map.get("params"))) {
|
return JSON.parseObject(map.get("params"), YxQueryUserBankListResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
/**
|
* 2.3.4 获取H5绑卡页面
|
*
|
* @param logNumber 日志编号
|
* @param funding 资金方代码
|
* @param logger 日志对象
|
* @param queryDTO
|
*/
|
public YxGetBindCardUrlResponse yxGetBindCardUrl(YxGetBindCardUrlDto queryDTO,
|
String funding, Logger logger, String logNumber) {
|
String url = "/flow/getBindCardUrl";
|
Map<String, Object> param = BeanUtil.beanToMap(queryDTO);
|
try {
|
logger.info("日志编号:" + logNumber + "用户银行卡列表查询接口参数 -> {}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "用户银行卡列表查询加密参数 -> {}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
|
// logger.info("日志编号:" + logNumber + "用户银行卡列表查询返回 -> {}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> map = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "用户银行卡列表查询加密返回 -> {}", map);
|
if (!TextUtils.isEmpty(map.get("params"))) {
|
return JSON.parseObject(map.get("params"), YxGetBindCardUrlResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
/**
|
* 2.1.1.MD5初筛撞库接口
|
*
|
* @param serialNo 流水号
|
* @param idNoMd5 身份证号MD5
|
* @param phoneMd5 手机号MD5
|
* @param userId 用户Id
|
* @param funding 资金方代码
|
* @param logNumber 日志编号
|
* @param logger 日志对象
|
* @return
|
*/
|
public YxApplyCheckResponse yxApplyCheckMd5(String serialNo, String idNoMd5, String phoneMd5, String userId,
|
String funding, Logger logger, String logNumber) {
|
// 请求url
|
String url = "/flow/applyCheck";
|
// 组装请求体
|
Map<String, Object> param = new HashMap<>();
|
param.put("serialNo", serialNo);
|
param.put("idNoMD5", idNoMd5);
|
param.put("phoneMD5", phoneMd5);
|
param.put("userId", userId);
|
try {
|
logger.info("日志编号:" + logNumber + "MD5初筛撞库接口参数->:{}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "MD5初筛撞库接口加密参数->:{}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
|
// logger.info("日志编号:" + logNumber + "MD5初筛撞库接口加密返回结果->:{}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "MD5初筛撞库接口加密返回resultMap->:{}", resultMap);
|
if (!TextUtils.isEmpty(resultMap.get("params"))) {
|
return JSON.parseObject(resultMap.get("params"), YxApplyCheckResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
logger.error("日志编号:" + logNumber + "MD5初筛撞库接口异常->:{}", e.getMessage());
|
}
|
return null;
|
}
|
|
/**
|
* 2.1.1.初筛撞库接口
|
*
|
* @param serialNo 流水号
|
* @param name 姓名
|
* @param idNo 身份证号
|
* @param phone 手机号
|
* @param userId 用户编号
|
* @param funding 资金方代码
|
* @param logger 日志对象
|
* @param logNumber 日志编号
|
* @return
|
*/
|
public YxApplyCheckResponse yxApplyCheck(String serialNo, String name, String idNo, String phone, String userId,
|
String funding, Logger logger, String logNumber) {
|
// 请求url
|
String url = "/flow/applyCheck";
|
// 组装请求体
|
Map<String, Object> param = new HashMap<>(16);
|
param.put("serialNo", serialNo);
|
param.put("name", name);
|
param.put("idNo", idNo);
|
param.put("phoneNo", phone);
|
param.put("userId", userId);
|
try {
|
logger.info("日志编号:" + logNumber + "初筛撞库接口请求参数->:{}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "初筛撞库接口请求加密参数->:{}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
|
// logger.info("日志编号:" + logNumber + "初筛撞库接口加密返回结果->:{}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "初筛撞库接口加密返回resultMap->:{}", resultMap);
|
if (!TextUtils.isEmpty(resultMap.get("params"))) {
|
return JSON.parseObject(resultMap.get("params"), YxApplyCheckResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
logger.error("日志编号:" + logNumber + "初筛撞库接口异常->:{}", e.getMessage());
|
}
|
return null;
|
}
|
|
|
/**
|
* 2.2.2.借款试算接口,用于借款前
|
*
|
* @param logger 日志对象
|
* @param funding 资金方代码
|
* @param logNumber 日志编号
|
* @param trialDto 借款试算接口Dto
|
*/
|
public YxTrialResponse yxTrial(YxTrialDto trialDto,
|
String funding, Logger logger, String logNumber) {
|
String trial = "/flow/trial";
|
Map<String, Object> param = new HashMap<>();
|
param.put("loanNo", trialDto.getLoanNo());
|
param.put("creditNo", trialDto.getCreditNo());
|
param.put("applyAmount", trialDto.getApplyAmount());
|
param.put("applyTerm", trialDto.getApplyTerm());
|
param.put("termType", trialDto.getTermType());
|
param.put("userId", trialDto.getUserId());
|
try {
|
logger.info("日志编号:" + logNumber + "借款试算参数->:{}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "借款试算加密参数->:{}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + trial, paramStr);
|
// logger.info("日志编号:" + logNumber + "借款试算加密返回->:{}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "借款试算加密返回resultMap->:{}", resultMap);
|
if (!TextUtils.isEmpty(resultMap.get("params"))) {
|
return JSON.parseObject(resultMap.get("params"), YxTrialResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 2.2.3.用信信息传输接口
|
*
|
* @param logNumber 日志编号
|
* @param funding 资金方代码
|
* @param logger 日志对象
|
* @param loanApplyDto 用信信息传输接口Dto
|
*/
|
public YxLoanApplyResponse yxLoanApply(YxLoanApplyDto loanApplyDto,
|
String funding, Logger logger, String logNumber) {
|
String loanApply = "/flow/loanApply";
|
Map<String, Object> param = new HashMap<>();
|
param.put("loanNo", loanApplyDto.getLoanNo());
|
param.put("creditNo", loanApplyDto.getCreditNo());
|
param.put("applyAmount", loanApplyDto.getApplyAmount());
|
param.put("applyTerm", loanApplyDto.getApplyTerm());
|
param.put("termType", loanApplyDto.getTermType());
|
param.put("payWay", loanApplyDto.getPayWay());
|
if (StringUtils.isNotEmpty(loanApplyDto.getVerifyCode())) {
|
param.put("verifyCode", loanApplyDto.getVerifyCode());
|
}
|
param.put("userId", loanApplyDto.getUserId());
|
try {
|
logger.info("日志编号:" + logNumber + "用信信息传输接口参数->:{}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "用信信息传输接口加密参数->:{}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + loanApply, paramStr);
|
// logger.info("日志编号:" + logNumber + "用信信息传输接口加密返回->:{}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "用信信息传输接口加密返回resultMap->:{}", resultMap);
|
if (!TextUtils.isEmpty(resultMap.get("params"))) {
|
return JSON.parseObject(resultMap.get("params"), YxLoanApplyResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 2.2.4.用信结果查询接口
|
*
|
* @param logger 日志对象
|
* @param funding 资金方代码
|
* @param logNumber 日志编号
|
* @param loanStatusQueryDto 用信结果查询接口Dto
|
*/
|
public YxLoanResultQueryResponse yxLoanStatusQuery(YxLoanStatusQueryDto loanStatusQueryDto,
|
String funding, Logger logger, String logNumber) {
|
String loanStatusQuery = "/flow/loanStatusQuery";
|
Map<String, Object> param = new HashMap<>();
|
param.put("loanNo", loanStatusQueryDto.getLoanNo());
|
try {
|
logger.info("日志编号:" + logNumber + "用信结果查询接口参数->:{}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "用信结果查询接口加密参数->:{}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + loanStatusQuery, paramStr);
|
// logger.info("日志编号:" + logNumber + "用信结果查询接口加密返回->:{}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "用信结果查询接口加密返回resultMap->:{}", resultMap);
|
if (!TextUtils.isEmpty(resultMap.get("params"))) {
|
return JSON.parseObject(resultMap.get("params"), YxLoanResultQueryResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 2.4.1.还款试算接口,用于放款后
|
*
|
* @param logNumber 日志编号
|
* @param funding 资金方代码
|
* @param logger 日志对象
|
* @param applyDto 还款试算接口Dto
|
*/
|
public YxPreRepayApplyResponse yxPreRepayApply(YxPreRepayApplyDto applyDto,
|
String funding, Logger logger, String logNumber) {
|
String getPreRepayApply = "/flow/preRepayApply";
|
Map<String, Object> param = new HashMap<>();
|
param.put("userId", applyDto.getUserId());
|
param.put("loanNo", applyDto.getLoanNo());
|
param.put("prePayType", applyDto.getPrePayType());
|
param.put("term", applyDto.getTerm());
|
try {
|
logger.info("日志编号:" + logNumber + "还款试算参数->:{}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "还款试算加密参数->:{}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + getPreRepayApply, paramStr);
|
// logger.info("日志编号:" + logNumber + "还款试算加密返回->:{}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "还款试算加密返回resultMap->:{}", resultMap);
|
if (!TextUtils.isEmpty(resultMap.get("params"))) {
|
return JSON.parseObject(resultMap.get("params"), YxPreRepayApplyResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 2.4.2.还款计划查询接口-合作方查询资金方还款计划
|
*
|
* @param logger 日志对象
|
* @param funding 资金方代码
|
* @param logNumber 日志编号
|
* @param planQueryDto 还款计划查询接口Dto
|
*/
|
public YxRepaymentPlanQueryResponse yxRepaymentPlanQuery(YxRepaymentPlanQueryDto planQueryDto,
|
String funding, Logger logger, String logNumber) {
|
String repaymentPlanQuery = "/flow/repaymentPlanQuery";
|
Map<String, Object> param = new HashMap<>();
|
param.put("userId", planQueryDto.getUserId());
|
param.put("loanNo", planQueryDto.getLoanNo());
|
param.put("reqSysCode", YXSignUtil.reqSysCode);
|
try {
|
logger.info("日志编号:" + logNumber + "还款计划查询参数->:{}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "还款计划查询加密参数->:{}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + repaymentPlanQuery, paramStr);
|
// logger.info("日志编号:" + logNumber + "还款计划查询加密返回->:{}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "还款计划查询加密返回resultMap->:{}", resultMap);
|
if (!TextUtils.isEmpty(resultMap.get("params"))) {
|
return JSON.parseObject(resultMap.get("params"), YxRepaymentPlanQueryResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
/**
|
* 2.4.3.用户还款请求接口-通过接口还款
|
*
|
* @param logNumber 日志编号
|
* @param repaymentApplyDto 用户还款请求接口Dto
|
* @param funding 资金方代码
|
* @param logger 日志对象
|
*/
|
public YxRepaymentApplyResponse yxRepaymentApply(YxRepaymentApplyDto repaymentApplyDto,
|
String funding, Logger logger, String logNumber) {
|
String repaymentApply = "/flow/repaymentApply";
|
Map<String, Object> param = new HashMap<>();
|
param.put("repayApplyNo", repaymentApplyDto.getRepayApplyNo());
|
param.put("userId", repaymentApplyDto.getUserId());
|
param.put("loanNo", repaymentApplyDto.getLoanNo());
|
param.put("repayType", repaymentApplyDto.getRepayType());
|
if (StringUtils.isNotEmpty(repaymentApplyDto.getAmount())) {
|
param.put("amount", repaymentApplyDto.getAmount());
|
}
|
param.put("bankCardNo", repaymentApplyDto.getBankCardNo());
|
List<Map<String, String>> repayList = new ArrayList<>();
|
for (RepayVo repayVo : repaymentApplyDto.getRepayList()) {
|
Map<String, String> repayParam = new HashMap<>();
|
if (StringUtils.isNotEmpty(repayVo.getRepayAmt())) {
|
repayParam.put("repayAmt", repayVo.getRepayAmt());
|
}
|
repayParam.put("repayTerm", repayVo.getRepayTerm());
|
repayList.add(repayParam);
|
}
|
param.put("repayList", repayList);
|
try {
|
logger.info("日志编号:" + logNumber + "用户还款请求接口参数->:{}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "用户还款请求接口加密参数->:{}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + repaymentApply, paramStr);
|
// logger.info("日志编号:" + logNumber + "用户还款请求接口加密返回->:{}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("用户还款请求接口加密返回resultMap->:{}", resultMap);
|
if (!TextUtils.isEmpty(resultMap.get("params"))) {
|
return JSON.parseObject(resultMap.get("params"), YxRepaymentApplyResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
/**
|
* 2.4.4.用户还款确认接口-通过接口还款,需要验证码时使用此接口
|
*
|
* @param logger 日志对象
|
* @param logNumber 日志编号
|
* @param funding 资金方代码
|
* @param repaymentApplyDto 用户还款请求接口Dto
|
*/
|
public YxRepaymentApplyResponse yxRepaymentConfirm(YxRepaymentApplyDto repaymentApplyDto,
|
String funding, Logger logger, String logNumber) {
|
String repaymentApply = "/flow/repaymentConfirm";
|
Map<String, Object> param = new HashMap<>();
|
param.put("repayApplyNo", repaymentApplyDto.getRepayApplyNo());
|
param.put("userId", repaymentApplyDto.getUserId());
|
param.put("loanNo", repaymentApplyDto.getLoanNo());
|
param.put("repayType", repaymentApplyDto.getRepayType());
|
if (StringUtils.isNotEmpty(repaymentApplyDto.getAmount())) {
|
param.put("amount", repaymentApplyDto.getAmount());
|
}
|
param.put("bankCardNo", repaymentApplyDto.getBankCardNo());
|
param.put("verifyCode", repaymentApplyDto.getVerifyCode());
|
List<Map<String, String>> repayList = new ArrayList<>();
|
for (RepayVo repayVo : repaymentApplyDto.getRepayList()) {
|
Map<String, String> repayParam = new HashMap<>();
|
if (StringUtils.isNotEmpty(repayVo.getRepayAmt())) {
|
repayParam.put("repayAmt", repayVo.getRepayAmt());
|
}
|
repayParam.put("repayTerm", repayVo.getRepayTerm());
|
repayList.add(repayParam);
|
}
|
param.put("repayList", repayList);
|
try {
|
logger.info("日志编号:" + logNumber + "用户还款确认接口参数->:{}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "用户还款确认接口加密参数->:{}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + repaymentApply, paramStr);
|
// logger.info("日志编号:" + logNumber + "用户还款确认接口加密返回->:{}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "用户还款确认接口加密返回resultMap->:{}", resultMap);
|
if (!TextUtils.isEmpty(resultMap.get("params"))) {
|
return JSON.parseObject(resultMap.get("params"), YxRepaymentApplyResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
/**
|
* 2.4.5.获取还款H5页面
|
*
|
* @param funding 资金方代码
|
* @param logNumber 日志编号
|
* @param logger 日志对象
|
* @param repaymentUrlDto 获取还款H5页面Dto
|
*/
|
public YxRepaymentUrlResponse yxRepaymentUrl(YxRepaymentUrlDto repaymentUrlDto,
|
String funding, Logger logger, String logNumber) {
|
String repaymentUrl = "/flow/repaymentUrl";
|
Map<String, Object> param = new HashMap<>();
|
param.put("loanNo", repaymentUrlDto.getLoanNo());
|
param.put("userId", repaymentUrlDto.getUserId());
|
param.put("returnUrl", repaymentUrlDto.getReturnUrl());
|
try {
|
logger.info("日志编号:" + logNumber + "还款计划查询参数->:{}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "还款计划查询加密参数->:{}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + repaymentUrl, paramStr);
|
// logger.info("日志编号:" + logNumber + "还款计划查询加密返回->:{}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "还款计划查询加密返回resultMap->:{}", resultMap);
|
if (!TextUtils.isEmpty(resultMap.get("params"))) {
|
return JSON.parseObject(resultMap.get("params"), YxRepaymentUrlResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
/**
|
* 2.1.2.授信申请
|
*
|
* @param logger 日志对象
|
* @param logNumber 日志编号
|
* @param userId 用户Id
|
* @param funding 资金方代码
|
* @param customer 客户申请记录
|
*/
|
public YXResponse yxCreditApply(Customer customer, String userId,
|
String funding, Logger logger, String logNumber) {
|
//流量方调用资金方进行授信信息传输,资金方对该信息进行校验,此接口为实时接口
|
String creditApplyUrl = "/flow/creditApply";
|
|
Map<String, Object> param = new HashMap<>();
|
param.put("creditNo", customer.getCreditNo());
|
param.put("sourceChannel", customer.getSourceChannel());
|
|
//用户授信信息
|
Map<String, Object> creditInfo = new HashMap<>();
|
creditInfo.put("userId", userId);
|
creditInfo.put("creditApplyAmount", customer.parseLoadAmount());
|
creditInfo.put("applyTerm", customer.getLoanTerm());
|
creditInfo.put("applyUse", customer.getUseOfLoan());
|
creditInfo.put("custName", customer.getName());
|
creditInfo.put("idNo", customer.getIdCard());
|
creditInfo.put("phoneNo", customer.getPhone());
|
creditInfo.put("sex", customer.getSex());
|
if (StringUtils.isNotEmpty(customer.getNationality())) {
|
creditInfo.put("nationality", customer.getNationality());
|
} else {
|
creditInfo.put("nationality", "中国");
|
}
|
creditInfo.put("nation", customer.getNation());
|
creditInfo.put("birthday", DateUtil.formatDate(DateUtil.parse(customer.getBirthday())));
|
creditInfo.put("idAddress", customer.getIdAddress());
|
creditInfo.put("signOrganization", customer.getSignOrganization());
|
creditInfo.put("idValidDateBegin", DateUtil.formatDate(DateUtil.parse(customer.getIdValidDateBegin())));
|
creditInfo.put("idValidDateEnd", DateUtil.formatDate(DateUtil.parse(customer.getIdValidDateEnd())));
|
if ("长期".equals(customer.getIdValidDateEnd())) {
|
creditInfo.put("idLongTerm", "1");
|
}
|
creditInfo.put("custEducation", formatYXEducation(customer.getEducation()));
|
creditInfo.put("marriage", formatYXMarriage(customer.getMaritalStatus()));
|
creditInfo.put("verifySimilarity", customer.getVerifySimilarity());
|
creditInfo.put("verifySimilarityName", customer.getVerifySimilarityName());
|
if (StringUtils.isNotEmpty(customer.getEmail())) {
|
creditInfo.put("email", customer.getEmail());
|
}
|
if (StringUtils.isNotEmpty(customer.getLng())) {
|
creditInfo.put("lng", customer.getLng());
|
} else {
|
creditInfo.put("lng", "0000-0000");
|
}
|
if (StringUtils.isNotEmpty(customer.getLat())) {
|
creditInfo.put("lat", customer.getLat());
|
} else {
|
creditInfo.put("lat", "0000-0000");
|
}
|
if (StringUtils.isNotEmpty(customer.getMac())) {
|
creditInfo.put("Mac", customer.getMac());
|
}
|
creditInfo.put("deviceID", customer.getDeviceId());
|
creditInfo.put("deviceOsVersion", customer.getDeviceOsVersion());
|
if (StringUtils.isNotEmpty(customer.getIdfa())) {
|
creditInfo.put("idfa", customer.getIdfa());
|
}
|
if (StringUtils.isNotEmpty(customer.getIdfv())) {
|
creditInfo.put("idfv", customer.getIdfv());
|
}
|
creditInfo.put("os", customer.getOs());
|
if (StringUtils.isNotEmpty(customer.getAndroidId())) {
|
creditInfo.put("androidId", customer.getAndroidId());
|
}
|
if (customer.getIsRoot() != null) {
|
creditInfo.put("isRoot", customer.getIsRoot());
|
} else {
|
creditInfo.put("isRoot", 0);
|
}
|
if (StringUtils.isNotEmpty(customer.getImei())) {
|
creditInfo.put("IMEI", customer.getImei());
|
}
|
creditInfo.put("liveProvince", customer.getLiveProvince());
|
creditInfo.put("liveCity", customer.getCity());
|
creditInfo.put("liveArea", customer.getLiveArea());
|
creditInfo.put("liveAddress", customer.getAddress());
|
creditInfo.put("client_ip", customer.getClientIp());
|
creditInfo.put("haveCar", CarStatusEnum.Car_1.getCode().equals(customer.getCarStatus()) ? 0 : 1);
|
creditInfo.put("haveHouse", HouseStatusEnum.House_1.getCode().equals(customer.getHouseStatus()) ? 0 : 1);
|
if (customer.getApplyDate() != null) {
|
creditInfo.put("registerDateTime", DateUtil.formatDateTime(customer.getApplyDate()));
|
}
|
creditInfo.put("familyMonthlyIncome", customer.getFamilyMonthlyIncome());
|
if (StringUtils.isNotEmpty(customer.getLivest())) {
|
creditInfo.put("livest", customer.getLivest());
|
} else {
|
creditInfo.put("livest", YiXinLivestEnum.UNKNOWN.getCode());
|
}
|
if (StringUtils.isNotEmpty(customer.getGpsProvince())) {
|
creditInfo.put("gpsProvince", customer.getGpsProvince());
|
} else {
|
creditInfo.put("gpsProvince", customer.getCompanyProvince());
|
}
|
if (StringUtils.isNotEmpty(customer.getGpsCity())) {
|
creditInfo.put("gpsCity", customer.getGpsCity());
|
} else {
|
creditInfo.put("gpsCity", customer.getCompanyCity());
|
}
|
if (StringUtils.isNotEmpty(customer.getGpsArea())) {
|
creditInfo.put("gpsArea", customer.getGpsArea());
|
} else {
|
creditInfo.put("gpsArea", customer.getCompanyArea());
|
}
|
creditInfo.put("gpsAddress", "0000-0000");
|
if (StringUtils.isNotEmpty(customer.getDeviceBrand())) {
|
creditInfo.put("deviceBrand", customer.getDeviceBrand());
|
} else {
|
creditInfo.put("deviceBrand", "华为");
|
}
|
//设备型号 例如: P30
|
creditInfo.put("deviceModel", "0000-0000");
|
//联系人列表,列表中需要包含家庭联系人、其它联系人,两种类型各一个
|
List<Map<String, String>> contactRelationLists = new ArrayList<>();
|
//家庭联系人
|
Map<String, String> HomeRelation = new HashMap<>();
|
String homeShip = formatYXRelationship(customer.getRelationship());
|
HomeRelation.put("contactRelation", homeShip);
|
HomeRelation.put("contactName", customer.getRelationshipName());
|
HomeRelation.put("contactPhoneNo", customer.getRelationshipPhone());
|
if (RelationshipEnum.Relationship_3.getCode().equals(homeShip)) {
|
if (StringUtils.isNotEmpty(customer.getCertNo()) && StringUtils.isNotEmpty(customer.getContactCompany())) {
|
HomeRelation.put("certNo", customer.getCertNo());
|
HomeRelation.put("contactCompany", customer.getContactCompany());
|
} else {
|
creditInfo.replace("marriage", MaritalStatusEnum.MaritalStatus_9.getSys());
|
HomeRelation.replace("contactRelation", YiXinHomeRelationEnum.BROTHERS.getCode());
|
}
|
}
|
contactRelationLists.add(HomeRelation);
|
//其他联系人
|
Map<String, String> otherRelation = new HashMap<>();
|
if (StringUtils.isNotEmpty(customer.getContactRelation())) {
|
otherRelation.put("contactRelation", customer.getContactRelation());
|
} else {
|
otherRelation.put("contactRelation", YiXinFriendRelationEnum.OTHER.getCode());
|
}
|
otherRelation.put("contactName", customer.getContactName());
|
otherRelation.put("contactPhoneNo", customer.getContactPhone());
|
contactRelationLists.add(otherRelation);
|
creditInfo.put("contactRelationLists", contactRelationLists);
|
|
//图片列表
|
List<Map<String, String>> pictureList = new ArrayList<>();
|
|
//正面身份证
|
Map<String, String> pictureFront = new HashMap<>();
|
pictureFront.put("methods", "0");
|
pictureFront.put("pictureType", "0");
|
pictureFront.put("pictureUrl", customer.getIdCardFrontPath());
|
pictureList.add(pictureFront);
|
|
//反面身份证
|
Map<String, String> pictureBack = new HashMap<>();
|
pictureBack.put("methods", "0");
|
pictureBack.put("pictureType", "1");
|
pictureBack.put("pictureUrl", customer.getIdCardBackPath());
|
pictureList.add(pictureBack);
|
creditInfo.put("pictureList", pictureList);
|
|
//活检照片
|
Map<String, String> pictureFace = new HashMap<>();
|
pictureFace.put("methods", "0");
|
pictureFace.put("pictureType", "2");
|
pictureFace.put("pictureUrl", customer.getFacePhotoPath());
|
pictureList.add(pictureFace);
|
creditInfo.put("pictureList", pictureList);
|
|
param.put("creditInfo", creditInfo);
|
|
|
//职位信息
|
Map<String, String> dutyInfo = new HashMap<>();
|
dutyInfo.put("income", MonthlyIncomeEnum.parseAmount(customer.getMonthlyIncome()));
|
dutyInfo.put("companyName", customer.getCompanyName());
|
dutyInfo.put("companyAddress", customer.getCompanyAddress());
|
dutyInfo.put("companyProvince", customer.getCompanyProvince());
|
dutyInfo.put("companyCity", customer.getCompanyCity());
|
dutyInfo.put("companyArea", customer.getCompanyArea());
|
dutyInfo.put("companyPhone", customer.getCompanyPhone());
|
dutyInfo.put("occupation", customer.getOccupation());
|
dutyInfo.put("duty", customer.getJobTitle());
|
dutyInfo.put("jobNature", customer.getCompanyNature());
|
|
param.put("dutyInfo", dutyInfo);
|
|
//银行卡相关
|
Map<String, String> debitCardInfo = new HashMap<>();
|
if (!TextUtils.isEmpty(customer.getCardNo())) {
|
debitCardInfo.put("cardNo", customer.getCardNo());
|
}
|
if (!TextUtils.isEmpty(customer.getBankCode())) {
|
debitCardInfo.put("bankCode", customer.getBankCode());
|
}
|
if (!TextUtils.isEmpty(customer.getBankName())) {
|
debitCardInfo.put("bankName", customer.getBankName());
|
}
|
if (!TextUtils.isEmpty(customer.getBankPhoneNo())) {
|
debitCardInfo.put("phoneNo", customer.getBankPhoneNo());
|
}
|
if (!TextUtils.isEmpty(customer.getBankCardName())) {
|
debitCardInfo.put("cardName", customer.getBankCardName());
|
}
|
param.put("debitCardInfo", debitCardInfo);
|
|
|
try {
|
logger.info("授信申请参数->:{}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("授信申请加密参数->:{}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + creditApplyUrl, paramStr);
|
// logger.info("授信申请加密返回->:{}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("授信结果查询加密返回resultMap->:{}", resultMap);
|
if (!TextUtils.isEmpty(resultMap.get("params"))) {
|
return JSON.parseObject(resultMap.get("params"), YXResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
logger.error("授信结果查询失败", e);
|
}
|
return null;
|
}
|
|
private String formatYXEducation(String eduction) {
|
if (EducationEnum.Education_0.getCode().equals(eduction)) {
|
return "06";
|
} else if (EducationEnum.Education_1.getCode().equals(eduction)) {
|
return "05";
|
} else if (EducationEnum.Education_2.getCode().equals(eduction)) {
|
return "04";
|
} else if (EducationEnum.Education_3.getCode().equals(eduction)) {
|
return "03";
|
} else if (EducationEnum.Education_4.getCode().equals(eduction)) {
|
return "02";
|
} else if (EducationEnum.Education_5.getCode().equals(eduction)) {
|
return "06";
|
} else {
|
return eduction;
|
}
|
}
|
|
private String formatYXMarriage(String marriage) {
|
if (MaritalStatusEnum.MaritalStatus_1.getSys().equals(marriage)) {
|
return "02";
|
} else if (MaritalStatusEnum.MaritalStatus_2.getSys().equals(marriage)) {
|
return "01";
|
} else if (MaritalStatusEnum.MaritalStatus_3.getSys().equals(marriage)) {
|
return "03";
|
} else if (MaritalStatusEnum.MaritalStatus_4.getSys().equals(marriage)) {
|
return "04";
|
} else {
|
return marriage;
|
}
|
}
|
|
private String formatYXRelationship(String relationship) {
|
if (RelationshipEnum.Relationship_1.equals(relationship)) {
|
return "02";
|
} else if (RelationshipEnum.Relationship_2.equals(relationship)) {
|
return "03";
|
} else {
|
return relationship;
|
}
|
}
|
|
|
/**
|
* 2.1.3.授信审批查询
|
*
|
* @param creditNo 授信编号
|
* @param funding 资金方代码
|
* @param userId 用户Id
|
* @param logNumber 日志编号
|
* @param logger 日志对象
|
*/
|
public YXAuditResponse yxGetCreditAudit(String userId, String creditNo,
|
String funding, Logger logger, String logNumber) {
|
|
String getCreditAudit = "/flow/getCreditAudit";
|
Map<String, Object> param = new HashMap<>();
|
param.put("creditNo", creditNo);
|
param.put("userId", userId);
|
try {
|
logger.info("日志编号:" + logNumber + "授信结果查询参数->:{}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "授信结果查询加密参数->:{}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + getCreditAudit, paramStr);
|
// logger.info("日志编号:" + logNumber + "授信结果查询加密返回->:{}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "授信结果查询加密返回resultMap->:{}", resultMap);
|
if (!TextUtils.isEmpty(resultMap.get("params"))) {
|
return JSON.parseObject(resultMap.get("params"), YXAuditResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
/**
|
* 2.1.5.额度查询接口
|
*
|
* @param logger 日志对象
|
* @param logNumber 日志编号
|
* @param userId 用户Id
|
* @param funding 资金方代码
|
* @param creditNo 授信编号
|
* @return
|
*/
|
public YXCreditLimitResponse yxGetCreditLimit(String userId, String creditNo,
|
String funding, Logger logger, String logNumber) {
|
String getCreditLimit = "/flow/getCreditLimit";
|
Map<String, Object> param = new HashMap<>();
|
param.put("creditNo", creditNo);
|
param.put("userId", userId);
|
try {
|
logger.info("日志编号:" + logNumber + "额度查询接口参数->:{}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "额度查询接口加密参数->:{}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + getCreditLimit, paramStr);
|
// logger.info("日志编号:" + logNumber + "额度查询接口加密返回->:{}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("额度查询接口加密返回resultMap->:{}", resultMap);
|
if (!TextUtils.isEmpty(resultMap.get("params"))) {
|
return JSON.parseObject(resultMap.get("params"), YXCreditLimitResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 2.5.1.合同列表查询接口
|
*
|
* @param funding 资金方代码
|
* @param userId 用户Id
|
* @param scene 使用场景 01用信绑卡 02还款绑卡 03借款申请相关 04贷后合同 05授信申请
|
* @param logNumber 日志编号
|
* @param logger 日志对象
|
* @param loanNo 贷款编号
|
* @return
|
*/
|
public YxContractResponse yxContractListQuery(String userId, String scene, String loanNo,
|
String funding, Logger logger, String logNumber) {
|
String getCreditLimit = "/flow/contractListQuery";
|
Map<String, Object> param = new HashMap<>();
|
param.put("scene", scene);
|
param.put("userId", userId);
|
param.put("reqSysCode", YXSignUtil.reqSysCode);
|
if (StringUtils.isNotEmpty(loanNo)) {
|
param.put("loanNo", loanNo);
|
}
|
try {
|
// logger.info("日志编号:" + logNumber + "合同接口请求参数->:{}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "合同接口请求加密参数->:{}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + getCreditLimit, paramStr);
|
// logger.info("日志编号:" + logNumber + "合同接口加密返回->:{}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
// logger.info("日志编号:" + logNumber + "合同接口加密返回resultMap->:{}", resultMap);
|
if (!TextUtils.isEmpty(resultMap.get("params"))) {
|
return JSON.parseObject(resultMap.get("params"), YxContractResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
|
}
|
|
/**
|
* 2.2.1.获取借款链接
|
*
|
* @param userId 用户id
|
* @param platform 平台来源
|
* @param funding 资金方代码
|
* @param creditNo 授信编号
|
* @param logger 日志对象
|
* @param logNumber 日志编号
|
* @return
|
*/
|
public YxLoanResponse yxGetLoanUrl(String userId, String creditNo, String platform,
|
String funding, Logger logger, String logNumber) {
|
// 请求url
|
String url = "/flow/getLoanUrl";
|
// 组装请求体
|
Map<String, Object> param = new HashMap<>(16);
|
param.put("userId", userId);
|
param.put("creditNo", creditNo);
|
param.put("platform", platform);
|
try {
|
logger.info("日志编号:" + logNumber + "借款链接接口请求参数->:{}", param);
|
String paramStr = YXSignUtil.buildRequest(param, getLocalPrivateKey(), getLvDiPublicKey(), funding);
|
// logger.info("日志编号:" + logNumber + "借款链接接口加密参数->:{}", paramStr);
|
String yxResult = HttpClientUtil.getInstance().postJsonData(yxPath + url, paramStr);
|
// logger.info("日志编号:" + logNumber + "借款链接接口加密返回结果->:{}", yxResult);
|
if (!TextUtils.isEmpty(yxResult)) {
|
Map<String, String> resultMap = YXSignUtil.parseLVDiRequest(JSON.parseObject(yxResult, Map.class), getLocalPrivateKey(), getLvDiPublicKey());
|
logger.info("日志编号:" + logNumber + "借款链接接口加密返回resultMap->:{}", resultMap);
|
if (!TextUtils.isEmpty(resultMap.get("params"))) {
|
return JSON.parseObject(resultMap.get("params"), YxLoanResponse.class);
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
logger.error("日志编号:" + logNumber + "借款链接接口异常->:{}", e.getMessage());
|
}
|
return null;
|
}
|
|
/**
|
* 获取私钥
|
*
|
* @return
|
*/
|
public static PrivateKey getLocalPrivateKey() throws Exception {
|
PrivateKey privateKey = getPrivateKey(YXSignUtil.LOCAL_PRIVATE_KEY);
|
return privateKey;
|
}
|
|
/**
|
* 获取公钥
|
*
|
* @return
|
*/
|
public PublicKey getLvDiPublicKey() throws Exception {
|
PublicKey pubK = getPublicKey(yxPubKey);
|
return pubK;
|
}
|
|
|
//获取公钥
|
public static PublicKey getPublicKey(String key) throws Exception {
|
byte[] decoded = java.util.Base64.getDecoder().decode(key);
|
RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded));
|
return pubKey;
|
}
|
|
//获取私钥
|
public static PrivateKey getPrivateKey(String key) throws Exception {
|
//Base64编码的私钥
|
byte[] decoded = java.util.Base64.getDecoder().decode(key);
|
PrivateKey priKey = KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(decoded));
|
return priKey;
|
}
|
|
public Map<String, String> getTxKeyInfo(String channelInfo) {
|
Map<String, String> keys = new HashMap<>();
|
if (!TextUtils.isEmpty(channelInfo) && (channelInfo.equals("suyihua") || channelInfo.equals("SUYIHUA"))) {
|
keys.put("appId", syhAppId);
|
keys.put("secret", syhSecret);
|
} else if (!TextUtils.isEmpty(channelInfo) && (channelInfo.equals("jixianghua") || channelInfo.equals("JIXIANGHUA"))) {
|
keys.put("appId", jxhAppId);
|
keys.put("secret", jxhSecret);
|
} else if (!TextUtils.isEmpty(channelInfo) && (channelInfo.equals("sankuaifenqi") || channelInfo.equals("SANKUAIFENQI"))) {
|
keys.put("appId", skAppId);
|
keys.put("secret", skSecret);
|
} else if (!TextUtils.isEmpty(channelInfo) && (channelInfo.equals("weixianghua") || channelInfo.equals("WEIXIANGHUA"))) {
|
keys.put("appId", wxhAppId);
|
keys.put("secret", wxhSecret);
|
} else if (!TextUtils.isEmpty(channelInfo) && (channelInfo.equals("kadana") || channelInfo.equals("KADANA"))) {
|
keys.put("appId", kdnAppId);
|
keys.put("secret", kdnSecret);
|
} else if (!TextUtils.isEmpty(channelInfo) && (channelInfo.equals("jxd") || channelInfo.equals("JXD"))) {
|
keys.put("appId", jxdAppId);
|
keys.put("secret", jxdSecret);
|
}else {
|
keys.put("appId", jydAppId);
|
keys.put("secret", jydSecret);
|
}
|
return keys;
|
}
|
|
}
|