Commit d8107c9e authored by liwenbin's avatar liwenbin

Merge branch 'zj-niwodai' of http://git.quantgroup.cn/data-spider/asset-server into zj-niwodai

parents ecf06b47 98f87ebc
...@@ -20,6 +20,7 @@ import org.apache.http.protocol.HttpContext; ...@@ -20,6 +20,7 @@ import org.apache.http.protocol.HttpContext;
import org.apache.http.ssl.SSLContexts; import org.apache.http.ssl.SSLContexts;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.util.ClassUtils;
import javax.net.ssl.*; import javax.net.ssl.*;
import java.io.File; import java.io.File;
...@@ -124,10 +125,11 @@ public class HttpClientConfig { ...@@ -124,10 +125,11 @@ public class HttpClientConfig {
return null; return null;
} }
}; };
String classesPath= ClassUtils.getDefaultClassLoader().getResource("").getPath();
KeyStore keyStore = KeyStore.getInstance("PKCS12"); KeyStore keyStore = KeyStore.getInstance("PKCS12");
keyStore.load(new FileInputStream(new File("F:\\9_QFNEW\\data-export-platform\\src\\main\\resources\\niwodai\\qg-keystore.jks")), "password".toCharArray()); keyStore.load(new FileInputStream(new File(classesPath + "/niwodai/" + "qg-keystore.jks")), "password".toCharArray());
SSLContext sslcontext = SSLContexts.custom() SSLContext sslcontext = SSLContexts.custom()
.loadTrustMaterial(new File("F:\\9_QFNEW\\data-export-platform\\src\\main\\resources\\niwodai\\qg-truststore.jks"), "password".toCharArray(), new TrustSelfSignedStrategy()) .loadTrustMaterial(new File(classesPath + "/niwodai/" + "qg-truststore.jks"), "password".toCharArray(), new TrustSelfSignedStrategy())
.loadKeyMaterial(keyStore, "password".toCharArray()) .loadKeyMaterial(keyStore, "password".toCharArray())
.build(); .build();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory( SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(
......
...@@ -30,4 +30,9 @@ public class RedisKeyConstants { ...@@ -30,4 +30,9 @@ public class RedisKeyConstants {
* 你我贷token * 你我贷token
*/ */
public static final String NI_WO_DAI_TOKEN_KEY = "DATA_EXPORT_PLATFORM:NIWODAI:TOKEN:YHABEA"; public static final String NI_WO_DAI_TOKEN_KEY = "DATA_EXPORT_PLATFORM:NIWODAI:TOKEN:YHABEA";
/**
* 完成路由的资方缓存KEY
*/
public static final String FINISH_ROUTE_AID_FUND_KEY="FINISH.ROUTE.AID.FUND.KEY.IJN9_";
} }
...@@ -148,7 +148,7 @@ public class AssetDistributeServiceImpl implements IAssetDistributeService{ ...@@ -148,7 +148,7 @@ public class AssetDistributeServiceImpl implements IAssetDistributeService{
return StatusConstants.FAIL; return StatusConstants.FAIL;
case DistributeConstants.RuleType.AID_FUND_ROUTE: { case DistributeConstants.RuleType.AID_FUND_ROUTE: {
GlobalResponse response = aidFundRouteService.aidFundRoute(assetForm, asset.getUserLoanType(), data); GlobalResponse response = aidFundRouteService.aidFundRoute(assetForm, asset.getUserLoanType(), data);
int status = response.getCode() == 0 ? StatusConstants.SUCCESS : StatusConstants.FAIL; int status = response.getCode() == 0 ? StatusConstants.WAIT : StatusConstants.FAIL;
//助贷资金路由 分配失败没有 mq消息 成功有 //助贷资金路由 分配失败没有 mq消息 成功有
if(status==0){ if(status==0){
// 助贷资金路由目前不从mq里接受终态 // 助贷资金路由目前不从mq里接受终态
...@@ -156,8 +156,7 @@ public class AssetDistributeServiceImpl implements IAssetDistributeService{ ...@@ -156,8 +156,7 @@ public class AssetDistributeServiceImpl implements IAssetDistributeService{
assetDistributeRecordService.updateAssetDistribute(assetDistributeRecord); assetDistributeRecordService.updateAssetDistribute(assetDistributeRecord);
} }
return status; return status;
} }case DistributeConstants.RuleType.DIVERSION:
case DistributeConstants.RuleType.DIVERSION:
notifyService.notifyFundServer(assetForm, data); notifyService.notifyFundServer(assetForm, data);
return StatusConstants.WAIT; return StatusConstants.WAIT;
default: default:
......
package com.quantgroup.asset.distribution.service.funding.impl; package com.quantgroup.asset.distribution.service.funding.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Stopwatch;
import com.quantgroup.asset.distribution.model.form.AssetForm; import com.quantgroup.asset.distribution.model.form.AssetForm;
import com.quantgroup.asset.distribution.model.response.GlobalResponse; import com.quantgroup.asset.distribution.model.response.GlobalResponse;
import com.quantgroup.asset.distribution.service.funding.IAidFundRouteRecordService; import com.quantgroup.asset.distribution.service.funding.IAidFundRouteRecordService;
import com.quantgroup.asset.distribution.service.funding.IAidFundRouteService; import com.quantgroup.asset.distribution.service.funding.IAidFundRouteService;
import com.quantgroup.asset.distribution.service.funding.IAidLoanFundConfigService; import com.quantgroup.asset.distribution.service.funding.IAidLoanFundConfigService;
import com.quantgroup.asset.distribution.service.httpclient.IHttpService;
import com.quantgroup.asset.distribution.service.jpa.entity.AidLoanFundConfig; import com.quantgroup.asset.distribution.service.jpa.entity.AidLoanFundConfig;
import com.quantgroup.asset.distribution.service.jpa.entity.AidLoanFundRouteRecord; import com.quantgroup.asset.distribution.service.jpa.entity.AidLoanFundRouteRecord;
import com.quantgroup.asset.distribution.service.jpa.repository.ICustomerTypeRuleConfigRepository;
import com.quantgroup.asset.distribution.service.redis.IRedisService; import com.quantgroup.asset.distribution.service.redis.IRedisService;
import com.quantgroup.asset.distribution.service.rule.IRuleService;
import com.quantgroup.asset.distribution.util.DateUtil; import com.quantgroup.asset.distribution.util.DateUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -25,8 +27,7 @@ import java.util.TreeSet; ...@@ -25,8 +27,7 @@ import java.util.TreeSet;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.quantgroup.asset.distribution.constant.RedisKeyConstants.AID_LOAN_ALL_AMOUNT_LIMIT_KEY; import static com.quantgroup.asset.distribution.constant.RedisKeyConstants.*;
import static com.quantgroup.asset.distribution.constant.RedisKeyConstants.AID_LOAN_COUNT_LIMIT_KEY;
/** /**
* Created by renfeng on 2019/7/19. * Created by renfeng on 2019/7/19.
...@@ -47,7 +48,9 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService { ...@@ -47,7 +48,9 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService {
private IRedisService<AssetForm> redisServiceAssetForm; private IRedisService<AssetForm> redisServiceAssetForm;
@Autowired @Autowired
private IHttpService iHttpService; private IRuleService ruleService;
@Autowired
private ICustomerTypeRuleConfigRepository iCustomerTypeRuleConfigRepository;
/** /**
* 助贷资金路由 * 助贷资金路由
...@@ -59,6 +62,8 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService { ...@@ -59,6 +62,8 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService {
@Override @Override
public GlobalResponse aidFundRoute(AssetForm assetForm,Integer userLoanType, Map<String, Object> data) { public GlobalResponse aidFundRoute(AssetForm assetForm,Integer userLoanType, Map<String, Object> data) {
Stopwatch started = Stopwatch.createStarted();
//第一步 查询所有助贷资金 //第一步 查询所有助贷资金
List<AidLoanFundConfig> aidLoanFundConfigList = iAidLoanFundConfigService.findAll(); List<AidLoanFundConfig> aidLoanFundConfigList = iAidLoanFundConfigService.findAll();
log.info("助贷资金路由开始, uuid : {} , bizNo : {} ,助贷资金池 : {} ",assetForm.getUuid(),assetForm.getBizNo(),JSON.toJSONString(aidLoanFundConfigList)); log.info("助贷资金路由开始, uuid : {} , bizNo : {} ,助贷资金池 : {} ",assetForm.getUuid(),assetForm.getBizNo(),JSON.toJSONString(aidLoanFundConfigList));
...@@ -86,39 +91,54 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService { ...@@ -86,39 +91,54 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService {
log.info("助贷资金优先级筛选开始, uuid : {} , bizNo : {} ,助贷资金池 : {} ",assetForm.getUuid(),assetForm.getBizNo(),JSON.toJSONString(aidLoanFundConfigList)); log.info("助贷资金优先级筛选开始, uuid : {} , bizNo : {} ,助贷资金池 : {} ",assetForm.getUuid(),assetForm.getBizNo(),JSON.toJSONString(aidLoanFundConfigList));
//按优先级排序 //按优先级排序
TreeSet<AidLoanFundConfig> aidLoanFundConfigSet = new TreeSet<>(Comparator.comparing(AidLoanFundConfig::getFundPriority)); TreeSet<AidLoanFundConfig> aidLoanFundConfigSet = new TreeSet<AidLoanFundConfig>(Comparator.comparing(AidLoanFundConfig::getFundPriority));
aidLoanFundConfigSet.addAll(aidLoanFundConfigList); aidLoanFundConfigSet.addAll(aidLoanFundConfigList);
AidLoanFundConfig first = aidLoanFundConfigSet.first();
log.info("助贷资金筛选完成, uuid : {} , bizNo : {} ,助贷资金 : {} ",assetForm.getUuid(),assetForm.getBizNo(),JSON.toJSONString(first)); for(AidLoanFundConfig aidLoanFundConfig : aidLoanFundConfigSet){
//此助贷资方如果已经被这笔订单路由过 就跳过
if(String.valueOf(aidLoanFundConfig.getFundId())
.equals(redisServiceAssetForm.getString(FINISH_ROUTE_AID_FUND_KEY + assetForm.getBizNo())))
continue;
//助贷资金分配规则校验
if(ruleService.valid(aidLoanFundConfig.getFundRuleEl(), data)){
//助贷资金准入接口调用
boolean accessResult = false;//todo 调用真实的准入接口
//保存主贷资金路由记录 //保存主贷资金路由记录
AidLoanFundRouteRecord aidLoanFundRouteRecord = new AidLoanFundRouteRecord(); AidLoanFundRouteRecord aidLoanFundRouteRecord = new AidLoanFundRouteRecord();
aidLoanFundRouteRecord.setAidFundRouteStatus(1);//1-未完成 2-成功 3-失败 aidLoanFundRouteRecord.setAidFundRouteStatus(accessResult?1:2);//1-准入成功 2-准入失败 3-进件成功 4-进件失败
aidLoanFundRouteRecord.setAssetNo(assetForm.getAssetNo()); aidLoanFundRouteRecord.setAssetNo(assetForm.getAssetNo());
aidLoanFundRouteRecord.setUuid(assetForm.getUuid()); aidLoanFundRouteRecord.setUuid(assetForm.getUuid());
aidLoanFundRouteRecord.setBizChannel(assetForm.getBizChannel()); aidLoanFundRouteRecord.setBizChannel(assetForm.getBizChannel());
aidLoanFundRouteRecord.setBizNo(assetForm.getBizNo()); aidLoanFundRouteRecord.setBizNo(assetForm.getBizNo());
aidLoanFundRouteRecord.setFinanceProductType(Integer.parseInt(assetForm.getBizType())); aidLoanFundRouteRecord.setFinanceProductType(Integer.parseInt(assetForm.getBizType()));
aidLoanFundRouteRecord.setUserLoanType(userLoanType); aidLoanFundRouteRecord.setUserLoanType(userLoanType);
aidLoanFundRouteRecord.setFundNo(first.getFundNo()); aidLoanFundRouteRecord.setFundNo(aidLoanFundConfig.getFundNo());
aidLoanFundRouteRecord.setFundId(first.getFundId()); aidLoanFundRouteRecord.setFundId(aidLoanFundConfig.getFundId());
aidLoanFundRouteRecord.setEnable(true); aidLoanFundRouteRecord.setEnable(true);
iAidFundRouteRecordService.saveAidLoanFundRouteRecord(aidLoanFundRouteRecord); iAidFundRouteRecordService.saveAidLoanFundRouteRecord(aidLoanFundRouteRecord);
//通知资方 log.info("主贷资金路由-准入完成, bizChannel : {} , uuid : {} , bizNo : {} , fundId : {} , 准入结果: {} , 耗时 : {}",assetForm.getBizChannel(),assetForm.getUuid(),assetForm.getBizNo(),aidLoanFundRouteRecord.getFundId(),accessResult,started.stop().elapsed(TimeUnit.MILLISECONDS));
Map<String,String> response = iHttpService.postHasResponse(assetForm.getCallbackUrl(), assetForm.transToNotifyMap(data));
if(accessResult){
log.info("助贷资金路由-通知资金系统结束,response :{}, uuid : {} , bizNo : {} , callbackUrl:{},params:{}", JSON.toJSONString(response),assetForm.getUuid(),assetForm.getBizNo(),assetForm.getCallbackUrl(), JSON.toJSONString(assetForm.transToNotifyMap(data))); //客户类别区分 1-自然流量 2-拒绝流量 留在这里 你我贷暂时不用 等以后要用时 随时可用
if(response==null || response.size()==0 || !"200".equals(response.get("statusCode")) || "error".equals(response.get("response"))) { // int customerType = 0 ;
assetForm.setRepeatCount(assetForm.getRepeatCount() + 1); // List<CustomerTypeRuleConfig> byEnableTrue = iCustomerTypeRuleConfigRepository.findByEnableTrue();
redisServiceAssetForm.rightPushEx("AID.LOAN.FUND.ROUTE.NOTIFY.83IUE",assetForm,1, TimeUnit.DAYS); // if(CollectionUtils.isNotEmpty(byEnableTrue)) {
log.info("助贷资金路由-通知资金系统失败,response :{}, uuid : {} , bizNo : {} , callbackUrl:{},params:{}", JSON.toJSONString(response),assetForm.getUuid(),assetForm.getBizNo(),assetForm.getCallbackUrl(), JSON.toJSONString(assetForm)); // for (CustomerTypeRuleConfig customerTypeRuleConfig : byEnableTrue) {
} // if (ruleService.valid(customerTypeRuleConfig.getCustomerTypeRuleEl(), data)) {
// customerType = customerTypeRuleConfig.getCustomerType();
// }
// }
// }
//todo 调用助贷资方进件接口 异步
log.info("主贷资金路由-进件完成, bizChannel : {} , uuid : {} , bizNo : {} , fundId : {} , 耗时 : {} ",assetForm.getBizChannel(),assetForm.getUuid(),assetForm.getBizNo(),aidLoanFundRouteRecord.getFundId(),started.stop().elapsed(TimeUnit.MILLISECONDS));
return GlobalResponse.success(); return GlobalResponse.success();
}
}
}
} }
return GlobalResponse.error("未匹配到助贷资金"); return GlobalResponse.error("未匹配到助贷资金");
} }
......
...@@ -48,6 +48,9 @@ public class AidLoanFundConfig implements Serializable{ ...@@ -48,6 +48,9 @@ public class AidLoanFundConfig implements Serializable{
@Column(name="fund_all_amount_limit") @Column(name="fund_all_amount_limit")
private String fundAllAmountLimit; private String fundAllAmountLimit;
@Column(name="fund_rule_el")
private String fundRuleEl;
@Column(name = "enable") @Column(name = "enable")
private Boolean enable; private Boolean enable;
......
package com.quantgroup.asset.distribution.service.jpa.entity;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* Created by renfeng on 2020/3/24.
*/
@Entity
@Table(name="customer_type_rule_config")
@Data
public class CustomerTypeRuleConfig implements Serializable{
private static final long serialVersionUID = -1L;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name="customer_type_rule_no")
private String customerTypeRuleNo;
@Column(name="customer_type_rule_desc")
private String customerTypeRuleDesc;
@Column(name="customer_type")
private Integer customerType;
@Column(name="customer_type_rule_el")
private String customerTypeRuleEl;
@Column(name = "enable")
private Boolean enable;
@Column(name="created_by")
private String createdBy;
@Column(name="updated_by")
private String updatedBy;
@Column(name = "created_at")
private Timestamp createdAt;
@Column(name = "updated_at")
private Timestamp updatedAt;
@PrePersist
public void prePersist() {
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
createdAt = timestamp;
updatedAt = timestamp;
}
@PreUpdate
public void preUpdate() {
updatedAt = new Timestamp(System.currentTimeMillis());
}
}
package com.quantgroup.asset.distribution.service.jpa.repository;
import com.quantgroup.asset.distribution.service.jpa.entity.CustomerTypeRuleConfig;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
/**
* Created by renfeng on 2019/7/17.
*/
public interface ICustomerTypeRuleConfigRepository extends JpaRepository<CustomerTypeRuleConfig, Long>{
List<CustomerTypeRuleConfig> findByEnableTrue();
}
package com.quantgroup.asset.distribution.service.niwodai; package com.quantgroup.asset.distribution.service.niwodai;
import com.quantgroup.asset.distribution.service.niwodai.vo.NiwodaiCostant; import com.quantgroup.asset.distribution.service.niwodai.vo.NiwodaiDataImportCheckResponseVO;
import com.quantgroup.asset.distribution.service.niwodai.vo.NiwodaiIncomingResponseVO; import com.quantgroup.asset.distribution.service.niwodai.vo.NiwodaiIncomingResponseVO;
import com.quantgroup.asset.distribution.service.niwodai.vo.NiwodaiIncomingResultResponseVO;
import java.util.Map; import java.util.Map;
public interface INiwodaiAssetService { public interface INiwodaiAssetService {
NiwodaiIncomingResponseVO incoming(String uuid, String orderId, String amount, Integer term, NiwodaiIncomingResultResponseVO incomingResult(String orderId);
NiwodaiCostant.MnoData mnoData);
NiwodaiDataImportCheckResponseVO dataCheck(String uuid);
NiwodaiIncomingResponseVO incoming(String uuid, String orderId, String amount, Integer term);
Map<String,Object> queryUserBasic2Info(String userId, String phoneNo, boolean isQuery); Map<String,Object> queryUserBasic2Info(String userId, String phoneNo, boolean isQuery);
} }
package com.quantgroup.asset.distribution.service.niwodai; package com.quantgroup.asset.distribution.service.niwodai;
import com.quantgroup.asset.distribution.service.niwodai.vo.NiwodaiDataImportCheckRequestVO; import com.quantgroup.asset.distribution.service.niwodai.vo.*;
import com.quantgroup.asset.distribution.service.niwodai.vo.NiwodaiDataImportCheckResponseVO;
import com.quantgroup.asset.distribution.service.niwodai.vo.NiwodaiIncomingRequestVO;
import com.quantgroup.asset.distribution.service.niwodai.vo.NiwodaiIncomingResponseVO;
public interface INiwodaiService { public interface INiwodaiService {
...@@ -12,4 +9,6 @@ public interface INiwodaiService { ...@@ -12,4 +9,6 @@ public interface INiwodaiService {
NiwodaiIncomingResponseVO incoming(NiwodaiIncomingRequestVO niwodaiIncomingRequestVO); NiwodaiIncomingResponseVO incoming(NiwodaiIncomingRequestVO niwodaiIncomingRequestVO);
NiwodaiIncomingResultResponseVO incoingResult(NiwodaiIncomingResultRequestVO requestVO);
} }
package com.quantgroup.asset.distribution.service.niwodai.impl; package com.quantgroup.asset.distribution.service.niwodai.impl;
import cn.quantgroup.motan.bean.UserInfo; import cn.quantgroup.motan.bean.UserInfo;
import cn.quantgroup.motan.enums.EducationEnum;
import cn.quantgroup.motan.enums.IncomeRangeEnum;
import cn.quantgroup.motan.vo.UserSysResult; import cn.quantgroup.motan.vo.UserSysResult;
import cn.quantgroup.user.IUserSdkService; import cn.quantgroup.user.IUserSdkService;
import cn.quantgroup.user.UserSdkServiceFactory; import cn.quantgroup.user.UserSdkServiceFactory;
import com.alibaba.druid.sql.visitor.functions.If;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson; import com.google.gson.Gson;
...@@ -19,7 +16,6 @@ import com.quantgroup.asset.distribution.service.httpclient.IHttpService; ...@@ -19,7 +16,6 @@ import com.quantgroup.asset.distribution.service.httpclient.IHttpService;
import com.quantgroup.asset.distribution.service.niwodai.INiwodaiAssetService; import com.quantgroup.asset.distribution.service.niwodai.INiwodaiAssetService;
import com.quantgroup.asset.distribution.service.niwodai.INiwodaiService; import com.quantgroup.asset.distribution.service.niwodai.INiwodaiService;
import com.quantgroup.asset.distribution.service.niwodai.vo.*; import com.quantgroup.asset.distribution.service.niwodai.vo.*;
import com.quantgroup.asset.distribution.util.AddressResolutionUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -30,7 +26,6 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -30,7 +26,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.HashMap; import java.util.HashMap;
...@@ -62,14 +57,48 @@ public class NiwodaiAssetServiceImpl implements INiwodaiAssetService { ...@@ -62,14 +57,48 @@ public class NiwodaiAssetServiceImpl implements INiwodaiAssetService {
} }
@Override @Override
public NiwodaiIncomingResponseVO incoming(String uuid, String orderId, String amount, Integer term, public NiwodaiIncomingResultResponseVO incomingResult(String orderId){
NiwodaiCostant.MnoData mnoData) { NiwodaiIncomingResultRequestVO vo = new NiwodaiIncomingResultRequestVO();
vo.setOrderId(orderId);
return niwodaiService.incoingResult(vo);
}
@Override
public NiwodaiDataImportCheckResponseVO dataCheck(String uuid){
NiwodaiDataImportCheckRequestVO requestVO = new NiwodaiDataImportCheckRequestVO();
requestVO.setExternalUserId(uuid);
UserSysResult<UserInfo> userInfoByUuid = userSdkService.findUserInfoByUuid(uuid);
if (!userInfoByUuid.isSuccess()){
log.error("准入检查获取用户中心信息失败 uuid : {}",uuid);
throw new QGException("获取用户中心信息失败", QGExceptionType.COMMON_ILLEGAL_PARAM);
}
requestVO.setPhone(userInfoByUuid.getData().getPhoneNo());
List<OCRIdCardRow> list = OCRIdCardDataService.get(uuid); List<OCRIdCardRow> list = OCRIdCardDataService.get(uuid);
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
log.error("准入检查获取用户OCR信息失败 uuid : {}",uuid);
throw new QGException("没有相关用户信息", QGExceptionType.COMMON_ILLEGAL_PARAM);
}
OCRIdCardRow ocrIdCardRow = list.get(0);
IdCardA idCardFront = JSON.parseObject(ocrIdCardRow.getIdCardContentA(), IdCardA.class);
requestVO.setIdcardNumber(idCardFront.getCitizen_id());
requestVO.setRealName(idCardFront.getName());
return niwodaiService.dataImportCheck(requestVO);
}
@Override
public NiwodaiIncomingResponseVO incoming(String uuid, String orderId, String amount, Integer term) {
List<OCRIdCardRow> list = OCRIdCardDataService.get(uuid);
if (CollectionUtils.isEmpty(list)) {
log.error("进件申请获取用户OCR信息失败 uuid : {}",uuid);
throw new QGException("没有相关用户信息", QGExceptionType.COMMON_ILLEGAL_PARAM); throw new QGException("没有相关用户信息", QGExceptionType.COMMON_ILLEGAL_PARAM);
} }
OCRIdCardRow ocrIdCardRow = list.get(0); OCRIdCardRow ocrIdCardRow = list.get(0);
UserSysResult<UserInfo> userInfoByUuid = userSdkService.findUserInfoByUuid(uuid); UserSysResult<UserInfo> userInfoByUuid = userSdkService.findUserInfoByUuid(uuid);
if (!userInfoByUuid.isSuccess()){
log.error("进件申请获取用户中心信息失败 uuid : {}",uuid);
throw new QGException("获取用户中心信息失败", QGExceptionType.COMMON_ILLEGAL_PARAM);
}
IdCardA idCardFront = JSON.parseObject(ocrIdCardRow.getIdCardContentA(), IdCardA.class); IdCardA idCardFront = JSON.parseObject(ocrIdCardRow.getIdCardContentA(), IdCardA.class);
IdCardB idCardBack = JSON.parseObject(ocrIdCardRow.getIdCardContentB(), IdCardB.class); IdCardB idCardBack = JSON.parseObject(ocrIdCardRow.getIdCardContentB(), IdCardB.class);
Map<String,Object> infoMap = queryUserBasic2Info(uuid,userInfoByUuid.getData().getPhoneNo(),true); Map<String,Object> infoMap = queryUserBasic2Info(uuid,userInfoByUuid.getData().getPhoneNo(),true);
...@@ -119,7 +148,7 @@ public class NiwodaiAssetServiceImpl implements INiwodaiAssetService { ...@@ -119,7 +148,7 @@ public class NiwodaiAssetServiceImpl implements INiwodaiAssetService {
compnayInfo.setCity(userInfo.getCity()); compnayInfo.setCity(userInfo.getCity());
compnayInfo.setProvince(userInfo.getProvince()); compnayInfo.setProvince(userInfo.getProvince());
vo.setCompanyInfo(compnayInfo); vo.setCompanyInfo(compnayInfo);
vo.setMnoData(mnoData); vo.setMnoData(new NiwodaiCostant.MnoData());
return niwodaiService.incoming(vo); return niwodaiService.incoming(vo);
} }
......
...@@ -34,6 +34,7 @@ public class NiwodaiServiceImpl implements INiwodaiService { ...@@ -34,6 +34,7 @@ public class NiwodaiServiceImpl implements INiwodaiService {
private String authUrl; private String authUrl;
@Value("${niwodai.url.incoming}") @Value("${niwodai.url.incoming}")
private String incomingUrl; private String incomingUrl;
private static String getIncomingResult = "/std/v1/apply-result";
@Value("${niwodai.client.id}") @Value("${niwodai.client.id}")
private String clientId; private String clientId;
@Value("${niwodai.client.secret}") @Value("${niwodai.client.secret}")
...@@ -73,6 +74,21 @@ public class NiwodaiServiceImpl implements INiwodaiService { ...@@ -73,6 +74,21 @@ public class NiwodaiServiceImpl implements INiwodaiService {
return null; return null;
} }
@Override
public NiwodaiIncomingResultResponseVO incoingResult(NiwodaiIncomingResultRequestVO requestVO){
String token = getToken();
if (StringUtils.isEmpty(token)) {
log.error("你我贷获取进件结果时获取token失败,requestVO : {}", JSON.toJSONString(requestVO));
throw new QGException("你我贷获取进件结果时获取token失败", COMMON_THIRD_PARTY_TIMEOUT);
}
String result = iHttpService.postNiwodaiJson(domain2 + getIncomingResult, commonHeader(token), JSON.toJSONString(requestVO),true);
if (StringUtils.isNotEmpty(result)){
return JSON.parseObject(result, NiwodaiIncomingResultResponseVO.class);
}
return null;
}
public String getToken() { public String getToken() {
String token = iRedisService.getString(RedisKeyConstants.NI_WO_DAI_TOKEN_KEY); String token = iRedisService.getString(RedisKeyConstants.NI_WO_DAI_TOKEN_KEY);
if (StringUtils.isBlank(token)) { if (StringUtils.isBlank(token)) {
......
...@@ -3,8 +3,10 @@ package com.quantgroup.asset.distribution.service.niwodai.vo; ...@@ -3,8 +3,10 @@ package com.quantgroup.asset.distribution.service.niwodai.vo;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
@Data @Data
public class NiwodaiAccessTokenResponseVO { public class NiwodaiAccessTokenResponseVO implements Serializable {
@JsonProperty("access_token") @JsonProperty("access_token")
private String accessToken; private String accessToken;
......
package com.quantgroup.asset.distribution.service.niwodai.vo;
import lombok.Data;
import java.io.Serializable;
@Data
public class NiwodaiIncomingResultRequestVO implements Serializable {
private String orderId;
}
package com.quantgroup.asset.distribution.service.niwodai.vo;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class NiwodaiIncomingResultResponseVO implements Serializable {
/**
* 300004:进件处理中; 300005:进件拒绝; 300006: 审批通过
*/
private String code;
/**
* 审批金额
*/
private BigDecimal approvedAmount;
/**
* 最小借款金额
*/
private BigDecimal minAmount;
/**
* 步长
*/
private BigDecimal step;
/**
* 额度有效期
*/
private Date validBefore;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment