Commit d0a6c0fb authored by liwenbin's avatar liwenbin

新橙项目上线前准备

parent e56866e9
package com.quantgroup.asset.distribution.constant.aid;
/**
* 助贷风控属性常量
* @author : Hyuk
* @description : AidRiskInfoConstants
* @date : 2020/7/15 5:58 下午
*/
public class AidRiskInfoConstants {
/**
* 量子分3
*/
public static final String QG_SCORE3 = "model_exec_data_source#xinyan_v5";
/**
* 量子分5
*/
public static final String QG_SCORE5 = "model_exec_data_source#bairong_v3_1";
/**
* 偿债能力
*/
public static final String QG_DEBT_PAYING_SCORE = "third_data_source#zs_consumeLevel";
/**
* 手机号风险等级
*/
public static final String QG_RISK_LEVEL_PHONE = "third_data_source#lhp_hit_by_phone";
/**
* 身份证号风险等级
*/
public static final String QG_RISK_LEVEL_IDNO = "third_data_source#lhp_hit_by_idNo";
}
......@@ -66,9 +66,6 @@ public class AidCommonCallbackController {
@Autowired
private INotifyService notifyService;
// private IAidAssetCommonService
@RequestMapping("/{fund_id}/{fund_product_id}/audit_result_callback")
public MiddleOfficeResponse auditResultCallback(@PathVariable("fund_id") String fundId,
@PathVariable("fund_product_id") String fundProId,
......
......@@ -71,6 +71,7 @@ public enum QGExceptionType {
AID_COMMON_PRE_AUDIT_ERROR(3022, "助贷通用预审出现错误, uuid : %s, bizNo : %s, fundId : %s"),
AID_COMMON_AUDIT_ERROR(3023, "助贷通用进件接口出现错误, uuid : %s, bizNo : %s, fundId : %s"),
AID_COMMON_AUDIT_RESULT_ERROR(3024, "助贷回调URL或content内容错误, fundId : %s, fundProductId : %s, content : %s"),
AID_COMMON_QUERY_AUDIT_RESULT_ERROR(3025, "助贷资方审核结果查询结果出现错误, uuid : %s, bizNo : %s, fundId : %s"),
AID_COMMON_AUDIT_RESULT_ORDER_ERROR(3026, "通用助贷结果接收订单状态异常, orderNo : %s, fundId : %s, orderStatus : %s"),
USER_OCR_INFO_IS_EMPTY(3019, "用户OCR信息为空, uuid : %s"),
......
......@@ -22,27 +22,27 @@ public class AidRiskInfo implements Serializable {
/**
* 量子分3
*/
private BigDecimal qgScore3;
private Object qgScore3;
/**
* 量子分5
*/
private BigDecimal qgScore5;
private Object qgScore5;
/**
* 偿债能力评分
*/
private BigDecimal qgDebtPayingScore;
private Object qgDebtPayingScore;
/**
* 量子风险等级手机号命中
*/
private String qgRiskLevelPhone;
private Object qgRiskLevelPhone;
/**
* 量子风险等级身份证号命中
*/
private String qgRiskLevelIdNo;
private Object qgRiskLevelIdNo;
public AidRiskInfo() {}
......
......@@ -7,6 +7,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import com.quantgroup.asset.distribution.service.feature.IFeatureService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -43,15 +44,13 @@ import lombok.extern.slf4j.Slf4j;
@Service
public class AssetAttributeServiceImpl implements IAssetAttributeService {
@Autowired
private IHttpService httpService;
@Autowired
private IAssetRepository assetRepository;
@Autowired
private IAssetAttributeExtendRepository assetAttributeExtendRepository;
@Autowired
private IFeatureService featureService;
@Value("${rule.engine.url}")
private String ruleEngineURL;
/**
* 获取所有资产扩展属性value
......@@ -85,7 +84,7 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
Map<String, Object> decAttributeValue = getDecAttributeValue(decKeys, assetForm);
data.putAll(decAttributeValue);
// 必填特征, 慎用....
Map<String, Object> necAttributeValue = getDecNecAttributeValue(necessaryKeys, assetForm, data);
Map<String, Object> necAttributeValue = getDecNecAttributeValue(necessaryKeys, assetForm);
data.putAll(necAttributeValue);
// 自有属性
Map<String, Object> propertyValue = getPropertyAttributeValue(propertyKeys, assetForm);
......@@ -98,11 +97,10 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
* 获取必填特征
* @param necessaryKeys
* @param assetForm
* @param data
* @return
*/
public Map<String, Object> getDecNecAttributeValue(Set<String> necessaryKeys, AssetForm assetForm, Map<String, Object> data) {
return getDecFeatureValueCommon(necessaryKeys, assetForm, 1);
public Map<String, Object> getDecNecAttributeValue(Set<String> necessaryKeys, AssetForm assetForm) {
return featureService.getFeatureData(necessaryKeys, assetForm, 1);
}
/**
......@@ -112,34 +110,9 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
* @return
*/
public Map<String, Object> getDecAttributeValue(Set<String> decKeys, AssetForm assetForm) {
return getDecFeatureValueCommon(decKeys, assetForm, 0);
return featureService.getFeatureData(decKeys, assetForm, 0);
}
/**
*
* @param keys
* @param assetForm
* @param type
* @return
*/
public Map<String, Object> getDecFeatureValueCommon(Set<String> keys, AssetForm assetForm, int type) {
if (CollectionUtils.isEmpty(keys)) { return MapUtils.EMPTY_MAP; }
Stopwatch stopwatch = Stopwatch.createStarted();
String result = httpService.post(ruleEngineURL + "/feature/get", new HashMap<String, String>(){{
put("uuid", assetForm.getUuid());
put("bizChannel", assetForm.getBizChannel());
put("bizNo", assetForm.getBizNo());
put("bizType", assetForm.getBizType());
put("keys", StringUtils.join(keys, ","));
put("method", "0");
put("type", type + "");
}});
JSONObject resultJSON = null;
QGPreconditions.checkArgument(StringUtils.isNotEmpty(result) && (resultJSON = JSON.parseObject(result)).getInteger("code") == 0, QGExceptionType.GET_DEC_ATTRIBUTE_VALUE_ERROR, assetForm.getUuid(), JSON.toJSONString(keys));
Map<String, Object > data = resultJSON.getJSONObject("body");
log.info("决策特征属性获取完成, uuid : {}, assetNo : {}, bizChannel : {}, bizNo : {}, bizType : {}, type : {}, data : {}, 耗时 : {}", assetForm.getUuid(), assetForm.getAssetNo(), assetForm.getBizChannel(), assetForm.getBizNo(), assetForm.getBizType(), type, JSON.toJSONString(data), stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
return data;
}
/**
* 获取自有属性值
......
package com.quantgroup.asset.distribution.service.feature;
import com.quantgroup.asset.distribution.model.form.AssetForm;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Map;
import java.util.Set;
/**
* @author : Hyuk
* @description : IFeatureService
* @date : 2020/7/15 5:45 下午
*/
public interface IFeatureService {
/**
* 这个是调用量子魔方接口
* @param keys
* @param assetForm
* @param type 0: 缓存拿特证,没有null 1: 必有特征,缓存没有就去特征平台请求
* @return
*/
Map<String, Object> getFeatureData(Set<String> keys, AssetForm assetForm, int type);
}
package com.quantgroup.asset.distribution.service.feature.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Stopwatch;
import com.quantgroup.asset.distribution.exception.QGExceptionType;
import com.quantgroup.asset.distribution.exception.QGPreconditions;
import com.quantgroup.asset.distribution.model.form.AssetForm;
import com.quantgroup.asset.distribution.service.feature.IFeatureService;
import com.quantgroup.asset.distribution.service.httpclient.IHttpService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
* @author : Hyuk
* @description : FeatureServiceImpl
* @date : 2020/7/15 5:47 下午
*/
@Slf4j
@Service
public class FeatureServiceImpl implements IFeatureService {
@Value("${rule.engine.url}")
private String ruleEngineURL;
@Autowired
private IHttpService httpService;
@Override
public Map<String, Object> getFeatureData(Set<String> keys, AssetForm assetForm, int type) {
if (CollectionUtils.isEmpty(keys)) { return MapUtils.EMPTY_MAP; }
Stopwatch stopwatch = Stopwatch.createStarted();
String result = httpService.post(ruleEngineURL + "/feature/get", new HashMap<String, String>(){{
put("uuid", assetForm.getUuid());
put("bizChannel", assetForm.getBizChannel());
put("bizNo", assetForm.getBizNo());
put("bizType", assetForm.getBizType());
put("keys", StringUtils.join(keys, ","));
put("method", "0");
put("type", type + "");
}});
JSONObject resultJSON = null;
QGPreconditions.checkArgument(StringUtils.isNotEmpty(result) && (resultJSON = JSON.parseObject(result)).getInteger("code") == 0, QGExceptionType.GET_DEC_ATTRIBUTE_VALUE_ERROR, assetForm.getUuid(), JSON.toJSONString(keys));
Map<String, Object > data = resultJSON.getJSONObject("body");
log.info("决策特征属性获取完成, uuid : {}, assetNo : {}, bizChannel : {}, bizNo : {}, bizType : {}, type : {}, data : {}, 耗时 : {}", assetForm.getUuid(), assetForm.getAssetNo(), assetForm.getBizChannel(), assetForm.getBizNo(), assetForm.getBizType(), type, JSON.toJSONString(data), stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
return data;
}
}
......@@ -113,7 +113,7 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService {
}
//助贷资金分配规则校验
if(ruleService.valid(aidLoanFundConfig.getFundRuleEl(), data)){
// 分配规则二次校验, md主要是ligeng的需求无法用表达式去满足, 特征值为null的居然让结果为true
// 分配规则二次校验, md主要是风控的需求无法用表达式去满足, 特征值为null的居然让结果为true
if (!secondValid(data, aidLoanFundConfig, asset)) { continue; }
// 助贷资金准入接口调用
boolean accessResult = false;
......@@ -209,6 +209,7 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService {
* @return
*/
private boolean secondValid(Map<String, Object> data, AidLoanFundConfig aidLoanFundConfig, Asset asset) {
boolean valid = true;
if ("970".equals(aidLoanFundConfig.getFundId()) && "1052".equals(aidLoanFundConfig.getFundProductId())) {
// 你我贷助贷资方
QGPreconditions.checkArgument(asset.getUserLoanType() != null, QGExceptionType.USER_LOAN_TYPE_IS_EMPTY, asset.getUuid());
......@@ -223,7 +224,25 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService {
}
}
}
} else if ("1050".equals(aidLoanFundConfig.getFundId()) && "1062".equals(aidLoanFundConfig.getFundProductId())) {
// 新橙
// 1、年龄22-55限制
Integer age = (Integer)data.get("user_age");
if (age == null || age.intValue() < 22 || age.intValue() > 55) {
valid = false;
}
return true;
// 2、新疆、青海、西藏、福建不导
String province = (String)data.get("user_province_code");
if (province == null || "65".equals(province) || "63".equals(province) || "54".equals(province) || "35".equals(province)) {
valid = false;
}
// 这里针对每个助贷资方单独打印一下为啥不导的日志
if (!valid) {
log.info("助贷资方导流, 用户命中二次校验规则, 不进行导流, uuid : {}, fundId : {}, fundProductId : {}, userAge : {}, province : {}",
asset.getUuid(), aidLoanFundConfig.getFundId(), aidLoanFundConfig.getFundProductId(), age, province);
}
}
return valid;
}
}
......@@ -44,6 +44,9 @@ public class AidFundInfoConfig implements Serializable {
@Column(name = "audit_url")
private String auditUrl;
@Column(name = "audit_result_url")
private String auditResultUrl;
@Column(name = "enable")
private Boolean enable;
......
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