Commit 5ddb769c authored by liwenbin's avatar liwenbin

你我贷需求

parent c849eda3
......@@ -77,7 +77,7 @@ public class NiWoDaiController {
alarmService.dingtalkAlarm("Error", "你我贷审核结果回调type错误", "bizNo : " + orderId + " , type : " + type + " , code : " + code + " , timestamp : " + timestamp + " , data : " + data);
return GlobalResponse.success();
}
if (code == null || (code != 300005 && code != 300006)) {
if (code == null || (code.intValue() != 300005 && code.intValue() != 300006)) {
log.info("你我贷审核进件回调结果code出现错误, orderId : {}, type : {}, code : {}, timestamp : {}, data : {}", orderId, type, code, timestamp , data);
alarmService.dingtalkAlarm("Error", "你我贷审核结果回调code出现错误", "bizNo : " + orderId + " , type : " + type + " , code : " + code + " , timestamp : " + timestamp + " , data : " + data);
return GlobalResponse.success();
......@@ -86,7 +86,7 @@ public class NiWoDaiController {
AssetForm assetForm = JSON.parseObject(aidLoanFundAuditOrder.getAssetFormText(), AssetForm.class);
Asset asset = JSON.parseObject(aidLoanFundAuditOrder.getAssetText(), Asset.class);
Map<String, Object> dataMap = JSON.parseObject(aidLoanFundAuditOrder.getDataText(), Map.class);
if (300005 == code) {
if (300005 == code.intValue()) {
// 将助贷审核订单状态改为拒绝
aidFundAuditOrderService.updateOrderStatus(aidLoanFundAuditOrder, AidFundStatus.Incoming.REJECT);
// 将分发记录改为失败
......@@ -101,10 +101,12 @@ public class NiWoDaiController {
return GlobalResponse.success();
}
// 通过了直接通知资金系统
String finance = financeProductService.createSingletonFinanceProduct(vo.getApprovedAmount().toString(), String.valueOf(vo.getApproveTerm()), AidFundConstants.FundId.NIWODAI, "1052");
String finance = financeProductService.createSingletonFinanceProduct(vo.getApprovedAmount().toString(), String.valueOf(vo.getApproveTerm()), aidLoanFundAuditOrder.getFundId(), aidLoanFundAuditOrder.getFundProductId());
assetForm = financeProductService.checkFundResult(assetForm, finance, Long.parseLong(vo.getValidBefore()));
assetForm.setAmount(vo.getApprovedAmount().toString());
assetForm.setTerm(String.valueOf(vo.getApproveTerm()));
// 将助贷审核订单状态改为成功
aidFundAuditOrderService.updateOrderStatus(aidLoanFundAuditOrder, AidFundStatus.Incoming.PASS);
notifyService.notifyFundServer(assetForm, dataMap);
}
log.info("你我贷审核进件回调结果处理完成, orderId : {}, type : {}, code : {}, timestamp : {}, data : {}", orderId,
......
......@@ -5,6 +5,7 @@ import com.quantgroup.asset.distribution.model.response.GlobalResponse;
import com.quantgroup.asset.distribution.service.asset.IAssetAttributeExtendConfigService;
import com.quantgroup.asset.distribution.service.authority.IAuthorityService;
import com.quantgroup.asset.distribution.service.distribute.IAssetDistributeRuleConfigService;
import com.quantgroup.asset.distribution.service.funding.IAidLoanFundConfigService;
import com.quantgroup.asset.distribution.service.funding.IFundModuleLimitTypeService;
import com.quantgroup.asset.distribution.service.redis.IRedisService;
import lombok.extern.slf4j.Slf4j;
......@@ -36,6 +37,8 @@ public class RedisFlushController {
private IAssetDistributeRuleConfigService assetDistributeRuleConfigService;
@Autowired
private IFundModuleLimitTypeService limitTypeService;
@Autowired
private IAidLoanFundConfigService aidLoanFundConfigService;
/**
* 助贷资金池刷新
......@@ -72,4 +75,13 @@ public class RedisFlushController {
if(authKey.equals(key)) { limitTypeService.clearCache(); }
return GlobalResponse.success();
}
@RequestMapping("/aid_loan_pool_flush")
public GlobalResponse AidLoanPoolFlush(String key) {
if(authKey.equals(key)) {
aidLoanFundConfigService.clearCache();
return GlobalResponse.success();
}
return GlobalResponse.error("authKey验证失败");
}
}
......@@ -104,7 +104,7 @@ public class AssetDistributeServiceImpl implements IAssetDistributeService{
if (valid) {
// 先创建记录,避免mq里消息来了就还没创建
AssetDistributeRecord assetDistributeRecord = assetDistributeRecordService.saveDistributeRecord(asset, record, StatusConstants.WAIT, ruleType);
int distributeStatus = beginDistribute(assetForm, asset, ruleType, assetDistributeRecord, data);
int distributeStatus = beginDistribute(assetForm, asset, ruleType.intValue(), assetDistributeRecord, data);
// 分发成功
if (distributeStatus == StatusConstants.SUCCESS || distributeStatus == StatusConstants.WAIT) {
log.info("用户执行分发节点, uuid : {}, bizNo : {}, assetNo : {}, bizChannel : {}, ruleId : {}, ruleName : {}, distributeStatus : {}",
......
package com.quantgroup.asset.distribution.service.funding;
import com.quantgroup.asset.distribution.model.form.AssetForm;
import com.quantgroup.asset.distribution.service.jpa.entity.Asset;
import java.util.Map;
......@@ -25,5 +26,5 @@ public interface IAidFundAssetService {
* @param userLoanType
* @return true:进件成功 false:进件失败
*/
public boolean audit(AssetForm assetForm, Map<String, Object> data, Integer userLoanType, String fundId);
public boolean audit(AssetForm assetForm, Map<String, Object> data, Asset asset, String fundId);
}
......@@ -32,5 +32,5 @@ public interface IAidLoanFundConfigService {
*/
AidLoanFundConfig findByFundNo(String fundNo);
void clearCache();
}
package com.quantgroup.asset.distribution.service.funding;
import com.quantgroup.asset.distribution.model.form.AssetForm;
import com.quantgroup.asset.distribution.service.jpa.entity.Asset;
/**
* @author : Hyuk
* @description : IAidLOanFundUserTagService
* @date : 2020/4/28 10:43 上午
*/
public interface IAidLoanFundUserTagService {
public void saveUserTag(AssetForm assetForm, Asset asset, String fundId, String tagText);
}
......@@ -5,6 +5,7 @@ import com.quantgroup.asset.distribution.exception.QGException;
import com.quantgroup.asset.distribution.exception.QGExceptionType;
import com.quantgroup.asset.distribution.model.form.AssetForm;
import com.quantgroup.asset.distribution.service.funding.IAidFundAssetService;
import com.quantgroup.asset.distribution.service.jpa.entity.Asset;
import com.quantgroup.asset.distribution.service.niwodai.INiwodaiAssetService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -36,10 +37,10 @@ public class AidFundAssetServiceImpl implements IAidFundAssetService {
}
@Override
public boolean audit(AssetForm assetForm, Map<String, Object> data, Integer userLoanType, String fundId) {
public boolean audit(AssetForm assetForm, Map<String, Object> data, Asset asset, String fundId) {
switch (fundId) {
case AidFundConstants.FundId.NIWODAI : {
return niwodaiAssetService.incoming(assetForm, data, userLoanType).getCode().equals(300007);
return niwodaiAssetService.incoming(assetForm, data, asset).getCode().equals(300007);
}
default :
throw new QGException(QGExceptionType.UNKNOW_AID_FUND_ID);
......
......@@ -60,7 +60,8 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService {
* 助贷资金路由
*
* @param assetForm
* @param userLoanType
* @param asset
* @param data
* @return
*/
@Override
......@@ -82,14 +83,14 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService {
.filter(aidLoanFundConfig->aidLoanFundConfig.getFundCountLimit() >=redisService.setIncr(AID_LOAN_COUNT_LIMIT_KEY + DateUtil.getDay(), 0, 3, TimeUnit.DAYS))
.collect(Collectors.toList());
}
//第四步 限制总额度筛选
if(CollectionUtils.isNotEmpty(aidLoanFundConfigList)){
// 获取已放款总金额 AID_LOAN_ALL_AMOUNT_LIMIT_KEY + DateUtil.getDay() //TODO 放redis
String allAmount = redisService.getString(AID_LOAN_ALL_AMOUNT_LIMIT_KEY + DateUtil.getDay());
aidLoanFundConfigList = aidLoanFundConfigList.parallelStream()
.filter(aidLoanFundConfig->new BigDecimal(aidLoanFundConfig.getFundAllAmountLimit()).compareTo(new BigDecimal(StringUtils.isEmpty(allAmount)?"0":allAmount))>0)
.collect(Collectors.toList());
}
//第四步 限制总额度筛选 额度筛选暂时没有用到
// if(CollectionUtils.isNotEmpty(aidLoanFundConfigList)){
// // 获取已放款总金额 AID_LOAN_ALL_AMOUNT_LIMIT_KEY + DateUtil.getDay() //TODO 放redis
// String allAmount = redisService.getString(AID_LOAN_ALL_AMOUNT_LIMIT_KEY + DateUtil.getDay());
// aidLoanFundConfigList = aidLoanFundConfigList.parallelStream()
// .filter(aidLoanFundConfig->new BigDecimal(aidLoanFundConfig.getFundAllAmountLimit()).compareTo(new BigDecimal(StringUtils.isEmpty(allAmount)?"0":allAmount))>0)
// .collect(Collectors.toList());
// }
//第五步 开始路由
if(CollectionUtils.isNotEmpty(aidLoanFundConfigList)){
......@@ -126,10 +127,11 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService {
aidLoanFundRouteRecord.setUserLoanType(asset.getUserLoanType());
aidLoanFundRouteRecord.setFundNo(aidLoanFundConfig.getFundNo());
aidLoanFundRouteRecord.setFundId(aidLoanFundConfig.getFundId());
aidLoanFundRouteRecord.setFundProductId(aidLoanFundConfig.getFundProductId());
aidLoanFundRouteRecord.setEnable(true);
aidLoanFundRouteRecord = iAidFundRouteRecordService.saveAidLoanFundRouteRecord(aidLoanFundRouteRecord);
log.info("助贷资金路由-准入完成, bizChannel : {} , uuid : {} , bizNo : {} , fundId : {} , 准入结果 : {} , 耗时 : {}",assetForm.getBizChannel(),assetForm.getUuid(),assetForm.getBizNo(),aidLoanFundRouteRecord.getFundId(),accessResult,started.elapsed(TimeUnit.MILLISECONDS));
log.info("助贷资金路由-准入完成, bizChannel : {} , uuid : {} , bizNo : {} , fundId : {} , fundProductId : {} , 准入结果 : {} , 耗时 : {}",assetForm.getBizChannel(),assetForm.getUuid(),assetForm.getBizNo(),aidLoanFundRouteRecord.getFundId(),aidLoanFundRouteRecord.getFundProductId(),accessResult,started.elapsed(TimeUnit.MILLISECONDS));
}
if(accessResult){
......@@ -146,10 +148,10 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService {
// 先创建进件订单记录
AidLoanFundAuditOrder aidLoanFundAuditOrder = createAidFundAuditOrder(aidLoanFundRouteRecord, assetForm, asset, data);
// 调用助贷资方进件接口 异步
boolean incomingResult = aidFundAssetService.audit(assetForm, data, asset.getUserLoanType(), aidLoanFundConfig.getFundId());
boolean incomingResult = aidFundAssetService.audit(assetForm, data, asset, aidLoanFundConfig.getFundId());
// 将助贷路由记录状态改为进件完成
iAidFundRouteRecordService.updateAidLoanFundRouteRecordStatus(aidLoanFundRouteRecord, AidFundStatus.Route.INCOMING_COMPLETE);
log.info("助贷资金路由-进件完成, bizChannel : {} , uuid : {} , bizNo : {} , fundId : {} , 进件结果 : {}, 耗时 : {} ",assetForm.getBizChannel(),assetForm.getUuid(),assetForm.getBizNo(),aidLoanFundRouteRecord.getFundId(),incomingResult,started.stop().elapsed(TimeUnit.MILLISECONDS));
log.info("助贷资金路由-进件完成, bizChannel : {} , uuid : {} , bizNo : {} , fundId : {} , fundProductId : {} , 进件结果 : {}, 耗时 : {} ",assetForm.getBizChannel(),assetForm.getUuid(),assetForm.getBizNo(),aidLoanFundRouteRecord.getFundId(),aidLoanFundRouteRecord.getFundProductId(),incomingResult,started.stop().elapsed(TimeUnit.MILLISECONDS));
if (incomingResult) {
aidFundAuditOrderService.updateOrderStatus(aidLoanFundAuditOrder, AidFundStatus.Incoming.WAIT);
......@@ -184,6 +186,7 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService {
aidLoanFundAuditOrder.setUuid(assetForm.getUuid());
aidLoanFundAuditOrder.setBizNo(assetForm.getBizNo());
aidLoanFundAuditOrder.setFundId(aidLoanFundRouteRecord.getFundId());
aidLoanFundAuditOrder.setFundProductId(aidLoanFundRouteRecord.getFundProductId());
aidLoanFundAuditOrder.setAssetFormText(JSON.toJSONString(assetForm));
aidLoanFundAuditOrder.setAssetText(JSON.toJSONString(asset));
aidLoanFundAuditOrder.setDataText(JSON.toJSONString(data));
......
......@@ -77,4 +77,9 @@ public class AidLoanFundConfigServiceImpl implements IAidLoanFundConfigService {
public AidLoanFundConfig findByFundNo(String fundNo) {
return iAidLoanFundConfigRepository.findByFundNo(fundNo);
}
@Override
public void clearCache() {
redisService.del(AID_LOAN_POOLKEYS_HMSET_KEY);
}
}
package com.quantgroup.asset.distribution.service.funding.impl;
import com.quantgroup.asset.distribution.model.form.AssetForm;
import com.quantgroup.asset.distribution.service.funding.IAidLoanFundUserTagService;
import com.quantgroup.asset.distribution.service.jpa.entity.AidLoanFundUserTag;
import com.quantgroup.asset.distribution.service.jpa.entity.Asset;
import com.quantgroup.asset.distribution.service.jpa.repository.IAidLoanFundUserTagRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.io.Serializable;
/**
* @author : Hyuk
* @description : AidLoanFundUserTagServiceImpl
* @date : 2020/4/28 10:44 上午
*/
@Slf4j
@Service
public class AidLoanFundUserTagServiceImpl implements IAidLoanFundUserTagService {
@Autowired
private IAidLoanFundUserTagRepository aidLoanFundUserTagRepository;
@Async
@Override
public void saveUserTag(AssetForm assetForm, Asset asset, String fundId, String tagText) {
AidLoanFundUserTag aidLoanFundUserTag = new AidLoanFundUserTag();
aidLoanFundUserTag.setAssetNo(asset.getAssetNo());
aidLoanFundUserTag.setUuid(assetForm.getUuid());
aidLoanFundUserTag.setBizNo(assetForm.getBizNo());
aidLoanFundUserTag.setFundId(fundId);
aidLoanFundUserTag.setTagText(tagText);
aidLoanFundUserTag.setEnable(true);
aidLoanFundUserTagRepository.save(aidLoanFundUserTag);
}
}
......@@ -38,6 +38,9 @@ public class AidLoanFundAuditOrder implements Serializable {
@Column(name = "fund_id")
private String fundId;
@Column(name = "fund_product_id")
private String fundProductId;
@Column(name = "asset_form_text")
private String assetFormText;
......
......@@ -45,6 +45,9 @@ public class AidLoanFundConfig implements Serializable{
@Column(name="fund_id")
private String fundId;
@Column(name = "fund_product_id")
private String fundProductId;
@Column(name="fund_all_amount_limit")
private String fundAllAmountLimit;
......
......@@ -48,6 +48,9 @@ public class AidLoanFundRouteRecord implements Serializable{
@Column(name="fund_id")
private String fundId;
@Column(name = "fund_product_id")
private String fundProductId;
@Column(name="aid_fund_route_no")
private String aidFundRouteNo;
......
package com.quantgroup.asset.distribution.service.jpa.entity;
import lombok.Data;
import javax.persistence.*;
import java.sql.Timestamp;
/**
* @author : Hyuk
* @description : AidLoanFundUserTag
* @date : 2020/4/28 10:38 上午
*/
@Entity
@Table(name="aid_loan_fund_user_tag")
@Data
public class AidLoanFundUserTag {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "asset_no")
private String assetNo;
@Column(name = "uuid")
private String uuid;
@Column(name = "biz_no")
private String bizNo;
@Column(name = "fund_id")
private String fundId;
@Column(name = "tag_text")
private String tagText;
@Column(name = "enable")
private Boolean enable;
@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.AidLoanFundUserTag;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @author : Hyuk
* @description : IAidLoanFundUserTag
* @date : 2020/4/28 10:42 上午
*/
public interface IAidLoanFundUserTagRepository extends JpaRepository<AidLoanFundUserTag, Long> {
}
......@@ -15,7 +15,7 @@ public interface INiwodaiAssetService {
NiwodaiDataImportCheckResponseVO preAudit(String uuid);
NiwodaiIncomingResponseVO incoming(AssetForm assetForm, Map<String, Object> data, Integer userLoanType);
NiwodaiIncomingResponseVO incoming(AssetForm assetForm, Map<String, Object> data, Asset asset);
Map<String,Object> queryUserBasic2Info(String userId, String phoneNo, boolean isQuery);
}
......@@ -11,11 +11,14 @@ import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.lkb.data.hbase.dataservice.verify.OCRIdCardDataService;
import com.lkb.data.hbase.row.verify.OCRIdCardRow;
import com.quantgroup.asset.distribution.constant.AidFundConstants;
import com.quantgroup.asset.distribution.enums.UserLoanType;
import com.quantgroup.asset.distribution.exception.QGException;
import com.quantgroup.asset.distribution.exception.QGExceptionType;
import com.quantgroup.asset.distribution.model.form.AssetForm;
import com.quantgroup.asset.distribution.service.funding.IAidLoanFundUserTagService;
import com.quantgroup.asset.distribution.service.httpclient.IHttpService;
import com.quantgroup.asset.distribution.service.jpa.entity.Asset;
import com.quantgroup.asset.distribution.service.niwodai.INiwodaiAssetService;
import com.quantgroup.asset.distribution.service.niwodai.INiwodaiService;
import com.quantgroup.asset.distribution.service.niwodai.vo.*;
......@@ -41,6 +44,8 @@ import java.util.concurrent.TimeUnit;
@Service
public class NiwodaiAssetServiceImpl implements INiwodaiAssetService {
@Autowired
private IAidLoanFundUserTagService aidLoanFundUserTagService;
@Autowired
IHttpService iHttpService;
@Autowired
......@@ -74,7 +79,12 @@ public class NiwodaiAssetServiceImpl implements INiwodaiAssetService {
log.error("你我贷准入检查获取用户中心信息失败 uuid : {}",uuid);
throw new QGException(QGExceptionType.GET_USER_INFO_ERROR);
}
requestVO.setPhone(getPhoneNoMask(userInfoByUuid.getData().getPhoneNo()));
String phoneNo = userInfoByUuid.getData().getPhoneNo();
if (phoneNo.startsWith("170") || phoneNo.startsWith("171")) {
log.info("你我贷准入检查, 用户手机号段过滤, uuid : {}, phone : {}", uuid, phoneNo);
return NiwodaiDataImportCheckResponseVO.createPassFalse();
}
requestVO.setPhone(getPhoneNoMask(phoneNo));
requestVO.setIdcardNumber(getIdNoMask(userInfoByUuid.getData().getIdNo()));
requestVO.setRealName(userInfoByUuid.getData().getName());
Stopwatch stopwatch = Stopwatch.createStarted();
......@@ -85,7 +95,7 @@ public class NiwodaiAssetServiceImpl implements INiwodaiAssetService {
@Override
public NiwodaiIncomingResponseVO incoming(AssetForm assetForm, Map<String, Object> data, Integer userLoanType) {
public NiwodaiIncomingResponseVO incoming(AssetForm assetForm, Map<String, Object> data, Asset asset) {
List<OCRIdCardRow> list = OCRIdCardDataService.get(assetForm.getUuid());
if (CollectionUtils.isEmpty(list)) {
log.error("你我贷进件申请获取用户OCR信息失败 uuid : {}, orderId : {}",assetForm.getUuid(), assetForm.getBizNo());
......@@ -145,8 +155,10 @@ public class NiwodaiAssetServiceImpl implements INiwodaiAssetService {
compnayInfo.setProvince(userInfo.getProvince());
vo.setCompanyInfo(compnayInfo);
vo.setMnoData(new NiwodaiCostant.MnoData());
NiwodaiCostant.RiskData riskData = getRiskData(userLoanType, data);
NiwodaiCostant.RiskData riskData = getRiskData(asset.getUserLoanType(), data);
vo.setChannelRiskData(JSON.toJSONString(riskData));
// 标签落库
aidLoanFundUserTagService.saveUserTag(assetForm, asset, AidFundConstants.FundId.NIWODAI, JSON.toJSONString(riskData));
return niwodaiService.incoming(vo, assetForm.getUuid());
}
......
......@@ -69,7 +69,7 @@ public class NiwodaiServiceImpl implements INiwodaiService {
log.error("你我贷进件时获取token失败, uuid : {}, bizNo : {}", uuid, requestVO.getOrderId());
throw new QGException(QGExceptionType.GET_NIWODAI_TOKEN_ERROR);
}
String result = iHttpService.postNiwodaiJson(domain2 + incomingUrl, commonHeader(token), JSON.toJSONString(requestVO),true);
String result = iHttpService.postNiwodaiJson(domain2 + incomingUrl, commonHeader(token), JSON.toJSONString(requestVO),false);
log.info("你我贷进件接口审核接口结束, uuid : {}, bizNo : {}, response : {}", uuid, requestVO.getOrderId(), result);
if (StringUtils.isNotEmpty(result)) {
NiwodaiIncomingResponseVO vo = JSON.parseObject(result, NiwodaiIncomingResponseVO.class);
......
......@@ -18,4 +18,11 @@ public class NiwodaiDataImportCheckResponseVO implements Serializable {
* 准入未通过原因 非必须
*/
private String reason;
public static NiwodaiDataImportCheckResponseVO createPassFalse() {
NiwodaiDataImportCheckResponseVO vo = new NiwodaiDataImportCheckResponseVO();
vo.setPass(false);
return vo;
}
}
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