Commit 579cfc65 authored by liwenbin's avatar liwenbin

f

parent f52ba6cc
...@@ -42,7 +42,8 @@ public enum QGExceptionType { ...@@ -42,7 +42,8 @@ public enum QGExceptionType {
NO_FUND_INFO_BEEN_HIT(3002, "未命中任何资方, bizChannel : %s, amount : %s, term : %s"), NO_FUND_INFO_BEEN_HIT(3002, "未命中任何资方, bizChannel : %s, amount : %s, term : %s"),
FUND_PRIORITY_IS_ERROR(3003, "资方优先级不符合要求, bizChannel : %s, amount : %s, term : %s"), FUND_PRIORITY_IS_ERROR(3003, "资方优先级不符合要求, bizChannel : %s, amount : %s, term : %s"),
NOT_FOUNT_CHANNEL_FUNDS_INFO(3004, "未找到渠道资方配置, 请检查; bizChannel : %s"), NOT_FOUNT_CHANNEL_FUNDS_INFO(3004, "未找到渠道资方配置, 请检查; bizChannel : %s"),
CHANNEL_FUND_CONFIG_GREATER_THAN_TOW(3005, "渠道资方有效配置大于2条,请检查; bizChannel : % s"); CHANNEL_FUND_CONFIG_GREATER_THAN_TOW(3005, "渠道资方有效配置大于2条,请检查; bizChannel : % s"),
HIT_FUND_BUT_AMOUNT_OR_TERM_IS_EMPTY(3006, "命中资方但额度或期数为空, 请检查!");
......
...@@ -225,27 +225,10 @@ public class AssetServiceImpl implements IAssetService{ ...@@ -225,27 +225,10 @@ public class AssetServiceImpl implements IAssetService{
if ("true".equals(assetForm.getAuditResult()) && (StringUtils.isEmpty(assetForm.getAmount()) || StringUtils.isEmpty(assetForm.getTerm()))) { if ("true".equals(assetForm.getAuditResult()) && (StringUtils.isEmpty(assetForm.getAmount()) || StringUtils.isEmpty(assetForm.getTerm()))) {
return null; return null;
} }
// 创建金融产品集,并初始化金额期数
JSONArray financeProductArray = new JSONArray();
JSONObject amountJSON = new JSONObject();
financeProductArray.add(amountJSON);
amountJSON.put("min", assetForm.getAmount());
amountJSON.put("max", assetForm.getAmount());
JSONArray termArray = new JSONArray();
amountJSON.put("terms", termArray);
JSONObject termJSON = new JSONObject();
termArray.add(termJSON);
try {
// 不能是string,否则资方那边会报错
termJSON.put("term", Integer.parseInt(assetForm.getTerm()));
} catch (Exception e) {
termJSON.put("term", Double.parseDouble(assetForm.getTerm()));
}
JSONArray fundArray = new JSONArray();
termJSON.put("fundInfo", fundArray);
FundModuleChannelFundConfig config = fundModuleCHannelFundConfigService.findByBizChannel(assetForm.getBizChannel()); FundModuleChannelFundConfig config = fundModuleCHannelFundConfigService.findByBizChannel(assetForm.getBizChannel());
QGPreconditions.checkArgument(config != null, QGExceptionType.NOT_FOUNT_CHANNEL_FUNDS_INFO, assetForm.getBizChannel()); QGPreconditions.checkArgument(config != null, QGExceptionType.NOT_FOUNT_CHANNEL_FUNDS_INFO, assetForm.getBizChannel());
JSONArray fundArray = new JSONArray();
List<ChannelFundConfig> fundConfigList = JSONArray.parseArray(config.getFunds(), ChannelFundConfig.class); List<ChannelFundConfig> fundConfigList = JSONArray.parseArray(config.getFunds(), ChannelFundConfig.class);
A : for (ChannelFundConfig channelFundConfig : fundConfigList) { A : for (ChannelFundConfig channelFundConfig : fundConfigList) {
List<ChannelFundConfig.Limit> limits = channelFundConfig.getLimits(); List<ChannelFundConfig.Limit> limits = channelFundConfig.getLimits();
...@@ -290,7 +273,6 @@ public class AssetServiceImpl implements IAssetService{ ...@@ -290,7 +273,6 @@ public class AssetServiceImpl implements IAssetService{
return null; return null;
} }
QGPreconditions.checkArgument(fundArray.size() != 0, QGExceptionType.NO_FUND_INFO_BEEN_HIT, assetForm.getBizChannel(), assetForm.getAmount(), assetForm.getTerm()); QGPreconditions.checkArgument(fundArray.size() != 0, QGExceptionType.NO_FUND_INFO_BEEN_HIT, assetForm.getBizChannel(), assetForm.getAmount(), assetForm.getTerm());
// 看命中优先级是否符合要求 // 看命中优先级是否符合要求
boolean[] bucket = new boolean[fundArray.size() + 1]; boolean[] bucket = new boolean[fundArray.size() + 1];
for (int i = 0, len = fundArray.size(); i < len; i++) { for (int i = 0, len = fundArray.size(); i < len; i++) {
...@@ -304,7 +286,7 @@ public class AssetServiceImpl implements IAssetService{ ...@@ -304,7 +286,7 @@ public class AssetServiceImpl implements IAssetService{
} }
bucket[priority] = true; bucket[priority] = true;
} }
String hitFinanceProduct = JSON.toJSONString(financeProductArray); String hitFinanceProduct = createFinancePro(assetForm, fundArray);
log.info("资方模块组成金融产品集完成, uuid : {}, assetNo : {}, bizNo : {}, bizChannel : {}, financeProduct : {}", assetForm.getUuid(), assetForm.getAssetNo(), assetForm.getBizNo(), assetForm.getBizChannel(), hitFinanceProduct); log.info("资方模块组成金融产品集完成, uuid : {}, assetNo : {}, bizNo : {}, bizChannel : {}, financeProduct : {}", assetForm.getUuid(), assetForm.getAssetNo(), assetForm.getBizNo(), assetForm.getBizChannel(), hitFinanceProduct);
return hitFinanceProduct; return hitFinanceProduct;
} }
...@@ -335,6 +317,36 @@ public class AssetServiceImpl implements IAssetService{ ...@@ -335,6 +317,36 @@ public class AssetServiceImpl implements IAssetService{
return assetForm; return assetForm;
} }
/**
* 组建金融产品集
* @param assetForm
* @param fundArray
* @return
*/
private String createFinancePro(AssetForm assetForm, JSONArray fundArray) {
// 首先判断是否有额度期数
QGPreconditions.checkArgument(StringUtils.isNotEmpty(assetForm.getAmount()) && StringUtils.isNotEmpty(assetForm.getTerm()), QGExceptionType.HIT_FUND_BUT_AMOUNT_OR_TERM_IS_EMPTY);
JSONArray financeProductArray = new JSONArray();
JSONObject amountJSON = new JSONObject();
financeProductArray.add(amountJSON);
amountJSON.put("min", assetForm.getAmount());
amountJSON.put("max", assetForm.getAmount());
JSONArray termArray = new JSONArray();
amountJSON.put("terms", termArray);
JSONObject termJSON = new JSONObject();
termArray.add(termJSON);
try {
// 不能是string,否则资方那边会报错
termJSON.put("term", Integer.parseInt(assetForm.getTerm()));
} catch (Exception e) {
termJSON.put("term", Double.parseDouble(assetForm.getTerm()));
}
termJSON.put("fundInfo", fundArray);
return JSON.toJSONString(financeProductArray);
}
/** /**
* 资方配置空跑 * 资方配置空跑
* @param testAssetForm * @param testAssetForm
......
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