Commit ab380ea0 authored by liwenbin's avatar liwenbin

你我贷增加前筛限制

parent 9ea2e679
......@@ -126,9 +126,4 @@ public class NiWoDaiController {
}
return true;
}
public static void main(String[] args) throws FileNotFoundException {
System.out.println(ResourceUtils.getURL("classpath:").getPath());
}
}
\ No newline at end of file
......@@ -62,7 +62,10 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
Map<String, Object> data = new HashMap<>();
// 决策特征Key
Set<String> decKeys = new HashSet<>();
// 自有属性
Set<String> propertyKeys = new HashSet<>();
// 必填特征...慎用,会花钱的
Set<String> necessaryKeys = new HashSet<>();
decKeys.add(AssetAttributeConstants.USER_LOAN_TYPE);
if (assetAttributeExtendConfigList != null && assetAttributeExtendConfigList.size() > 0) {
for (AssetAttributeExtendConfig config : assetAttributeExtendConfigList) {
......@@ -71,12 +74,19 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
} else if (config.getAssetAttributeType() == 2) {
// 自有属性,amount和term
propertyKeys.add(config.getAssetAttributeCode());
} else if (config.getAssetAttributeType() == 3) {
// 决策必填特征
necessaryKeys.add(config.getAssetAttributeCode());
}
}
}
// 请求决策特征
Map<String, Object> decAttributeValue = getDecAttributeValue(decKeys, assetForm);
data.putAll(decAttributeValue);
// 必填特征, 慎用....
Map<String, Object> necAttributeValue = getDecNecAttributeValue(necessaryKeys, assetForm, data);
data.putAll(necAttributeValue);
// 自有属性
Map<String, Object> propertyValue = getPropertyAttributeValue(propertyKeys, assetForm);
data.putAll(propertyValue);
......@@ -84,26 +94,50 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
return data;
}
/**
* 获取必填特征
* @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);
}
/**
* 获取所有决策特征属性值
* @param decKeys
* @param assetForm
* @return
*/
public Map<String, Object> getDecAttributeValue(Set<String> decKeys, AssetForm assetForm) {
if (CollectionUtils.isEmpty(decKeys)) { return MapUtils.EMPTY_MAP; }
return getDecFeatureValueCommon(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(decKeys, ","));
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(decKeys));
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 : {}, data : {}, 耗时 : {}", assetForm.getUuid(), assetForm.getAssetNo(), assetForm.getBizChannel(), assetForm.getBizNo(), assetForm.getBizType(), JSON.toJSONString(data), stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
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;
}
......
......@@ -17,7 +17,7 @@ public interface IAidFundAssetService {
* @param assetForm
* @return
*/
public boolean preAudit(AssetForm assetForm, String fundId);
public boolean preAudit(AssetForm assetForm, String fundId, Map<String, Object> data);
/**
* 进件审核
......
......@@ -26,10 +26,10 @@ public class AidFundAssetServiceImpl implements IAidFundAssetService {
private INiwodaiAssetService niwodaiAssetService;
@Override
public boolean preAudit(AssetForm assetForm, String fundId) {
public boolean preAudit(AssetForm assetForm, String fundId, Map<String, Object> data) {
switch (fundId) {
case AidFundConstants.FundId.NIWODAI : {
return niwodaiAssetService.preAudit(assetForm.getUuid()).getPass().booleanValue();
return niwodaiAssetService.preAudit(assetForm.getUuid(), data).getPass().booleanValue();
}
default :
throw new QGException(QGExceptionType.UNKNOW_AID_FUND_ID);
......
......@@ -115,7 +115,7 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService {
if (status == AidFundStatus.Route.PRE_PASS) {
accessResult = true;
} else {
accessResult = aidFundAssetService.preAudit(assetForm, aidLoanFundConfig.getFundId());
accessResult = aidFundAssetService.preAudit(assetForm, aidLoanFundConfig.getFundId(), data);
// 保存主贷资金路由记录
aidLoanFundRouteRecord = new AidLoanFundRouteRecord();
aidLoanFundRouteRecord.setAidFundRouteStatus(accessResult ? AidFundStatus.Route.PRE_PASS : AidFundStatus.Route.PRE_REJECT);//1-准入成功 2-准入失败 3-进件完成
......
......@@ -13,7 +13,7 @@ public interface INiwodaiAssetService {
NiwodaiIncomingResultResponseVO incomingResult(String orderId);
NiwodaiDataImportCheckResponseVO preAudit(String uuid);
NiwodaiDataImportCheckResponseVO preAudit(String uuid, Map<String, Object> data);
NiwodaiIncomingResponseVO incoming(AssetForm assetForm, Map<String, Object> data, Asset asset);
......
......@@ -72,16 +72,35 @@ public class NiwodaiAssetServiceImpl implements INiwodaiAssetService {
}
@Override
public NiwodaiDataImportCheckResponseVO preAudit(String uuid) {
public NiwodaiDataImportCheckResponseVO preAudit(String uuid, Map<String, Object> data) {
NiwodaiDataImportCheckRequestVO requestVO = new NiwodaiDataImportCheckRequestVO();
UserSysResult<UserInfo> userInfoByUuid = userSdkService.findUserInfoByUuid(uuid);
if (!userInfoByUuid.isSuccess()){
log.error("你我贷准入检查获取用户中心信息失败 uuid : {}",uuid);
throw new QGException(QGExceptionType.GET_USER_INFO_ERROR);
}
// 因为渠道限制不一样,死条件先在代码里写死
String phoneNo = userInfoByUuid.getData().getPhoneNo();
if (phoneNo.startsWith("170") || phoneNo.startsWith("171")) {
log.info("你我贷准入检查, 用户手机号段过滤, uuid : {}, phone : {}", uuid, phoneNo);
log.info("你我贷准入检查, 用户手机号段过滤, uuid : {}, phone : {}", uuid, getPhoneNoMask(phoneNo));
return NiwodaiDataImportCheckResponseVO.createPassFalse();
}
// 年龄过滤, 23>= age <= 50 通过,其余拒绝
Integer age = (Integer)data.get("user_age");
if (age == null || age.intValue() < 23 || age.intValue() > 50) {
log.info("你我贷准入检查, 用户年龄过滤, uuid : {}, age : {}", uuid, age);
return NiwodaiDataImportCheckResponseVO.createPassFalse();
}
// 用户归属地过滤,西藏、新疆、福建过滤
String province = (String)data.get("user_province_code");
if (StringUtils.isEmpty(province) || province.startsWith("-999999") || "54".equals(province.trim()) || "65".equals(province.trim()) || "35".equals(province.trim())) {
log.info("你我贷准入检查, 用户归属地过滤, uuid : {}, province : {}", uuid, province);
return NiwodaiDataImportCheckResponseVO.createPassFalse();
}
// 黑名单过滤
Integer countBlackList = (Integer)data.get("filter_user_info_in_black");
if (countBlackList == null || countBlackList.intValue() > 0) {
log.info("你我贷准入检查, 用户黑名单过滤, uuid : {}, countBlackList : {}", uuid, countBlackList);
return NiwodaiDataImportCheckResponseVO.createPassFalse();
}
requestVO.setPhone(getPhoneNoMask(phoneNo));
......@@ -473,5 +492,14 @@ public class NiwodaiAssetServiceImpl implements INiwodaiAssetService {
return riskData;
}
public static void main(String[] args) {
Map<String, Object> data= new HashMap<>();
Integer age = (Integer)data.get("user_age");
System.out.println(age);
if (age == null || age.intValue() < 22 || age.intValue() > 50) {
System.out.println("不要");
} else {
System.out.println("要");
}
}
}
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