Commit 279cd9c5 authored by liwenbin's avatar liwenbin

init

parent 390d74a0
...@@ -50,6 +50,68 @@ public class FundModuleController { ...@@ -50,6 +50,68 @@ public class FundModuleController {
@RequestMapping("save_channel_funds_config") @RequestMapping("save_channel_funds_config")
public GlobalResponse saveChannelFundsConfig(Integer type, Long id, String bizChannel, String funds, String remarks, public GlobalResponse saveChannelFundsConfig(Integer type, Long id, String bizChannel, String funds, String remarks,
String auditor, String proposer) { String auditor, String proposer) {
return saveChannelFundsConfigCommon(type, id, bizChannel, funds, remarks, auditor, proposer, 1);
}
@RequestMapping("/get_channel_fund_configs")
public GlobalResponse getChannelFundConfigs(String bizChannel, Long fundId, Integer pageNum, Integer pageSize) {
return getChannelFundsConfigCommon(bizChannel, fundId, pageNum, pageSize, 1);
}
@RequestMapping("/get_audit_infos")
public GlobalResponse getAuditInfos(String targetName, Integer auditStatus, Integer auditType, Integer auditTarget, String applyStartTime, String applyEndTime, String user, Integer pageNum, Integer pageSize) {
log.info("资方模块接口, 获取审批列表开始, targetName : {}, auditStatus : {}, auditType : {}, auditTarget : {}, applyStartTime : {}, applyEndTime : {}, user : {}, pageNum : {}, pageSize : {}", targetName, auditStatus, auditType, auditTarget, applyStartTime, applyEndTime, user, pageNum, pageSize);
if (pageNum == null || pageSize == null) {
return GlobalResponse.create(FundModuleResponse.PAGEING_CONDITIONS_IS_EMPTY);
}
if (StringUtils.isEmpty(user)) {
return GlobalResponse.create(FundModuleResponse.USER_IS_EMPTY);
}
Stopwatch stopwatch = Stopwatch.createStarted();
GlobalResponse response = fundModuleService.getAuditInfos(targetName, auditStatus, auditType, auditTarget, applyStartTime, applyEndTime, user, pageNum, pageSize);
log.info("资方模块接口, 获取审批列表结束, targetName : {}, auditStatus : {}, auditType : {}, auditTarget : {}, applyStartTime : {}, applyEndTime : {}, user : {}, pageNum : {}, pageSize : {}, 耗时 : {}, response : {}", targetName, auditStatus, auditType, auditTarget, applyStartTime, applyEndTime, user, pageNum, pageSize, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS), JSON.toJSONString(response));
return response;
}
@RequestMapping("/find_channel_fund_config")
public GlobalResponse findChannelFundConfig(Long configId) {
return findChannelFundConfigCommon(configId, 1);
}
@RequestMapping("/audit")
public GlobalResponse audit(Long id, Integer auditStatus) {
log.info("资方模块接口,审批执行开始, id : {}, auditStatus : {}", id, auditStatus);
if (id == null) {
return GlobalResponse.create(FundModuleResponse.ID_IS_EMPTY);
}
if (auditStatus == null) {
return GlobalResponse.create(FundModuleResponse.AUDIT_STATUS_IS_EMPTY);
}
Stopwatch stopwatch = Stopwatch.createStarted();
GlobalResponse response = fundModuleService.audit(id, auditStatus);
log.info("资方模块接口,审批执行开始, id : {}, auditStatus : {}, 耗时 : {}, response : {}", id, auditStatus, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS), JSON.toJSONString(response));
return response;
}
@RequestMapping("/save_channel_funds_config_new")
public GlobalResponse saveChannelFundsConfigNew(Integer type, Long id, String bizChannel, String funds, String remarks,
String auditor, String proposer) {
return saveChannelFundsConfigCommon(type, id, bizChannel, funds, remarks, auditor, proposer, 2);
}
@RequestMapping("/get_channel_fund_configs_new")
public GlobalResponse getChannelFundConfigsNew(String bizChannel, Long fundId, Integer pageNum, Integer pageSize) {
return getChannelFundsConfigCommon(bizChannel, fundId, pageNum, pageSize, 2);
}
@RequestMapping("/find_channel_fund_config_new")
public GlobalResponse findChannelFundConfigNew(Long configId) {
return findChannelFundConfigCommon(configId, 2);
}
private GlobalResponse saveChannelFundsConfigCommon(Integer type, Long id, String bizChannel, String funds, String remarks,
String auditor, String proposer, int oldOrNew) {
log.info("资方模块接口, 新增或修改资方配置开始, type : {}, id : {}, bizChannel : {}, funds : {}, remarks : {}, auditor : {}, proposer : {}", type, id, bizChannel, funds, remarks, auditor, proposer); log.info("资方模块接口, 新增或修改资方配置开始, type : {}, id : {}, bizChannel : {}, funds : {}, remarks : {}, auditor : {}, proposer : {}", type, id, bizChannel, funds, remarks, auditor, proposer);
// 参数校验 // 参数校验
if (type == null) { if (type == null) {
...@@ -74,62 +136,50 @@ public class FundModuleController { ...@@ -74,62 +136,50 @@ public class FundModuleController {
return GlobalResponse.create(FundModuleResponse.AUDITOR_OR_PROPOSER_IS_EMPTY); return GlobalResponse.create(FundModuleResponse.AUDITOR_OR_PROPOSER_IS_EMPTY);
} }
Stopwatch stopwatch = Stopwatch.createStarted(); Stopwatch stopwatch = Stopwatch.createStarted();
GlobalResponse response = fundModuleService.saveChannelFundConfig(type, id, bizChannel, funds, remarks, auditor, proposer); GlobalResponse response = null;
if (oldOrNew == 1) {
// 老接口
response = fundModuleService.saveChannelFundConfig(type, id, bizChannel, funds, remarks, auditor, proposer);
} else {
// 新接口
response = fundModuleService.saveChannelFundConfigNew(type, id, bizChannel, funds, remarks, auditor, proposer);
}
log.info("资方模块接口, 新增或修改资方配置结束, type : {}, id : {}, bizChannel : {}, funds : {}, remarks : {}, auditor : {}, proposer : {}, 耗时 : {}, reponse : {}", type, id, bizChannel, funds, remarks, auditor, proposer, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS), JSON.toJSONString(response)); log.info("资方模块接口, 新增或修改资方配置结束, type : {}, id : {}, bizChannel : {}, funds : {}, remarks : {}, auditor : {}, proposer : {}, 耗时 : {}, reponse : {}", type, id, bizChannel, funds, remarks, auditor, proposer, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS), JSON.toJSONString(response));
return response; return response;
} }
@RequestMapping("/get_channel_fund_configs") private GlobalResponse getChannelFundsConfigCommon(String bizChannel, Long fundId, Integer pageNum, Integer pageSize, int oldOrNew) {
public GlobalResponse getChannelFundConfigs(String bizChannel, Long fundId, Integer pageNum, Integer pageSize) {
log.info("资方模块接口, 查询渠道资方配置信息开始, bizChannel : {}, fundId : {}, pageNum : {}, pageSize : {}", bizChannel, fundId, pageNum, pageSize); log.info("资方模块接口, 查询渠道资方配置信息开始, bizChannel : {}, fundId : {}, pageNum : {}, pageSize : {}", bizChannel, fundId, pageNum, pageSize);
if (pageNum == null || pageSize == null) { if (pageNum == null || pageSize == null) {
return GlobalResponse.create(FundModuleResponse.PAGEING_CONDITIONS_IS_EMPTY); return GlobalResponse.create(FundModuleResponse.PAGEING_CONDITIONS_IS_EMPTY);
} }
Stopwatch stopwatch = Stopwatch.createStarted(); Stopwatch stopwatch = Stopwatch.createStarted();
GlobalResponse response = fundModuleService.getChannelFundConfigs(bizChannel, fundId, pageNum, pageSize); GlobalResponse response = null;
log.info("资方模块接口, 查询渠道资方配置信息结束, bizChannel : {}, fundId : {}, pageNum : {}, pageSize : {}, 耗时 : {}, response : {}", bizChannel, fundId, pageNum, pageSize, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS), JSON.toJSONString(response)); if (oldOrNew == 1) {
return response; // 老接口
} response = fundModuleService.getChannelFundConfigs(bizChannel, fundId, pageNum, pageSize);
} else {
@RequestMapping("/get_audit_infos") response = fundModuleService.getChannelFundConfigsNew(bizChannel, fundId, pageNum, pageSize);
public GlobalResponse getAuditInfos(String targetName, Integer auditStatus, Integer auditType, Integer auditTarget, String applyStartTime, String applyEndTime, String user, Integer pageNum, Integer pageSize) {
log.info("资方模块接口, 获取审批列表开始, targetName : {}, auditStatus : {}, auditType : {}, auditTarget : {}, applyStartTime : {}, applyEndTime : {}, user : {}, pageNum : {}, pageSize : {}", targetName, auditStatus, auditType, auditTarget, applyStartTime, applyEndTime, user, pageNum, pageSize);
if (pageNum == null || pageSize == null) {
return GlobalResponse.create(FundModuleResponse.PAGEING_CONDITIONS_IS_EMPTY);
} }
if (StringUtils.isEmpty(user)) {
return GlobalResponse.create(FundModuleResponse.USER_IS_EMPTY); log.info("资方模块接口, 查询渠道资方配置信息结束, bizChannel : {}, fundId : {}, pageNum : {}, pageSize : {}, 耗时 : {}, response : {}", bizChannel, fundId, pageNum, pageSize, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS), JSON.toJSONString(response));
}
Stopwatch stopwatch = Stopwatch.createStarted();
GlobalResponse response = fundModuleService.getAuditInfos(targetName, auditStatus, auditType, auditTarget, applyStartTime, applyEndTime, user, pageNum, pageSize);
log.info("资方模块接口, 获取审批列表结束, targetName : {}, auditStatus : {}, auditType : {}, auditTarget : {}, applyStartTime : {}, applyEndTime : {}, user : {}, pageNum : {}, pageSize : {}, 耗时 : {}, response : {}", targetName, auditStatus, auditType, auditTarget, applyStartTime, applyEndTime, user, pageNum, pageSize, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS), JSON.toJSONString(response));
return response; return response;
} }
@RequestMapping("/find_channel_fund_config") private GlobalResponse findChannelFundConfigCommon(Long configId, int oldOrNew) {
public GlobalResponse findChannelFundConfig(Long configId) {
log.info("资方模块接口,根据id获取资方配置, configId : {}", configId); log.info("资方模块接口,根据id获取资方配置, configId : {}", configId);
if (configId == null) { if (configId == null) {
return GlobalResponse.create(FundModuleResponse.ID_IS_EMPTY); return GlobalResponse.create(FundModuleResponse.ID_IS_EMPTY);
} }
Stopwatch stopwatch = Stopwatch.createStarted(); Stopwatch stopwatch = Stopwatch.createStarted();
GlobalResponse response = fundModuleService.findChannelFundConfigById(configId); GlobalResponse response = null;
log.info("资方模块接口, 根据id获取资方配置, configId : {} 耗时 : {}, response : {}", configId, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS), JSON.toJSONString(response)); if (oldOrNew == 1) {
return response; // 老接口
} response = fundModuleService.findChannelFundConfigById(configId);
} else {
@RequestMapping("/audit") response = fundModuleService.findChannelFundConfigNewById(configId);
public GlobalResponse audit(Long id, Integer auditStatus) {
log.info("资方模块接口,审批执行开始, id : {}, auditStatus : {}", id, auditStatus);
if (id == null) {
return GlobalResponse.create(FundModuleResponse.ID_IS_EMPTY);
} }
if (auditStatus == null) { log.info("资方模块接口, 根据id获取资方配置, configId : {} 耗时 : {}, response : {}", configId, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS), JSON.toJSONString(response));
return GlobalResponse.create(FundModuleResponse.AUDIT_STATUS_IS_EMPTY);
}
Stopwatch stopwatch = Stopwatch.createStarted();
GlobalResponse response = fundModuleService.audit(id, auditStatus);
log.info("资方模块接口,审批执行开始, id : {}, auditStatus : {}, 耗时 : {}, response : {}", id, auditStatus, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS), JSON.toJSONString(response));
return response; return response;
} }
} }
...@@ -24,7 +24,7 @@ public enum FundModuleResponse implements GlobalResponseEnum{ ...@@ -24,7 +24,7 @@ public enum FundModuleResponse implements GlobalResponseEnum{
USER_IS_EMPTY(4012, "用户信息为空"), USER_IS_EMPTY(4012, "用户信息为空"),
AUDIT_STATUS_IS_EMPTY(4013, "审批状态为空!"), AUDIT_STATUS_IS_EMPTY(4013, "审批状态为空!"),
UKNOW_AUDIT_STATUS(4014, "未知的审批状态"), UKNOW_AUDIT_STATUS(4014, "未知的审批状态"),
CHANNEL_FUND_CONFIG_IS_AUDITING(4015, "该渠道资方配置正在审核中,不允许修改!"); CHANNEL_FUND_CONFIG_IS_AUDITING(4015, "该渠道资方配置正在审核中,不允许进行操作!");
@Getter @Getter
private int code; private int code;
......
...@@ -57,9 +57,9 @@ public interface IApprovalLogService { ...@@ -57,9 +57,9 @@ public interface IApprovalLogService {
public ApprovalLog findById(Long id); public ApprovalLog findById(Long id);
/** /**
* 查询该条配置是否正在审批 * 查询渠道配置是否正在审批
* @param channelFundConfigId * @param bizChannel
* @return * @return
*/ */
public Boolean isAuditing(Long channelFundConfigId); public Boolean isAuditing(String bizChannel);
} }
...@@ -12,6 +12,8 @@ import javax.persistence.criteria.Order; ...@@ -12,6 +12,8 @@ import javax.persistence.criteria.Order;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import com.quantgroup.asset.distribution.service.funding.IFundModuleChannelFundConfigNewService;
import com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfigNew;
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.data.domain.Page; import org.springframework.data.domain.Page;
...@@ -38,6 +40,8 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{ ...@@ -38,6 +40,8 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{
private IApprovalLogRepository approvalLogRepository; private IApprovalLogRepository approvalLogRepository;
@Autowired @Autowired
private IFundModuleChannelFundConfigService fundModuleChannelFundConfigService; private IFundModuleChannelFundConfigService fundModuleChannelFundConfigService;
@Autowired
private IFundModuleChannelFundConfigNewService fundModuleChannelFundConfigNewService;
@Override @Override
public void createApprovalLog(AuditTypeEnum auditType, AuditTargetEnum auditTarget, String targetName, public void createApprovalLog(AuditTypeEnum auditType, AuditTargetEnum auditTarget, String targetName,
...@@ -111,9 +115,10 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{ ...@@ -111,9 +115,10 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{
public void audit(ApprovalLog approvalLog, Integer auditStatus) { public void audit(ApprovalLog approvalLog, Integer auditStatus) {
if (auditStatus == AuditStatusEnum.PASS.getCode()) { if (auditStatus == AuditStatusEnum.PASS.getCode()) {
// 先更改审核记录, 这里返回的是新配置 // 先更改审核记录, 这里返回的是新配置
FundModuleChannelFundConfig config = fundModuleChannelFundConfigService.auditPassConfig(approvalLog.getPreConfigId(), approvalLog.getAuditConfigId()); // FundModuleChannelFundConfig config = fundModuleChannelFundConfigService.auditPassConfig(approvalLog.getPreConfigId(), approvalLog.getAuditConfigId());
FundModuleChannelFundConfigNew config = fundModuleChannelFundConfigNewService.auditPassConfig(approvalLog.getPreConfigId(), approvalLog.getAuditConfigId());
// 根据新配置清楚渠道缓存 // 根据新配置清楚渠道缓存
fundModuleChannelFundConfigService.clearChannelFundConfigCache(config.getBizChannel()); fundModuleChannelFundConfigNewService.clearChannelFundConfigCache(config.getBizChannel());
} }
updateApprovalLogAuditStatus(approvalLog, auditStatus); updateApprovalLogAuditStatus(approvalLog, auditStatus);
} }
...@@ -126,7 +131,7 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{ ...@@ -126,7 +131,7 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{
/** /**
* 更改审批记录状态和审批时间 * 更改审批记录状态和审批时间
* @param approvalLog * @param approvalLog
* @param s * @param auditStatus
*/ */
private void updateApprovalLogAuditStatus(ApprovalLog approvalLog, Integer auditStatus) { private void updateApprovalLogAuditStatus(ApprovalLog approvalLog, Integer auditStatus) {
approvalLog.setAuditTime(DateUtil.getCurDateTime()); approvalLog.setAuditTime(DateUtil.getCurDateTime());
...@@ -135,7 +140,8 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{ ...@@ -135,7 +140,8 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{
} }
@Override @Override
public Boolean isAuditing(Long channelFundConfigId) { public Boolean isAuditing(String bizChannel) {
return approvalLogRepository.findByPreConfigIdAndAuditStatus(channelFundConfigId, AuditStatusEnum.WAIT.getCode()) != null; return approvalLogRepository.findByAuditTypeAndAuditTargetAndTargetNameAndAuditStatusAndEnableIsTrue(AuditTypeEnum.ONLINE.getCode(),
AuditTargetEnum.FUND_CONFIG.getCode(), bizChannel, AuditStatusEnum.WAIT.getCode()) != null;
} }
} }
package com.quantgroup.asset.distribution.service.funding;
import com.quantgroup.asset.distribution.model.response.GlobalResponse;
import com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfig;
import com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfigNew;
import java.util.Map;
/**
* @author : Hyuk
* @description : IFundModuleChannelFundConfigNewService
* @date : 2020/2/26 5:31 下午
*/
public interface IFundModuleChannelFundConfigNewService {
public Map<String, Object> getChannelFundConfigsByChannelOrFundId(String bizChannel, Long fundId, Integer pageNum, Integer pageSize);
public GlobalResponse addChannelFundConfig(String bizChannel, String funds, String remarks, String proposer, String auditor);
public GlobalResponse updateChannelFundConfig(Long id, String bizChannel, String funds, String remarks, String proposer, String auditor);
public FundModuleChannelFundConfigNew findByBizChannel(String bizChannel);
public FundModuleChannelFundConfigNew findById(Long id);
public FundModuleChannelFundConfigNew auditPassConfig(Long preId, Long auditId);
public void clearChannelFundConfigCache(String bizChannel);
}
...@@ -27,6 +27,20 @@ public interface IFundModuleService { ...@@ -27,6 +27,20 @@ public interface IFundModuleService {
*/ */
public GlobalResponse saveChannelFundConfig(Integer type, Long id, String bizChannel, String funds, String remarks, public GlobalResponse saveChannelFundConfig(Integer type, Long id, String bizChannel, String funds, String remarks,
String auditor, String proposer); String auditor, String proposer);
/**
* 保存或更改渠道资方配置(新)
* @param type
* @param id
* @param bizChannel
* @param funds
* @param remarks
* @param auditor
* @param proposer
* @return
*/
public GlobalResponse saveChannelFundConfigNew(Integer type, Long id, String bizChannel, String funds, String remarks,
String auditor, String proposer);
/** /**
* 获取渠道资方配置信息 * 获取渠道资方配置信息
...@@ -37,6 +51,17 @@ public interface IFundModuleService { ...@@ -37,6 +51,17 @@ public interface IFundModuleService {
* @return * @return
*/ */
public GlobalResponse getChannelFundConfigs(String bizChannel, Long fundId, Integer pageNum, Integer pageSize); public GlobalResponse getChannelFundConfigs(String bizChannel, Long fundId, Integer pageNum, Integer pageSize);
/**
* 获取渠道资方配置信息(新)
* @param bizChannel
* @param fundId
* @param pageNum
* @param pageSize
* @return
*/
public GlobalResponse getChannelFundConfigsNew(String bizChannel, Long fundId, Integer pageNum, Integer pageSize);
/** /**
* 获取审批列表 * 获取审批列表
...@@ -59,6 +84,13 @@ public interface IFundModuleService { ...@@ -59,6 +84,13 @@ public interface IFundModuleService {
* @return * @return
*/ */
public GlobalResponse findChannelFundConfigById(Long configId); public GlobalResponse findChannelFundConfigById(Long configId);
/**
* 根据id获取资方配置(新)
* @param configId
* @return
*/
public GlobalResponse findChannelFundConfigNewById(Long configId);
/** /**
* 审批接口 * 审批接口
......
package com.quantgroup.asset.distribution.service.funding.impl;
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.IFundModuleChannelFundConfigNewService;
import com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfig;
import com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfigNew;
import com.quantgroup.asset.distribution.service.jpa.repository.IFundModuleChannelFundConfigNewRepository;
import com.quantgroup.asset.distribution.util.fund.module.ChannelFundConfigUtil;
import lombok.extern.slf4j.Slf4j;
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;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.*;
/**
* @author : Hyuk
* @description : FundModuleChannelFundConfigNewServiceImpl
* @date : 2020/2/26 5:38 下午
*/
@Slf4j
@Service
public class FundModuleChannelFundConfigNewServiceImpl implements IFundModuleChannelFundConfigNewService {
@Autowired
private IFundModuleChannelFundConfigNewRepository fundModuleChannelFundConfigNewRepository;
@Autowired
private IApprovalLogService approvalLogService;
@Override
public Map<String, Object> getChannelFundConfigsByChannelOrFundId(String bizChannel, Long fundId, Integer pageNum, Integer pageSize) {
// 分页条件
Pageable pageable = new PageRequest(pageNum < 0 ? 0 : pageNum, pageSize);
Specification<FundModuleChannelFundConfigNew> specification = new Specification<FundModuleChannelFundConfigNew>() {
@Override
public Predicate toPredicate(Root<FundModuleChannelFundConfigNew> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(root.get("enable"), true));
if(StringUtils.isNotEmpty(bizChannel)){
predicates.add(cb.equal(root.get("bizChannel"), bizChannel));
}
if(fundId != null){
predicates.add(cb.like(root.get("fundIds"), "%" + fundId + "%"));
}
query.where(predicates.toArray(new Predicate[predicates.size()]));
return query.getRestriction();
}
};
Page<FundModuleChannelFundConfigNew> channelFundConfigs = fundModuleChannelFundConfigNewRepository.findAll(specification, pageable);
Map<String, Object> result = new HashMap<>();
result.put("total", channelFundConfigs.getTotalElements());
result.put("pages", channelFundConfigs.getTotalPages());
result.put("pageSize", channelFundConfigs.getSize());
result.put("pageNum", channelFundConfigs.getNumber());
result.put("list", channelFundConfigs.getContent());
return result;
}
@Transactional(rollbackFor=Exception.class)
@Override
public GlobalResponse addChannelFundConfig(String bizChannel, String funds, String remarks, String proposer, String auditor) {
// 新增配置, 根据渠道查询如果库里已存在,返回异常;
FundModuleChannelFundConfigNew fundModuleChannelFundConfigNew = findByBizChannel(bizChannel);
if (fundModuleChannelFundConfigNew != null) {
log.info("资方模块, 渠道 : {}资方配置已存在, 添加失败!", bizChannel);
return GlobalResponse.create(FundModuleResponse.CHANNEL_FUND_CONFIG_IS_EXIST);
}
// 渠道资方配置是否正在审核
if (approvalLogService.isAuditing(bizChannel)) {
log.info("资方模块, 渠道 : {} 资方配置正在审批中, 不允许修改", bizChannel);
return GlobalResponse.create(FundModuleResponse.CHANNEL_FUND_CONFIG_IS_AUDITING);
}
FundModuleChannelFundConfigNew newConfig = createdNewChannelFundConfigNew(bizChannel, funds, remarks);
createdChannelFundConfigApprovalLog(bizChannel, proposer, auditor, null, newConfig.getId());
return GlobalResponse.create(FundModuleResponse.SUCCESS);
}
@Transactional(rollbackFor=Exception.class)
@Override
public GlobalResponse updateChannelFundConfig(Long id, String bizChannel, String funds, String remarks, String proposer, String auditor) {
// 更改配置, 根据id查询如果库里不存在,返回异常
FundModuleChannelFundConfigNew configNew = fundModuleChannelFundConfigNewRepository.findByIdAndEnableIsTrue(id);
if (configNew == null) {
log.info("资方模块, 渠道 : {}, 配置id : {}, 资方配置不存在, 修改失败!", bizChannel, id);
return GlobalResponse.create(FundModuleResponse.CHANNEL_FUND_CONFIG_NOT_EXIST);
}
// 如果该条配置在审批,不允许更改
boolean isAuditing = approvalLogService.isAuditing(bizChannel);
if (isAuditing) {
log.info("资方模块, 渠道 : {}, 配置id : {}, 正在审批中, 不允许修改", bizChannel, id);
return GlobalResponse.create(FundModuleResponse.CHANNEL_FUND_CONFIG_IS_AUDITING);
}
FundModuleChannelFundConfigNew newConfig = createdNewChannelFundConfigNew(bizChannel, funds, remarks);
createdChannelFundConfigApprovalLog(bizChannel, proposer, auditor, id, newConfig.getId());
return GlobalResponse.create(FundModuleResponse.SUCCESS);
}
@Cacheable(value="cacheManager", key="'ASSET_DISTRIBUTION:FUND_MODULE:CHANNEL_FUND_CONFIG:CK9A_'+#bizChannel")
@Override
public FundModuleChannelFundConfigNew findByBizChannel(String bizChannel) {
List<FundModuleChannelFundConfigNew> configList = fundModuleChannelFundConfigNewRepository.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
public FundModuleChannelFundConfigNew findById(Long id) {
return fundModuleChannelFundConfigNewRepository.findById(id);
}
@Override
public FundModuleChannelFundConfigNew auditPassConfig(Long preId, Long auditId) {
FundModuleChannelFundConfigNew config = updateEnable(auditId, true);
if (preId != null) {
updateEnable(preId, false);
}
return config;
}
@CacheEvict(value = "cacheManager", key="'ASSET_DISTRIBUTION:FUND_MODULE:CHANNEL_FUND_CONFIG:CK9A_'+#bizChannel")
@Override
public void clearChannelFundConfigCache(String bizChannel) {
log.info("渠道资方配置缓存清除, bizChannel : {}", bizChannel);
}
/**
* 更改配置enable状态
* @param id
* @param enable
*/
private FundModuleChannelFundConfigNew updateEnable(Long id, Boolean enable) {
FundModuleChannelFundConfigNew config = fundModuleChannelFundConfigNewRepository.findById(id);
config.setEnable(enable);
return fundModuleChannelFundConfigNewRepository.save(config);
}
/**
* 创建一条新配置记录
* @param bizChannel
* @param funds
* @param remarks
* @return
*/
private FundModuleChannelFundConfigNew createdNewChannelFundConfigNew(String bizChannel, String funds, String remarks) {
FundModuleChannelFundConfigNew config = new FundModuleChannelFundConfigNew();
config.setBizChannel(bizChannel);
config.setFunds(funds);
config.setRemarks(remarks);
config.setFundIds(ChannelFundConfigUtil.getAllFundIds(funds));
config.setFundLimitTranslate(ChannelFundConfigUtil.getFundLimitTranslate(funds));
config.setEnable(false);
return fundModuleChannelFundConfigNewRepository.save(config);
}
/**
* 创建渠道资方配置审批记录
* @param bizChannel
* @param proposer
* @param auditor
* @param preConfigId
* @param auditConfigId
*/
private void createdChannelFundConfigApprovalLog(String bizChannel, String proposer, String auditor, Long preConfigId, Long auditConfigId) {
approvalLogService.createApprovalLog(AuditTypeEnum.ONLINE, AuditTargetEnum.FUND_CONFIG, bizChannel, proposer, auditor, preConfigId, auditConfigId);
}
}
package com.quantgroup.asset.distribution.service.funding.impl; package com.quantgroup.asset.distribution.service.funding.impl;
import java.util.ArrayList; import java.util.*;
import java.util.Collections; import java.util.stream.Collectors;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.quantgroup.asset.distribution.model.entity.fund.ChannelFundConfig;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
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;
...@@ -88,7 +88,7 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne ...@@ -88,7 +88,7 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne
log.info("资方模块, 渠道 : {}资方配置已存在, 添加失败!", bizChannel); log.info("资方模块, 渠道 : {}资方配置已存在, 添加失败!", bizChannel);
return GlobalResponse.create(FundModuleResponse.CHANNEL_FUND_CONFIG_IS_EXIST); return GlobalResponse.create(FundModuleResponse.CHANNEL_FUND_CONFIG_IS_EXIST);
} }
FundModuleChannelFundConfig newConfig = fundModuleChannelFundConfig = createdNewChannelFundConfig(bizChannel, funds, remarks); FundModuleChannelFundConfig newConfig = createdNewChannelFundConfig(bizChannel, funds, remarks);
createdChannelFundConfigApprovalLog(bizChannel, proposer, auditor, null, newConfig.getId()); createdChannelFundConfigApprovalLog(bizChannel, proposer, auditor, null, newConfig.getId());
return GlobalResponse.create(FundModuleResponse.SUCCESS); return GlobalResponse.create(FundModuleResponse.SUCCESS);
} }
...@@ -103,7 +103,7 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne ...@@ -103,7 +103,7 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne
return GlobalResponse.create(FundModuleResponse.CHANNEL_FUND_CONFIG_NOT_EXIST); return GlobalResponse.create(FundModuleResponse.CHANNEL_FUND_CONFIG_NOT_EXIST);
} }
// 如果该条配置在审批,不允许更改 // 如果该条配置在审批,不允许更改
boolean isAuditing = approvalLogService.isAuditing(id); boolean isAuditing = approvalLogService.isAuditing(bizChannel);
if (isAuditing) { if (isAuditing) {
log.info("资方模块, 渠道 : {}, 配置id : {}, 正在审批中, 不允许修改", bizChannel, id); log.info("资方模块, 渠道 : {}, 配置id : {}, 正在审批中, 不允许修改", bizChannel, id);
return GlobalResponse.create(FundModuleResponse.CHANNEL_FUND_CONFIG_IS_AUDITING); return GlobalResponse.create(FundModuleResponse.CHANNEL_FUND_CONFIG_IS_AUDITING);
...@@ -196,4 +196,40 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne ...@@ -196,4 +196,40 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne
public void clearChannelFundConfigCache(String bizChannel) { public void clearChannelFundConfigCache(String bizChannel) {
log.info("渠道资方配置缓存清除, bizChannel : {}", bizChannel); log.info("渠道资方配置缓存清除, bizChannel : {}", bizChannel);
} }
/**
* 渠道资方配置按条件类型分组
* @param fundModuleChannelFundConfig
* @return
*/
private FundModuleChannelFundConfig groupByLimit(FundModuleChannelFundConfig fundModuleChannelFundConfig) {
List<ChannelFundConfig> fundConfigList = JSONArray.parseArray(fundModuleChannelFundConfig.getFunds(), ChannelFundConfig.class);
// 条件类型分组, key:条件类型
Map<String, List<ChannelFundConfig>> channelFundConfigMap = new LinkedHashMap<>();
for (ChannelFundConfig channelFundConfig : fundConfigList) {
List<ChannelFundConfig.Limit> limits = channelFundConfig.getLimits();
// 先把每个资方下的条件排序,保证多个条件下的条件顺序相同
Collections.sort(limits, Comparator.comparingInt(l -> l.getLimit().hashCode()));
StringBuilder key = new StringBuilder();
limits.forEach(limit -> key.append(limit.getLimit()));
if (channelFundConfigMap.get(key.toString()) == null) {
channelFundConfigMap.put(key.toString(), new ArrayList<>());
}
channelFundConfigMap.get(key.toString()).add(channelFundConfig);
}
// 分完组后,开始对组内优先级进行排序
channelFundConfigMap.entrySet().stream().forEach(entry -> {
Collections.sort(entry.getValue(), Comparator.comparingInt(config -> config.getPriority()));
});
// 重新组装
List<ChannelFundConfig> sortedList = new ArrayList<>();
channelFundConfigMap.entrySet().forEach(e -> {
sortedList.addAll(e.getValue());
});
fundModuleChannelFundConfig.setFunds(JSON.toJSONString(sortedList));
return fundModuleChannelFundConfig;
}
} }
...@@ -5,6 +5,8 @@ import java.util.List; ...@@ -5,6 +5,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import com.quantgroup.asset.distribution.service.funding.IFundModuleChannelFundConfigNewService;
import com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfigNew;
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.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -48,6 +50,8 @@ public class FundModuleServiceImpl implements IFundModuleService{ ...@@ -48,6 +50,8 @@ public class FundModuleServiceImpl implements IFundModuleService{
@Autowired @Autowired
private IFundModuleChannelFundConfigService fundModuleChannelFundConfigService; private IFundModuleChannelFundConfigService fundModuleChannelFundConfigService;
@Autowired @Autowired
private IFundModuleChannelFundConfigNewService fundModuleChannelFundConfigNewService;
@Autowired
private IApprovalLogService approvalLogService; private IApprovalLogService approvalLogService;
@Value("${clotho.url}") @Value("${clotho.url}")
private String clothoURL; private String clothoURL;
...@@ -91,7 +95,18 @@ public class FundModuleServiceImpl implements IFundModuleService{ ...@@ -91,7 +95,18 @@ public class FundModuleServiceImpl implements IFundModuleService{
} else if (type == FundModuleConstants.CHANNEL_FUNDS_OPERATOR_TYPE_UPDATE) { } else if (type == FundModuleConstants.CHANNEL_FUNDS_OPERATOR_TYPE_UPDATE) {
return fundModuleChannelFundConfigService.updateChannelFundConfig(id, bizChannel, funds, remarks, proposer, auditor); return fundModuleChannelFundConfigService.updateChannelFundConfig(id, bizChannel, funds, remarks, proposer, auditor);
} }
return GlobalResponse.create(FundModuleResponse.SUCCESS); return GlobalResponse.create(FundModuleResponse.UNKNOW_TYPE);
}
@HandleException
@Override
public GlobalResponse saveChannelFundConfigNew(Integer type, Long id, String bizChannel, String funds, String remarks, String auditor, String proposer) {
if (type == FundModuleConstants.CHANNEL_FUNDS_OPERAOTR_TYPE_ADD) {
return fundModuleChannelFundConfigNewService.addChannelFundConfig(bizChannel, funds, remarks, proposer, auditor);
} else if (type == FundModuleConstants.CHANNEL_FUNDS_OPERATOR_TYPE_UPDATE) {
return fundModuleChannelFundConfigNewService.updateChannelFundConfig(id, bizChannel, funds, remarks, proposer, auditor);
}
return GlobalResponse.create(FundModuleResponse.UNKNOW_TYPE);
} }
@HandleException @HandleException
...@@ -104,6 +119,16 @@ public class FundModuleServiceImpl implements IFundModuleService{ ...@@ -104,6 +119,16 @@ public class FundModuleServiceImpl implements IFundModuleService{
return GlobalResponse.success(result); return GlobalResponse.success(result);
} }
@HandleException
@Override
public GlobalResponse getChannelFundConfigsNew(String bizChannel, Long fundId, Integer pageNum, Integer pageSize) {
Map<String, Object> result = fundModuleChannelFundConfigNewService.getChannelFundConfigsByChannelOrFundId(bizChannel, fundId, pageNum, pageSize);
if (result == null || result.size() == 0) {
return GlobalResponse.create(FundModuleResponse.HAS_NO_DATA);
}
return GlobalResponse.success(result);
}
@HandleException @HandleException
@Override @Override
public GlobalResponse getAuditInfos(String targetName, Integer auditStatus, Integer auditType, Integer auditTarget, public GlobalResponse getAuditInfos(String targetName, Integer auditStatus, Integer auditType, Integer auditTarget,
...@@ -124,7 +149,17 @@ public class FundModuleServiceImpl implements IFundModuleService{ ...@@ -124,7 +149,17 @@ public class FundModuleServiceImpl implements IFundModuleService{
} }
return GlobalResponse.success(config); return GlobalResponse.success(config);
} }
@HandleException
@Override
public GlobalResponse findChannelFundConfigNewById(Long configId) {
FundModuleChannelFundConfigNew config = fundModuleChannelFundConfigNewService.findById(configId);
if (config == null) {
return GlobalResponse.create(FundModuleResponse.HAS_NO_DATA);
}
return GlobalResponse.success(config);
}
@HandleException @HandleException
@Override @Override
public GlobalResponse audit(Long id, Integer auditStatus) { public GlobalResponse audit(Long id, Integer auditStatus) {
......
package com.quantgroup.asset.distribution.service.jpa.entity;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author : Hyuk
* @description : FundModuleChannelFundConfigNew
* @date : 2020/2/26 5:40 下午
*/
@Data
@Table(name = "fund_module_channel_fund_config_new")
@Entity
public class FundModuleChannelFundConfigNew implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "biz_channel")
private String bizChannel;
@Column(name = "funds")
private String funds;
@Column(name = "remarks")
private String remarks;
@Column(name = "fund_ids")
private String fundIds;
@Column(name = "fund_limit_translate")
private String fundLimitTranslate;
@Column(name = "enable")
private Boolean enable;
@Column(name = "created_at")
private Timestamp createdAt;
@Column(name = "updated_at")
private Timestamp updatedAt;
@PrePersist
public void prePersist() {
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
createdAt = timestamp;
updatedAt = timestamp;
}
@PreUpdate
public void preUpdate() {
updatedAt = new Timestamp(System.currentTimeMillis());
}
}
...@@ -38,6 +38,9 @@ public class FundModuleLimitTypeConfig implements Serializable{ ...@@ -38,6 +38,9 @@ public class FundModuleLimitTypeConfig implements Serializable{
@Column(name = "code") @Column(name = "code")
private String code; private String code;
@Column(name = "type")
private String type;
@Column(name = "enable") @Column(name = "enable")
private Boolean enable; private Boolean enable;
......
...@@ -8,6 +8,9 @@ import com.quantgroup.asset.distribution.service.jpa.entity.ApprovalLog; ...@@ -8,6 +8,9 @@ import com.quantgroup.asset.distribution.service.jpa.entity.ApprovalLog;
public interface IApprovalLogRepository extends JpaRepository<ApprovalLog, Long>, JpaSpecificationExecutor<ApprovalLog>{ public interface IApprovalLogRepository extends JpaRepository<ApprovalLog, Long>, JpaSpecificationExecutor<ApprovalLog>{
public ApprovalLog findByIdAndEnableIsTrue(Long id); public ApprovalLog findByIdAndEnableIsTrue(Long id);
public ApprovalLog findByPreConfigIdAndAuditStatus(Long preConfigId, Integer auditStatus); public ApprovalLog findByAuditTypeAndAuditTargetAndTargetNameAndAuditStatusAndEnableIsTrue(Integer auditType,
Integer auditTarget,
String targetName,
Integer auditStatus);
} }
package com.quantgroup.asset.distribution.service.jpa.repository;
import com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfig;
import com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfigNew;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
/**
* @author : Hyuk
* @description : IFundModuleChannelFundConfigNewRepository
* @date : 2020/2/26 5:53 下午
*/
public interface IFundModuleChannelFundConfigNewRepository extends JpaRepository<FundModuleChannelFundConfigNew, Long>, JpaSpecificationExecutor<FundModuleChannelFundConfigNew> {
/**
* 根据渠道号查询渠道资方配置
* @param bizChannel
* @return
*/
public List<FundModuleChannelFundConfigNew> findByBizChannelAndEnableIsTrue(String bizChannel);
/**
* 根据配置id查询资方配置
* @param id
* @return
*/
public FundModuleChannelFundConfigNew findByIdAndEnableIsTrue(Long id);
/**
* 根据id查询资方配置, 主要是审核部分用, 这时候配置还没应用到线上, enable还是false
* @param id
* @return
*/
public FundModuleChannelFundConfigNew findById(Long id);
}
package com.quantgroup.asset.distribution.util.fund.module; package com.quantgroup.asset.distribution.util.fund.module;
import java.util.HashSet; import java.util.*;
import java.util.LinkedHashSet;
import java.util.Set;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
...@@ -71,4 +70,22 @@ public class ChannelFundConfigUtil { ...@@ -71,4 +70,22 @@ public class ChannelFundConfigUtil {
} }
return StringUtils.join(fundIdSet, ","); return StringUtils.join(fundIdSet, ",");
} }
/**
* 根据资方配置获取资方对应条件
* @param funds
* @return
*/
public static String getFundLimitTranslate(String funds) {
Map<String, String> map = new LinkedHashMap<>();
JSONArray array = JSONArray.parseArray(funds);
for (int i = 0, len = array.size(); i < len; i++) {
JSONObject data = array.getJSONObject(i);
String fundId = data.getString("fundId");
JSONObject limitObj = data.getJSONObject("limits");
String limitTranslate = limitObj.getString("limitTranslate");
map.put(fundId, limitTranslate);
}
return JSON.toJSONString(map);
}
} }
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