Commit 279cd9c5 authored by liwenbin's avatar liwenbin

init

parent 390d74a0
......@@ -24,7 +24,7 @@ public enum FundModuleResponse implements GlobalResponseEnum{
USER_IS_EMPTY(4012, "用户信息为空"),
AUDIT_STATUS_IS_EMPTY(4013, "审批状态为空!"),
UKNOW_AUDIT_STATUS(4014, "未知的审批状态"),
CHANNEL_FUND_CONFIG_IS_AUDITING(4015, "该渠道资方配置正在审核中,不允许修改!");
CHANNEL_FUND_CONFIG_IS_AUDITING(4015, "该渠道资方配置正在审核中,不允许进行操作!");
@Getter
private int code;
......
......@@ -57,9 +57,9 @@ public interface IApprovalLogService {
public ApprovalLog findById(Long id);
/**
* 查询该条配置是否正在审批
* @param channelFundConfigId
* 查询渠道配置是否正在审批
* @param bizChannel
* @return
*/
public Boolean isAuditing(Long channelFundConfigId);
public Boolean isAuditing(String bizChannel);
}
......@@ -12,6 +12,8 @@ import javax.persistence.criteria.Order;
import javax.persistence.criteria.Predicate;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
......@@ -38,6 +40,8 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{
private IApprovalLogRepository approvalLogRepository;
@Autowired
private IFundModuleChannelFundConfigService fundModuleChannelFundConfigService;
@Autowired
private IFundModuleChannelFundConfigNewService fundModuleChannelFundConfigNewService;
@Override
public void createApprovalLog(AuditTypeEnum auditType, AuditTargetEnum auditTarget, String targetName,
......@@ -111,9 +115,10 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{
public void audit(ApprovalLog approvalLog, Integer auditStatus) {
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);
}
......@@ -126,7 +131,7 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{
/**
* 更改审批记录状态和审批时间
* @param approvalLog
* @param s
* @param auditStatus
*/
private void updateApprovalLogAuditStatus(ApprovalLog approvalLog, Integer auditStatus) {
approvalLog.setAuditTime(DateUtil.getCurDateTime());
......@@ -135,7 +140,8 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{
}
@Override
public Boolean isAuditing(Long channelFundConfigId) {
return approvalLogRepository.findByPreConfigIdAndAuditStatus(channelFundConfigId, AuditStatusEnum.WAIT.getCode()) != null;
public Boolean isAuditing(String bizChannel) {
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);
}
......@@ -28,6 +28,20 @@ public interface IFundModuleService {
public GlobalResponse saveChannelFundConfig(Integer type, Long id, String bizChannel, String funds, String remarks,
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);
/**
* 获取渠道资方配置信息
* @param bizChannel
......@@ -38,6 +52,17 @@ public interface IFundModuleService {
*/
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);
/**
* 获取审批列表
* @param targetName
......@@ -60,6 +85,13 @@ public interface IFundModuleService {
*/
public GlobalResponse findChannelFundConfigById(Long configId);
/**
* 根据id获取资方配置(新)
* @param configId
* @return
*/
public GlobalResponse findChannelFundConfigNewById(Long configId);
/**
* 审批接口
* @param id 审理log id
......
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;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
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.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -88,7 +88,7 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne
log.info("资方模块, 渠道 : {}资方配置已存在, 添加失败!", bizChannel);
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());
return GlobalResponse.create(FundModuleResponse.SUCCESS);
}
......@@ -103,7 +103,7 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne
return GlobalResponse.create(FundModuleResponse.CHANNEL_FUND_CONFIG_NOT_EXIST);
}
// 如果该条配置在审批,不允许更改
boolean isAuditing = approvalLogService.isAuditing(id);
boolean isAuditing = approvalLogService.isAuditing(bizChannel);
if (isAuditing) {
log.info("资方模块, 渠道 : {}, 配置id : {}, 正在审批中, 不允许修改", bizChannel, id);
return GlobalResponse.create(FundModuleResponse.CHANNEL_FUND_CONFIG_IS_AUDITING);
......@@ -196,4 +196,40 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne
public void clearChannelFundConfigCache(String 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;
import java.util.Map;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -48,6 +50,8 @@ public class FundModuleServiceImpl implements IFundModuleService{
@Autowired
private IFundModuleChannelFundConfigService fundModuleChannelFundConfigService;
@Autowired
private IFundModuleChannelFundConfigNewService fundModuleChannelFundConfigNewService;
@Autowired
private IApprovalLogService approvalLogService;
@Value("${clotho.url}")
private String clothoURL;
......@@ -91,7 +95,18 @@ public class FundModuleServiceImpl implements IFundModuleService{
} else if (type == FundModuleConstants.CHANNEL_FUNDS_OPERATOR_TYPE_UPDATE) {
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
......@@ -104,6 +119,16 @@ public class FundModuleServiceImpl implements IFundModuleService{
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
@Override
public GlobalResponse getAuditInfos(String targetName, Integer auditStatus, Integer auditType, Integer auditTarget,
......@@ -125,6 +150,16 @@ public class FundModuleServiceImpl implements IFundModuleService{
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
@Override
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());
}
}
......@@ -39,6 +39,9 @@ public class FundModuleLimitTypeConfig implements Serializable{
@Column(name = "code")
private String code;
@Column(name = "type")
private String type;
@Column(name = "enable")
private Boolean enable;
......
......@@ -9,5 +9,8 @@ public interface IApprovalLogRepository extends JpaRepository<ApprovalLog, Long
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;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.*;
import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;
import com.alibaba.fastjson.JSONArray;
......@@ -71,4 +70,22 @@ public class ChannelFundConfigUtil {
}
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