|
@@ -2,19 +2,25 @@ package com.hrsk.cloud.eg.infrastructure.loanMannager.threedocking.impl;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.hrsk.cloud.eg.clinet.dto.data.plan.command.EgLoanApiConfigInfoCmd;
|
|
|
import com.hrsk.cloud.eg.clinet.dto.data.plan.command.PlanCmd;
|
|
|
-import com.hrsk.cloud.eg.clinet.dto.data.user.command.UserBaseInfoCmd;
|
|
|
+import com.hrsk.cloud.eg.clinet.dto.data.user.command.*;
|
|
|
import com.hrsk.cloud.eg.clinet.vo.DataVo;
|
|
|
+import com.hrsk.cloud.eg.clinet.vo.OrderResponseVo;
|
|
|
import com.hrsk.cloud.eg.domain.common.constant.ServerCodeEnums;
|
|
|
+import com.hrsk.cloud.eg.domain.utils.Md5Util;
|
|
|
import com.hrsk.cloud.eg.infrastructure.config.client.HessianUtils;
|
|
|
import com.hrsk.cloud.eg.infrastructure.config.client.RetryRestTemplate;
|
|
|
import com.hrsk.cloud.eg.infrastructure.loanMannager.threedocking.LoanDockingApi;
|
|
|
import com.hrsk.cloud.eg.infrastructure.service.EgApiService;
|
|
|
import com.hrsk.cloud.eg.infrastructure.utils.DateUtil;
|
|
|
+import com.hrsk.cloud.eg.infrastructure.utils.UserUtils;
|
|
|
import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.catalina.User;
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
+import org.springframework.scheduling.annotation.AsyncResult;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -28,7 +34,10 @@ import java.io.UnsupportedEncodingException;
|
|
|
import java.security.InvalidAlgorithmParameterException;
|
|
|
import java.security.InvalidKeyException;
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* @Author zjc
|
|
@@ -96,7 +105,7 @@ public class BaiXinShunTaiCreditService implements LoanDockingApi {
|
|
|
Object deserialize = HessianUtils.deserialize(requestConfig);
|
|
|
JSONObject config = JSONObject.parseObject(deserialize.toString());
|
|
|
log.info("青岛佰信顺泰对接参数:{}", JSON.toJSONString(config));
|
|
|
- String phoneMd5 = userInfo.getPhoneMd5() == null ? Md5Util.encoderByMd5(userInfo.getUserMobile()) : userInfo.getPhoneMd5();
|
|
|
+ String phoneMd5 = userInfo.getUserMobileMD5() == null ? Md5Util.encoderByMd5(userInfo.getUserMobile()) : userInfo.getUserMobileMD5()
|
|
|
CheckInfo checkInfo = new CheckInfo();
|
|
|
checkInfo.setPhoneNo(phoneMd5);
|
|
|
RquestParam requestParam=new RquestParam();
|
|
@@ -131,11 +140,274 @@ public class BaiXinShunTaiCreditService implements LoanDockingApi {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public ServerCodeEnums getType() {
|
|
|
return ServerCodeEnums.QingDaoBaiXinSHunTaiCreditService;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public OrderResponseVo qualityApply(UserBaseInfoCmd user, PlanCmd planDto, EgLoanApiConfigInfoCmd configInfoCmd) {
|
|
|
+ try {
|
|
|
+ log.info("credit QingDaoBaiXinShunTaiCreditService createApplyAndOrder begin...userId:{}", user.getUserId());
|
|
|
+ String configJson =HessianUtils.deserialize(configInfoCmd.getRequestConfig()).toString() ;
|
|
|
+ JSONObject config = JSONObject.parseObject(configJson);
|
|
|
+ log.info("青岛佰信顺泰对接参数:{}", JSON.toJSONString(config));
|
|
|
+
|
|
|
+ BaiXinShunTaiCreditService.ApplyInfo applyInfoApi = new BaiXinShunTaiCreditService.ApplyInfo();
|
|
|
+
|
|
|
+ if (user.getPoliceBirthBate() != null) {//年龄
|
|
|
+ applyInfoApi.setAge(DateUtil.getAgeByBirth(DateUtil.convertString2Date(user.getPoliceBirthBate(), "yyyy-MM-dd")) + "");
|
|
|
+ } else if (user.getAge() != null) {
|
|
|
+ applyInfoApi.setAge(user.getAge() + "");
|
|
|
+ } else {
|
|
|
+ applyInfoApi.setAge("0");
|
|
|
+ }
|
|
|
+ applyInfoApi.setCompany_id(Integer.valueOf(config.getString("company_id")));
|
|
|
+ applyInfoApi.setPromotion_prefix(config.getString("promotion_prefix"));//渠道名
|
|
|
+ applyInfoApi.setCustName(UserUtils.getUserName(user.getRealName(), user.getPoliceSex()));//客户姓名
|
|
|
+ applyInfoApi.setCity(user.getCityAllName());
|
|
|
+ applyInfoApi.setPhoneNo(user.getUserMobile());//手机号码
|
|
|
+ applyInfoApi.setSex(user.getPoliceSex().equals("男") ? 0 : 1);//性别
|
|
|
+ getLoanAmount(user.getXdApplyParam(),applyInfoApi);
|
|
|
+ getProfession(user, applyInfoApi);//职业
|
|
|
+ UserProfessionOfficeWorkersCmd xdProfessionOfficeWorkers = user.getOfficeWorkers();
|
|
|
+ applyInfoApi.setSalaryType(xdProfessionOfficeWorkers!=null&&xdProfessionOfficeWorkers.getSalaryPayment() == 1?"1":"2");//工资情况
|
|
|
+ getSocialSecurity(user, applyInfoApi);//社保
|
|
|
+ getProvidentFund(user, applyInfoApi);//公积金
|
|
|
+ UserAssetCarInfoCmd carInfo = user.getCarInfo();
|
|
|
+ getCar(carInfo, applyInfoApi);//车
|
|
|
+ UserAssetHouseInfoCmd houseInfo = user.getHouseInfo();
|
|
|
+ getHouseProperty(houseInfo,applyInfoApi);//房
|
|
|
+ getCreditCard(user,applyInfoApi);//信用卡额度
|
|
|
+ getZhiMaSorce(user,applyInfoApi);//芝麻分
|
|
|
+ UserAssetInsuranceInfoCmd xdAssetInsuranceInfo = user.getInsuranceInfo();
|
|
|
+ applyInfoApi.setLifeInsurance(xdAssetInsuranceInfo == null || xdAssetInsuranceInfo.getInsuranceType() == 1 ? "2" : "1");//保单
|
|
|
+
|
|
|
+ getMonthlyIncome(xdProfessionOfficeWorkers, user.getBusinessOwner(), user.getSelfEmployed(), user, applyInfoApi);//月收入
|
|
|
+ getEducation(user,applyInfoApi);//学历
|
|
|
+ getLoanTerm(user.getXdApplyParam(),applyInfoApi);//借款周期
|
|
|
+
|
|
|
+ RquestParam requestParam=new RquestParam();
|
|
|
+ requestParam.setTimestamp(DateUtil.getFormatDate(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
+ requestParam.setData(encryptAes(JSON.toJSONString(applyInfoApi), config.getString("key")));
|
|
|
+ requestParam.setReqId(config.getString("reqId"));
|
|
|
+ requestParam.setMerchantNo(config.getString("merchantNo"));
|
|
|
+ log.info("青岛佰信顺泰请求参数:{},加密后:{}", JSON.toJSONString(applyInfoApi), JSON.toJSONString(requestParam.getData()));
|
|
|
+
|
|
|
+ String url = config.getString("applyUrl");
|
|
|
+ JSONObject response = null;
|
|
|
+ try {
|
|
|
+ response = httpRestTemplate.restTemplate().postForObject(url, requestParam, JSONObject.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("青岛佰信顺泰申请异常,异常信息:{}", e.getMessage(), e);
|
|
|
+ }
|
|
|
+ log.info("credit createApplyAndOrder QingDaoBaiXinShunTaiCreditService response userId:{}, result:{}", user.getUserId(), response);
|
|
|
+ if (response == null) {
|
|
|
+ return OrderResponseVo.fail("返回数据为空",ServerCodeEnums.BaiYiJinFu.getMsg());
|
|
|
+ }
|
|
|
+ if (response.getString("dealStatus").equals("0000")) {
|
|
|
+ return OrderResponseVo.ok(ServerCodeEnums.BaiYiJinFu.getMsg());
|
|
|
+ }
|
|
|
+ return OrderResponseVo.fail(response.getString("delDesc"),ServerCodeEnums.BaiYiJinFu.getMsg());
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("青岛佰信顺泰申请失败", e);
|
|
|
+ return OrderResponseVo.fail("请求失败",ServerCodeEnums.BaiYiJinFu.getMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void getLoanAmount(XdApplyCmd xdApplyParam, ApplyInfo applyInfoApi) {
|
|
|
+ if (xdApplyParam==null||xdApplyParam.getBorrowMoney()<4){
|
|
|
+ applyInfoApi.setLoanAmount("1");
|
|
|
+ }else if (xdApplyParam.getBorrowMoney()>=4&&xdApplyParam.getBorrowMoney()<5){
|
|
|
+ applyInfoApi.setLoanAmount("2");
|
|
|
+ }else if (xdApplyParam.getBorrowMoney()>=5&&xdApplyParam.getBorrowMoney()<10){
|
|
|
+ applyInfoApi.setLoanAmount("3");
|
|
|
+ }else if (xdApplyParam.getBorrowMoney()>=10&&xdApplyParam.getBorrowMoney()<20){
|
|
|
+ applyInfoApi.setLoanAmount("4");
|
|
|
+ }else {
|
|
|
+ applyInfoApi.setLoanAmount("5");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //社保
|
|
|
+ private void getSocialSecurity(UserBaseInfoCmd userBasicInfo, BaiXinShunTaiCreditService.ApplyInfo applyInfoApi) {
|
|
|
+ if (userBasicInfo.getSocialSecurity() == null || userBasicInfo.getSocialSecurity() == 0) {
|
|
|
+ applyInfoApi.setSocialSecurity("0");
|
|
|
+ } else if (userBasicInfo.getSocialSecurity() == 1) {
|
|
|
+ applyInfoApi.setSocialSecurity("1");
|
|
|
+ } else {
|
|
|
+ applyInfoApi.setSocialSecurity("2");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //公基金
|
|
|
+ private void getProvidentFund(UserBaseInfoCmd userBasicInfo, BaiXinShunTaiCreditService.ApplyInfo applyInfoApi) {
|
|
|
+ if (userBasicInfo.getAccumulation()==null||userBasicInfo.getAccumulation()==0){
|
|
|
+ applyInfoApi.setProvidentFund("无公积金");
|
|
|
+ }else if (userBasicInfo.getAccumulation()==1){
|
|
|
+ applyInfoApi.setProvidentFund("1");
|
|
|
+ }else {
|
|
|
+ applyInfoApi.setProvidentFund("2");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void getProfession(UserBaseInfoCmd userBasicInfo, BaiXinShunTaiCreditService.ApplyInfo applyInfoApi) {
|
|
|
+ List<Integer> officeWorker = new ArrayList<>();
|
|
|
+ officeWorker.add(1);
|
|
|
+ officeWorker.add(7);
|
|
|
+ officeWorker.add(8);
|
|
|
+ officeWorker.add(9);
|
|
|
+ officeWorker.add(10);
|
|
|
+ if (null == userBasicInfo || userBasicInfo.getProfession() == null) {
|
|
|
+ applyInfoApi.setProfession("2");//上班族
|
|
|
+ } else if (userBasicInfo.getProfession().equals(4)) {
|
|
|
+ applyInfoApi.setProfession("1");//自由职业
|
|
|
+ } else if (officeWorker.contains(userBasicInfo.getProfession())) {
|
|
|
+ applyInfoApi.setProfession("2");//上班族
|
|
|
+ } else if (userBasicInfo.getProfession().equals(2)) {
|
|
|
+ applyInfoApi.setProfession("3");//个体户
|
|
|
+ } else if (userBasicInfo.getProfession().equals(5)) {
|
|
|
+ applyInfoApi.setProfession("4");
|
|
|
+ }else {
|
|
|
+ applyInfoApi.setProfession("2");//上班族
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //1:上班族{1,7,8,9,10 }
|
|
|
+ //2:企业主{5}
|
|
|
+ //3:自由职业者{2,3,4,6}
|
|
|
+ private void getEducation(UserBaseInfoCmd userBasicInfo, BaiXinShunTaiCreditService.ApplyInfo applyInfoApi) {
|
|
|
+ if (userBasicInfo == null || userBasicInfo.getEducationCode() == -1) {
|
|
|
+ applyInfoApi.setDegree("1");
|
|
|
+ } else if (userBasicInfo.getEducationCode() == 0) {
|
|
|
+ applyInfoApi.setDegree("1");
|
|
|
+ } else if (userBasicInfo.getEducationCode() == 1) {
|
|
|
+ applyInfoApi.setDegree("2");
|
|
|
+ } else if (userBasicInfo.getEducationCode() == 2) {
|
|
|
+ applyInfoApi.setDegree("3");
|
|
|
+ } else if (userBasicInfo.getEducationCode() == 3) {
|
|
|
+ applyInfoApi.setDegree("3");
|
|
|
+ } else {
|
|
|
+ applyInfoApi.setDegree("3");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void getCar(UserAssetCarInfoCmd carInfo, BaiXinShunTaiCreditService.ApplyInfo applyInfoApi) {
|
|
|
+ if (carInfo==null||carInfo.getCarType()==null||carInfo.getCarType() == 1){
|
|
|
+ applyInfoApi.setCar("0");
|
|
|
+ }else if (carInfo.getCarType()==2){
|
|
|
+ applyInfoApi.setCar("2");//全款
|
|
|
+ }else {
|
|
|
+ applyInfoApi.setCar("1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void getHouseProperty(UserAssetHouseInfoCmd houseInfo, BaiXinShunTaiCreditService.ApplyInfo applyInfoApi) {
|
|
|
+ if (null == houseInfo || houseInfo.getHouseType() == null || houseInfo.getHouseType() == 2) {
|
|
|
+ applyInfoApi.setEstate("0");
|
|
|
+ } else if (houseInfo.getHouseType() == 12) {
|
|
|
+ applyInfoApi.setEstate("2");//可抵押 全款
|
|
|
+ } else {
|
|
|
+ applyInfoApi.setEstate("1");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void getZhiMaSorce(UserBaseInfoCmd userBasicInfo, BaiXinShunTaiCreditService.ApplyInfo applyInfoApi) {
|
|
|
+ if (userBasicInfo.getSesame() == null) {
|
|
|
+ applyInfoApi.setZhiMaScore("0");
|
|
|
+ } else if (userBasicInfo.getSesame() == 2) {
|
|
|
+ applyInfoApi.setZhiMaScore("0");
|
|
|
+ } else if (userBasicInfo.getSesame() == 3) {
|
|
|
+ applyInfoApi.setZhiMaScore("1");
|
|
|
+ } else if (userBasicInfo.getSesame() == 4) {
|
|
|
+ applyInfoApi.setZhiMaScore("2");
|
|
|
+ } else {
|
|
|
+ applyInfoApi.setZhiMaScore("3");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void getCreditCard(UserBaseInfoCmd userBasicInfo, BaiXinShunTaiCreditService.ApplyInfo applyInfoApi) {
|
|
|
+ if (null==userBasicInfo||userBasicInfo.getCreditCard()==5){
|
|
|
+ applyInfoApi.setCreditCardLimit("0");
|
|
|
+ }else if (userBasicInfo.getCreditCard()==1){
|
|
|
+ applyInfoApi.setCreditCardLimit("1");
|
|
|
+ }else if (userBasicInfo.getCreditCard()==3 || userBasicInfo.getCreditCard()==4){
|
|
|
+ applyInfoApi.setCreditCardLimit("4");
|
|
|
+ }else{
|
|
|
+ applyInfoApi.setCreditCardLimit("2");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void getMonthlyIncome(UserProfessionOfficeWorkersCmd xdProfessionOfficeWorkers, UserProfessionBusinessOwnerCmd businessOwner, UserProfessionSelfEmployedCmd employed, UserBaseInfoCmd userBasicInfo, BaiXinShunTaiCreditService.ApplyInfo applyInfoApi) {
|
|
|
+ if (userBasicInfo.getProfession() == 4 || userBasicInfo.getProfession() == 6) {
|
|
|
+ Integer moneyIncome = userBasicInfo.getMoneyIncome();
|
|
|
+ if (moneyIncome == null) {
|
|
|
+ applyInfoApi.setMonthIncome("5000");
|
|
|
+ } else {
|
|
|
+ applyInfoApi.setMonthIncome(moneyIncome.toString());
|
|
|
+ }
|
|
|
+ } else if (userBasicInfo.getProfession() == 5 || userBasicInfo.getProfession() == 2) {
|
|
|
+ if (userBasicInfo.getProfession() == 2) {
|
|
|
+ if (employed == null || null == employed.getTurnover()) {
|
|
|
+ applyInfoApi.setMonthIncome("5000");
|
|
|
+ }else if (employed.getTurnover() == 1 || employed.getTurnover() == 2) {
|
|
|
+ applyInfoApi.setMonthIncome("3000");
|
|
|
+ } else if (employed.getTurnover() == 3) {
|
|
|
+ applyInfoApi.setMonthIncome("8000");
|
|
|
+ } else if (employed.getTurnover() == 4) {
|
|
|
+ applyInfoApi.setMonthIncome("15000");
|
|
|
+ } else if (employed.getTurnover() == 5) {
|
|
|
+ applyInfoApi.setMonthIncome("20000");
|
|
|
+ } else {
|
|
|
+ applyInfoApi.setMonthIncome("10000");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (userBasicInfo.getProfession() == 5) {
|
|
|
+ if (null == businessOwner || null == businessOwner.getCompanyCommWater()) {
|
|
|
+ applyInfoApi.setMonthIncome("5000");
|
|
|
+ }else if (businessOwner.getCompanyCommWater().equals("1")) {
|
|
|
+ applyInfoApi.setMonthIncome("50000");
|
|
|
+ } else if (businessOwner.getCompanyCommWater().equals("2")){
|
|
|
+ applyInfoApi.setMonthIncome("200000");
|
|
|
+ }else if (businessOwner.getCompanyCommWater().equals("3")){
|
|
|
+ applyInfoApi.setMonthIncome("300000");
|
|
|
+ }else if (businessOwner.getCompanyCommWater().equals("4")){
|
|
|
+ applyInfoApi.setMonthIncome("500000");
|
|
|
+ }else {
|
|
|
+ applyInfoApi.setMonthIncome("1000000");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (null==xdProfessionOfficeWorkers||null==xdProfessionOfficeWorkers.getMonthlyIncome()){
|
|
|
+ applyInfoApi.setMonthIncome("5000");
|
|
|
+ }else {
|
|
|
+ Integer moneyIncome = xdProfessionOfficeWorkers.getMonthlyIncome();
|
|
|
+ if (moneyIncome == 1 || moneyIncome == 2) {
|
|
|
+ applyInfoApi.setMonthIncome("3000");
|
|
|
+ } else if (moneyIncome == 3 || moneyIncome == 4) {
|
|
|
+ applyInfoApi.setMonthIncome("8000");
|
|
|
+ } else if (moneyIncome == 5) {
|
|
|
+ applyInfoApi.setMonthIncome("12000");
|
|
|
+ } else if (moneyIncome == 6) {
|
|
|
+ applyInfoApi.setMonthIncome("20000");
|
|
|
+ } else if (moneyIncome == 7) {
|
|
|
+ applyInfoApi.setMonthIncome("50000");
|
|
|
+ } else {
|
|
|
+ applyInfoApi.setMonthIncome("100000");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**借款周期
|
|
|
+ *
|
|
|
+ * 借款期限 1.1个月 2.3个月 3.6个月 4.9个月 5.12个月 6.24个月 7.36个月 8.36个月以上
|
|
|
+ * */
|
|
|
+ private void getLoanTerm(XdApplyCmd xdApplyParam, BaiXinShunTaiCreditService.ApplyInfo applyInfoApi) {
|
|
|
+ if (xdApplyParam==null||xdApplyParam.getBorrowLimit() == null||xdApplyParam.getBorrowLimit()<6) {
|
|
|
+ applyInfoApi.setLoanTerm("01");
|
|
|
+ }else if (xdApplyParam.getBorrowLimit()>=6&&xdApplyParam.getBorrowLimit() <8){
|
|
|
+ applyInfoApi.setLoanTerm("02");
|
|
|
+ }else{
|
|
|
+ applyInfoApi.setLoanTerm("03");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public static String encryptAes(String data, String secretKey) {
|
|
|
try {
|