Commit 400be065 authored by 王向伟's avatar 王向伟

添加节点顺序和非通知节点配置

parent c1bd44ab
......@@ -128,5 +128,11 @@ public class ChannelConf extends Primary {
@Column(name = "extend_data")
private String extendData;
@Column(name = "callback_no_push_progress")
private String callbackNoPushProgress;
@Column(name = "pre_progress")
private String preProgress;
}
......@@ -18,6 +18,8 @@ public class ChannelConfBaseModel {
private String env;
private Integer fundId;
private Integer p2pFundId;
private String callbackNoPushProgress;
private String preProgress;
/**
......
......@@ -7,10 +7,8 @@ import cn.quantgroup.cashloanflowboss.api.channel.util.ChannelConfUtil;
import cn.quantgroup.cashloanflowboss.spi.clf.entity.*;
import cn.quantgroup.cashloanflowboss.spi.clf.model.KANoticeType;
import cn.quantgroup.cashloanflowboss.spi.clf.service.CLFCenterService;
import cn.quantgroup.cashloanflowboss.utils.IgnorePropertiesUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
......@@ -41,7 +39,6 @@ public class ChannelConfServiceImpl implements ChannelConfService {
private ChannelConfRepository channelConfRepository;
@Override
public Page<ChannelListModel> getChannelInfo(Integer pageNumber, Integer pageSize, Long channelId, String channelName) {
......@@ -70,18 +67,19 @@ public class ChannelConfServiceImpl implements ChannelConfService {
} else {
// boss channel_conf 为空,从clf 查询数据
ClfChannelConfiguration channelConfiguration = clfCenterService.findChannelConfigurationByChannelId(channelId);
ClfCallbackConfiguration callbackConfiguration = clfCenterService.findCallbackConfigurationByChannelId(channelId);
ClfOrderCallBack approve = clfCenterService.findOrderCallBackByByCallbackStatusAndChannelId(KANoticeType.FUAD_ASSIFN_SUCC.name(), channelId);
ClfOrderCallBack orderStatus = clfCenterService.findOrderCallBackByByCallbackStatusAndChannelId(KANoticeType.FUND_SUCC.name(), channelId);
ClfOrderCallBack repaymentPlan = clfCenterService.findOrderCallBackByByCallbackStatusAndChannelId(KANoticeType.REPAYMENT.name(), channelId);
channelConfVo = ChannelConfUtil.getChannelConfVoByClf(channelConfiguration, approve, orderStatus, repaymentPlan);
channelConfVo = ChannelConfUtil.getChannelConfVoByClf(channelConfiguration, approve, orderStatus, repaymentPlan,callbackConfiguration);
}
List<ChannelApplyInfoStrategy> channelApplyInfoStrategyByChannelId = clfCenterService.findChannelApplyInfoStrategyByChannelId(channelId);
channelConfVo.setApplyConf(channelApplyInfoStrategyByChannelId);
ChannelSecurityKey channelSecurityKey = clfCenterService.findChannelSecurityByChannelId(channelId);
if(Objects.nonNull(channelSecurityKey)){
if (Objects.nonNull(channelSecurityKey)) {
channelConfVo.getAddInfo().setPublicKey(channelSecurityKey.getChannelPublicKey());
}
return channelConfVo;
......@@ -116,6 +114,7 @@ public class ChannelConfServiceImpl implements ChannelConfService {
ClfChannelConfiguration channelConfigurationExsit = clfCenterService.findChannelConfigurationByChannelId(basicInfo.getChannelId());
if (channelConfigurationExsit == null) {
// 新保存
channelConfiguration.setCreatedAt(new Timestamp(System.currentTimeMillis()));
......@@ -127,7 +126,7 @@ public class ChannelConfServiceImpl implements ChannelConfService {
clfCenterService.saveOrderCall(clfOrderCallBackList);
} else {
// update
// BeanUtils.copyProperties(channelConfiguration, channelConfigurationExsit, IgnorePropertiesUtil.getNullPropertyNames(channelConfiguration));
// BeanUtils.copyProperties(channelConfiguration, channelConfigurationExsit, IgnorePropertiesUtil.getNullPropertyNames(channelConfiguration));
channelConfiguration.setId(channelConfigurationExsit.getId());
clfCenterService.saveChannelConfiguration(channelConfiguration);
......@@ -138,7 +137,17 @@ public class ChannelConfServiceImpl implements ChannelConfService {
clfOrderCallBack.setId(orderCallBackExsit.getId());
}
}
clfCenterService.saveOrderCall(clfOrderCallBackList);
ClfCallbackConfiguration clfCallbackConfiguration = clfCenterService.findCallbackConfigurationByChannelId(basicInfo.getChannelId());
if(Objects.isNull(clfCallbackConfiguration)){
clfCallbackConfiguration = ChannelConfUtil.convert2ClfCallbackConfiguration(basicInfo);
}else {
clfCallbackConfiguration.setPreProgress(basicInfo.getPreProgress());
clfCallbackConfiguration.setCallbackNoPushProgress(basicInfo.getCallbackNoPushProgress());
}
clfCenterService.saveCallbackConfiguration(clfCallbackConfiguration);
}
//保存进件配置项
......@@ -153,7 +162,7 @@ public class ChannelConfServiceImpl implements ChannelConfService {
String channelPublicKey = addInfo.getPublicKey();
ChannelSecurityKey channelSecurityKey = clfCenterService.findChannelSecurityByChannelId(channelConf.getChannelId());
if(Objects.isNull(channelSecurityKey)){
if (Objects.isNull(channelSecurityKey)) {
channelSecurityKey = new ChannelSecurityKey();
channelSecurityKey.setIsActive(true);
channelSecurityKey.setCreatedAt(new Timestamp(System.currentTimeMillis()));
......@@ -169,7 +178,7 @@ public class ChannelConfServiceImpl implements ChannelConfService {
List<ClfChannelConfiguration> all = clfCenterService.findAll();
List<ChannelModel> channelModelList = new ArrayList<>(all.size());
all.forEach(e->{
all.forEach(e -> {
ChannelModel model = new ChannelModel();
model.setId(e.getId());
model.setName(e.getChannelName());
......@@ -182,28 +191,26 @@ public class ChannelConfServiceImpl implements ChannelConfService {
@Override
public String exportChannelConf(Long channelId) {
ClfChannelConfiguration channelConfiguration= clfCenterService.findChannelConfigurationByChannelId(channelId);
List<CallbackConfiguration> callbackConfigurations = clfCenterService.findCallbackConfigurationByChannelId(channelId);
ClfChannelConfiguration channelConfiguration = clfCenterService.findChannelConfigurationByChannelId(channelId);
ClfCallbackConfiguration callbackConfiguration = clfCenterService.findCallbackConfigurationByChannelId(channelId);
List<ChannelApplyInfoStrategy> channelApplyInfoStrategies = clfCenterService.findChannelApplyInfoStrategyByChannelId(channelId);
ChannelSecurityKey channelSecurityKey = clfCenterService.findChannelSecurityByChannelId(channelId);
StringJoiner joiner = new StringJoiner("\n");
if(Objects.nonNull(channelConfiguration)){
if (Objects.nonNull(channelConfiguration)) {
joiner.add(generateInsertSql(channelConfiguration));
}
if(CollectionUtils.isNotEmpty(callbackConfigurations)){
for (CallbackConfiguration callbackConfiguration : callbackConfigurations) {
joiner.add(generateInsertSql(callbackConfiguration));
}
if (Objects.nonNull(callbackConfiguration)) {
joiner.add(generateInsertSql(callbackConfiguration));
}
if(CollectionUtils.isNotEmpty(channelApplyInfoStrategies)){
if (CollectionUtils.isNotEmpty(channelApplyInfoStrategies)) {
for (ChannelApplyInfoStrategy channelApplyInfoStrategy : channelApplyInfoStrategies) {
joiner.add(generateInsertSql(channelApplyInfoStrategy));
}
}
if(Objects.nonNull(channelSecurityKey)){
if (Objects.nonNull(channelSecurityKey)) {
joiner.add(generateInsertSql(channelSecurityKey));
}
......@@ -212,14 +219,14 @@ public class ChannelConfServiceImpl implements ChannelConfService {
//生成sql语句
private String generateInsertSql(Object obj){
private String generateInsertSql(Object obj) {
if(Objects.isNull(obj)){
if (Objects.isNull(obj)) {
return null;
}
Class<?> clazz = obj.getClass();
Annotation[] annotations = clazz.getAnnotations();
if(annotations.length <= 0){
if (annotations.length <= 0) {
throw new RuntimeException("类名上没有注解,不能获得表名");
}
......@@ -227,7 +234,7 @@ public class ChannelConfServiceImpl implements ChannelConfService {
joiner.add("insert into");
//获得表名
for (Annotation annotation : annotations) {
if(annotation instanceof Table){
if (annotation instanceof Table) {
//只获得@Table注解的,@Entity有了以后再加
Table table = (Table) annotation;
String tableName = table.name();
......@@ -238,26 +245,26 @@ public class ChannelConfServiceImpl implements ChannelConfService {
Field[] declaredFields = clazz.getDeclaredFields();
if(declaredFields.length <= 0){
if (declaredFields.length <= 0) {
throw new RuntimeException("没有字段,不能获得表的列名");
}
Map<String,Object> field2Value = new HashMap<>();
Map<String, Object> field2Value = new HashMap<>();
for (Field declaredField : declaredFields) {
declaredField.setAccessible(true);
Id idAnnotation = declaredField.getAnnotation(Id.class);
if(Objects.nonNull(idAnnotation)){
if (Objects.nonNull(idAnnotation)) {
continue;
}
Column annotation = declaredField.getAnnotation(Column.class);
if(Objects.isNull(annotation)){
log.warn("{}字段没有对应的列",declaredField.getName());
if (Objects.isNull(annotation)) {
log.warn("{}字段没有对应的列", declaredField.getName());
continue;
}
try {
field2Value.put(annotation.name(),declaredField.get(obj));
field2Value.put(annotation.name(), declaredField.get(obj));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
......@@ -269,25 +276,25 @@ public class ChannelConfServiceImpl implements ChannelConfService {
for (Map.Entry<String, Object> entry : field2Value.entrySet()) {
fields.add(entry.getKey());
//空值
if(Objects.isNull(entry.getValue())){
if (Objects.isNull(entry.getValue())) {
values.add(null);
continue;
}
//非空值
Object value = entry.getValue();
//数字不加引号
if(value instanceof Number || value instanceof Boolean){
if (value instanceof Number || value instanceof Boolean) {
values.add(value.toString());
continue;
}
//枚举存ordinal 存name的表单独判断
if(value instanceof Enum){
Enum e = (Enum)value;
values.add(e.ordinal()+"");
if (value instanceof Enum) {
Enum e = (Enum) value;
values.add(e.ordinal() + "");
continue;
}
//其他类型一律按照字符串处理,有问题加if判断
values.add("'"+value.toString()+"'");
values.add("'" + value.toString() + "'");
}
joiner.add("(");
......
package cn.quantgroup.cashloanflowboss.api.channel.util;
import java.sql.Timestamp;
import cn.quantgroup.cashloanflowboss.spi.clf.model.KANoticeType;
import cn.quantgroup.cashloanflowboss.spi.clf.entity.ClfOrderCallBack;
import cn.quantgroup.cashloanflowboss.spi.clf.model.CallbackRouter;
import cn.quantgroup.cashloanflowboss.spi.clf.entity.ClfCallbackConfiguration;
import cn.quantgroup.cashloanflowboss.spi.clf.model.EncType;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import cn.quantgroup.cashloanflowboss.api.channel.entity.ChannelConf;
import cn.quantgroup.cashloanflowboss.api.channel.model.ChannelConfAddModel;
import cn.quantgroup.cashloanflowboss.api.channel.model.ChannelConfBaseModel;
import cn.quantgroup.cashloanflowboss.api.channel.model.ChannelConfVo;
import cn.quantgroup.cashloanflowboss.spi.clf.entity.ClfCallbackConfiguration;
import cn.quantgroup.cashloanflowboss.spi.clf.entity.ClfChannelConfiguration;
import cn.quantgroup.cashloanflowboss.spi.clf.entity.ClfOrderCallBack;
import cn.quantgroup.cashloanflowboss.spi.clf.model.CallbackRouter;
import cn.quantgroup.cashloanflowboss.spi.clf.model.EncType;
import cn.quantgroup.cashloanflowboss.spi.clf.model.KANoticeType;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* function:
* date: 2019/8/2
......@@ -79,9 +79,9 @@ public class ChannelConfUtil {
channelConfiguration.setSpiderCenterChannelCode(basicInfo.getRiskCode());
channelConfiguration.setSpiderCenterMerchantChannelCode(basicInfo.getAuthCode());
if(Objects.nonNull(basicInfo.getBizType())){
channelConfiguration.setXyqbProductId(basicInfo.getBizType()+"");
}else {
if (Objects.nonNull(basicInfo.getBizType())) {
channelConfiguration.setXyqbProductId(basicInfo.getBizType() + "");
} else {
channelConfiguration.setXyqbProductId(null);
}
return channelConfiguration;
......@@ -223,7 +223,7 @@ public class ChannelConfUtil {
}
}
public static ChannelConfVo getChannelConfVoByClf(ClfChannelConfiguration channelConfiguration, ClfOrderCallBack approve, ClfOrderCallBack orderStatus, ClfOrderCallBack repaymentPlan) {
public static ChannelConfVo getChannelConfVoByClf(ClfChannelConfiguration channelConfiguration, ClfOrderCallBack approve, ClfOrderCallBack orderStatus, ClfOrderCallBack repaymentPlan, ClfCallbackConfiguration callbackConfiguration) {
ChannelConfVo channelConfVo = new ChannelConfVo();
ChannelConfBaseModel channelConfBaseModel = new ChannelConfBaseModel();
if (channelConfiguration != null) {
......@@ -233,7 +233,7 @@ public class ChannelConfUtil {
channelConfBaseModel.setEnv("");
channelConfBaseModel.setFundId(0);
channelConfBaseModel.setP2pFundId(0);
if(StringUtils.isNotEmpty(channelConfiguration.getXyqbProductId())){
if (StringUtils.isNotEmpty(channelConfiguration.getXyqbProductId())) {
channelConfBaseModel.setBizType(Integer.valueOf(channelConfiguration.getXyqbProductId()));
}
channelConfBaseModel.setAesKey(channelConfiguration.getAesKey());
......@@ -242,6 +242,11 @@ public class ChannelConfUtil {
channelConfBaseModel.setRiskCode(channelConfiguration.getSpiderCenterChannelCode());
}
if (callbackConfiguration != null) {
channelConfBaseModel.setCallbackNoPushProgress(callbackConfiguration.getCallbackNoPushProgress());
channelConfBaseModel.setPreProgress(callbackConfiguration.getPreProgress());
}
ChannelConfAddModel channelConfAddModel = new ChannelConfAddModel();
channelConfAddModel.setEnvPath("");
......
......@@ -61,7 +61,6 @@ public class CashLoanFlowBossDataSourceConfiguration {
@Primary
@Bean(name = "bossEntityManager")
public LocalContainerEntityManagerFactoryBean entityManager(EntityManagerFactoryBuilder builder) {
return builder.dataSource(createDataSource())
.packages("cn.quantgroup.cashloanflowboss.api")
.persistenceUnit(uniquename)
......
package cn.quantgroup.cashloanflowboss.spi.clf.entity;
import cn.quantgroup.cashloanflowboss.spi.clf.model.CallbackRouter;
import lombok.*;
import org.apache.commons.lang3.StringUtils;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Map;
import java.util.Set;
/**
* Created by liqing on 2017/5/5 0005.
*/
@Setter
@Getter
@Entity
@Table(name = "callback_configuration", catalog = "cash_loan_flow")
public class CallbackConfiguration implements Serializable {
private static final long serialVersionUID = -1L;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "channel_id")
private Long channelId;
@Column(name = "is_loan_makeup")
private Boolean isLoanMakeup;
@Column(name = "is_repay_makeup")
private Boolean isRepayMakeup;
@Column(name = "loan_makeup_strategy")
private String loanMakeupStrategy;
@Column(name = "repay_makeup_strategy")
private String repayMakeupStrategy;
@Column(name = "is_active")
private Boolean isActive;
@Column(name = "only_new_user")
private Boolean onlyNewUser;
@Column(name = "callback_service_name")
private String callbackServiceName;
@Column(name = "callback_no_push_progress")
private String callbackNoPushProgress;
@Column(name = "pre_progress")
private String preProgress;
@Column(name = "retry_max_times")
private Long retryMaxTimes;
@Enumerated(EnumType.ORDINAL)
@Column(name = "callback_router")
private CallbackRouter callbackRouter;
// @Transient
// private LoanMakeupStrategyModel loanMakeupStrategyModel;
// @Transient
// private RepayMakeupStrategyModel repayMakeupStrategyModel;
//
// public void generateMakeupStrategyModel() {
// if (StringUtils.isNotBlank(loanMakeupStrategy)) {
// loanMakeupStrategyModel = Constants.GSON.fromJson(loanMakeupStrategy, LoanMakeupStrategyModel.class);
// }
// if (StringUtils.isNotBlank(repayMakeupStrategy)) {
// repayMakeupStrategyModel = Constants.GSON.fromJson(repayMakeupStrategy, RepayMakeupStrategyModel.class);
// }
// }
//
// public LoanMakeupStrategyModel getLoanMakeupStrategyModel() {
// if (loanMakeupStrategyModel == null) {
// loanMakeupStrategyModel = Constants.GSON.fromJson(loanMakeupStrategy, LoanMakeupStrategyModel.class);
// }
// return loanMakeupStrategyModel;
// }
//
// public RepayMakeupStrategyModel getRepayMakeupStrategyModel() {
// if (repayMakeupStrategyModel == null) {
// repayMakeupStrategyModel = Constants.GSON.fromJson(repayMakeupStrategy, RepayMakeupStrategyModel.class);
// }
// return repayMakeupStrategyModel;
// }
//
// @Setter
// @Getter
// @Builder
// @NoArgsConstructor
// @AllArgsConstructor
// public static class LoanMakeupStrategyModel implements Serializable {
// private static final long serialVersionUID = -1L;
//
// private Map<Integer, Integer> preProgressMap; // 前一个应推送的状态映射
// private Map<Integer, Integer> pushStatusMap; // 应推送的状态映射
// private Set<Integer> allStatus; // 所有需要关注的状态
// private Long hourAgo; // 关注hourAgo小时之内发生变更的状态
// private Integer maxCount; // 最多一次补偿数量
//
// public String toJson() {
// return Constants.GSON.toJson(this);
// }
// }
//
// @Setter
// @Getter
// @Builder
// @NoArgsConstructor
// @AllArgsConstructor
// public static class RepayMakeupStrategyModel implements Serializable {
// private static final long serialVersionUID = -1L;
//
// private Long hourAgo; // 关注hourAgo小时之内发生收到的还款
// private Integer maxCount; // 最多一次补偿数量
//
// public String toJson() {
// return Constants.GSON.toJson(this);
// }
// }
}
......@@ -14,4 +14,5 @@ import org.springframework.stereotype.Repository;
@CashLoanFlowDataSource
@Repository
public interface ClfCallbackConfigurationRepository extends JpaRepository<ClfCallbackConfiguration, Long> {
ClfCallbackConfiguration findByChannelId(Long channelId);
}
package cn.quantgroup.cashloanflowboss.spi.clf.repository;
import cn.quantgroup.cashloanflowboss.core.persistence.CashLoanFlowDataSource;
import cn.quantgroup.cashloanflowboss.spi.clf.entity.CallbackConfiguration;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created by liqing on 2017/5/5 0005.
*/
@CashLoanFlowDataSource
@Repository
public interface ICallbackConfigurationRepository extends JpaRepository<CallbackConfiguration, Long> {
List<CallbackConfiguration> findByChannelId(Long channelId);
}
......@@ -42,7 +42,7 @@ public interface CLFCenterService {
void saveChannelApplyInfoStrategy(ChannelApplyInfoStrategy channelApplyInfoStrategy);
List<CallbackConfiguration> findCallbackConfigurationByChannelId(Long channelId);
ClfCallbackConfiguration findCallbackConfigurationByChannelId(Long channelId);
List<ClfChannelConfiguration> findAll();
......
......@@ -49,8 +49,6 @@ public class CLFCenterServiceImpl implements CLFCenterService {
private ChannelApplyInfoStrategyRepository channelApplyInfoStrategyRepository;
@Autowired
private ICallbackConfigurationRepository callbackConfigurationRepository;
@Autowired
private ChannelSecurityKeyRepository channelSecurityKeyRepository;
......@@ -177,8 +175,8 @@ public class CLFCenterServiceImpl implements CLFCenterService {
@Override
public List<CallbackConfiguration> findCallbackConfigurationByChannelId(Long channelId) {
return callbackConfigurationRepository.findByChannelId(channelId);
public ClfCallbackConfiguration findCallbackConfigurationByChannelId(Long channelId) {
return clfCallbackConfigurationRepository.findByChannelId(channelId);
}
......
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