Commit 8ed49915 authored by liwenbin's avatar liwenbin

fix

parent 9dfb4bb1
...@@ -2,7 +2,6 @@ package com.quantgroup.asset.distribution.service.asset.impl; ...@@ -2,7 +2,6 @@ package com.quantgroup.asset.distribution.service.asset.impl;
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.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -69,8 +68,6 @@ public class AssetServiceImpl implements IAssetService{ ...@@ -69,8 +68,6 @@ public class AssetServiceImpl implements IAssetService{
public void assetsIn(AssetForm assetForm) { public void assetsIn(AssetForm assetForm) {
try { try {
Stopwatch stopwatch = Stopwatch.createStarted(); Stopwatch stopwatch = Stopwatch.createStarted();
// 如果使用资方模块则去命中资方,创建金融产品集
hitFundIfUseFundModule(assetForm);
// 转换为资产Object // 转换为资产Object
Asset asset = assetForm.transToAsset(); Asset asset = assetForm.transToAsset();
// 获取所有资产扩展属性配置 // 获取所有资产扩展属性配置
...@@ -81,6 +78,8 @@ public class AssetServiceImpl implements IAssetService{ ...@@ -81,6 +78,8 @@ public class AssetServiceImpl implements IAssetService{
assetAttributeService.saveAssetAttrubite(asset, assetAttributeExtendConfigList, data); assetAttributeService.saveAssetAttrubite(asset, assetAttributeExtendConfigList, data);
// 把资产基础属性值放入data // 把资产基础属性值放入data
data = addAssetAttributeToData(asset, data); data = addAssetAttributeToData(asset, data);
// 如果使用资方模块则去命中资方,创建金融产品集
hitFundIfUseFundModule(assetForm, data);
// 资产分发 // 资产分发
assetDistributeService.distribute(assetForm, asset, data); assetDistributeService.distribute(assetForm, asset, data);
log.info("资产分发完成, uuid : {}, bizNo : {}, assetNo : {}, bizChannel : {}, 耗时 : {}", assetForm.getUuid(), log.info("资产分发完成, uuid : {}, bizNo : {}, assetNo : {}, bizChannel : {}, 耗时 : {}", assetForm.getUuid(),
...@@ -213,16 +212,13 @@ public class AssetServiceImpl implements IAssetService{ ...@@ -213,16 +212,13 @@ public class AssetServiceImpl implements IAssetService{
* 如果使用资方模块,需要去命中资方 * 如果使用资方模块,需要去命中资方
* @param assetForm * @param assetForm
*/ */
public void hitFundIfUseFundModule(AssetForm assetForm) { public void hitFundIfUseFundModule(AssetForm assetForm, Map<String, Object> data) {
if ("false".equals(assetForm.getAuditResult())) { if ("false".equals(assetForm.getAuditResult())) {
return; return;
} }
if ("true".equals(assetForm.getAuditResult()) && StringUtils.isNotEmpty(assetForm.getFinanceProducts())) { if ("true".equals(assetForm.getAuditResult()) && StringUtils.isNotEmpty(assetForm.getFinanceProducts())) {
return; return;
} }
Map<String, Object> data = new HashMap<>();
data.put("amount", assetForm.getAmount());
data.put("term", assetForm.getTerm());
// 创建金融产品集,并初始化金额期数 // 创建金融产品集,并初始化金额期数
JSONArray financeProductArray = new JSONArray(); JSONArray financeProductArray = new JSONArray();
JSONObject amountJSON = new JSONObject(); JSONObject amountJSON = new JSONObject();
...@@ -249,6 +245,8 @@ public class AssetServiceImpl implements IAssetService{ ...@@ -249,6 +245,8 @@ public class AssetServiceImpl implements IAssetService{
} }
} }
} }
log.info("资方模块用户命中资方条件, uuid : {}, assetNo : {}, bizNo : {}, fundId : {}, fundProductId : {}",
assetForm.getUuid(), assetForm.getAssetNo(), assetForm.getBizNo(), channelFundConfig.getFundId(), channelFundConfig.getFundProductId());
// 创建并增加资方配置 // 创建并增加资方配置
JSONObject fundInfoJSON = new JSONObject(); JSONObject fundInfoJSON = new JSONObject();
fundInfoJSON.put("fundId", channelFundConfig.getFundId()); fundInfoJSON.put("fundId", channelFundConfig.getFundId());
...@@ -262,7 +260,7 @@ public class AssetServiceImpl implements IAssetService{ ...@@ -262,7 +260,7 @@ public class AssetServiceImpl implements IAssetService{
// 如果fundArray为空,未命中任何一个资方 // 如果fundArray为空,未命中任何一个资方
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()]; 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++) {
int priority = fundArray.getJSONObject(i).getIntValue("priority"); int priority = fundArray.getJSONObject(i).getIntValue("priority");
if (!(priority > 0 && priority <= len)) { if (!(priority > 0 && priority <= len)) {
......
...@@ -12,6 +12,8 @@ import javax.persistence.criteria.Root; ...@@ -12,6 +12,8 @@ import javax.persistence.criteria.Root;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
...@@ -69,7 +71,7 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne ...@@ -69,7 +71,7 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne
@Override @Override
public GlobalResponse addChannelFundConfig(String bizChannel, String funds, String remarks) { public GlobalResponse addChannelFundConfig(String bizChannel, String funds, String remarks) {
// 新增配置, 根据渠道查询如果库里已存在,返回异常;测试一下渠道号存在2条配置去find正常否 // 新增配置, 根据渠道查询如果库里已存在,返回异常;
FundModuleChannelFundConfig fundModuleChannelFundConfig = fundModuleChannelFundConfigRepository.findByBizChannelAndEnableIsTrue(bizChannel); FundModuleChannelFundConfig fundModuleChannelFundConfig = fundModuleChannelFundConfigRepository.findByBizChannelAndEnableIsTrue(bizChannel);
if (fundModuleChannelFundConfig != null) { if (fundModuleChannelFundConfig != null) {
log.info("资方模块, 渠道 : {}资方配置已存在, 添加失败!", bizChannel); log.info("资方模块, 渠道 : {}资方配置已存在, 添加失败!", bizChannel);
...@@ -85,6 +87,7 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne ...@@ -85,6 +87,7 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne
return GlobalResponse.create(FundModuleResponse.SUCCESS); return GlobalResponse.create(FundModuleResponse.SUCCESS);
} }
@CacheEvict(value = "cacheManager", key="'ASSET_DISTRIBUTION:FUND_MODULE:CHANNEL_FUND_CONFIG:AC8A_'+#bizChannel")
@Override @Override
public GlobalResponse updateChannelFundConfig(Long id, String bizChannel, String funds, String remarks) { public GlobalResponse updateChannelFundConfig(Long id, String bizChannel, String funds, String remarks) {
// 更改配置, 根据id查询如果库里不存在,返回异常 // 更改配置, 根据id查询如果库里不存在,返回异常
...@@ -102,6 +105,7 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne ...@@ -102,6 +105,7 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne
return GlobalResponse.create(FundModuleResponse.SUCCESS); return GlobalResponse.create(FundModuleResponse.SUCCESS);
} }
@Cacheable(value="cacheManager", key="'ASSET_DISTRIBUTION:FUND_MODULE:CHANNEL_FUND_CONFIG:AC8A_'+#bizChannel")
@Override @Override
public FundModuleChannelFundConfig findByBizChannel(String bizChannel) { public FundModuleChannelFundConfig findByBizChannel(String bizChannel) {
return fundModuleChannelFundConfigRepository.findByBizChannelAndEnableIsTrue(bizChannel); return fundModuleChannelFundConfigRepository.findByBizChannelAndEnableIsTrue(bizChannel);
......
...@@ -50,7 +50,7 @@ public class FundModuleServiceImpl implements IFundModuleService{ ...@@ -50,7 +50,7 @@ public class FundModuleServiceImpl implements IFundModuleService{
@Override @Override
public GlobalResponse getAllFundsInfo() { public GlobalResponse getAllFundsInfo() {
Stopwatch stopwatch = Stopwatch.createStarted(); Stopwatch stopwatch = Stopwatch.createStarted();
String text = httpService.get(clothoURL + "/ex/funding/corp/all"); String text = httpService.get(clothoURL + "/ex/funding/corp/all.json");
log.info("拉取xyqb所有资方信息完成, 耗时 : {}, 结果 : {}", stopwatch.stop().elapsed(TimeUnit.MILLISECONDS), text); log.info("拉取xyqb所有资方信息完成, 耗时 : {}, 结果 : {}", stopwatch.stop().elapsed(TimeUnit.MILLISECONDS), text);
QGPreconditions.checkArgument(StringUtils.isNotEmpty(text), QGExceptionType.GET_ALL_FUNDS_INFO_ERROR, text); QGPreconditions.checkArgument(StringUtils.isNotEmpty(text), QGExceptionType.GET_ALL_FUNDS_INFO_ERROR, text);
JSONObject data = JSONObject.parseObject(text); JSONObject data = JSONObject.parseObject(text);
......
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