Commit b875f416 authored by 鹿朋's avatar 鹿朋

Merge branch 'fund_route' of http://git.quantgroup.cn/data-spider/asset-server into fund_route

# Conflicts:
#	src/main/java/com/quantgroup/asset/distribution/service/newrule/CoreFilter.java
parents 56c61c2e dc586c81
......@@ -10,6 +10,7 @@ import com.quantgroup.asset.distribution.service.newrule.third.AuditResponce;
import com.quantgroup.asset.distribution.util.UUIDUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -37,6 +38,7 @@ public class NewAssertController {
auditResponce.setAssetNo(UUIDUtil.getAssetNo());
coreFilter.coreHandle(auditResponce);
} catch (Exception e) {
log.error("风控通知审核结果处理异常, e:{}", ExceptionUtils.getStackTrace(e));
return GlobalResponse.error(e.getMessage());
}
return GlobalResponse.create(AssetResponse.SUCCESS);
......
......@@ -138,8 +138,7 @@ public class ChannelRouteController {
if (bindingResult.hasErrors()){
return GlobalResponse.error(bindingResult.getFieldError().getDefaultMessage());
}
channelRouteService.addChannelConfig(channelRouteAddVo.getChannelRouteSaveVoList(),channelRouteAddVo.getType());
return GlobalResponse.success();
return channelRouteService.addChannelConfig(channelRouteAddVo.getChannelRouteSaveVoList(),channelRouteAddVo.getType());
}
/**
......
......@@ -10,7 +10,7 @@ import lombok.Getter;
@Getter
public enum OrganizationType {
DIVERSION("DIVERSION","导流"),
LOAN("LOAN","助贷");
ASSISTANCE("ASSISTANCE","助贷");
private String value;
......
......@@ -4,6 +4,7 @@ import lombok.Data;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.Map;
......
package com.quantgroup.asset.distribution.model.entity.route.routerecord;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.quantgroup.asset.distribution.util.PageVo;
import lombok.Data;
......@@ -11,6 +12,8 @@ public class RouteRecordQueryVo extends PageVo {
private String creditNo;
private String uuid;
private Byte status;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Timestamp routedAtMin;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Timestamp routedAtMax;
}
package com.quantgroup.asset.distribution.service.jpa.entity;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
......@@ -16,6 +17,7 @@ import java.util.Objects;
@Table(name = "channel_rule", schema = "asset-distribution", catalog = "")
@DynamicInsert
@DynamicUpdate
@Data
public class ChannelRuleEntity {
private Long id;
private Long fundProductId;
......
......@@ -9,7 +9,7 @@ import java.util.List;
public interface IChannelRuleRepository extends JpaRepository<ChannelRuleEntity, Long>, QueryDslPredicateExecutor<ChannelRuleEntity> {
ChannelRuleEntity getByFundProductIdEquals(long fundProductId);
List<ChannelRuleEntity> getByChannelId(long channelId);
List<ChannelRuleEntity> getByChannelIdOrderByPriority(long channelId);
List<ChannelRuleEntity> getAllByEnableEquals(Boolean enable);
......@@ -19,4 +19,5 @@ public interface IChannelRuleRepository extends JpaRepository<ChannelRuleEntity,
void deleteAllByChannelIdEqualsAndEnableEquals(Long channelId,Boolean enable);
List<ChannelRuleEntity> getByChannelIdAndFundProductIdOrderByPriority(long channelId, long fundProductId);
}
......@@ -23,7 +23,7 @@ public interface IChannelRouteService {
FundProInfoVo getFundProductInfo(Long fundId, Long fundCorpId);
void addChannelConfig(List<ChannelRouteSaveVo> channelRouteSaveVoList,Integer type);
GlobalResponse addChannelConfig(List<ChannelRouteSaveVo> channelRouteSaveVoList,Integer type);
void publishChannelConfig(Long channelId);
......
......@@ -42,13 +42,13 @@ public class ChannelRouteServiceImpl implements IChannelRouteService {
BooleanExpression booleanExpression = Expressions.asBoolean(true).isTrue();
if (Objects.nonNull(channelRouteQueryVo.getChannelId())){
booleanExpression = booleanExpression.and(QChannelRuleEntity.channelRuleEntity.channelId.like(String.valueOf(channelRouteQueryVo.getChannelId())));
booleanExpression = booleanExpression.and(QChannelRuleEntity.channelRuleEntity.channelId.like(channelRouteQueryVo.getChannelId() +"%"));
}
if (Objects.nonNull(channelRouteQueryVo.getFundId())){
booleanExpression = booleanExpression.and(QChannelRuleEntity.channelRuleEntity.fundId.like(String.valueOf(channelRouteQueryVo.getFundId())));
booleanExpression = booleanExpression.and(QChannelRuleEntity.channelRuleEntity.fundId.like(channelRouteQueryVo.getFundId() +"%"));
}
if (!StringUtils.isEmpty(channelRouteQueryVo.getFundName())){
booleanExpression = booleanExpression.and(QChannelRuleEntity.channelRuleEntity.fundName.like(String.valueOf(channelRouteQueryVo.getFundName())));
booleanExpression = booleanExpression.and(QChannelRuleEntity.channelRuleEntity.fundName.like(channelRouteQueryVo.getFundName() +"%"));
}
if (Objects.nonNull(channelRouteQueryVo.getPublishStatus())){
booleanExpression = booleanExpression.and(QChannelRuleEntity.channelRuleEntity.publishStatus.eq(channelRouteQueryVo.getPublishStatus()));
......@@ -142,7 +142,7 @@ public class ChannelRouteServiceImpl implements IChannelRouteService {
List<FundProductEntity> fundProductEntityList = fundProductRepository.getAllByEnableEquals(Byte.valueOf("1"));
List<Long> fundIdList = new ArrayList<>();
fundProductEntityList.stream().forEach(fundProductEntity -> {
if (!fundIdList.contains(fundProductEntity.getFundId())){
if (!fundIdList.contains(fundProductEntity.getFundId()) && !StringUtils.isEmpty(fundProductEntity.getBasicRule())){
fundIdList.add(fundProductEntity.getFundId());
}
});
......@@ -171,12 +171,18 @@ public class ChannelRouteServiceImpl implements IChannelRouteService {
@Override
@Transactional
public void addChannelConfig(List<ChannelRouteSaveVo> channelRouteSaveVoList,Integer type) {
public GlobalResponse addChannelConfig(List<ChannelRouteSaveVo> channelRouteSaveVoList,Integer type) {
/**
* 编辑时要去掉所有该渠道有效性为0的其他配置(覆盖之前的未更新编辑信息)
*/
if ( 0 != type ){
channelRuleRepository.deleteAllByChannelIdEqualsAndEnableEquals(channelRouteSaveVoList.get(0).getChannelId(),Boolean.FALSE);
}else if ( 1 == type){
//新增判重
List<ChannelRuleEntity> all = channelRuleRepository.getAllByChannelIdEqualsAndEnableEquals(channelRouteSaveVoList.get(0).getChannelId(), Boolean.TRUE);
if (!CollectionUtils.isEmpty(all)){
return GlobalResponse.error("该渠道已经新增过了");
}
}
List<ChannelRuleEntity> channelRuleEntityList = getChannelRuleEntityList(channelRouteSaveVoList);
......@@ -196,6 +202,7 @@ public class ChannelRouteServiceImpl implements IChannelRouteService {
channelRuleRepository.save(channelRuleEntity);
}
});
return GlobalResponse.success();
}
private List<ChannelRuleEntity> getChannelRuleEntityList(List<ChannelRouteSaveVo> channelRouteSaveVoList){
......
......@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.quantgroup.asset.distribution.config.code.AreaCode;
import com.quantgroup.asset.distribution.config.code.InitAreaCode;
import com.quantgroup.asset.distribution.constant.CommonConstants;
import com.quantgroup.asset.distribution.enums.route.SystemType;
import com.quantgroup.asset.distribution.model.entity.route.fundproduct.*;
import com.quantgroup.asset.distribution.model.response.GlobalResponse;
......@@ -30,17 +29,12 @@ import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import shaded.com.google.common.collect.Lists;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service
@Slf4j
......@@ -83,14 +77,15 @@ public class FundProductServiceImpl implements IFundProductService {
//索引 和 每页大小 排序 条件
BooleanExpression booleanExpression = Expressions.asBoolean(true).isTrue();
log.info("fundId={}",fundProductQueryVo.getFundId());
if (Objects.nonNull(fundProductQueryVo.getFundId())){
booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.fundId.like(String.valueOf(fundProductQueryVo.getFundId())));
booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.fundId.like(fundProductQueryVo.getFundId() +"%"));
}
if (Objects.nonNull(fundProductQueryVo.getFundProId())){
booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.fundProId.like(String.valueOf(fundProductQueryVo.getFundProId())));
booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.fundProId.like(fundProductQueryVo.getFundProId() +"%"));
}
if (!StringUtils.isEmpty(fundProductQueryVo.getFundName())){
booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.fundName.like(fundProductQueryVo.getFundName()));
booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.fundName.like(fundProductQueryVo.getFundName()+"%"));
}
if (!StringUtils.isEmpty(fundProductQueryVo.getFundType())){
booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.fundType.eq(fundProductQueryVo.getFundType()));
......@@ -111,7 +106,7 @@ public class FundProductServiceImpl implements IFundProductService {
//查询总条数
long count = fundProductRepository.count(booleanExpression);
//查询数据
Page<FundProductEntity> plantPage = fundProductRepository.findAll(booleanExpression, new PageRequest(fundProductQueryVo.getPageIndex()-1, fundProductQueryVo.getPageSize(), new Sort(Sort.Direction.DESC, "createdAt")));
Page<FundProductEntity> plantPage = fundProductRepository.findAll(booleanExpression, new PageRequest(fundProductQueryVo.getPageIndex()-1, fundProductQueryVo.getPageSize(), new Sort(Sort.Direction.DESC, "updatedAt")));
List<FundProductEntity> fundProductEntities = new ArrayList<>();
fundProductEntities = plantPage.getContent();
......@@ -171,28 +166,43 @@ public class FundProductServiceImpl implements IFundProductService {
basic.addAll(orther);
//3.基本信息和其他信息字段,对应的value
Map<Long,String> map = new HashMap<>();
//3.1解析基本规则10 <= age && age <= 50 && 10 <= amount && amount <= 20000 && term == 12 && ! include(not_permit_tels,tel)
//3.1解析基本规则10 <= age && age <= 50 && 10 <= amount && amount <= 20000 && (term == 12 || term == 10) && ! include(not_permit_tels,tel)
//获取资金产品存的value
String basicRule = one.getBasicRule();
//解析value
String[] split = basicRule.split("&&");
for (int i = 0 ; i<split.length;i++){
for (ProductRuleEntity productRuleEntity:basic){
for (String item : split) {
for (ProductRuleEntity productRuleEntity : basic) {
//在value中寻找对应的规则
if ("not_permit_tels".equals(productRuleEntity.getRuleVal())){
map.put(productRuleEntity.getId(),one.getTelRule());
if ("not_permit_tels".equals(productRuleEntity.getRuleVal())) {
map.put(productRuleEntity.getId(), one.getTelRule());
break;
}
if (split[i].contains(productRuleEntity.getRuleVal())){
//取出value中的值
String numeric = getNumeric(split[i]);
String s = map.get(productRuleEntity.getId());
if (StringUtils.isEmpty(s)){
map.put(productRuleEntity.getId(),numeric);
}else {
map.put(productRuleEntity.getId(),s.concat(",").concat(numeric));
if (item.contains(productRuleEntity.getRuleVal())) {
if ("term".equals(productRuleEntity.getRuleVal())) {
String[] splitTerm = item.split("\\|\\|");
for (String value : splitTerm) {
//取出value中的值
String numeric = getNumeric(value);
String s = map.get(productRuleEntity.getId());
if (StringUtils.isEmpty(s)) {
map.put(productRuleEntity.getId(), numeric);
} else {
map.put(productRuleEntity.getId(), s.concat(",").concat(numeric));
}
}
break;
} else {
//取出value中的值
String numeric = getNumeric(item);
String s = map.get(productRuleEntity.getId());
if (StringUtils.isEmpty(s)) {
map.put(productRuleEntity.getId(), numeric);
} else {
map.put(productRuleEntity.getId(), s.concat(",").concat(numeric));
}
break;
}
break;
}
}
}
......@@ -274,7 +284,7 @@ public class FundProductServiceImpl implements IFundProductService {
allByEnableEquals.stream().forEach(productRuleEntity -> {
String value = ruleValueMap.get(productRuleEntity.getId());
if (!StringUtils.isEmpty(value)){
//10 <= age && age <= 50 && 10 <= amount && amount <= 20000 && term == 12 && ! include(not_permit_tels,tel)
//10 <= age && age <= 50 && 10 <= amount && amount <= 20000 && (term == 12 || term == 11) && ! include(not_permit_tels,tel)
switch (productRuleEntity.getRuleVal()){
case "age":
basicRule.append(value.replace(",", " <= age && age <= ")).append(" && ");
......@@ -283,7 +293,17 @@ public class FundProductServiceImpl implements IFundProductService {
basicRule.append(value.replace(","," <= amount && amount <= ")).append(" && ");
break;
case "term":
basicRule.append("term == ").append(value).append(" && ");
basicRule.append("(");
String[] split = value.split(",");
for (int i = 0;i<split.length;i++){
basicRule.append("term == ").append(split[i]);
if (i != split.length-1){
basicRule.append(" || ");
}
}
basicRule.append(")").append(" && ");
//basicRule.append("term == ").append(value).append(" && ");
break;
case "not_permit_tels":
basicRule.append("! include(not_permit_tels,tel)").append(" && ");
......@@ -292,7 +312,9 @@ public class FundProductServiceImpl implements IFundProductService {
case "name_same":
case "tel_same":
case "tel_no_same":
ruleList.append(productRuleEntity.getId()).append(",");
if ("1".equals(value)){
ruleList.append(productRuleEntity.getId()).append(",");
}
break;
case "area_term":
one.setAreaTerm(Integer.valueOf(value));
......@@ -318,7 +340,9 @@ public class FundProductServiceImpl implements IFundProductService {
}
});
one.setBasicRule(basicRule.substring(0,basicRule.lastIndexOf(" && ")));
one.setRuleList(ruleList.substring(0,ruleList.lastIndexOf(",")));
if (!StringUtils.isEmpty(ruleList)){
one.setRuleList(ruleList.substring(0,ruleList.lastIndexOf(",")));
}
one.setAreaRule(JSONObject.toJSONString(areaRuleConcrete));
fundProductRepository.save(one);
return GlobalResponse.success();
......
......@@ -43,7 +43,7 @@ public class WhiteListServiceImpl implements IWhiteListService {
booleanExpression = booleanExpression.and(QWhiteListEntity.whiteListEntity.phone.eq(String.valueOf(whiteListQueryVo.getPhone())));
}
if (!StringUtils.isEmpty(whiteListQueryVo.getFundName())){
booleanExpression = booleanExpression.and(QWhiteListEntity.whiteListEntity.fundName.like(String.valueOf(whiteListQueryVo.getFundName())));
booleanExpression = booleanExpression.and(QWhiteListEntity.whiteListEntity.fundName.like(whiteListQueryVo.getFundName() +"%"));
}
//1.查询条件,2.索引和每页的大小,3.排序根据某个字段进行排序
......
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