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; ...@@ -10,6 +10,7 @@ import com.quantgroup.asset.distribution.service.newrule.third.AuditResponce;
import com.quantgroup.asset.distribution.util.UUIDUtil; import com.quantgroup.asset.distribution.util.UUIDUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; 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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
...@@ -37,6 +38,7 @@ public class NewAssertController { ...@@ -37,6 +38,7 @@ public class NewAssertController {
auditResponce.setAssetNo(UUIDUtil.getAssetNo()); auditResponce.setAssetNo(UUIDUtil.getAssetNo());
coreFilter.coreHandle(auditResponce); coreFilter.coreHandle(auditResponce);
} catch (Exception e) { } catch (Exception e) {
log.error("风控通知审核结果处理异常, e:{}", ExceptionUtils.getStackTrace(e));
return GlobalResponse.error(e.getMessage()); return GlobalResponse.error(e.getMessage());
} }
return GlobalResponse.create(AssetResponse.SUCCESS); return GlobalResponse.create(AssetResponse.SUCCESS);
......
...@@ -138,8 +138,7 @@ public class ChannelRouteController { ...@@ -138,8 +138,7 @@ public class ChannelRouteController {
if (bindingResult.hasErrors()){ if (bindingResult.hasErrors()){
return GlobalResponse.error(bindingResult.getFieldError().getDefaultMessage()); return GlobalResponse.error(bindingResult.getFieldError().getDefaultMessage());
} }
channelRouteService.addChannelConfig(channelRouteAddVo.getChannelRouteSaveVoList(),channelRouteAddVo.getType()); return channelRouteService.addChannelConfig(channelRouteAddVo.getChannelRouteSaveVoList(),channelRouteAddVo.getType());
return GlobalResponse.success();
} }
/** /**
......
...@@ -10,7 +10,7 @@ import lombok.Getter; ...@@ -10,7 +10,7 @@ import lombok.Getter;
@Getter @Getter
public enum OrganizationType { public enum OrganizationType {
DIVERSION("DIVERSION","导流"), DIVERSION("DIVERSION","导流"),
LOAN("LOAN","助贷"); ASSISTANCE("ASSISTANCE","助贷");
private String value; private String value;
......
...@@ -4,6 +4,7 @@ import lombok.Data; ...@@ -4,6 +4,7 @@ import lombok.Data;
import org.hibernate.validator.constraints.NotBlank; import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty; import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.Valid;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.Map; import java.util.Map;
......
package com.quantgroup.asset.distribution.model.entity.route.routerecord; package com.quantgroup.asset.distribution.model.entity.route.routerecord;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.quantgroup.asset.distribution.util.PageVo; import com.quantgroup.asset.distribution.util.PageVo;
import lombok.Data; import lombok.Data;
...@@ -11,6 +12,8 @@ public class RouteRecordQueryVo extends PageVo { ...@@ -11,6 +12,8 @@ public class RouteRecordQueryVo extends PageVo {
private String creditNo; private String creditNo;
private String uuid; private String uuid;
private Byte status; private Byte status;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Timestamp routedAtMin; private Timestamp routedAtMin;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Timestamp routedAtMax; private Timestamp routedAtMax;
} }
package com.quantgroup.asset.distribution.service.jpa.entity; package com.quantgroup.asset.distribution.service.jpa.entity;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.DynamicUpdate;
...@@ -16,6 +17,7 @@ import java.util.Objects; ...@@ -16,6 +17,7 @@ import java.util.Objects;
@Table(name = "channel_rule", schema = "asset-distribution", catalog = "") @Table(name = "channel_rule", schema = "asset-distribution", catalog = "")
@DynamicInsert @DynamicInsert
@DynamicUpdate @DynamicUpdate
@Data
public class ChannelRuleEntity { public class ChannelRuleEntity {
private Long id; private Long id;
private Long fundProductId; private Long fundProductId;
......
...@@ -9,7 +9,7 @@ import java.util.List; ...@@ -9,7 +9,7 @@ import java.util.List;
public interface IChannelRuleRepository extends JpaRepository<ChannelRuleEntity, Long>, QueryDslPredicateExecutor<ChannelRuleEntity> { public interface IChannelRuleRepository extends JpaRepository<ChannelRuleEntity, Long>, QueryDslPredicateExecutor<ChannelRuleEntity> {
ChannelRuleEntity getByFundProductIdEquals(long fundProductId); ChannelRuleEntity getByFundProductIdEquals(long fundProductId);
List<ChannelRuleEntity> getByChannelId(long channelId); List<ChannelRuleEntity> getByChannelIdOrderByPriority(long channelId);
List<ChannelRuleEntity> getAllByEnableEquals(Boolean enable); List<ChannelRuleEntity> getAllByEnableEquals(Boolean enable);
...@@ -19,4 +19,5 @@ public interface IChannelRuleRepository extends JpaRepository<ChannelRuleEntity, ...@@ -19,4 +19,5 @@ public interface IChannelRuleRepository extends JpaRepository<ChannelRuleEntity,
void deleteAllByChannelIdEqualsAndEnableEquals(Long channelId,Boolean enable); void deleteAllByChannelIdEqualsAndEnableEquals(Long channelId,Boolean enable);
List<ChannelRuleEntity> getByChannelIdAndFundProductIdOrderByPriority(long channelId, long fundProductId);
} }
...@@ -83,46 +83,65 @@ public class CoreFilter { ...@@ -83,46 +83,65 @@ public class CoreFilter {
@Async @Async
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void coreHandle(AuditResponce auditResponce){ public void coreHandle(AuditResponce auditResponce) {
try { try {
List<ChannelRuleEntity> channelRuleEntityList = channelRuleRepository.getByChannelId(Long.parseLong(auditResponce.getBizChannel())); List<ChannelRuleEntity> channelRuleEntityList;
if (CollectionUtils.isEmpty(channelRuleEntityList)){ FilterResult result = new FilterResult();
throw new RuntimeException("渠道配置产品集不存在,运营人员配置有问题");
}
UserAssociationBean associationBean = userCenterService.getUserAssociationBean(auditResponce.getUuid());
List<FinanceProduct> financeProducts = new ArrayList<>(); List<FinanceProduct> financeProducts = new ArrayList<>();
List<RoutingRecordVO> routingRecordList = 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) { for (ChannelRuleEntity channelRuleEntity : channelRuleEntityList) {
FundProductEntity fundProduct = fundProductRepository.getByIdEquals(channelRuleEntity.getFundProductId()); FundProductEntity fundProduct = fundProductRepository.getByIdEquals(channelRuleEntity.getFundProductId());
if (fundProduct == null){ log.info("coreHandle | 开始路由channelRuleEntity={}", channelRuleEntity.toString());
log.error("这种情况不可能出现,需要看下原因 {}",JSON.toJSONString(channelRuleEntity)); if (fundProduct == null) {
log.error("这种情况不可能出现,需要看下原因 {}", JSON.toJSONString(channelRuleEntity));
continue; continue;
} }
if (currentVerify(fundProduct,auditResponce,associationBean,channelRuleEntity)){ if (currentVerify(fundProduct, auditResponce, associationBean, channelRuleEntity)) {
financeProducts.add(build(auditResponce,fundProduct,channelRuleEntity)); log.info("coreHandle | 所有规则校验通过");
} financeProducts.add(build(auditResponce, fundProduct, channelRuleEntity));
routingRecordList.add(generateRouteRecord(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)); 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")) || (!"success".equals(response.get("response")) && (!JSONObject.isValidObject(response.get("response"))
|| 0 != JSONObject.parseObject(response.get("response")).getInteger("code").intValue()))) { || 0 != JSONObject.parseObject(response.get("response")).getInteger("code").intValue()))) {
MarkdownMessage markdownMessage = new MarkdownMessage(); MarkdownMessage markdownMessage = new MarkdownMessage();
markdownMessage.setTitle("通知业务系统审核结果失败告警"); markdownMessage.setTitle("通知业务系统审核结果失败告警");
markdownMessage.add(String.format(AUDIT_FAIL_TEXT,auditResponce.getUuid())); markdownMessage.add(String.format(AUDIT_FAIL_TEXT, auditResponce.getUuid()));
alarmService.sendMsgWithAlert(markdownMessage); alarmService.sendMsgWithAlert(markdownMessage);
log.error("通知业务系统审核结果失败 {}",JSON.toJSONString(auditResponce)); log.error("通知业务系统审核结果失败 {}", JSON.toJSONString(auditResponce));
throw new QGException(QGExceptionType.NOTIFY_BIZ_ERROR); throw new QGException(QGExceptionType.NOTIFY_BIZ_ERROR);
} else { } else {
log.info("coreHandle | 保存路由记录");
RoutingRecordEntity routingRecordEntity = new RoutingRecordEntity(); RoutingRecordEntity routingRecordEntity = new RoutingRecordEntity();
routingRecordEntity.setCreditNo(auditResponce.getBizNo()); routingRecordEntity.setCreditNo(auditResponce.getBizNo());
routingRecordEntity.setPhone(associationBean.getPhoneNo()); routingRecordEntity.setPhone(associationBean.getPhoneNo());
routingRecordEntity.setUuid(auditResponce.getUuid()); routingRecordEntity.setUuid(auditResponce.getUuid());
if (CollectionUtils.isEmpty(financeProducts)){ if (CollectionUtils.isEmpty(financeProducts)) {
routingRecordEntity.setStatus(new Byte("0")); routingRecordEntity.setStatus(new Byte("0"));
}else { } else {
routingRecordEntity.setStatus(new Byte("1")); routingRecordEntity.setStatus(new Byte("1"));
routingRecordEntity.setRoutedResult(JSON.toJSONString(routingRecordList)); routingRecordEntity.setRoutedResult(JSON.toJSONString(routingRecordList));
} }
...@@ -135,17 +154,17 @@ public class CoreFilter { ...@@ -135,17 +154,17 @@ public class CoreFilter {
alarmService.dingtalkAlarm("Warn", "资金路由分发出现异常", "bizChannel : " + auditResponce.getBizChannel() alarmService.dingtalkAlarm("Warn", "资金路由分发出现异常", "bizChannel : " + auditResponce.getBizChannel()
+ " , bizType : " + auditResponce.getBizType() + " , bizNo : " + auditResponce.getBizNo() + " , bizType : " + auditResponce.getBizType() + " , bizNo : " + auditResponce.getBizNo()
+ " , uuid : " + auditResponce.getUuid() + " , uuid : " + auditResponce.getUuid()
+ " , 错误信息 : "+ ExceptionUtils.getMessage(e)); + " , 错误信息 : " + ExceptionUtils.getMessage(e));
} }
} }
private RoutingRecordVO generateRouteRecord(ChannelRuleEntity channelRuleEntity){ private RoutingRecordVO generateRouteRecord(ChannelRuleEntity channelRuleEntity) {
RoutingRecordVO routingRecordVO = new RoutingRecordVO(); RoutingRecordVO routingRecordVO = new RoutingRecordVO();
BeanUtils.copyProperties(channelRuleEntity,routingRecordVO); BeanUtils.copyProperties(channelRuleEntity, routingRecordVO);
return 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 fundInfo = new FundInfo();
fundInfo.setFundId(fundProduct.getFundId()); fundInfo.setFundId(fundProduct.getFundId());
fundInfo.setFundProductId(fundProduct.getFundProId() + ""); fundInfo.setFundProductId(fundProduct.getFundProId() + "");
...@@ -163,27 +182,28 @@ public class CoreFilter { ...@@ -163,27 +182,28 @@ public class CoreFilter {
return financeProduct; return financeProduct;
} }
private Boolean currentVerify(FundProductEntity fundProduct,AuditResponce auditResponce, private Boolean currentVerify(FundProductEntity fundProduct, AuditResponce auditResponce,
UserAssociationBean associationBean,ChannelRuleEntity channelRuleEntity){ UserAssociationBean associationBean, ChannelRuleEntity channelRuleEntity) {
if (fundProduct.getEnable().equals(new Byte("0"))){ if (fundProduct.getEnable().equals(new Byte("0"))) {
return Boolean.FALSE; return Boolean.FALSE;
} }
WhiteListEntity whiteListEntity = whiteListRepository.getByPhoneEquals(associationBean.getPhoneNo()); WhiteListEntity whiteListEntity = whiteListRepository.getByPhoneEquals(associationBean.getPhoneNo());
Boolean basicInfoVerify = basicInfoVerify(fundProduct,associationBean,auditResponce,channelRuleEntity); Boolean basicInfoVerify = basicInfoVerify(fundProduct, associationBean, auditResponce, channelRuleEntity);
if (whiteListEntity != null && basicInfoVerify){ if (whiteListEntity != null && basicInfoVerify) {
log.info("currentVerify | 走白名单");
return Boolean.TRUE; return Boolean.TRUE;
} }
return specialInfoVerify(fundProduct, associationBean) && basicInfoVerify; return specialInfoVerify(fundProduct, associationBean) && basicInfoVerify;
} }
private Boolean basicInfoVerify(FundProductEntity fundProduct, UserAssociationBean associationBean, private Boolean basicInfoVerify(FundProductEntity fundProduct, UserAssociationBean associationBean,
AuditResponce auditResponce, ChannelRuleEntity channelRuleEntity){ AuditResponce auditResponce, ChannelRuleEntity channelRuleEntity) {
if (StringUtils.isBlank(fundProduct.getBasicRule())){ if (StringUtils.isBlank(fundProduct.getBasicRule())) {
log.error("后台基础配置出问题了,资方产品信息是 {}", JSON.toJSONString(fundProduct)); log.error("后台基础配置出问题了,资方产品信息是 {}", JSON.toJSONString(fundProduct));
throw new RuntimeException("后台基础配置出问题了"); throw new RuntimeException("后台基础配置出问题了");
} }
long channelId = channelRuleEntity.getChannelId(); long channelId = channelRuleEntity.getChannelId();
if (channelId != Long.parseLong(auditResponce.getBizChannel())){ if (channelId != Long.parseLong(auditResponce.getBizChannel())) {
return Boolean.FALSE; return Boolean.FALSE;
} }
if (StringUtils.isNotBlank(auditResponce.getCreditLevel()) || (StringUtils.isNotBlank(auditResponce.getCreditLevel()) if (StringUtils.isNotBlank(auditResponce.getCreditLevel()) || (StringUtils.isNotBlank(auditResponce.getCreditLevel())
...@@ -191,47 +211,47 @@ public class CoreFilter { ...@@ -191,47 +211,47 @@ public class CoreFilter {
return Boolean.FALSE; return Boolean.FALSE;
} }
if (StringUtils.isNotBlank(auditResponce.getUserTag()) || (StringUtils.isNotBlank(auditResponce.getUserTag()) if (StringUtils.isNotBlank(auditResponce.getUserTag()) || (StringUtils.isNotBlank(auditResponce.getUserTag())
&& !channelRuleEntity.getUserTag().contains(auditResponce.getUserTag()))){ && !channelRuleEntity.getUserTag().contains(auditResponce.getUserTag()))) {
return Boolean.FALSE; return Boolean.FALSE;
} }
String basicRule = fundProduct.getBasicRule(); String basicRule = fundProduct.getBasicRule();
Expression compiledExp = AviatorEvaluator.compile(basicRule); Expression compiledExp = AviatorEvaluator.compile(basicRule);
List<ProductRuleEntity> ruleEntityList = productRuleService.getAll(); List<ProductRuleEntity> ruleEntityList = productRuleService.getAll();
Map<String,Object> env = Maps.newConcurrentMap(); Map<String, Object> env = Maps.newConcurrentMap();
if (StringUtils.isNotBlank(fundProduct.getTelRule())){ if (StringUtils.isNotBlank(fundProduct.getTelRule())) {
env.put(RuleConstant.NOT_PERMIT_TEL, Lists.newArrayList(Arrays.stream(fundProduct.getTelRule() env.put(RuleConstant.NOT_PERMIT_TEL, Lists.newArrayList(Arrays.stream(fundProduct.getTelRule()
.split(CommonConstants.COMMA)).mapToInt(s -> Integer.parseInt(s)))); .split(CommonConstants.COMMA)).mapToInt(s -> Integer.parseInt(s))));
} }
for (ProductRuleEntity pre : ruleEntityList) { for (ProductRuleEntity pre : ruleEntityList) {
if (pre.getEnable().equals(new Byte("0"))){ if (pre.getEnable().equals(new Byte("0"))) {
continue; continue;
} }
String currentRuleVal = pre.getRuleVal(); String currentRuleVal = pre.getRuleVal();
if (!basicRule.contains(currentRuleVal)){ if (!basicRule.contains(currentRuleVal)) {
continue; continue;
} }
if (currentRuleVal.equals(RuleConstant.AMOUNT)){ if (currentRuleVal.equals(RuleConstant.AMOUNT)) {
env.put(currentRuleVal, new BigDecimal(auditResponce.getAmount())); env.put(currentRuleVal, new BigDecimal(auditResponce.getAmount()));
} }
if (currentRuleVal.equals(RuleConstant.TERM)){ if (currentRuleVal.equals(RuleConstant.TERM)) {
env.put(currentRuleVal, Integer.parseInt(auditResponce.getTerm())); env.put(currentRuleVal, Integer.parseInt(auditResponce.getTerm()));
} }
int age = IdCardUtil.getAge(associationBean.getIdNo()); int age = IdCardUtil.getAge(associationBean.getIdNo());
env.put(RuleConstant.AGE, age); env.put(RuleConstant.AGE, age);
if (currentRuleVal.equals(RuleConstant.NOT_PERMIT_TEL)){ if (currentRuleVal.equals(RuleConstant.NOT_PERMIT_TEL)) {
env.put(RuleConstant.NOT_PERMIT_TELS,Integer.parseInt(StringUtils.substring(associationBean.getPhoneNo(),0,3))); env.put(RuleConstant.NOT_PERMIT_TELS, Integer.parseInt(StringUtils.substring(associationBean.getPhoneNo(), 0, 3)));
} }
} }
Boolean execute = (Boolean) compiledExp.execute(env); Boolean execute = (Boolean) compiledExp.execute(env);
log.info("基础校验结果 {}",execute); log.info("基础校验结果 {}", execute);
if (execute){ if (execute) {
execute = commonVerify(fundProduct,associationBean,auditResponce); execute = commonVerify(fundProduct, associationBean, auditResponce);
} }
log.info("公共校验结果 {}",execute); log.info("公共校验结果 {}", execute);
return 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) { for (IRuleVerifyService ruleService : RuleHandleFactory.COMMON_VERIFY) {
RuleParam ruleParam = new RuleParam(); RuleParam ruleParam = new RuleParam();
ruleParam.setUserInfo(associationBean); ruleParam.setUserInfo(associationBean);
...@@ -239,7 +259,7 @@ public class CoreFilter { ...@@ -239,7 +259,7 @@ public class CoreFilter {
ruleParam.setArea(fundProduct.getAreaRule()); ruleParam.setArea(fundProduct.getAreaRule());
ruleParam.setUuid(auditResponce.getUuid()); ruleParam.setUuid(auditResponce.getUuid());
ruleParam.setCardExpireEnum(IdCardExpireEnum.parse(fundProduct.getCardLimit())); ruleParam.setCardExpireEnum(IdCardExpireEnum.parse(fundProduct.getCardLimit()));
if (!ruleService.pass(ruleParam)){ if (!ruleService.pass(ruleParam)) {
log.info("当前用户公共校验不通过 {}", JSON.toJSONString(associationBean)); log.info("当前用户公共校验不通过 {}", JSON.toJSONString(associationBean));
return Boolean.FALSE; return Boolean.FALSE;
} }
...@@ -247,9 +267,9 @@ public class CoreFilter { ...@@ -247,9 +267,9 @@ public class CoreFilter {
return Boolean.TRUE; return Boolean.TRUE;
} }
private Boolean specialInfoVerify(FundProductEntity fundProduct,UserAssociationBean associationBean){ private Boolean specialInfoVerify(FundProductEntity fundProduct, UserAssociationBean associationBean) {
String ruleList = fundProduct.getRuleList(); String ruleList = fundProduct.getRuleList();
if (StringUtils.isBlank(ruleList)){ if (StringUtils.isBlank(ruleList)) {
return Boolean.TRUE; return Boolean.TRUE;
} }
String[] rules = ruleList.split(CommonConstants.COMMA); String[] rules = ruleList.split(CommonConstants.COMMA);
...@@ -258,11 +278,13 @@ public class CoreFilter { ...@@ -258,11 +278,13 @@ public class CoreFilter {
IRuleVerifyService ruleVerifyService = ruleHandleFactory.getRuleVerifyServiceMap(productRuleEntity.getRuleEngine()); IRuleVerifyService ruleVerifyService = ruleHandleFactory.getRuleVerifyServiceMap(productRuleEntity.getRuleEngine());
RuleParam ruleParam = new RuleParam(); RuleParam ruleParam = new RuleParam();
ruleParam.setUserInfo(associationBean); ruleParam.setUserInfo(associationBean);
if (!ruleVerifyService.pass(ruleParam)){ if (!ruleVerifyService.pass(ruleParam)) {
log.info("当前用户其他规则检验不通过 {}", JSON.toJSONString(associationBean)); log.info("当前用户其他规则检验不通过 {}", JSON.toJSONString(associationBean));
return Boolean.FALSE; return Boolean.FALSE;
} }
} }
log.info("specialInfoVerify | 当前用户其他规则检验通过");
return Boolean.TRUE; return Boolean.TRUE;
} }
} }
...@@ -23,7 +23,7 @@ public interface IChannelRouteService { ...@@ -23,7 +23,7 @@ public interface IChannelRouteService {
FundProInfoVo getFundProductInfo(Long fundId, Long fundCorpId); FundProInfoVo getFundProductInfo(Long fundId, Long fundCorpId);
void addChannelConfig(List<ChannelRouteSaveVo> channelRouteSaveVoList,Integer type); GlobalResponse addChannelConfig(List<ChannelRouteSaveVo> channelRouteSaveVoList,Integer type);
void publishChannelConfig(Long channelId); void publishChannelConfig(Long channelId);
......
...@@ -42,13 +42,13 @@ public class ChannelRouteServiceImpl implements IChannelRouteService { ...@@ -42,13 +42,13 @@ public class ChannelRouteServiceImpl implements IChannelRouteService {
BooleanExpression booleanExpression = Expressions.asBoolean(true).isTrue(); BooleanExpression booleanExpression = Expressions.asBoolean(true).isTrue();
if (Objects.nonNull(channelRouteQueryVo.getChannelId())){ 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())){ 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())){ 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())){ if (Objects.nonNull(channelRouteQueryVo.getPublishStatus())){
booleanExpression = booleanExpression.and(QChannelRuleEntity.channelRuleEntity.publishStatus.eq(channelRouteQueryVo.getPublishStatus())); booleanExpression = booleanExpression.and(QChannelRuleEntity.channelRuleEntity.publishStatus.eq(channelRouteQueryVo.getPublishStatus()));
...@@ -142,7 +142,7 @@ public class ChannelRouteServiceImpl implements IChannelRouteService { ...@@ -142,7 +142,7 @@ public class ChannelRouteServiceImpl implements IChannelRouteService {
List<FundProductEntity> fundProductEntityList = fundProductRepository.getAllByEnableEquals(Byte.valueOf("1")); List<FundProductEntity> fundProductEntityList = fundProductRepository.getAllByEnableEquals(Byte.valueOf("1"));
List<Long> fundIdList = new ArrayList<>(); List<Long> fundIdList = new ArrayList<>();
fundProductEntityList.stream().forEach(fundProductEntity -> { fundProductEntityList.stream().forEach(fundProductEntity -> {
if (!fundIdList.contains(fundProductEntity.getFundId())){ if (!fundIdList.contains(fundProductEntity.getFundId()) && !StringUtils.isEmpty(fundProductEntity.getBasicRule())){
fundIdList.add(fundProductEntity.getFundId()); fundIdList.add(fundProductEntity.getFundId());
} }
}); });
...@@ -171,12 +171,18 @@ public class ChannelRouteServiceImpl implements IChannelRouteService { ...@@ -171,12 +171,18 @@ public class ChannelRouteServiceImpl implements IChannelRouteService {
@Override @Override
@Transactional @Transactional
public void addChannelConfig(List<ChannelRouteSaveVo> channelRouteSaveVoList,Integer type) { public GlobalResponse addChannelConfig(List<ChannelRouteSaveVo> channelRouteSaveVoList,Integer type) {
/** /**
* 编辑时要去掉所有该渠道有效性为0的其他配置(覆盖之前的未更新编辑信息) * 编辑时要去掉所有该渠道有效性为0的其他配置(覆盖之前的未更新编辑信息)
*/ */
if ( 0 != type ){ if ( 0 != type ){
channelRuleRepository.deleteAllByChannelIdEqualsAndEnableEquals(channelRouteSaveVoList.get(0).getChannelId(),Boolean.FALSE); 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); List<ChannelRuleEntity> channelRuleEntityList = getChannelRuleEntityList(channelRouteSaveVoList);
...@@ -196,6 +202,7 @@ public class ChannelRouteServiceImpl implements IChannelRouteService { ...@@ -196,6 +202,7 @@ public class ChannelRouteServiceImpl implements IChannelRouteService {
channelRuleRepository.save(channelRuleEntity); channelRuleRepository.save(channelRuleEntity);
} }
}); });
return GlobalResponse.success();
} }
private List<ChannelRuleEntity> getChannelRuleEntityList(List<ChannelRouteSaveVo> channelRouteSaveVoList){ private List<ChannelRuleEntity> getChannelRuleEntityList(List<ChannelRouteSaveVo> channelRouteSaveVoList){
......
...@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONArray; ...@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.quantgroup.asset.distribution.config.code.AreaCode; import com.quantgroup.asset.distribution.config.code.AreaCode;
import com.quantgroup.asset.distribution.config.code.InitAreaCode; 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.enums.route.SystemType;
import com.quantgroup.asset.distribution.model.entity.route.fundproduct.*; import com.quantgroup.asset.distribution.model.entity.route.fundproduct.*;
import com.quantgroup.asset.distribution.model.response.GlobalResponse; import com.quantgroup.asset.distribution.model.response.GlobalResponse;
...@@ -30,17 +29,12 @@ import org.springframework.data.domain.Sort; ...@@ -30,17 +29,12 @@ import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import shaded.com.google.common.collect.Lists;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service @Service
@Slf4j @Slf4j
...@@ -83,14 +77,15 @@ public class FundProductServiceImpl implements IFundProductService { ...@@ -83,14 +77,15 @@ public class FundProductServiceImpl implements IFundProductService {
//索引 和 每页大小 排序 条件 //索引 和 每页大小 排序 条件
BooleanExpression booleanExpression = Expressions.asBoolean(true).isTrue(); BooleanExpression booleanExpression = Expressions.asBoolean(true).isTrue();
log.info("fundId={}",fundProductQueryVo.getFundId());
if (Objects.nonNull(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())){ 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())){ 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())){ if (!StringUtils.isEmpty(fundProductQueryVo.getFundType())){
booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.fundType.eq(fundProductQueryVo.getFundType())); booleanExpression = booleanExpression.and(QFundProductEntity.fundProductEntity.fundType.eq(fundProductQueryVo.getFundType()));
...@@ -111,7 +106,7 @@ public class FundProductServiceImpl implements IFundProductService { ...@@ -111,7 +106,7 @@ public class FundProductServiceImpl implements IFundProductService {
//查询总条数 //查询总条数
long count = fundProductRepository.count(booleanExpression); 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<>(); List<FundProductEntity> fundProductEntities = new ArrayList<>();
fundProductEntities = plantPage.getContent(); fundProductEntities = plantPage.getContent();
...@@ -171,31 +166,46 @@ public class FundProductServiceImpl implements IFundProductService { ...@@ -171,31 +166,46 @@ public class FundProductServiceImpl implements IFundProductService {
basic.addAll(orther); basic.addAll(orther);
//3.基本信息和其他信息字段,对应的value //3.基本信息和其他信息字段,对应的value
Map<Long,String> map = new HashMap<>(); 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 //获取资金产品存的value
String basicRule = one.getBasicRule(); String basicRule = one.getBasicRule();
//解析value //解析value
String[] split = basicRule.split("&&"); String[] split = basicRule.split("&&");
for (int i = 0 ; i<split.length;i++){ for (String item : split) {
for (ProductRuleEntity productRuleEntity:basic){ for (ProductRuleEntity productRuleEntity : basic) {
//在value中寻找对应的规则 //在value中寻找对应的规则
if ("not_permit_tels".equals(productRuleEntity.getRuleVal())){ if ("not_permit_tels".equals(productRuleEntity.getRuleVal())) {
map.put(productRuleEntity.getId(),one.getTelRule()); map.put(productRuleEntity.getId(), one.getTelRule());
break; 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中的值 //取出value中的值
String numeric = getNumeric(split[i]); String numeric = getNumeric(item);
String s = map.get(productRuleEntity.getId()); String s = map.get(productRuleEntity.getId());
if (StringUtils.isEmpty(s)){ if (StringUtils.isEmpty(s)) {
map.put(productRuleEntity.getId(),numeric); map.put(productRuleEntity.getId(), numeric);
}else { } else {
map.put(productRuleEntity.getId(),s.concat(",").concat(numeric)); map.put(productRuleEntity.getId(), s.concat(",").concat(numeric));
} }
break; break;
} }
} }
} }
}
//3.2基本规则剩下的字段 //3.2基本规则剩下的字段
//区域类型的规则 //区域类型的规则
String areaRule = one.getAreaRule(); String areaRule = one.getAreaRule();
...@@ -274,7 +284,7 @@ public class FundProductServiceImpl implements IFundProductService { ...@@ -274,7 +284,7 @@ public class FundProductServiceImpl implements IFundProductService {
allByEnableEquals.stream().forEach(productRuleEntity -> { allByEnableEquals.stream().forEach(productRuleEntity -> {
String value = ruleValueMap.get(productRuleEntity.getId()); String value = ruleValueMap.get(productRuleEntity.getId());
if (!StringUtils.isEmpty(value)){ 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()){ switch (productRuleEntity.getRuleVal()){
case "age": case "age":
basicRule.append(value.replace(",", " <= age && age <= ")).append(" && "); basicRule.append(value.replace(",", " <= age && age <= ")).append(" && ");
...@@ -283,7 +293,17 @@ public class FundProductServiceImpl implements IFundProductService { ...@@ -283,7 +293,17 @@ public class FundProductServiceImpl implements IFundProductService {
basicRule.append(value.replace(","," <= amount && amount <= ")).append(" && "); basicRule.append(value.replace(","," <= amount && amount <= ")).append(" && ");
break; break;
case "term": 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; break;
case "not_permit_tels": case "not_permit_tels":
basicRule.append("! include(not_permit_tels,tel)").append(" && "); basicRule.append("! include(not_permit_tels,tel)").append(" && ");
...@@ -292,7 +312,9 @@ public class FundProductServiceImpl implements IFundProductService { ...@@ -292,7 +312,9 @@ public class FundProductServiceImpl implements IFundProductService {
case "name_same": case "name_same":
case "tel_same": case "tel_same":
case "tel_no_same": case "tel_no_same":
if ("1".equals(value)){
ruleList.append(productRuleEntity.getId()).append(","); ruleList.append(productRuleEntity.getId()).append(",");
}
break; break;
case "area_term": case "area_term":
one.setAreaTerm(Integer.valueOf(value)); one.setAreaTerm(Integer.valueOf(value));
...@@ -318,7 +340,9 @@ public class FundProductServiceImpl implements IFundProductService { ...@@ -318,7 +340,9 @@ public class FundProductServiceImpl implements IFundProductService {
} }
}); });
one.setBasicRule(basicRule.substring(0,basicRule.lastIndexOf(" && "))); one.setBasicRule(basicRule.substring(0,basicRule.lastIndexOf(" && ")));
if (!StringUtils.isEmpty(ruleList)){
one.setRuleList(ruleList.substring(0,ruleList.lastIndexOf(","))); one.setRuleList(ruleList.substring(0,ruleList.lastIndexOf(",")));
}
one.setAreaRule(JSONObject.toJSONString(areaRuleConcrete)); one.setAreaRule(JSONObject.toJSONString(areaRuleConcrete));
fundProductRepository.save(one); fundProductRepository.save(one);
return GlobalResponse.success(); return GlobalResponse.success();
......
...@@ -43,7 +43,7 @@ public class WhiteListServiceImpl implements IWhiteListService { ...@@ -43,7 +43,7 @@ public class WhiteListServiceImpl implements IWhiteListService {
booleanExpression = booleanExpression.and(QWhiteListEntity.whiteListEntity.phone.eq(String.valueOf(whiteListQueryVo.getPhone()))); booleanExpression = booleanExpression.and(QWhiteListEntity.whiteListEntity.phone.eq(String.valueOf(whiteListQueryVo.getPhone())));
} }
if (!StringUtils.isEmpty(whiteListQueryVo.getFundName())){ 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.排序根据某个字段进行排序 //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