Commit 1d3c4395 authored by liwenbin's avatar liwenbin

fix

parent 1c740e30
......@@ -41,7 +41,8 @@ public enum QGExceptionType {
GET_ALL_FUNDS_INFO_ERROR(3001, "拉取所有资方信息失败, res : %s"),
NO_FUND_INFO_BEEN_HIT(3002, "未命中任何资方, 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");
......
package com.quantgroup.asset.distribution.service.funding.impl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -10,6 +11,7 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
......@@ -24,6 +26,8 @@ import org.springframework.transaction.annotation.Transactional;
import com.quantgroup.asset.distribution.enums.funding.AuditTargetEnum;
import com.quantgroup.asset.distribution.enums.funding.AuditTypeEnum;
import com.quantgroup.asset.distribution.enums.response.FundModuleResponse;
import com.quantgroup.asset.distribution.exception.QGException;
import com.quantgroup.asset.distribution.exception.QGExceptionType;
import com.quantgroup.asset.distribution.model.response.GlobalResponse;
import com.quantgroup.asset.distribution.service.approval.IApprovalLogService;
import com.quantgroup.asset.distribution.service.funding.IFundModuleChannelFundConfigService;
......@@ -75,12 +79,11 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne
return result;
}
// @CacheEvict(value = "cacheManager", key="'ASSET_DISTRIBUTION:FUND_MODULE:CHANNEL_FUND_CONFIG:AC8A_'+#bizChannel")
@Transactional(rollbackFor=Exception.class)
@Override
public GlobalResponse addChannelFundConfig(String bizChannel, String funds, String remarks, String proposer, String auditor) {
// 新增配置, 根据渠道查询如果库里已存在,返回异常;
FundModuleChannelFundConfig fundModuleChannelFundConfig = fundModuleChannelFundConfigRepository.findByBizChannelAndEnableIsTrue(bizChannel);
FundModuleChannelFundConfig fundModuleChannelFundConfig = findByBizChannel(bizChannel);
if (fundModuleChannelFundConfig != null) {
log.info("资方模块, 渠道 : {}资方配置已存在, 添加失败!", bizChannel);
return GlobalResponse.create(FundModuleResponse.CHANNEL_FUND_CONFIG_IS_EXIST);
......@@ -113,7 +116,23 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne
@Cacheable(value="cacheManager", key="'ASSET_DISTRIBUTION:FUND_MODULE:CHANNEL_FUND_CONFIG:AC8A_'+#bizChannel")
@Override
public FundModuleChannelFundConfig findByBizChannel(String bizChannel) {
return fundModuleChannelFundConfigRepository.findByBizChannelAndEnableIsTrue(bizChannel);
List<FundModuleChannelFundConfig> configList = fundModuleChannelFundConfigRepository.findByBizChannelAndEnableIsTrue(bizChannel);
if (CollectionUtils.isEmpty(configList)) { return null; }
// 避免脏读
if (configList.size() > 2) {
throw new QGException(QGExceptionType.CHANNEL_FUND_CONFIG_GREATER_THAN_TOW, bizChannel);
}
Collections.sort(configList, (c1, c2) -> {
// 别直接把相减把long类型转成int,可能越界
if (c2.getId() > c1.getId()) {
return 1;
} else if (c2.getId() < c1.getId()) {
return -1;
} else {
return 0;
}
});
return configList.get(0);
}
@Override
......
package com.quantgroup.asset.distribution.service.jpa.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfig;
......@@ -19,7 +18,7 @@ public interface IFundModuleChannelFundConfigRepository extends JpaRepository<Fu
* @param bizChannel
* @return
*/
public FundModuleChannelFundConfig findByBizChannelAndEnableIsTrue(String bizChannel);
public List<FundModuleChannelFundConfig> findByBizChannelAndEnableIsTrue(String bizChannel);
/**
* 根据id查询渠道资方配置
......@@ -29,7 +28,7 @@ public interface IFundModuleChannelFundConfigRepository extends JpaRepository<Fu
public FundModuleChannelFundConfig findByIdAndEnableIsTrue(Long id);
/**
*
* 注意,这个是给渠道资方配置审批用的,慎用,这个不关注enable状态
* @param id
* @return
*/
......
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