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);
}
......@@ -83,46 +83,65 @@ public class CoreFilter {
@Async
@Transactional(rollbackFor = Exception.class)
public void coreHandle(AuditResponce auditResponce){
public void coreHandle(AuditResponce auditResponce) {
try {
List<ChannelRuleEntity> channelRuleEntityList = channelRuleRepository.getByChannelId(Long.parseLong(auditResponce.getBizChannel()));
if (CollectionUtils.isEmpty(channelRuleEntityList)){
throw new RuntimeException("渠道配置产品集不存在,运营人员配置有问题");
}
UserAssociationBean associationBean = userCenterService.getUserAssociationBean(auditResponce.getUuid());
List<ChannelRuleEntity> channelRuleEntityList;
FilterResult result = new FilterResult();
List<FinanceProduct> financeProducts = new ArrayList<>();
List<RoutingRecordVO> routingRecordList = new ArrayList<>();
UserAssociationBean associationBean = userCenterService.getUserAssociationBean(auditResponce.getUuid());
if (auditResponce.getAuditResult()) {
//白名单
WhiteListEntity whiteListEntity = whiteListRepository.getByPhoneEquals(associationBean.getPhoneNo());
if (whiteListEntity != null && whiteListEntity.getStatus().equals(Byte.valueOf("1"))) {
log.info("白名单用户,phoneNo:{}", associationBean.getPhoneNo());
channelRuleEntityList = channelRuleRepository.getByChannelIdAndFundProductIdOrderByPriority(Long.parseLong(auditResponce.getBizChannel()), whiteListEntity.getFundProductId());
} else {
channelRuleEntityList = channelRuleRepository.getByChannelIdOrderByPriority(Long.parseLong(auditResponce.getBizChannel()));
}
if (CollectionUtils.isEmpty(channelRuleEntityList)) {
throw new RuntimeException("渠道配置产品集不存在,运营人员配置有问题");
}
for (ChannelRuleEntity channelRuleEntity : channelRuleEntityList) {
FundProductEntity fundProduct = fundProductRepository.getByIdEquals(channelRuleEntity.getFundProductId());
if (fundProduct == null){
log.error("这种情况不可能出现,需要看下原因 {}",JSON.toJSONString(channelRuleEntity));
log.info("coreHandle | 开始路由channelRuleEntity={}", channelRuleEntity.toString());
if (fundProduct == null) {
log.error("这种情况不可能出现,需要看下原因 {}", JSON.toJSONString(channelRuleEntity));
continue;
}
if (currentVerify(fundProduct,auditResponce,associationBean,channelRuleEntity)){
financeProducts.add(build(auditResponce,fundProduct,channelRuleEntity));
}
if (currentVerify(fundProduct, auditResponce, associationBean, channelRuleEntity)) {
log.info("coreHandle | 所有规则校验通过");
financeProducts.add(build(auditResponce, fundProduct, channelRuleEntity));
routingRecordList.add(generateRouteRecord(channelRuleEntity));
}
FilterResult result = new FilterResult();
}
if (CollectionUtils.isEmpty(financeProducts)) {
log.error("筛选完成后没有可用的配置, bizNo:{}", auditResponce.getBizNo());
auditResponce.setAuditResult(false);
} else {
result.setFinanceProducts(JSON.toJSONString(financeProducts));
Map<String,String> response = httpService.postHasResponse(auditResponce.getCallbackUrl(), result.get(auditResponce));
if(MapUtils.isEmpty(response) || !(HttpStatus.OK.value() + "").equals(response.get("statusCode"))
}
}
log.info("coreHandle | 通知业务系统审核结果");
Map<String, String> response = httpService.postHasResponse(auditResponce.getCallbackUrl(), result.get(auditResponce));
if (MapUtils.isEmpty(response) || !(HttpStatus.OK.value() + "").equals(response.get("statusCode"))
|| (!"success".equals(response.get("response")) && (!JSONObject.isValidObject(response.get("response"))
|| 0 != JSONObject.parseObject(response.get("response")).getInteger("code").intValue()))) {
MarkdownMessage markdownMessage = new MarkdownMessage();
markdownMessage.setTitle("通知业务系统审核结果失败告警");
markdownMessage.add(String.format(AUDIT_FAIL_TEXT,auditResponce.getUuid()));
markdownMessage.add(String.format(AUDIT_FAIL_TEXT, auditResponce.getUuid()));
alarmService.sendMsgWithAlert(markdownMessage);
log.error("通知业务系统审核结果失败 {}",JSON.toJSONString(auditResponce));
log.error("通知业务系统审核结果失败 {}", JSON.toJSONString(auditResponce));
throw new QGException(QGExceptionType.NOTIFY_BIZ_ERROR);
} else {
log.info("coreHandle | 保存路由记录");
RoutingRecordEntity routingRecordEntity = new RoutingRecordEntity();
routingRecordEntity.setCreditNo(auditResponce.getBizNo());
routingRecordEntity.setPhone(associationBean.getPhoneNo());
routingRecordEntity.setUuid(auditResponce.getUuid());
if (CollectionUtils.isEmpty(financeProducts)){
if (CollectionUtils.isEmpty(financeProducts)) {
routingRecordEntity.setStatus(new Byte("0"));
}else {
} else {
routingRecordEntity.setStatus(new Byte("1"));
routingRecordEntity.setRoutedResult(JSON.toJSONString(routingRecordList));
}
......@@ -135,17 +154,17 @@ public class CoreFilter {
alarmService.dingtalkAlarm("Warn", "资金路由分发出现异常", "bizChannel : " + auditResponce.getBizChannel()
+ " , bizType : " + auditResponce.getBizType() + " , bizNo : " + auditResponce.getBizNo()
+ " , uuid : " + auditResponce.getUuid()
+ " , 错误信息 : "+ ExceptionUtils.getMessage(e));
+ " , 错误信息 : " + ExceptionUtils.getMessage(e));
}
}
private RoutingRecordVO generateRouteRecord(ChannelRuleEntity channelRuleEntity){
private RoutingRecordVO generateRouteRecord(ChannelRuleEntity channelRuleEntity) {
RoutingRecordVO routingRecordVO = new RoutingRecordVO();
BeanUtils.copyProperties(channelRuleEntity,routingRecordVO);
BeanUtils.copyProperties(channelRuleEntity, routingRecordVO);
return routingRecordVO;
}
private FinanceProduct build(AuditResponce auditResponce, FundProductEntity fundProduct,ChannelRuleEntity channelRuleEntity){
private FinanceProduct build(AuditResponce auditResponce, FundProductEntity fundProduct, ChannelRuleEntity channelRuleEntity) {
FundInfo fundInfo = new FundInfo();
fundInfo.setFundId(fundProduct.getFundId());
fundInfo.setFundProductId(fundProduct.getFundProId() + "");
......@@ -163,27 +182,28 @@ public class CoreFilter {
return financeProduct;
}
private Boolean currentVerify(FundProductEntity fundProduct,AuditResponce auditResponce,
UserAssociationBean associationBean,ChannelRuleEntity channelRuleEntity){
if (fundProduct.getEnable().equals(new Byte("0"))){
private Boolean currentVerify(FundProductEntity fundProduct, AuditResponce auditResponce,
UserAssociationBean associationBean, ChannelRuleEntity channelRuleEntity) {
if (fundProduct.getEnable().equals(new Byte("0"))) {
return Boolean.FALSE;
}
WhiteListEntity whiteListEntity = whiteListRepository.getByPhoneEquals(associationBean.getPhoneNo());
Boolean basicInfoVerify = basicInfoVerify(fundProduct,associationBean,auditResponce,channelRuleEntity);
if (whiteListEntity != null && basicInfoVerify){
Boolean basicInfoVerify = basicInfoVerify(fundProduct, associationBean, auditResponce, channelRuleEntity);
if (whiteListEntity != null && basicInfoVerify) {
log.info("currentVerify | 走白名单");
return Boolean.TRUE;
}
return specialInfoVerify(fundProduct, associationBean) && basicInfoVerify;
}
private Boolean basicInfoVerify(FundProductEntity fundProduct, UserAssociationBean associationBean,
AuditResponce auditResponce, ChannelRuleEntity channelRuleEntity){
if (StringUtils.isBlank(fundProduct.getBasicRule())){
AuditResponce auditResponce, ChannelRuleEntity channelRuleEntity) {
if (StringUtils.isBlank(fundProduct.getBasicRule())) {
log.error("后台基础配置出问题了,资方产品信息是 {}", JSON.toJSONString(fundProduct));
throw new RuntimeException("后台基础配置出问题了");
}
long channelId = channelRuleEntity.getChannelId();
if (channelId != Long.parseLong(auditResponce.getBizChannel())){
if (channelId != Long.parseLong(auditResponce.getBizChannel())) {
return Boolean.FALSE;
}
if (StringUtils.isNotBlank(auditResponce.getCreditLevel()) || (StringUtils.isNotBlank(auditResponce.getCreditLevel())
......@@ -191,47 +211,47 @@ public class CoreFilter {
return Boolean.FALSE;
}
if (StringUtils.isNotBlank(auditResponce.getUserTag()) || (StringUtils.isNotBlank(auditResponce.getUserTag())
&& !channelRuleEntity.getUserTag().contains(auditResponce.getUserTag()))){
&& !channelRuleEntity.getUserTag().contains(auditResponce.getUserTag()))) {
return Boolean.FALSE;
}
String basicRule = fundProduct.getBasicRule();
Expression compiledExp = AviatorEvaluator.compile(basicRule);
List<ProductRuleEntity> ruleEntityList = productRuleService.getAll();
Map<String,Object> env = Maps.newConcurrentMap();
if (StringUtils.isNotBlank(fundProduct.getTelRule())){
Map<String, Object> env = Maps.newConcurrentMap();
if (StringUtils.isNotBlank(fundProduct.getTelRule())) {
env.put(RuleConstant.NOT_PERMIT_TEL, Lists.newArrayList(Arrays.stream(fundProduct.getTelRule()
.split(CommonConstants.COMMA)).mapToInt(s -> Integer.parseInt(s))));
}
for (ProductRuleEntity pre : ruleEntityList) {
if (pre.getEnable().equals(new Byte("0"))){
if (pre.getEnable().equals(new Byte("0"))) {
continue;
}
String currentRuleVal = pre.getRuleVal();
if (!basicRule.contains(currentRuleVal)){
if (!basicRule.contains(currentRuleVal)) {
continue;
}
if (currentRuleVal.equals(RuleConstant.AMOUNT)){
if (currentRuleVal.equals(RuleConstant.AMOUNT)) {
env.put(currentRuleVal, new BigDecimal(auditResponce.getAmount()));
}
if (currentRuleVal.equals(RuleConstant.TERM)){
if (currentRuleVal.equals(RuleConstant.TERM)) {
env.put(currentRuleVal, Integer.parseInt(auditResponce.getTerm()));
}
int age = IdCardUtil.getAge(associationBean.getIdNo());
env.put(RuleConstant.AGE, age);
if (currentRuleVal.equals(RuleConstant.NOT_PERMIT_TEL)){
env.put(RuleConstant.NOT_PERMIT_TELS,Integer.parseInt(StringUtils.substring(associationBean.getPhoneNo(),0,3)));
if (currentRuleVal.equals(RuleConstant.NOT_PERMIT_TEL)) {
env.put(RuleConstant.NOT_PERMIT_TELS, Integer.parseInt(StringUtils.substring(associationBean.getPhoneNo(), 0, 3)));
}
}
Boolean execute = (Boolean) compiledExp.execute(env);
log.info("基础校验结果 {}",execute);
if (execute){
execute = commonVerify(fundProduct,associationBean,auditResponce);
log.info("基础校验结果 {}", execute);
if (execute) {
execute = commonVerify(fundProduct, associationBean, auditResponce);
}
log.info("公共校验结果 {}",execute);
log.info("公共校验结果 {}", execute);
return execute;
}
private Boolean commonVerify(FundProductEntity fundProduct,UserAssociationBean associationBean,AuditResponce auditResponce){
private Boolean commonVerify(FundProductEntity fundProduct, UserAssociationBean associationBean, AuditResponce auditResponce) {
for (IRuleVerifyService ruleService : RuleHandleFactory.COMMON_VERIFY) {
RuleParam ruleParam = new RuleParam();
ruleParam.setUserInfo(associationBean);
......@@ -239,7 +259,7 @@ public class CoreFilter {
ruleParam.setArea(fundProduct.getAreaRule());
ruleParam.setUuid(auditResponce.getUuid());
ruleParam.setCardExpireEnum(IdCardExpireEnum.parse(fundProduct.getCardLimit()));
if (!ruleService.pass(ruleParam)){
if (!ruleService.pass(ruleParam)) {
log.info("当前用户公共校验不通过 {}", JSON.toJSONString(associationBean));
return Boolean.FALSE;
}
......@@ -247,9 +267,9 @@ public class CoreFilter {
return Boolean.TRUE;
}
private Boolean specialInfoVerify(FundProductEntity fundProduct,UserAssociationBean associationBean){
private Boolean specialInfoVerify(FundProductEntity fundProduct, UserAssociationBean associationBean) {
String ruleList = fundProduct.getRuleList();
if (StringUtils.isBlank(ruleList)){
if (StringUtils.isBlank(ruleList)) {
return Boolean.TRUE;
}
String[] rules = ruleList.split(CommonConstants.COMMA);
......@@ -258,11 +278,13 @@ public class CoreFilter {
IRuleVerifyService ruleVerifyService = ruleHandleFactory.getRuleVerifyServiceMap(productRuleEntity.getRuleEngine());
RuleParam ruleParam = new RuleParam();
ruleParam.setUserInfo(associationBean);
if (!ruleVerifyService.pass(ruleParam)){
if (!ruleVerifyService.pass(ruleParam)) {
log.info("当前用户其他规则检验不通过 {}", JSON.toJSONString(associationBean));
return Boolean.FALSE;
}
}
log.info("specialInfoVerify | 当前用户其他规则检验通过");
return Boolean.TRUE;
}
}
......@@ -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,31 +166,46 @@ 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())){
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(split[i]);
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));
if (StringUtils.isEmpty(s)) {
map.put(productRuleEntity.getId(), numeric);
} else {
map.put(productRuleEntity.getId(), s.concat(",").concat(numeric));
}
break;
}
}
}
}
//3.2基本规则剩下的字段
//区域类型的规则
String areaRule = one.getAreaRule();
......@@ -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":
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(" && ")));
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