Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master'

张均强 4 rokov pred
rodič
commit
8cead83a76

+ 4 - 4
common/fire-dto/src/main/java/com/fire/dto/ChannelInfo.java

@@ -35,6 +35,10 @@ public class ChannelInfo {
     @ApiModelProperty("供应商id")
     private Long supplierId;
 
+    @TableField(exist = false)
+    @ApiModelProperty("供应商名称")
+    private String supplierName;
+
     @ApiModelProperty("通道名称")
     private String channelName;
 
@@ -85,10 +89,6 @@ public class ChannelInfo {
     @JsonIgnoreProperties
     Map<Long, Map<String, ChannelProductInfo>> productListMap;
 
-    @ApiModelProperty("供应商名称")
-    @TableField(exist = false)
-    private String supplierName;
-
     @TableField(exist = false)
     @ApiModelProperty(value = "通道权重", hidden = true)
     private Integer weight;

+ 5 - 0
common/fire-dto/src/main/java/com/fire/dto/DistributeGroupChannel.java

@@ -1,6 +1,7 @@
 package com.fire.dto;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -27,6 +28,10 @@ public class DistributeGroupChannel {
     @ApiModelProperty("通道id")
     private Long channelId;
 
+    @TableField(exist = false)
+    @ApiModelProperty("通道名称")
+    private String channelName;
+
     @ApiModelProperty("通道组id")
     private Long channelGroupId;
 

+ 2 - 2
modules/admin/src/main/java/com/fire/admin/rest/ChannelInfoRest.java

@@ -45,8 +45,8 @@ public class ChannelInfoRest {
 
     @GetMapping("/getAllChannelnfos")
     @ApiOperation(value = "不带分页获取所有通道", notes = "get_all_channelinfos.py")
-    public BaseRestResponse getAllChannelInfos() {
-        List<ChannelInfo> channelInfos = channelInfoService.list();
+    public BaseRestResponse getAllChannelInfos(Integer operator) {
+        List<ChannelInfo> channelInfos = channelInfoService.getChannelInfoByOperator(operator);
         if (channelInfos != null) {
             return new BaseRestResponse(channelInfos);
         }

+ 35 - 0
modules/admin/src/main/java/com/fire/admin/rest/DistGroupChannelRest.java

@@ -0,0 +1,35 @@
+package com.fire.admin.rest;
+
+import com.fire.admin.service.DistGroupChannelService;
+import com.fire.dto.response.BaseResponse;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+/**
+ * @author: admin
+ * @Description:
+ * @date: 2021-06-23 11:17
+ * @Modified By:
+ */
+
+@Api(tags = "分发组关联通道相关接口")
+@RestController
+@RequestMapping("/distGroupChannel")
+public class DistGroupChannelRest {
+
+    @Resource
+    private DistGroupChannelService distGroupChannelService;
+
+    @ApiOperation(value ="删除分发组下通道", notes = "delete_channel_info.py")
+    @DeleteMapping("/delete/{id}")
+    public BaseResponse deleteChannelById(@PathVariable("id") Long id) {
+        distGroupChannelService.removeChannelById(id);
+        return new BaseResponse();
+    }
+}

+ 2 - 2
modules/admin/src/main/java/com/fire/admin/service/ChannelInfoService.java

@@ -19,6 +19,8 @@ public interface ChannelInfoService extends IService<ChannelInfo> {
 
     IPage<ChannelInfo> getChannelList(ChannelPageParam channelPageParam);
 
+    List<ChannelInfo> getChannelInfoByOperator(Integer operator);
+
     List<ChannelSupplier> getSupplierInfo(String supplierName);
 
     List<FireProductInfo> getChannelProduct(Integer operator);
@@ -27,8 +29,6 @@ public interface ChannelInfoService extends IService<ChannelInfo> {
 
     void insertChannelInfo(ChannelInfo channelInfo);
 
-    void saveOrUpdateChannelInfos(List<ChannelInfo> channelInfos);
-
     void deleteChannelAndChanProdByChannelId(Long channelId);
 
     int deleteChannelBySupplierId(Long supplierId);

+ 3 - 1
modules/admin/src/main/java/com/fire/admin/service/DistGroupChannelService.java

@@ -15,7 +15,9 @@ public interface DistGroupChannelService extends IService<DistributeGroupChannel
 
     List<DistributeGroupChannel> getChannelInfoByDistGroupId(Long distGroupId);
 
-    void saveOrUpdateChannel(List<DistributeGroupChannel> channels);
+    void saveOrUpdateChannels(List<DistributeGroupChannel> channels);
 
     int removeChannelByDistGroupId(Long id);
+
+    void removeChannelById(Long id);
 }

+ 1 - 1
modules/admin/src/main/java/com/fire/admin/service/DistributeGroupService.java

@@ -15,7 +15,7 @@ public interface DistributeGroupService extends IService<DistributeGroup> {
 
     List<DistributeGroup> getDistributeGroupList(Long channelGroupId);
 
-    void saveDistributeGroups(List<DistributeGroup> distributeGroup);
+    void saveOrUpdateDistributeGroups(List<DistributeGroup> distributeGroup);
 
     int removeDistributeGroupByChannelGroupId(Long channelGroupId);
 

+ 11 - 1
modules/admin/src/main/java/com/fire/admin/service/impl/BankCardServiceImpl.java

@@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fire.admin.mapper.BankCardMapper;
 import com.fire.admin.service.BankCardService;
 import com.fire.admin.util.SecurityUtil;
+import com.fire.common.exception.BaseException;
 import com.fire.dto.BankCard;
+import com.fire.dto.enums.Status;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import redis.clients.jedis.JedisCluster;
@@ -31,7 +33,7 @@ public class BankCardServiceImpl extends ServiceImpl<BankCardMapper, BankCard> i
     private JedisCluster jedisCluster;
 
     /**
-     * @Description: TODO 获取银行列表,distinguish :1 供应商  2: 客户
+     * @Description: TODO 获取银行列表,distinguish :1 供应商  2: 客户
      * @Param: [relationId, distinguish]
      * @return: java.util.List<com.fire.dto.BankCard>
      * @Date: 2021/6/16 11:44
@@ -60,8 +62,14 @@ public class BankCardServiceImpl extends ServiceImpl<BankCardMapper, BankCard> i
                     bankCard.setUpdateTime(new Date());
                     log.info("修改的银行卡是:【{}】", bankCards);
                 }
+
+                if (bankCard.getCardNo() == null) {
+                    throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
+                }
             }
             this.saveOrUpdateBatch(bankCards);
+        } else {
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
 
@@ -72,6 +80,8 @@ public class BankCardServiceImpl extends ServiceImpl<BankCardMapper, BankCard> i
             if (result > 0) {
                 log.info("编号为:【{}】的银行卡删除成功!", bankId);
             }
+        } else {
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
 }

+ 17 - 6
modules/admin/src/main/java/com/fire/admin/service/impl/ChannelGroupServiceImpl.java

@@ -7,10 +7,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fire.admin.mapper.ChannelGroupMapper;
 import com.fire.admin.request.ChannelGroupPageParam;
 import com.fire.admin.service.ChannelGroupService;
+import com.fire.admin.service.DistGroupChannelService;
 import com.fire.admin.service.DistributeGroupService;
 import com.fire.admin.util.SecurityUtil;
 import com.fire.common.exception.BaseException;
 import com.fire.dto.ChannelGroup;
+import com.fire.dto.DistributeGroup;
 import com.fire.dto.enums.Status;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
@@ -43,6 +45,9 @@ public class ChannelGroupServiceImpl extends ServiceImpl<ChannelGroupMapper, Cha
     @Resource
     private DistributeGroupService distributeGroupService;
 
+    @Resource
+    private DistGroupChannelService distGroupChannelService;
+
     @Resource
     private RocketMQTemplate rocketMQTemplate;
 
@@ -62,6 +67,7 @@ public class ChannelGroupServiceImpl extends ServiceImpl<ChannelGroupMapper, Cha
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void addChannelGroup(ChannelGroup channelGroup) {
         if (channelGroup != null) {
             if (channelGroup.getChannelGroupId() == null) {
@@ -75,11 +81,12 @@ public class ChannelGroupServiceImpl extends ServiceImpl<ChannelGroupMapper, Cha
                 log.info("添加的通道组是:【{}】", channelGroup);
             }
         } else {
-            throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void updateChannelGroupById(ChannelGroup channelGroup) {
         if (channelGroup != null) {
             channelGroup.setUpdator(SecurityUtil.getUser().getUsername());
@@ -91,27 +98,31 @@ public class ChannelGroupServiceImpl extends ServiceImpl<ChannelGroupMapper, Cha
             }
 
             if (ObjectUtil.isNotEmpty(channelGroup.getDistributeGroups())) {
-                distributeGroupService.saveDistributeGroups(channelGroup.getDistributeGroups());
+                distributeGroupService.saveOrUpdateDistributeGroups(channelGroup.getDistributeGroups());
+            }
+
+            for (DistributeGroup distributeGroup : channelGroup.getDistributeGroups()) {
+                distGroupChannelService.saveOrUpdateChannels(distributeGroup.getChannels());
             }
 
         } else {
-            throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
 
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public void delChanGrouAndDistGrouByChanGrouId(Long channelGroupId) {
         if (channelGroupId != null) {
             int channelGroupResult = baseMapper.deleteById(channelGroupId);
             int distributeGroupResult = distributeGroupService.removeDistributeGroupByChannelGroupId(channelGroupId);
-            if (channelGroupResult > 0 && distributeGroupResult > 0) {
+            if (channelGroupResult > 0 || distributeGroupResult > 0) {
                 rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
                 log.info("编号为【{}】的通道组删除成功!", channelGroupId);
                 log.info("通道组编号为【{}】的分发组删除成功!", channelGroupId);
             }
         } else {
-            throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
 

+ 38 - 37
modules/admin/src/main/java/com/fire/admin/service/impl/ChannelInfoServiceImpl.java

@@ -1,6 +1,7 @@
 package com.fire.admin.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -71,6 +72,19 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
         return null;
     }
 
+    @Override
+    public List<ChannelInfo> getChannelInfoByOperator(Integer operator) {
+        if (operator != null) {
+            LambdaQueryWrapper<ChannelInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+            lambdaQueryWrapper.eq(ChannelInfo::getOperator, operator);
+            List<ChannelInfo> channelInfos = baseMapper.selectList(lambdaQueryWrapper);
+            if (ObjectUtil.isNotEmpty(channelInfos)) {
+                return channelInfos;
+            }
+        }
+        return null;
+    }
+
     @Override
     public List<ChannelSupplier> getSupplierInfo(String supplierName) {
         return supplierService.getSupplierInfo(supplierName);
@@ -86,6 +100,7 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void updateChannelInfoById(ChannelInfo channelInfo) {
         if (channelInfo != null) {
             channelInfo.setUpdator(SecurityUtil.getUser().getUsername());
@@ -100,12 +115,13 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
                 log.info("添加的通道产品是:【{}】", channelInfo.getChannelProductInfos().toString());
             }
         } else {
-            throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
 
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void insertChannelInfo(ChannelInfo channelInfo) {
         if (channelInfo != null) {
             if (channelInfo.getChannelId() == null) {
@@ -124,49 +140,29 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
                 log.info("添加的通道是:【{}】", channelInfo);
             }
         } else {
-            throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
 
     }
 
     @Override
-    public void saveOrUpdateChannelInfos(List<ChannelInfo> channelInfos) {
-        if (ObjectUtil.isNotEmpty(channelInfos)) {
-            for (ChannelInfo info : channelInfos) {
-                if (info.getChannelId() == null) {
-                    info.setChannelId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
-                    info.setCreator(SecurityUtil.getUser().getUsername());
-                    info.setCreateTime(new Date());
-                    log.info("添加的通道是:", channelInfos);
-                } else {
-                    info.setUpdator(SecurityUtil.getUser().getUsername());
-                    info.setUpdateTime(new Date());
-                    log.info("修改的通道是:", channelInfos);
-                }
-            }
-            this.saveOrUpdateBatch(channelInfos);
-        } else {
-            throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
-        }
-    }
-
-    @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public void deleteChannelAndChanProdByChannelId(Long channelId) {
         if (channelId != null) {
             int channelResult = baseMapper.deleteById(channelId);
             int channelProductResult = channelProductService.deleteChannelProductByChanId(channelId);
-            if (channelResult > 0 && channelProductResult > 0) {
+            if (channelResult > 0 || channelProductResult > 0) {
                 rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
                 log.info("编号为:【{}】的通道删除成功!", channelId);
                 log.info("通道编号为:【{}】的通道产品删除成功!", channelId);
             }
         } else {
-            throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int deleteChannelBySupplierId(Long supplierId) {
         if (supplierId != null) {
             Map<String, Object> map = new HashMap<>();
@@ -179,7 +175,7 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
                 return 0;
             }
         } else {
-            throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
 
@@ -192,23 +188,28 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
                 return result;
             }
         } else {
-            throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
         return 0;
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void setInvalid(Long channelId, Integer isValid) {
-        ChannelInfo channelInfo = ChannelInfo.builder().channelId(channelId)
-                .isValid(isValid).build();
-        int result = baseMapper.updateById(channelInfo);
-        if (result > 0) {
-            rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
-            if (channelInfo.getIsValid() == 0) {
-                log.info("编号为【{}】的通道已置无效", channelId);
-            } else {
-                log.info("编号为【{}】的通道已置有效", channelId);
+        if (channelId != null && isValid != null) {
+            ChannelInfo channelInfo = ChannelInfo.builder().channelId(channelId)
+                    .isValid(isValid).build();
+            int result = baseMapper.updateById(channelInfo);
+            if (result > 0) {
+                rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
+                if (channelInfo.getIsValid() == 0) {
+                    log.info("编号为【{}】的通道已置无效", channelId);
+                } else {
+                    log.info("编号为【{}】的通道已置有效", channelId);
+                }
             }
+        } else {
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
 }

+ 7 - 2
modules/admin/src/main/java/com/fire/admin/service/impl/ChannelProductServiceImpl.java

@@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
 import org.springframework.messaging.support.MessageBuilder;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import redis.clients.jedis.JedisCluster;
 
 import javax.annotation.Resource;
@@ -70,10 +71,13 @@ public class ChannelProductServiceImpl extends ServiceImpl<ChannelProductMapper,
             if (result) {
                 rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
             }
+        } else {
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void deleteChannelProductByChanProdId(Long channelProductId) {
         if (channelProductId != null) {
             int result = baseMapper.deleteById(channelProductId);
@@ -82,11 +86,12 @@ public class ChannelProductServiceImpl extends ServiceImpl<ChannelProductMapper,
                 log.info("通道产品编号为【{}】的通道产品删除成功!", channelProductId);
             }
         } else {
-            throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int deleteChannelProductByChanId(Long channelId) {
         if (channelId != null) {
             Map<String, Object> map = new HashMap<>();
@@ -98,7 +103,7 @@ public class ChannelProductServiceImpl extends ServiceImpl<ChannelProductMapper,
             }
             return 0;
         } else {
-            throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
 

+ 36 - 4
modules/admin/src/main/java/com/fire/admin/service/impl/DistGroupChannelServiceImpl.java

@@ -4,11 +4,14 @@ import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fire.admin.mapper.DistGroupChannelMapper;
 import com.fire.admin.service.DistGroupChannelService;
+import com.fire.common.exception.BaseException;
 import com.fire.dto.DistributeGroupChannel;
+import com.fire.dto.enums.Status;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
 import org.springframework.messaging.support.MessageBuilder;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import redis.clients.jedis.JedisCluster;
 
 import javax.annotation.Resource;
@@ -46,21 +49,33 @@ public class DistGroupChannelServiceImpl extends ServiceImpl<DistGroupChannelMap
     }
 
     @Override
-    public void saveOrUpdateChannel(List<DistributeGroupChannel> channels) {
+    public void saveOrUpdateChannels(List<DistributeGroupChannel> channels) {
         if (ObjectUtil.isNotEmpty(channels)) {
-            for (DistributeGroupChannel info : channels) {
-                if (info.getId() == null) {
-                    info.setId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
+            for (DistributeGroupChannel channel : channels) {
+                if (channel.getId() == null) {
+                    channel.setId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
                     log.info("添加的通道是:", channels);
                 } else {
                     log.info("修改的通道是:", channels);
                 }
+
+                if (channel.getChannelGroupId() == null) {
+                    channel.setChannelGroupId(1L);
+                }
+
+                if (channel.getWeight() == null) {
+                    throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
+                }
+
             }
             this.saveOrUpdateBatch(channels);
+        } else {
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int removeChannelByDistGroupId(Long distGroupId) {
         if (distGroupId != null) {
             Map<String, Object> map = new HashMap<>();
@@ -68,9 +83,26 @@ public class DistGroupChannelServiceImpl extends ServiceImpl<DistGroupChannelMap
             int result = baseMapper.deleteByMap(map);
             if (result > 0) {
                 rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
+                log.info("分发组编号为【{}】的通道删除成功!", distGroupId);
                 return result;
             }
+        } else {
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
         return 0;
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void removeChannelById(Long id) {
+        if (id != null) {
+            int result = baseMapper.deleteById(id);
+            if (result > 0) {
+                rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
+                log.info("编号为【{}】的通道删除成功!", id);
+            }
+        } else {
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
+        }
+    }
 }

+ 31 - 7
modules/admin/src/main/java/com/fire/admin/service/impl/DistributeGroupServiceImpl.java

@@ -9,11 +9,13 @@ import com.fire.admin.service.DistributeGroupService;
 import com.fire.admin.util.SecurityUtil;
 import com.fire.common.exception.BaseException;
 import com.fire.dto.DistributeGroup;
+import com.fire.dto.DistributeGroupChannel;
 import com.fire.dto.enums.Status;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
 import org.springframework.messaging.support.MessageBuilder;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import redis.clients.jedis.JedisCluster;
 
 import javax.annotation.Resource;
@@ -60,34 +62,53 @@ public class DistributeGroupServiceImpl extends ServiceImpl<DistributeGroupMappe
     }
 
     @Override
-    public void saveDistributeGroups(List<DistributeGroup> distributeGroups) {
+    public void saveOrUpdateDistributeGroups(List<DistributeGroup> distributeGroups) {
         if (ObjectUtil.isNotEmpty(distributeGroups)) {
             for (DistributeGroup distributeGroup : distributeGroups) {
                 if (distributeGroup.getDistributeGroupId() == null) {
                     distributeGroup.setDistributeGroupId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
                     distributeGroup.setCreator(SecurityUtil.getUser().getUsername());
                     distributeGroup.setCreateTime(new Date());
-                    if (distributeGroup.getChannelGroupId() == null) {
-                        distributeGroup.setChannelId(1L);
-                    }
                     log.info("添加的分发组是:", distributeGroups);
                 } else {
                     distributeGroup.setUpdator(SecurityUtil.getUser().getUsername());
                     distributeGroup.setUpdateTime(new Date());
                     log.info("修改的分发组是:", distributeGroups);
                 }
+
+                if (distributeGroup.getName() == null) {
+                    throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
+                }
+
+                if (distributeGroup.getChannelGroupId() == null) {
+                    distributeGroup.setChannelGroupId(1L);
+                }
+
+                if (distributeGroup.getWeight() == null) {
+                    throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
+                }
+
             }
             boolean result = this.saveOrUpdateBatch(distributeGroups);
+
+            for (DistributeGroup distributeGroup : distributeGroups) {
+                Long distributeGroupId = distributeGroup.getDistributeGroupId();
+                for (DistributeGroupChannel channel : distributeGroup.getChannels()) {
+                    channel.setDistributeGroupId(distributeGroupId);
+                }
+            }
+
             if (result) {
                 rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
                 log.info("分发组是:【{}】", distributeGroups);
             }
         } else {
-            throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int removeDistributeGroupByChannelGroupId(Long channelGroupId) {
         if (channelGroupId != null) {
             Map<String, Object> map = new HashMap<>();
@@ -97,23 +118,26 @@ public class DistributeGroupServiceImpl extends ServiceImpl<DistributeGroupMappe
                 rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
                 return result;
             }
+        } else {
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
         return 0;
     }
 
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void removeDistGroupAndChannelByDistGroupId(Long distGroupId) {
         if (distGroupId != null) {
             int distResult = baseMapper.deleteById(distGroupId);
             int channelResult = distGroupChannelService.removeChannelByDistGroupId(distGroupId);
-            if (distResult > 0 && channelResult > 0) {
+            if (distResult > 0 || channelResult > 0) {
                 rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
                 log.info("编号为【{}】的分发组删除成功!", distGroupId);
                 log.info("分发组编号为【{}】的通道删除成功!", distGroupId);
             }
         } else {
-            throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
 

+ 27 - 11
modules/admin/src/main/java/com/fire/admin/service/impl/SupplierServiceImpl.java

@@ -79,6 +79,7 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void updateSupplierById(ChannelSupplier channelSupplier) {
         if (channelSupplier != null) {
             channelSupplier.setUpdator(SecurityUtil.getUser().getUsername());
@@ -105,11 +106,21 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void saveSupplier(ChannelSupplier channelSupplier) {
         if (channelSupplier != null) {
             channelSupplier.setSupplierId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
             channelSupplier.setCreator(SecurityUtil.getUser().getUsername());
             channelSupplier.setCreateTime(new Date());
+            List<ChannelSupplier> supplierList = this.getSupplierInfo(null);
+            if (ObjectUtil.isNotEmpty(supplierList)) {
+                for (ChannelSupplier supplier : supplierList) {
+                    String supplierName = supplier.getSupplierName();
+                    if (channelSupplier.getSupplierName().equals(supplierName)) {
+                        throw new BaseException(Status.RECORDING_EXISTS.status(), Status.RECORDING_EXISTS.message());
+                    }
+                }
+            }
             int result = baseMapper.insert(channelSupplier);
             if (result > 0) {
                 jedisCluster.hset(SUPPLIER_AMOUNT.key(), SUPPLIER_AMOUNT.key() + channelSupplier.getSupplierId(), "0");
@@ -122,12 +133,12 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
     }
 
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public void deleteSupplierAndChannelBySupplierId(Long supplierId) {
         if (supplierId != null) {
             int supplierResult = baseMapper.deleteById(supplierId);
             int channelResult = channelInfoService.deleteChannelBySupplierId(supplierId);
-            if (supplierResult > 0 && channelResult > 0) {
+            if (supplierResult > 0 || channelResult > 0) {
                 rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
                 log.info("编号为:【{}】的供应商删除成功!", supplierId);
                 log.info("供应商编号为:【{}】的通道删除成功!", supplierId);
@@ -138,17 +149,22 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void setInvalid(Long supplierId, Integer isValid) {
-        ChannelSupplier channelSupplier = ChannelSupplier.builder().supplierId(supplierId)
-                .isValid(isValid).build();
-        int result = baseMapper.updateById(channelSupplier);
-        if (result > 0) {
-            rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
-            if (channelSupplier.getIsValid() == 0) {
-                log.info("编号为【{}】的供应商已置无效", supplierId);
-            } else {
-                log.info("编号为【{}】的供应商已置有效", supplierId);
+        if (supplierId != null && isValid != null) {
+            ChannelSupplier channelSupplier = ChannelSupplier.builder().supplierId(supplierId)
+                    .isValid(isValid).build();
+            int result = baseMapper.updateById(channelSupplier);
+            if (result > 0) {
+                rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
+                if (channelSupplier.getIsValid() == 0) {
+                    log.info("编号为【{}】的供应商已置无效", supplierId);
+                } else {
+                    log.info("编号为【{}】的供应商已置有效", supplierId);
+                }
             }
+        } else {
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
 }

+ 6 - 3
modules/admin/src/main/resources/mapper/DistGroupChannelMapper.xml

@@ -5,6 +5,7 @@
     <resultMap id="distGroupChannelResultMap" type="com.fire.dto.DistributeGroupChannel">
         <id column="id" property="id"/>
         <result column="channel_id" property="channelId"/>
+        <result column="channel_name" property="channelName"/>
         <result column="channel_group_id" property="channelGroupId"/>
         <result column="distribute_group_id" property="distributeGroupId"/>
         <result column="weight" property="weight"/>
@@ -13,18 +14,20 @@
     <sql id="common_field">
         aci.channel_id,
         aci.channel_name,
+        dgc.id,
         dgc.weight
     </sql>
 
     <select id="getChannelInfoByDistGroupId" resultMap="distGroupChannelResultMap">
         SELECT
         <include refid="common_field"/>
-        FROM access_channel_info AS aci LEFT JOIN distribute_group_channel AS dgc
+        FROM distribute_group_channel AS dgc LEFT JOIN access_channel_info AS aci
         ON aci.channel_id = dgc.channel_id
         <where>
-            aci.is_delete = 0
+           <if test="distGroupId!=null">
+               dgc.distribute_group_id = #{distGroupId}
+           </if>
         </where>
-            ORDER BY aci.create_time DESC
     </select>
 
 </mapper>