Explorar el Código

bug处理 供应商银行卡

杜魏 hace 4 años
padre
commit
49d91bbe84

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

@@ -42,8 +42,11 @@ public class ChannelProductInfo {
     @ApiModelProperty("备注")
     private String remark;
 
-    @ApiModelProperty("产品是否有效(默认Y)")
-    private String channelProductStatus;
+    @ApiModelProperty("产品是否有效 0-无效 1-有效")
+    private Integer isValid;
+
+    @ApiModelProperty("结算价格百分比")
+    private Double discount;
 
     @TableField(exist = false)
     private ChannelInfo channelInfo;

+ 1 - 0
modules/admin/src/main/java/com/fire/admin/mapper/ChannelProductMapper.java

@@ -11,4 +11,5 @@ import com.fire.dto.ChannelProductInfo;
  */
 public interface ChannelProductMapper extends BaseMapper<ChannelProductInfo> {
 
+
 }

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

@@ -4,6 +4,7 @@ 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;
@@ -12,6 +13,8 @@ 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:
@@ -50,14 +53,17 @@ public class ChannelInfoRest {
 
     @PutMapping("/update")
     @ApiModelProperty(value = "修改通道", notes = "update_channelInfo.py")
-    public BaseResponse updateChannelInfo(@RequestBody ChannelInfo channelInfo) {
-        channelInfoService.updateChannelInfoById(channelInfo);
-        return new BaseResponse();
+    public BaseRestResponse updateChannelInfo(@RequestBody ChannelInfo channelInfo) {
+        List<ChannelProductInfo> channelProductInfoList = channelInfoService.updateChannelInfoById(channelInfo);
+        if (channelProductInfoList != null) {
+            return new BaseRestResponse(channelProductInfoList);
+        } else {
+            return new BaseRestResponse(null);
+        }
     }
 
     @PutMapping("/delete")
     @ApiOperation(value = "通道逻辑删除", notes = "delete_channelInfo.py")
-
     public BaseResponse deleteChannelById(Integer ChannelId) {
         channelInfoService.deleteChannelById(ChannelId);
         return new BaseResponse();

+ 4 - 6
modules/admin/src/main/java/com/fire/admin/rest/ChannelProductInfoRest.java

@@ -1,7 +1,5 @@
 package com.fire.admin.rest;
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.fire.admin.request.ChannelProductPageParam;
 import com.fire.admin.service.ChannelProductService;
 import com.fire.dto.ChannelProductInfo;
 import com.fire.dto.response.BaseRestResponse;
@@ -9,10 +7,11 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModelProperty;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 /**
  * @author: admin
  * @Description:
@@ -33,8 +32,8 @@ public class ChannelProductInfoRest {
 
     @PostMapping("/list")
     @ApiModelProperty(value = "通道产品列表", notes = "channelProduct_list.py")
-    public BaseRestResponse channelProductList(@RequestBody ChannelProductPageParam channelProductPageParam) {
-        IPage<ChannelProductInfo> channelProductList = channelProductService.getChannelProductList(channelProductPageParam);
+    public BaseRestResponse channelProductList(Long channelId) {
+        List<ChannelProductInfo> channelProductList = channelProductService.getChannelProductList(channelId);
         if (channelProductList != null) {
             return new BaseRestResponse(channelProductList);
         } else {
@@ -43,5 +42,4 @@ public class ChannelProductInfoRest {
     }
 
 
-
 }

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

@@ -37,7 +37,7 @@ public class ChannelSupplierRest {
     @PostMapping("/list")
     @ApiOperation(value = "供应商列表", notes = "supplier_list.py")
     public BaseRestResponse supplierList(@RequestBody SupplierPageParam supplierPageParam) {
-        IPage<ChannelSupplier> supplierList = supplierService.getSupplierList(supplierPageParam, supplierPageParam.getSupplierName());
+        IPage<ChannelSupplier> supplierList = supplierService.getSupplierList(supplierPageParam);
         if (supplierList != null) {
             return new BaseRestResponse(supplierList);
         } else {

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

@@ -4,6 +4,9 @@ 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 java.util.List;
 
 /**
  * @author: admin
@@ -15,7 +18,9 @@ public interface ChannelInfoService extends IService<ChannelInfo> {
 
     IPage<ChannelInfo> getChannelList(ChannelPageParam channelPageParam);
 
-    void updateChannelInfoById(ChannelInfo channelInfo);
+    
+
+    List<ChannelProductInfo> updateChannelInfoById(ChannelInfo channelInfo);
 
     void insertChannelInfo(ChannelInfo channelInfo);
 

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

@@ -1,10 +1,10 @@
 package com.fire.admin.service;
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.fire.admin.request.ChannelProductPageParam;
 import com.fire.dto.ChannelProductInfo;
 
+import java.util.List;
+
 /**
  * @author: admin
  * @Description:
@@ -13,6 +13,8 @@ import com.fire.dto.ChannelProductInfo;
  */
 public interface ChannelProductService extends IService<ChannelProductInfo> {
 
-    IPage<ChannelProductInfo> getChannelProductList(ChannelProductPageParam channelProductPageParam);
+    List<ChannelProductInfo> getChannelProductList(Long channelId);
+
+    void saveChannelProducts(List<ChannelProductInfo> channelProductInfos);
 
 }

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

@@ -1,8 +1,8 @@
 package com.fire.admin.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.fire.admin.request.SupplierPageParam;
 import com.fire.dto.BankCard;
 import com.fire.dto.ChannelSupplier;
 
@@ -16,7 +16,7 @@ import java.util.List;
  */
 public interface SupplierService extends IService<ChannelSupplier> {
 
-    IPage<ChannelSupplier> getSupplierList(Page page, String supplierName);
+    IPage<ChannelSupplier> getSupplierList(SupplierPageParam supplierPageParam);
 
     List<BankCard> updateSupplierBySupplierId(ChannelSupplier channelSupplier);
 

+ 2 - 3
modules/admin/src/main/java/com/fire/admin/service/impl/BankCardServiceImpl.java

@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapp
 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.dto.BankCard;
 import org.springframework.stereotype.Service;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -34,9 +33,9 @@ public class BankCardServiceImpl extends ServiceImpl<BankCardMapper, BankCard> i
     @Override
     public void saveBankCards(@RequestBody List<BankCard> bankCards) {
         for (BankCard bankCard : bankCards) {
-            bankCard.setCreator(SecurityUtil.getUser().getUsername());
+            bankCard.setCreator("admin");
             bankCard.setCreateTime(new Date());
-            bankCard.setUpdator(SecurityUtil.getUser().getUsername());
+            bankCard.setUpdator("admin");
             bankCard.setUpdateTime(new Date());
         }
         if (bankCards != null) {

+ 36 - 3
modules/admin/src/main/java/com/fire/admin/service/impl/ChannelInfoServiceImpl.java

@@ -6,9 +6,17 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fire.admin.mapper.ChannelInfoMapper;
 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 org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
 /**
  * @author: admin
  * @Description:
@@ -18,15 +26,29 @@ import org.springframework.stereotype.Service;
 @Service
 public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, ChannelInfo> implements ChannelInfoService {
 
+    @Autowired
+    private ChannelProductService channelProductService;
+
     @Override
     public IPage<ChannelInfo> getChannelList(ChannelPageParam channelPageParam) {
         LambdaQueryWrapper<ChannelInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-        lambdaQueryWrapper.eq(channelPageParam.getChannelId() != null, ChannelInfo::getChannelId, channelPageParam.getSupplierId())
+        lambdaQueryWrapper.eq(channelPageParam.getChannelId() != null, ChannelInfo::getChannelId, channelPageParam.getChannelId())
                 .eq(channelPageParam.getSupplierId() != null, ChannelInfo::getSupplierId, channelPageParam.getSupplierId())
-                .eq(channelPageParam.getChannelName() != null, ChannelInfo::getChannelName, channelPageParam.getChannelName())
+                .like(channelPageParam.getChannelName() != null, ChannelInfo::getChannelName, channelPageParam.getChannelName())
                 .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()));
+            }
             return channelInfoList;
         } else {
             return null;
@@ -34,15 +56,26 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
     }
 
     @Override
-    public void updateChannelInfoById(ChannelInfo channelInfo) {
+    public List<ChannelProductInfo> updateChannelInfoById(ChannelInfo channelInfo) {
         int result = baseMapper.updateById(channelInfo);
         if (result > 0) {
             // TODO: 2021/5/24 向MQ推送消息
         }
+        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推送消息

+ 16 - 9
modules/admin/src/main/java/com/fire/admin/service/impl/ChannelProductServiceImpl.java

@@ -1,14 +1,14 @@
 package com.fire.admin.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-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.ChannelProductMapper;
-import com.fire.admin.request.ChannelProductPageParam;
 import com.fire.admin.service.ChannelProductService;
 import com.fire.dto.ChannelProductInfo;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @author: admin
  * @Description:
@@ -19,14 +19,21 @@ import org.springframework.stereotype.Service;
 public class ChannelProductServiceImpl extends ServiceImpl<ChannelProductMapper, ChannelProductInfo> implements ChannelProductService {
 
     @Override
-    public IPage<ChannelProductInfo> getChannelProductList(ChannelProductPageParam channelProductPageParam) {
-        QueryWrapper<ChannelProductInfo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq(channelProductPageParam.getChannelId() != null, "channel_id", channelProductPageParam.getChannelId());
-        IPage<ChannelProductInfo> channelProductInfoIPage = baseMapper.selectPage(channelProductPageParam, queryWrapper);
-        if (channelProductInfoIPage != null) {
-            return channelProductInfoIPage;
+    public List<ChannelProductInfo> getChannelProductList(Long channelId) {
+        List<ChannelProductInfo> channelProductInfos = new LambdaQueryChainWrapper<>(baseMapper)
+                        .eq(channelId != null, ChannelProductInfo::getChannelId, channelId).list();
+        if (channelProductInfos != null) {
+            return channelProductInfos;
         } else {
             return null;
         }
     }
+
+    @Override
+    public void saveChannelProducts(List<ChannelProductInfo> channelProductInfos) {
+        boolean result = this.saveOrUpdateBatch(channelProductInfos);
+        if (result) {
+            // TODO: 2021/5/25 向MQ推送消息
+        }
+    }
 }

+ 25 - 9
modules/admin/src/main/java/com/fire/admin/service/impl/SupplierServiceImpl.java

@@ -3,9 +3,9 @@ package com.fire.admin.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 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;
@@ -14,8 +14,11 @@ 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
@@ -31,12 +34,25 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
     private BankCardService bankCardService;
 
     @Override
-    public IPage<ChannelSupplier> getSupplierList(Page page, String supplierName) {
+    public IPage<ChannelSupplier> getSupplierList(SupplierPageParam supplierPageParam) {
         LambdaQueryWrapper<ChannelSupplier> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-        lambdaQueryWrapper.eq(supplierName != null, ChannelSupplier::getSupplierName, supplierName)
-                .eq(ChannelSupplier::getIsDelete, 0);
-        IPage<ChannelSupplier> supplierList = baseMapper.selectPage(page, lambdaQueryWrapper);
+        lambdaQueryWrapper.like(supplierPageParam.getSupplierName() != null, ChannelSupplier::getSupplierName, supplierPageParam.getSupplierName())
+                .eq(ChannelSupplier::getIsDelete, 0)
+                .orderByDesc(ChannelSupplier::getBalance, ChannelSupplier::getIsValid);
+        IPage<ChannelSupplier> supplierList = baseMapper.selectPage(supplierPageParam, lambdaQueryWrapper);
+
         if (supplierList != null) {
+            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));
+            for (ChannelSupplier supplier : supplierList.getRecords()) {
+                supplier.setBankCards(bankCardMap.get(supplier.getSupplierId()));
+            }
             return supplierList;
         } else {
             return null;
@@ -50,13 +66,13 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
         LambdaUpdateWrapper<ChannelSupplier> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
         lambdaUpdateWrapper.eq(channelSupplier.getSupplierId() != null, ChannelSupplier::getSupplierId, channelSupplier.getSupplierId());
         int result = baseMapper.update(channelSupplier, lambdaUpdateWrapper);
-        List<BankCard> bankCardList = bankCardService.getBankCardList(channelSupplier.getSupplierId());
-        if (channelSupplier.getBankCards() != null) {
-            bankCardService.saveBankCards(channelSupplier.getBankCards());
-        }
         if (result > 0) {
             // TODO: 2021/5/18 向MQ推送消息
         }
+        if (channelSupplier.getBankCards() != null) {
+            bankCardService.saveBankCards(channelSupplier.getBankCards());
+        }
+        List<BankCard> bankCardList = bankCardService.getBankCardList(channelSupplier.getSupplierId());
         if (bankCardList != null) {
             return bankCardList;
         } else {