杜魏 4 yıl önce
ebeveyn
işleme
ad8ac08791

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

@@ -90,12 +90,7 @@ public class ChannelInfoRest {
     @DeleteMapping("/delete/{channelId}")
     @ApiOperation(value = "通道逻辑删除", notes = "delete_channelInfo.py")
     public BaseResponse deleteChannelById(@PathVariable("channelId") Long channelId) {
-        try {
-            channelInfoService.deleteChannelAndChanProdByChannelId(channelId);
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error("参数异常!");
-        }
+        channelInfoService.deleteChannelAndChanProdAndChanMiddByChannelId(channelId);
         return new BaseResponse();
     }
 

+ 1 - 6
modules/admin/src/main/java/com/fire/admin/rest/ChannelSupplierRest.java

@@ -57,12 +57,7 @@ public class ChannelSupplierRest {
     @DeleteMapping("/delete/{supplierId}")
     @ApiOperation(value = "删除供应商", notes = "supplier_delete.py")
     public BaseResponse deleteSupplierBySupplierId(@PathVariable("supplierId") Long supplierId) {
-        try {
-            supplierService.deleteSupplierAndChannelBySupplierId(supplierId);
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error("参数异常!");
-        }
+        supplierService.deleteSupplierAndChannelBySupplierId(supplierId);
         return new BaseResponse();
     }
 

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

@@ -29,7 +29,7 @@ public interface ChannelInfoService extends IService<ChannelInfo> {
 
     void insertChannelInfo(ChannelInfo channelInfo);
 
-    void deleteChannelAndChanProdByChannelId(Long channelId);
+    void deleteChannelAndChanProdAndChanMiddByChannelId(Long channelId);
 
     int deleteChannelBySupplierId(Long supplierId);
 

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

@@ -20,4 +20,6 @@ public interface DistGroupChannelService extends IService<DistributeGroupChannel
     int removeChannelByDistGroupId(Long id);
 
     void removeChannelById(Long id);
+
+    int removeChannelByChannelId(Long channelId);
 }

+ 16 - 2
modules/admin/src/main/java/com/fire/admin/service/impl/ChannelGroupServiceImpl.java

@@ -88,6 +88,7 @@ public class ChannelGroupServiceImpl extends ServiceImpl<ChannelGroupMapper, Cha
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void updateChannelGroupById(ChannelGroup channelGroup) {
+//        Integer count = 0;
         if (channelGroup != null) {
             channelGroup.setUpdator(SecurityUtil.getUser().getUsername());
             channelGroup.setUpdateTime(new Date());
@@ -102,11 +103,22 @@ public class ChannelGroupServiceImpl extends ServiceImpl<ChannelGroupMapper, Cha
             }
 
             for (DistributeGroup distributeGroup : channelGroup.getDistributeGroups()) {
+               /* List<DistributeGroupChannel> channelList = distGroupChannelService.getChannelInfoByDistGroupId(distributeGroup.getDistributeGroupId());
+                if (channelList.size() > 1) {
+                    for (int i = 0; i < channelList.size() - 1; i++) {
+                        if (channelList.get(i).getChannelName().equals(channelList.get(i + 1).getChannelName())) {
+                            count++;
+                        }
+                        if (count > 1) {
+                            throw new BaseException("不能添加重复通道!");
+                        }
+                    }
+                }*/
                 distGroupChannelService.saveOrUpdateChannels(distributeGroup.getChannels());
             }
 
         } else {
-            throw new BaseException(Status.PARAM_LOSS.status(),Status.PARAM_LOSS.message());
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
 
@@ -116,9 +128,11 @@ public class ChannelGroupServiceImpl extends ServiceImpl<ChannelGroupMapper, Cha
         if (channelGroupId != null) {
             int channelGroupResult = baseMapper.deleteById(channelGroupId);
             int distributeGroupResult = distributeGroupService.removeDistributeGroupByChannelGroupId(channelGroupId);
-            if (channelGroupResult > 0 || distributeGroupResult > 0) {
+            if (channelGroupResult > 0) {
                 rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
                 log.info("编号为【{}】的通道组删除成功!", channelGroupId);
+            }
+            if (distributeGroupResult > 0) {
                 log.info("通道组编号为【{}】的分发组删除成功!", channelGroupId);
             }
         } else {

+ 14 - 6
modules/admin/src/main/java/com/fire/admin/service/impl/ChannelInfoServiceImpl.java

@@ -10,6 +10,7 @@ import com.fire.admin.mapper.FireProductMapper;
 import com.fire.admin.request.ChannelPageParam;
 import com.fire.admin.service.ChannelInfoService;
 import com.fire.admin.service.ChannelProductService;
+import com.fire.admin.service.DistGroupChannelService;
 import com.fire.admin.service.SupplierService;
 import com.fire.admin.util.SecurityUtil;
 import com.fire.common.exception.BaseException;
@@ -51,6 +52,9 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
     @Resource
     private ChannelProductService channelProductService;
 
+    @Resource
+    private DistGroupChannelService distGroupChannelService;
+
     @Resource
     private FireProductMapper fireProductMapper;
 
@@ -147,15 +151,21 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void deleteChannelAndChanProdByChannelId(Long channelId) {
+    public void deleteChannelAndChanProdAndChanMiddByChannelId(Long channelId) {
         if (channelId != null) {
             int channelResult = baseMapper.deleteById(channelId);
             int channelProductResult = channelProductService.deleteChannelProductByChanId(channelId);
-            if (channelResult > 0 || channelProductResult > 0) {
+            int channelMiddleResult = distGroupChannelService.removeChannelByChannelId(channelId);
+            if (channelResult > 0) {
                 rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
                 log.info("编号为:【{}】的通道删除成功!", channelId);
+            }
+            if (channelProductResult > 0) {
                 log.info("通道编号为:【{}】的通道产品删除成功!", channelId);
             }
+            if (channelMiddleResult > 0) {
+                log.info("通道编号为:【{}】的通道删除成功!", channelId);
+            }
         } else {
             throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
@@ -169,11 +179,9 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
             map.put("supplier_id", supplierId);
             int result = baseMapper.deleteByMap(map);
             if (result > 0) {
-                rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
                 return result;
-            } else {
-                return 0;
             }
+            return 0;
         } else {
             throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
@@ -187,10 +195,10 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
                 log.info("编号为【{}】的通道删除成功!", channelId);
                 return result;
             }
+            return 0;
         } else {
             throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
-        return 0;
     }
 
     @Override

+ 5 - 4
modules/admin/src/main/java/com/fire/admin/service/impl/ChannelProductServiceImpl.java

@@ -45,10 +45,11 @@ public class ChannelProductServiceImpl extends ServiceImpl<ChannelProductMapper,
     public List<ChannelProductInfo> getChannelProductList(Long channelId) {
         List<ChannelProductInfo> channelProductInfos = new LambdaQueryChainWrapper<>(baseMapper)
                 .eq(channelId != null, ChannelProductInfo::getChannelId, channelId).list();
+
         if (channelProductInfos != null) {
-            /*for (ChannelProductInfo info : channelProductInfos) {
+            for (ChannelProductInfo info : channelProductInfos) {
                 info.setFacePrice(info.getFacePrice()/10000);
-            }*/
+            }
             return channelProductInfos;
         }
         return null;
@@ -64,7 +65,8 @@ public class ChannelProductServiceImpl extends ServiceImpl<ChannelProductMapper,
                 } else {
                     log.info("通道产品已修改为:【{}】", channelProductInfos);
                 }
-                info.setDiscount((new BigDecimal(info.getPrice()).divide(new BigDecimal(10000))).divide(new BigDecimal(info.getFacePrice()), 4, BigDecimal.ROUND_DOWN));
+                info.setFacePrice(info.getFacePrice() * 10000);
+                info.setDiscount((new BigDecimal(info.getPrice()).divide(new BigDecimal(info.getFacePrice()), 4, BigDecimal.ROUND_DOWN)));
             }
 
             boolean result = this.saveOrUpdateBatch(channelProductInfos);
@@ -98,7 +100,6 @@ public class ChannelProductServiceImpl extends ServiceImpl<ChannelProductMapper,
             map.put("channel_id", channelId);
             int result = baseMapper.deleteByMap(map);
             if (result > 0) {
-                rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
                 return result;
             }
             return 0;

+ 15 - 8
modules/admin/src/main/java/com/fire/admin/service/impl/DistGroupChannelServiceImpl.java

@@ -59,11 +59,6 @@ public class DistGroupChannelServiceImpl extends ServiceImpl<DistGroupChannelMap
                     log.info("修改的通道是:", channels);
                 }
 
-
-                /*if (channels.get(channels.size() - 1).getChannelName().equals(channels.get(channels.size()).getChannelName())) {
-                    throw new BaseException("通道不能重复!"*//*Status.RECORDING_EXISTS.status(), Status.RECORDING_EXISTS.message()*//*);
-                }*/
-
                 if (channel.getChannelGroupId() == null) {
                     channel.setChannelGroupId(1L);
                 }
@@ -85,14 +80,12 @@ public class DistGroupChannelServiceImpl extends ServiceImpl<DistGroupChannelMap
             map.put("distribute_group_id", distGroupId);
             int result = baseMapper.deleteByMap(map);
             if (result > 0) {
-                rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
-                log.info("分发组编号为【{}】的通道删除成功!", distGroupId);
                 return result;
             }
+            return 0;
         } else {
             throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
-        return 0;
     }
 
     @Override
@@ -108,4 +101,18 @@ public class DistGroupChannelServiceImpl extends ServiceImpl<DistGroupChannelMap
             throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
     }
+
+    public int removeChannelByChannelId(Long channelId) {
+        if (channelId != null) {
+            Map<String, Object> map = new HashMap<>();
+            map.put("channel_id", channelId);
+            int result = baseMapper.deleteByMap(map);
+            if (result > 0) {
+                return result;
+            }
+            return 0;
+        } else {
+            throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
+        }
+    }
 }

+ 5 - 3
modules/admin/src/main/java/com/fire/admin/service/impl/DistributeGroupServiceImpl.java

@@ -113,13 +113,12 @@ public class DistributeGroupServiceImpl extends ServiceImpl<DistributeGroupMappe
             map.put("channel_group_id", channelGroupId);
             int result = baseMapper.deleteByMap(map);
             if (result > 0) {
-                rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
                 return result;
             }
+            return 0;
         } else {
             throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
         }
-        return 0;
     }
 
 
@@ -129,9 +128,12 @@ public class DistributeGroupServiceImpl extends ServiceImpl<DistributeGroupMappe
         if (distGroupId != null) {
             int distResult = baseMapper.deleteById(distGroupId);
             int channelResult = distGroupChannelService.removeChannelByDistGroupId(distGroupId);
-            if (distResult > 0 || channelResult > 0) {
+            if (distResult > 0) {
                 rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
                 log.info("编号为【{}】的分发组删除成功!", distGroupId);
+            }
+            if (channelResult > 0) {
+                rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
                 log.info("分发组编号为【{}】的通道删除成功!", distGroupId);
             }
         } else {

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

@@ -138,9 +138,11 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
         if (supplierId != null) {
             int supplierResult = baseMapper.deleteById(supplierId);
             int channelResult = channelInfoService.deleteChannelBySupplierId(supplierId);
-            if (supplierResult > 0 || channelResult > 0) {
+            if (supplierResult > 0) {
                 rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
                 log.info("编号为:【{}】的供应商删除成功!", supplierId);
+            }
+            if (channelResult > 0) {
                 log.info("供应商编号为:【{}】的通道删除成功!", supplierId);
             }
         } else {