Jelajahi Sumber

完善通道及通道产品

杜魏 4 tahun lalu
induk
melakukan
3ec072e3c5

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

@@ -1,5 +1,6 @@
 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;
@@ -23,7 +24,7 @@ import java.util.List;
 @TableName("access_channel_info")
 public class ChannelInfo {
 
-    @TableId("channel_id")
+    @TableId(value = "channel_id",type = IdType.AUTO)
     @ApiModelProperty("通道id")
     private Long channelId;
 
@@ -33,8 +34,8 @@ public class ChannelInfo {
     @ApiModelProperty("通道名称")
     private String channelName;
 
-    @ApiModelProperty("对应运营商产品ID YD:移动 LT:联通 DX:电信")
-    private String operatorCode;
+    @ApiModelProperty("对应运营商 1:移动 2:电信 3:联通")
+    private Integer operator;
 
     @ApiModelProperty("是否有效 0:无效 1:有效")
     private Integer isValid;

+ 2 - 1
common/fire-dto/src/main/java/com/fire/dto/ChannelProductInfo.java

@@ -1,5 +1,6 @@
 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;
@@ -20,7 +21,7 @@ import lombok.NoArgsConstructor;
 @TableName("channel_product_info")
 public class ChannelProductInfo {
 
-    @TableId("channel_product_id")
+    @TableId(value = "channel_product_id", type = IdType.AUTO)
     @ApiModelProperty("主键")
     private Long channelProductId;
 

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

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.fire.admin.request.ChannelPageParam;
 import com.fire.admin.service.ChannelInfoService;
 import com.fire.dto.ChannelInfo;
-import com.fire.dto.ChannelProductInfo;
 import com.fire.dto.response.BaseResponse;
 import com.fire.dto.response.BaseRestResponse;
 import io.swagger.annotations.Api;
@@ -13,8 +12,6 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.List;
-
 /**
  * @author: admin
  * @Description:
@@ -53,13 +50,9 @@ public class ChannelInfoRest {
 
     @PutMapping("/update")
     @ApiModelProperty(value = "修改通道", notes = "update_channelInfo.py")
-    public BaseRestResponse updateChannelInfo(@RequestBody ChannelInfo channelInfo) {
-        List<ChannelProductInfo> channelProductInfoList = channelInfoService.updateChannelInfoById(channelInfo);
-        if (channelProductInfoList != null) {
-            return new BaseRestResponse(channelProductInfoList);
-        } else {
-            return new BaseRestResponse(null);
-        }
+    public BaseResponse updateChannelInfo(@RequestBody ChannelInfo channelInfo) {
+        channelInfoService.updateChannelInfoById(channelInfo);
+        return new BaseResponse();
     }
 
     @PutMapping("/delete")

+ 3 - 10
modules/admin/src/main/java/com/fire/admin/rest/ChannelSupplierRest.java

@@ -3,7 +3,6 @@ package com.fire.admin.rest;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.fire.admin.request.SupplierPageParam;
 import com.fire.admin.service.SupplierService;
-import com.fire.dto.BankCard;
 import com.fire.dto.ChannelSupplier;
 import com.fire.dto.response.BaseResponse;
 import com.fire.dto.response.BaseRestResponse;
@@ -13,8 +12,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.List;
-
 /**
  * @author: admin
  * @Description:
@@ -54,13 +51,9 @@ public class ChannelSupplierRest {
 
     @PostMapping("/update")
     @ApiOperation(value = "修改供应商", notes = "supplier_update.py")
-    public BaseRestResponse updateSupplierBySupplierId(@RequestBody ChannelSupplier channelSupplier) {
-        List<BankCard> bankCardList = supplierService.updateSupplierBySupplierId(channelSupplier);
-        if (bankCardList != null) {
-            return new BaseRestResponse(bankCardList);
-        } else {
-            return new BaseRestResponse(null);
-        }
+    public BaseResponse updateSupplierBySupplierId(@RequestBody ChannelSupplier channelSupplier) {
+        supplierService.updateSupplierBySupplierId(channelSupplier);
+        return new BaseResponse();
     }
 
     @PutMapping("/delete")

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

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fire.admin.request.ChannelPageParam;
 import com.fire.dto.ChannelInfo;
-import com.fire.dto.ChannelProductInfo;
+import com.fire.dto.FireProductInfo;
 
 import java.util.List;
 
@@ -18,9 +18,9 @@ public interface ChannelInfoService extends IService<ChannelInfo> {
 
     IPage<ChannelInfo> getChannelList(ChannelPageParam channelPageParam);
 
-    
+    List<FireProductInfo> getProductByProductName(Integer operator);
 
-    List<ChannelProductInfo> updateChannelInfoById(ChannelInfo channelInfo);
+    void updateChannelInfoById(ChannelInfo channelInfo);
 
     void insertChannelInfo(ChannelInfo channelInfo);
 

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

@@ -3,11 +3,8 @@ package com.fire.admin.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fire.admin.request.SupplierPageParam;
-import com.fire.dto.BankCard;
 import com.fire.dto.ChannelSupplier;
 
-import java.util.List;
-
 /**
  * @author: admin
  * @Description:
@@ -18,7 +15,7 @@ public interface SupplierService extends IService<ChannelSupplier> {
 
     IPage<ChannelSupplier> getSupplierList(SupplierPageParam supplierPageParam);
 
-    List<BankCard> updateSupplierBySupplierId(ChannelSupplier channelSupplier);
+    void updateSupplierBySupplierId(ChannelSupplier channelSupplier);
 
     void saveSupplier(ChannelSupplier channelSupplier);
 

+ 33 - 24
modules/admin/src/main/java/com/fire/admin/service/impl/ChannelInfoServiceImpl.java

@@ -2,20 +2,21 @@ package com.fire.admin.service.impl;
 
 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;
 import com.fire.admin.mapper.ChannelInfoMapper;
+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.dto.ChannelInfo;
 import com.fire.dto.ChannelProductInfo;
+import com.fire.dto.FireProductInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
 
 /**
  * @author: admin
@@ -29,6 +30,9 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
     @Autowired
     private ChannelProductService channelProductService;
 
+    @Autowired
+    private FireProductMapper fireProductMapper;
+
     @Override
     public IPage<ChannelInfo> getChannelList(ChannelPageParam channelPageParam) {
         LambdaQueryWrapper<ChannelInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -38,16 +42,9 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
                 .eq(ChannelInfo::getIsDelete, 0);
         IPage<ChannelInfo> channelInfoList = baseMapper.selectPage(channelPageParam, lambdaQueryWrapper);
         if (channelInfoList != null) {
-            List<Long> channelInfoIds = new ArrayList<>();
-            for (ChannelInfo channelInfo : channelInfoList.getRecords()) {
-                channelInfoIds.add(channelInfo.getChannelId());
-            }
-
-            List<ChannelProductInfo> channelProductInfos = new ArrayList<>();
 
-            Map<Long, List<ChannelProductInfo>> map = channelProductInfos.stream().collect(Collectors.groupingBy(ChannelProductInfo::getChannelId));
-            for (ChannelInfo channelInfo : channelInfoList.getRecords()) {
-                channelInfo.setChannelProductInfos(map.get(channelInfo.getChannelId()));
+            for (ChannelInfo info : channelInfoList.getRecords()) {
+                info.setChannelProductInfos(channelProductService.getChannelProductList(info.getChannelId()));
             }
             return channelInfoList;
         } else {
@@ -56,7 +53,14 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
     }
 
     @Override
-    public List<ChannelProductInfo> updateChannelInfoById(ChannelInfo channelInfo) {
+    public List<FireProductInfo> getProductByProductName(Integer operator) {
+        return new LambdaQueryChainWrapper<>(fireProductMapper).eq(operator != null, FireProductInfo::getOperator, operator).list();
+    }
+
+    @Override
+    public void updateChannelInfoById(ChannelInfo channelInfo) {
+        channelInfo.setUpdator("admin");
+        channelInfo.setUpdateTime(new Date());
         int result = baseMapper.updateById(channelInfo);
         if (result > 0) {
             // TODO: 2021/5/24 向MQ推送消息
@@ -64,27 +68,32 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
         if (channelInfo.getChannelProductInfos() != null) {
             channelProductService.saveChannelProducts(channelInfo.getChannelProductInfos());
         }
-        List<ChannelProductInfo> channelProductList = channelProductService.getChannelProductList(channelInfo.getChannelId());
-        if (channelProductList != null) {
-            return channelProductList;
-        } else {
-            return null;
-        }
 
     }
 
     @Override
     public void insertChannelInfo(ChannelInfo channelInfo) {
-
-        int result = baseMapper.insert(channelInfo);
-        if (result > 0) {
-            // TODO: 2021/5/24 向MQ推送消息
+        channelInfo.setCreator("admin");
+        channelInfo.setCreateTime(new Date());
+        List<FireProductInfo> fireProductInfos = this.getProductByProductName(channelInfo.getOperator());
+        List<ChannelProductInfo> channelProductInfos = channelInfo.getChannelProductInfos();
+        for (FireProductInfo fireProductInfo : fireProductInfos) {
+            String fireProductName = fireProductInfo.getProductName();
+            for (ChannelProductInfo channelProductInfo : channelProductInfos) {
+                String channelProductName = channelProductInfo.getChannelProductName();
+                if (fireProductInfos != null && !fireProductName.equals(channelProductName)) {
+                    int result = baseMapper.insert(channelInfo);
+                    if (result > 0) {
+                        // TODO: 2021/5/24 向MQ推送消息
+                    }
+                }
+            }
         }
     }
 
     @Override
     public void deleteChannelById(Integer channelId) {
-        int result = baseMapper.delChannelById(channelId);
+        int result = baseMapper.deleteById(channelId);
         if (result > 0) {
             // TODO: 2021/5/20 向MQ推送消息
         }

+ 10 - 16
modules/admin/src/main/java/com/fire/admin/service/impl/SupplierServiceImpl.java

@@ -8,17 +8,12 @@ import com.fire.admin.mapper.ChannelSupplierMapper;
 import com.fire.admin.request.SupplierPageParam;
 import com.fire.admin.service.BankCardService;
 import com.fire.admin.service.SupplierService;
-import com.fire.dto.BankCard;
 import com.fire.dto.ChannelSupplier;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
 import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
 
 /**
  * @author: admin
@@ -42,17 +37,21 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
         IPage<ChannelSupplier> supplierList = baseMapper.selectPage(supplierPageParam, lambdaQueryWrapper);
 
         if (supplierList != null) {
-            List<Integer> supplierIds = new ArrayList<>();
+           /* List<Integer> supplierIds = new ArrayList<>();
             for (ChannelSupplier supplier : supplierList.getRecords()) {
                 supplierIds.add(supplier.getSupplierId());
             }
 
             List<BankCard> bankCards = new ArrayList<>();
 
-            Map<Integer, List<BankCard>> bankCardMap = bankCards.stream().collect(Collectors.groupingBy(BankCard::getSupplierId));
+            Map<Integer, List<BankCard>> map = bankCards.stream().collect(Collectors.groupingBy(BankCard::getSupplierId));
             for (ChannelSupplier supplier : supplierList.getRecords()) {
-                supplier.setBankCards(bankCardMap.get(supplier.getSupplierId()));
+                supplier.setBankCards(map.get(supplier.getSupplierId()));
+            }*/
+            for (ChannelSupplier supplier : supplierList.getRecords()) {
+                supplier.setBankCards(bankCardService.getBankCardList(supplier.getSupplierId()));
             }
+
             return supplierList;
         } else {
             return null;
@@ -60,7 +59,7 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
     }
 
     @Override
-    public List<BankCard> updateSupplierBySupplierId(ChannelSupplier channelSupplier) {
+    public void updateSupplierBySupplierId(ChannelSupplier channelSupplier) {
         channelSupplier.setUpdator("admin");
         channelSupplier.setUpdateTime(new Date());
         LambdaUpdateWrapper<ChannelSupplier> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
@@ -72,12 +71,7 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
         if (channelSupplier.getBankCards() != null) {
             bankCardService.saveBankCards(channelSupplier.getBankCards());
         }
-        List<BankCard> bankCardList = bankCardService.getBankCardList(channelSupplier.getSupplierId());
-        if (bankCardList != null) {
-            return bankCardList;
-        } else {
-            return null;
-        }
+
     }
 
     @Override
@@ -92,7 +86,7 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
 
     @Override
     public void deleteSupplierBySupplierId(Integer supplierId) {
-        int result = baseMapper.deleteSupplierById(supplierId);
+        int result = baseMapper.deleteById(supplierId);
         if (result > 0) {
             // TODO:2021/5/18 向MQ推送消息
         }