Bläddra i källkod

供应商加款

杜魏 4 år sedan
förälder
incheckning
1e4ebafe55
21 ändrade filer med 366 tillägg och 120 borttagningar
  1. 4 4
      common/fire-dto/src/main/java/com/fire/dto/ChannelInfo.java
  2. 4 0
      common/fire-dto/src/main/java/com/fire/dto/ChannelSupplier.java
  3. 15 7
      modules/admin/src/main/java/com/fire/admin/mapper/AdditionalPaymentMapper.java
  4. 1 1
      modules/admin/src/main/java/com/fire/admin/rest/BankCardRest.java
  5. 9 2
      modules/admin/src/main/java/com/fire/admin/rest/ChannelInfoRest.java
  6. 6 0
      modules/admin/src/main/java/com/fire/admin/rest/ChannelSupplierRest.java
  7. 60 0
      modules/admin/src/main/java/com/fire/admin/rest/SupplierAdditionalPaymentController.java
  8. 35 14
      modules/admin/src/main/java/com/fire/admin/service/AdditionalPaymentService.java
  9. 1 1
      modules/admin/src/main/java/com/fire/admin/service/BankCardService.java
  10. 1 0
      modules/admin/src/main/java/com/fire/admin/service/ChannelInfoService.java
  11. 1 0
      modules/admin/src/main/java/com/fire/admin/service/SupplierService.java
  12. 89 21
      modules/admin/src/main/java/com/fire/admin/service/impl/AdditionalPaymentServiceImpl.java
  13. 3 3
      modules/admin/src/main/java/com/fire/admin/service/impl/BankCardServiceImpl.java
  14. 7 5
      modules/admin/src/main/java/com/fire/admin/service/impl/ChannelGroupServiceImpl.java
  15. 49 25
      modules/admin/src/main/java/com/fire/admin/service/impl/ChannelInfoServiceImpl.java
  16. 10 8
      modules/admin/src/main/java/com/fire/admin/service/impl/ChannelProductServiceImpl.java
  17. 1 1
      modules/admin/src/main/java/com/fire/admin/service/impl/CustomerServiceImpl.java
  18. 5 5
      modules/admin/src/main/java/com/fire/admin/service/impl/DistributeGroupServiceImpl.java
  19. 37 16
      modules/admin/src/main/java/com/fire/admin/service/impl/SupplierServiceImpl.java
  20. 4 2
      modules/admin/src/main/java/com/fire/admin/vo/AdditionalPaymentVo.java
  21. 24 5
      modules/admin/src/main/resources/mapper/AdditionalPaymentMapper.xml

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

@@ -1,13 +1,11 @@
 package com.fire.dto;
 
 import com.baomidou.mybatisplus.annotation.*;
-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 com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
@@ -23,7 +21,9 @@ import java.util.Map;
  */
 @ApiModel("通道实体")
 @Data
+@Builder
 @NoArgsConstructor
+@AllArgsConstructor
 @TableName("access_channel_info")
 public class ChannelInfo {
 

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

@@ -3,6 +3,8 @@ package com.fire.dto;
 import com.baomidou.mybatisplus.annotation.*;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
@@ -17,7 +19,9 @@ import java.util.List;
  */
 @ApiModel("供应商实体")
 @Data
+@Builder
 @NoArgsConstructor
+@AllArgsConstructor
 @TableName("channel_supplier")
 public class ChannelSupplier {
 

+ 15 - 7
modules/admin/src/main/java/com/fire/admin/mapper/AdditionalPaymentMapper.java

@@ -20,12 +20,20 @@ public interface AdditionalPaymentMapper extends BaseMapper<AdditionalPayment> {
 
 
     /**
-    * @Description:  TODO  分页获取加款记录
-    * @Param: [page, additionalPaymentDto]
-    * @return: com.baomidou.mybatisplus.core.metadata.IPage<com.fire.admin.vo.AdditionalPaymentVo>
-    * @Author: liuliu
-    * @Date: 2021/6/7 12:24
-    */
-    IPage<AdditionalPaymentVo> selectAddiPayCustomerPageInfo(Page page,@Param("select")  AdditionalPaymentDto additionalPaymentDto);
+     * @Description: TODO  分页获取加款记录
+     * @Param: [page, additionalPaymentDto]
+     * @return: com.baomidou.mybatisplus.core.metadata.IPage<com.fire.admin.vo.AdditionalPaymentVo>
+     * @Author: liuliu
+     * @Date: 2021/6/7 12:24
+     */
+    IPage<AdditionalPaymentVo> selectAddiPayCustomerPageInfo(Page page, @Param("select") AdditionalPaymentDto additionalPaymentDto);
+
+    /**
+     * @param page
+     * @param additionalPaymentDto
+     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.fire.admin.vo.AdditionalPaymentVo>
+     * @Description: 分页获取供应商加款记录
+     */
+    IPage<AdditionalPaymentVo> getSupplierAddPayPageInfo(Page page, @Param("info") AdditionalPaymentDto additionalPaymentDto);
 
 }

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

@@ -53,7 +53,7 @@ public class BankCardRest {
     @PostMapping("/add")
     @ApiOperation(value = "批量添加银行卡", notes = "add_bankcards.py")
     public BaseResponse addBankCard(@RequestBody List<BankCard> bankCards) {
-        bankCardService.saveBankCards(bankCards);
+        bankCardService.saveOrUpdateBankCards(bankCards);
         return new BaseResponse();
     }
 

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

@@ -25,7 +25,7 @@ import java.util.List;
  */
 @Api(tags = "通道相关接口")
 @RestController
-@RequestMapping("channel")
+@RequestMapping("/channel")
 @Slf4j
 public class ChannelInfoRest {
 
@@ -36,7 +36,7 @@ public class ChannelInfoRest {
         this.channelInfoService = channelInfoService;
     }
 
-    @PostMapping("list")
+    @PostMapping("/list")
     @ApiOperation(value = "通道列表", notes = "channel_list.py")
     public BaseRestResponse channelInfoList(@RequestBody ChannelPageParam channelPageParam) {
         IPage<ChannelInfo> channelList = channelInfoService.getChannelList(channelPageParam);
@@ -94,4 +94,11 @@ public class ChannelInfoRest {
         }
         return new BaseResponse();
     }
+
+    @PutMapping("/setIsValid")
+    @ApiOperation(value = "置无效/有效", notes = "set_isvalid.py")
+    public BaseResponse setInvalid(Long channelId, Integer isValid) {
+        channelInfoService.setInvalid(channelId, isValid);
+        return new BaseResponse();
+    }
 }

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

@@ -68,4 +68,10 @@ public class ChannelSupplierRest {
         return new BaseResponse();
     }
 
+    @PutMapping("/setIsValid")
+    @ApiOperation(value = "置无效/有效", notes = "set_invalid.py")
+    public BaseResponse setInvalid(Long supplierId, Integer isValid) {
+        supplierService.setInvalid(supplierId, isValid);
+        return new BaseResponse();
+    }
 }

+ 60 - 0
modules/admin/src/main/java/com/fire/admin/rest/SupplierAdditionalPaymentController.java

@@ -0,0 +1,60 @@
+package com.fire.admin.rest;
+
+import com.fire.admin.dto.AdditionalPaymentDto;
+import com.fire.admin.service.AdditionalPaymentService;
+import com.fire.dto.response.BaseResponse;
+import com.fire.dto.response.BaseRestResponse;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+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;
+
+/**
+ * @author: admin
+ * @Description:
+ * @date: 2021-06-11 10:00
+ * @Modified By:
+ */
+@Api(tags = "供应商加款相关接口")
+@RestController
+@RequestMapping("/supplierPayment")
+public class SupplierAdditionalPaymentController {
+
+    private AdditionalPaymentService additionalPaymentService;
+
+    @Autowired
+    public SupplierAdditionalPaymentController(AdditionalPaymentService additionalPaymentService) {
+        this.additionalPaymentService = additionalPaymentService;
+    }
+
+    @ApiOperation("供应商加款")
+    @PostMapping("/add")
+    public BaseResponse makeAdditionalPayment(@RequestBody AdditionalPaymentDto additionalPaymentDto) {
+        additionalPaymentService.insertSupplierAdditionalPayment(additionalPaymentDto);
+        return new BaseResponse();
+    }
+
+
+    @ApiOperation("分页获取供应商加款信息")
+    @PostMapping("/list")
+    public BaseRestResponse makeGetAdditionalPaymentPage(@RequestBody AdditionalPaymentDto additionalPaymentDto) {
+        return new BaseRestResponse(additionalPaymentService.getSupplierAdditionalPaymentPage(additionalPaymentDto));
+    }
+
+    @ApiOperation("更改加款记录,只能更改凭证,其余的都不能修改")
+    @PostMapping("/update")
+    public BaseResponse makeUpdateAdditionalPayment(@RequestBody AdditionalPaymentDto additionalPaymentDto) {
+        additionalPaymentService.updAdditionPayment(additionalPaymentDto);
+        return new BaseResponse();
+    }
+
+
+    @ApiOperation("供应商加款撤销")
+    @PostMapping("/cancel")
+    public BaseRestResponse additionalPayment(@RequestBody AdditionalPaymentDto additionalPaymentDto) {
+        return new BaseRestResponse(additionalPaymentService.cancelSupplierAdditionalPayment(additionalPaymentDto));
+    }
+}

+ 35 - 14
modules/admin/src/main/java/com/fire/admin/service/AdditionalPaymentService.java

@@ -1,7 +1,6 @@
 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.dto.AdditionalPaymentDto;
 import com.fire.admin.vo.AdditionalPaymentVo;
@@ -25,6 +24,13 @@ public interface AdditionalPaymentService extends IService<AdditionalPayment> {
      */
     void insertAdditionalPaymen(AdditionalPaymentDto additionalPaymentDto);
 
+    /**
+     * @Description: 供应商加款新增
+     * @Param: [additionalPaymentDto]
+     * @return: void
+     * @Date: 2021/6/4 15:57
+     */
+    void insertSupplierAdditionalPayment(AdditionalPaymentDto additionalPaymentDto);
 
     /**
      * @Description: TODO 分页获取客户账户信息
@@ -35,25 +41,40 @@ public interface AdditionalPaymentService extends IService<AdditionalPayment> {
      */
     IPage<AdditionalPaymentVo> getAdditionalPaymentPage(AdditionalPaymentDto additionalPaymentDto);
 
+    /**
+     * @Description: TODO 分页获取供应商账户信息
+     * @Param: [additionalPaymentDto]
+     * @return: com.baomidou.mybatisplus.core.metadata.IPage<com.fire.admin.vo.AdditionalPaymentVo>
+     * @Date: 2021/6/7 14:26
+     */
+    IPage<AdditionalPaymentVo> getSupplierAdditionalPaymentPage(AdditionalPaymentDto additionalPaymentDto);
 
 
     /**
-    * @Description:  TODO 修改客户信息
-    * @Param: [additionalPaymentDto]
-    * @return: void
-    * @Author: liuliu
-    * @Date: 2021/6/7 16:50
-    */
-    void  updAdditionPayment(AdditionalPaymentDto additionalPaymentDto);
+     * @Description: TODO 修改客户信息
+     * @Param: [additionalPaymentDto]
+     * @return: void
+     * @Author: liuliu
+     * @Date: 2021/6/7 16:50
+     */
+    void updAdditionPayment(AdditionalPaymentDto additionalPaymentDto);
 
 
     /**
-    * @Description:  TODO 客户加款撤销
-    * @Param: [additionalPaymentDto]
-    * @return: void
-    * @Author: liuliu
-    * @Date: 2021/6/8 14:58
-    */
+     * @Description: TODO 客户加款撤销
+     * @Param: [additionalPaymentDto]
+     * @return: void
+     * @Author: liuliu
+     * @Date: 2021/6/8 14:58
+     */
     String cancelAdditionalPayment(AdditionalPaymentDto additionalPaymentDto);
 
+    /**
+     * @Description: 供应商加款撤销
+     * @Param: [additionalPaymentDto]
+     * @return: void
+     * @Author: liuliu
+     * @Date: 2021/6/8 14:58
+     */
+    String cancelSupplierAdditionalPayment(AdditionalPaymentDto additionalPaymentDto);
 }

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

@@ -22,7 +22,7 @@ public interface BankCardService extends IService<BankCard> {
      */
     List<BankCard> getBankCardList(Long relationId, Integer distinguish);
 
-    void saveBankCards(List<BankCard> bankCards);
+    void saveOrUpdateBankCards(List<BankCard> bankCards);
 
     void deleteBankCards(Long id);
 

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

@@ -29,4 +29,5 @@ public interface ChannelInfoService extends IService<ChannelInfo> {
 
     void deleteChannelById(Long id);
 
+    void setInvalid(Long channelId, Integer isValid);
 }

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

@@ -27,4 +27,5 @@ public interface SupplierService extends IService<ChannelSupplier> {
 
     void deleteBankCardById(Long bankId);
 
+    void setInvalid(Long supplierId, Integer isValid);
 }

+ 89 - 21
modules/admin/src/main/java/com/fire/admin/service/impl/AdditionalPaymentServiceImpl.java

@@ -1,6 +1,5 @@
 package com.fire.admin.service.impl;
 
-import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -17,17 +16,14 @@ import com.fire.common.redis.RedisAmountScript;
 import com.fire.dto.AdditionalPayment;
 import com.fire.dto.CustomerInfo;
 import com.fire.dto.enums.Status;
-import com.fire.utils.date.DateUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import redis.clients.jedis.JedisCluster;
 
 import java.math.BigDecimal;
-import java.time.LocalDateTime;
 
-import static com.fire.dto.enums.RedisKey.CUSTOMER_AMOUNT;
-import static com.fire.dto.enums.RedisKey.GLOBAL_ID_INCR;
+import static com.fire.dto.enums.RedisKey.*;
 
 /**
  * @author: liuliu
@@ -45,11 +41,11 @@ public class AdditionalPaymentServiceImpl extends ServiceImpl<AdditionalPaymentM
     private JedisCluster jedisCluster;
 
     @Autowired
-    public AdditionalPaymentServiceImpl(AliyunOSSUtil aliyunOSSUtil, RedisAmountScript redisAmountScript,CustomerService customerService,JedisCluster jedisCluster) {
+    public AdditionalPaymentServiceImpl(AliyunOSSUtil aliyunOSSUtil, RedisAmountScript redisAmountScript, CustomerService customerService, JedisCluster jedisCluster) {
         this.aliyunOSSUtil = aliyunOSSUtil;
         this.redisAmountScript = redisAmountScript;
-        this.customerService=customerService;
-        this.jedisCluster=jedisCluster;
+        this.customerService = customerService;
+        this.jedisCluster = jedisCluster;
     }
 
     /**
@@ -77,6 +73,30 @@ public class AdditionalPaymentServiceImpl extends ServiceImpl<AdditionalPaymentM
 
     }
 
+    /**
+     * @Description: TODO 供应商新增加款记录
+     * @Param: [additionalPaymentDto]
+     * @return: void
+     * @Date: 2021/6/4 15:28
+     */
+    @Override
+    public void insertSupplierAdditionalPayment(AdditionalPaymentDto additionalPaymentDto) {
+        if (additionalPaymentDto.getType().equals("supplier")) {
+            additionalPaymentDto.setDistinguish(1);
+            // TODO 客户加款
+            int count = this.additionalPayment(additionalPaymentDto);
+            if (count > 0) {
+                // TODO 加款成功之后,把加款的金额写入数据库
+                redisAmountScript.changeAmount(SUPPLIER_AMOUNT.key(), Long.getLong(additionalPaymentDto.getRelationId()), "add", additionalPaymentDto.getAmount().multiply(new BigDecimal(10000)).longValue(), 0L);
+            }
+        } else if (additionalPaymentDto.getType().equals("suppler")) {
+            additionalPaymentDto.setDistinguish(1);
+            // TODO 供应商加款
+            this.additionalPayment(additionalPaymentDto);
+        }
+
+    }
+
     /**
      * @Description: TODO  客户和供应商加款共用和方法
      * @Param: [additionalPaymentDto]
@@ -88,7 +108,7 @@ public class AdditionalPaymentServiceImpl extends ServiceImpl<AdditionalPaymentM
 
         if (ObjectUtil.isNotEmpty(additionalPaymentDto.getType()) && ObjectUtil.isNotEmpty(additionalPaymentDto.getRelationId())) {
             AdditionalPayment payment = AdditionalPayment.builder()
-                    .id( jedisCluster.incr(GLOBAL_ID_INCR.key()))
+                    .id(jedisCluster.incr(GLOBAL_ID_INCR.key()))
                     .cardNo(additionalPaymentDto.getCardNo())
                     .bankDeposit(additionalPaymentDto.getBankDeposit())
                     .account(additionalPaymentDto.getAccount())
@@ -129,6 +149,25 @@ public class AdditionalPaymentServiceImpl extends ServiceImpl<AdditionalPaymentM
         return baseMapper.selectAddiPayCustomerPageInfo(page, additionalPaymentDto);
     }
 
+    /**
+     * @Description: TODO  分页获取供应商加款信息
+     * @Param: [additionalPaymentDto]
+     * @return: com.baomidou.mybatisplus.core.metadata.IPage<com.fire.admin.vo.AdditionalPaymentVo>
+     * @Date: 2021/6/7 14:28
+     */
+    @Override
+    public IPage<AdditionalPaymentVo> getSupplierAdditionalPaymentPage(AdditionalPaymentDto additionalPaymentDto) {
+
+        Page page = new Page();
+        //  对前端页码及每页显示的数量进行处理
+        if (ObjectUtil.isNotEmpty(additionalPaymentDto.getCurrent()) && ObjectUtil.isNotEmpty(additionalPaymentDto.getSize())) {
+            page.setSize(additionalPaymentDto.getSize());
+            page.setCurrent(additionalPaymentDto.getCurrent());
+        }
+
+        return baseMapper.getSupplierAddPayPageInfo(page, additionalPaymentDto);
+    }
+
 
     /**
      * @Description: TODO 修改客户加款信息
@@ -145,17 +184,17 @@ public class AdditionalPaymentServiceImpl extends ServiceImpl<AdditionalPaymentM
     }
 
     /**
-    * @Description:  TODO  客户账单撤销
-    * @Param:
-    * @return: void
-    * @Author: liuliu
-    * @Date: 2021/6/8 14:57
-    */
+     * @Description: TODO  客户账单撤销
+     * @Param:
+     * @return: void
+     * @Author: liuliu
+     * @Date: 2021/6/8 14:57
+     */
     @Override
     public String cancelAdditionalPayment(AdditionalPaymentDto additionalPaymentDto) {
 
         // TODO  客户的撤销
-        if(ObjectUtil.isNotEmpty(additionalPaymentDto.getRelationId()) && additionalPaymentDto.getType().equals("customer")){
+        if (ObjectUtil.isNotEmpty(additionalPaymentDto.getRelationId()) && additionalPaymentDto.getType().equals("customer")) {
             additionalPaymentDto.setUndo(1);
             // TODO  实例化对象
             AdditionalPayment payment = this.formatAdditionalPaymentDto(additionalPaymentDto);
@@ -163,10 +202,39 @@ public class AdditionalPaymentServiceImpl extends ServiceImpl<AdditionalPaymentM
             int count = baseMapper.updateById(payment);
             // TODO 获取客户授信金额
             CustomerInfo customerInfo = customerService.getcustomerOne(Long.parseLong(payment.getRelationId()));
-            if(count >0){
+            if (count > 0) {
+                // TODO 撤销
+                Long amount = redisAmountScript.changeAmount(CUSTOMER_AMOUNT.key(), Long.parseLong(payment.getRelationId()), "sub", payment.getAmount(), customerInfo.getCreditAmount());
+                log.info("客户加款撤销。 客户编号为:【{}】 撤销金额为:【{}】 ,授信额度为:【{}】 剩余额度为:【{}】", payment.getRelationId(), additionalPaymentDto.getAmount(), new BigDecimal(customerInfo.getCreditAmount()).divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_DOWN), new BigDecimal(amount).divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_DOWN));
+                return payment.getRelationId().concat("_").concat(amount.toString());
+            }
+        }
+
+        return null;
+
+    }
+
+    /**
+     * @Description: TODO  客户账单撤销
+     * @Param: additionalPaymentDto
+     * @return: void
+     * @Date: 2021/6/8 14:57
+     */
+    @Override
+    public String cancelSupplierAdditionalPayment(AdditionalPaymentDto additionalPaymentDto) {
+
+        // 供应商的撤销
+        if (ObjectUtil.isNotEmpty(additionalPaymentDto.getRelationId()) && additionalPaymentDto.getType().equals("supplier")) {
+            additionalPaymentDto.setUndo(1);
+            //  实例化对象
+            AdditionalPayment payment = this.formatAdditionalPaymentDto(additionalPaymentDto);
+            //  修改记录的撤销状态
+            int count = baseMapper.updateById(payment);
+
+            if (count > 0) {
                 // TODO 撤销
-                Long  amount = redisAmountScript.changeAmount(CUSTOMER_AMOUNT.key(), Long.parseLong(payment.getRelationId()), "sub", payment.getAmount(), customerInfo.getCreditAmount());
-                log.info("客户加款撤销。 客户编号为:【{}】 撤销金额为:【{}】 ,授信额度为:【{}】 剩余额度为:【{}】",payment.getRelationId(),additionalPaymentDto.getAmount(),new BigDecimal(customerInfo.getCreditAmount()).divide(new BigDecimal("10000"),2,BigDecimal.ROUND_DOWN),new BigDecimal(amount).divide(new BigDecimal("10000"),2,BigDecimal.ROUND_DOWN));
+                Long amount = redisAmountScript.changeAmount(SUPPLIER_AMOUNT.key(), Long.parseLong(payment.getRelationId()), "sub", payment.getAmount(),10000000L);
+                log.info("供应商加款撤销。 供应商编号为:【{}】 撤销金额为:【{}】 ,授信额度为:【{}】 剩余额度为:【{}】", payment.getRelationId(), additionalPaymentDto.getAmount(), new BigDecimal(10000000L).divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_DOWN), new BigDecimal(amount).divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_DOWN));
                 return payment.getRelationId().concat("_").concat(amount.toString());
             }
         }
@@ -175,8 +243,8 @@ public class AdditionalPaymentServiceImpl extends ServiceImpl<AdditionalPaymentM
 
     }
 
-    private AdditionalPayment formatAdditionalPaymentDto(AdditionalPaymentDto additionalPaymentDto){
-       return AdditionalPayment.builder()
+    private AdditionalPayment formatAdditionalPaymentDto(AdditionalPaymentDto additionalPaymentDto) {
+        return AdditionalPayment.builder()
                 .id(additionalPaymentDto.getId())
                 .relationId(additionalPaymentDto.getRelationId())
                 .amount(additionalPaymentDto.getAmount().multiply(new BigDecimal(10000)).longValue())

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

@@ -7,10 +7,10 @@ import com.fire.admin.mapper.BankCardMapper;
 import com.fire.admin.service.BankCardService;
 import com.fire.dto.BankCard;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import redis.clients.jedis.JedisCluster;
 
+import javax.annotation.Resource;
 import java.util.Date;
 import java.util.List;
 
@@ -26,7 +26,7 @@ import static com.fire.dto.enums.RedisKey.GLOBAL_ID_INCR;
 @Slf4j
 public class BankCardServiceImpl extends ServiceImpl<BankCardMapper, BankCard> implements BankCardService {
 
-    @Autowired
+    @Resource
     private JedisCluster jedisCluster;
 
     @Override
@@ -42,7 +42,7 @@ public class BankCardServiceImpl extends ServiceImpl<BankCardMapper, BankCard> i
     }
 
     @Override
-    public void saveBankCards(List<BankCard> bankCards) {
+    public void saveOrUpdateBankCards(List<BankCard> bankCards) {
         if (ObjectUtil.isNotEmpty(bankCards)) {
             for (BankCard bankCard : bankCards) {
                 if (bankCard.getId() == null) {

+ 7 - 5
modules/admin/src/main/java/com/fire/admin/service/impl/ChannelGroupServiceImpl.java

@@ -13,11 +13,11 @@ import com.fire.dto.ChannelGroup;
 import com.fire.dto.enums.Status;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.messaging.support.MessageBuilder;
 import org.springframework.stereotype.Service;
 import redis.clients.jedis.JedisCluster;
 
+import javax.annotation.Resource;
 import java.util.Date;
 import java.util.List;
 
@@ -35,13 +35,13 @@ import static com.fire.dto.enums.RedisKey.GLOBAL_ID_INCR;
 @Slf4j
 public class ChannelGroupServiceImpl extends ServiceImpl<ChannelGroupMapper, ChannelGroup> implements ChannelGroupService {
 
-    @Autowired
+    @Resource
     private JedisCluster jedisCluster;
 
-    @Autowired
+    @Resource
     private DistributeGroupService distributeGroupService;
 
-    @Autowired
+    @Resource
     private RocketMQTemplate rocketMQTemplate;
 
     @Override
@@ -63,7 +63,9 @@ public class ChannelGroupServiceImpl extends ServiceImpl<ChannelGroupMapper, Cha
     @Override
     public void addChannelGroup(ChannelGroup channelGroup) {
         if (channelGroup != null) {
-            channelGroup.setChannelGroupId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
+            if (channelGroup.getChannelGroupId() == null) {
+                channelGroup.setChannelGroupId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
+            }
             channelGroup.setCreator("admin");
             channelGroup.setCreateTime(new Date());
             int result = baseMapper.insert(channelGroup);

+ 49 - 25
modules/admin/src/main/java/com/fire/admin/service/impl/ChannelInfoServiceImpl.java

@@ -17,11 +17,11 @@ import com.fire.dto.FireProductInfo;
 import com.fire.dto.enums.Status;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.messaging.support.MessageBuilder;
 import org.springframework.stereotype.Service;
 import redis.clients.jedis.JedisCluster;
 
+import javax.annotation.Resource;
 import java.util.Date;
 import java.util.List;
 
@@ -39,19 +39,19 @@ import static com.fire.dto.enums.RedisKey.GLOBAL_ID_INCR;
 @Slf4j
 public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, ChannelInfo> implements ChannelInfoService {
 
-    @Autowired
+    @Resource
     private SupplierService supplierService;
 
-    @Autowired
+    @Resource
     private ChannelProductService channelProductService;
 
-    @Autowired
+    @Resource
     private FireProductMapper fireProductMapper;
 
-    @Autowired
+    @Resource
     private JedisCluster jedisCluster;
 
-    @Autowired
+    @Resource
     private RocketMQTemplate rocketMQTemplate;
 
     @Override
@@ -84,32 +84,41 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
 
     @Override
     public void updateChannelInfoById(ChannelInfo channelInfo) {
-        channelInfo.setUpdator("admin");
-        channelInfo.setUpdateTime(new Date());
-        int result = baseMapper.updateById(channelInfo);
-        if (result > 0) {
-            rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
-            log.info("通道已修改为:【{}】", channelInfo);
-        }
-        if (ObjectUtil.isNotEmpty(channelInfo.getChannelProductInfos())) {
-            channelProductService.saveChannelProducts(channelInfo.getChannelProductInfos());
-            log.info("添加的通道产品是:【{}】", channelInfo.getChannelProductInfos().toString());
+        if (channelInfo != null) {
+            channelInfo.setUpdator("admin");
+            channelInfo.setUpdateTime(new Date());
+            int result = baseMapper.updateById(channelInfo);
+            if (result > 0) {
+                rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
+                log.info("通道已修改为:【{}】", channelInfo);
+            }
+            if (ObjectUtil.isNotEmpty(channelInfo.getChannelProductInfos())) {
+                channelProductService.saveChannelProducts(channelInfo.getChannelProductInfos());
+                log.info("添加的通道产品是:【{}】", channelInfo.getChannelProductInfos().toString());
+            }
+        } else {
+            throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
         }
 
     }
 
     @Override
     public void insertChannelInfo(ChannelInfo channelInfo) {
-        if (channelInfo.getChannelId() == null) {
-            channelInfo.setChannelId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
-        }
-        channelInfo.setCreator("admin");
-        channelInfo.setCreateTime(new Date());
-        int result = baseMapper.insert(channelInfo);
-        if (result > 0) {
-            rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
-            log.info("添加的通道是:【{}】", channelInfo);
+        if (channelInfo != null) {
+            if (channelInfo.getChannelId() == null) {
+                channelInfo.setChannelId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
+            }
+            channelInfo.setCreator("admin");
+            channelInfo.setCreateTime(new Date());
+            int result = baseMapper.insert(channelInfo);
+            if (result > 0) {
+                rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
+                log.info("添加的通道是:【{}】", channelInfo);
+            }
+        } else {
+            throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
         }
+
     }
 
     @Override
@@ -124,4 +133,19 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
             throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
         }
     }
+
+    @Override
+    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);
+            }
+        }
+    }
 }

+ 10 - 8
modules/admin/src/main/java/com/fire/admin/service/impl/ChannelProductServiceImpl.java

@@ -8,11 +8,11 @@ import com.fire.admin.service.ChannelProductService;
 import com.fire.dto.ChannelProductInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.messaging.support.MessageBuilder;
 import org.springframework.stereotype.Service;
 import redis.clients.jedis.JedisCluster;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.util.List;
 
@@ -30,10 +30,10 @@ import static com.fire.dto.enums.RedisKey.GLOBAL_ID_INCR;
 @Slf4j
 public class ChannelProductServiceImpl extends ServiceImpl<ChannelProductMapper, ChannelProductInfo> implements ChannelProductService {
 
-    @Autowired
+    @Resource
     private JedisCluster jedisCluster;
 
-    @Autowired
+    @Resource
     private RocketMQTemplate rocketMQTemplate;
 
     @Override
@@ -55,7 +55,7 @@ public class ChannelProductServiceImpl extends ServiceImpl<ChannelProductMapper,
                     info.setChannelProductId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
                 }
 
-                info.setDiscount(new BigDecimal(info.getPrice()).setScale(4, BigDecimal.ROUND_DOWN).divide(new BigDecimal(info.getFacePrice())));
+                info.setDiscount((new BigDecimal(info.getPrice()).divide(new BigDecimal(10000))).divide(new BigDecimal(info.getFacePrice()), 4, BigDecimal.ROUND_DOWN));
             }
 
             boolean result = this.saveOrUpdateBatch(channelProductInfos);
@@ -74,10 +74,12 @@ public class ChannelProductServiceImpl extends ServiceImpl<ChannelProductMapper,
 
     @Override
     public void deleteChannelProductById(Long channelProductId) {
-        int result = baseMapper.deleteById(channelProductId);
-        if (result > 0) {
-            rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
-            log.info("编号为:【{}】的通道产品删除成功!", channelProductId);
+        if (channelProductId != null) {
+            int result = baseMapper.deleteById(channelProductId);
+            if (result > 0) {
+                rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
+                log.info("编号为:【{}】的通道产品删除成功!", channelProductId);
+            }
         }
     }
 }

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

@@ -174,7 +174,7 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, CustomerInf
                 cars.setRelationId(Long.parseLong(String.valueOf(customerDto.getCustomerId())));
             });
 
-            bankCardService.saveBankCards(customerDto.getBankCards());
+            bankCardService.saveOrUpdateBankCards(customerDto.getBankCards());
         }
 
         if (count > 0) {

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

@@ -10,11 +10,11 @@ import com.fire.dto.DistributeGroup;
 import com.fire.dto.enums.Status;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.messaging.support.MessageBuilder;
 import org.springframework.stereotype.Service;
 import redis.clients.jedis.JedisCluster;
 
+import javax.annotation.Resource;
 import java.util.List;
 
 import static com.fire.common.constants.RocketTags.SUPPLIER_TAG;
@@ -31,10 +31,10 @@ import static com.fire.dto.enums.RedisKey.GLOBAL_ID_INCR;
 @Slf4j
 public class DistributeGroupServiceImpl extends ServiceImpl<DistributeGroupMapper, DistributeGroup> implements DistributeGroupService {
 
-    @Autowired
+    @Resource
     private JedisCluster jedisCluster;
 
-    @Autowired
+    @Resource
     private RocketMQTemplate rocketMQTemplate;
 
     @Override
@@ -56,8 +56,8 @@ public class DistributeGroupServiceImpl extends ServiceImpl<DistributeGroupMappe
             boolean result = this.saveOrUpdateBatch(distributeGroups);
             if (result) {
                 rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
+                log.info("添加或修改的分发组是:【{}】", distributeGroups);
             }
-            log.info("添加的分发组是:【{}】", distributeGroups.toString());
         } else {
             throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
         }
@@ -69,8 +69,8 @@ public class DistributeGroupServiceImpl extends ServiceImpl<DistributeGroupMappe
             int result = baseMapper.deleteById(distributeGroupId);
             if (result > 0) {
                 rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
+                log.info("编号为【{}】的分发组删除成功!", distributeGroupId);
             }
-            log.info("编号为【{}】的分发组删除成功!", distributeGroupId);
         } else {
             throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
         }

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

@@ -14,11 +14,11 @@ import com.fire.dto.ChannelSupplier;
 import com.fire.dto.enums.Status;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.messaging.support.MessageBuilder;
 import org.springframework.stereotype.Service;
 import redis.clients.jedis.JedisCluster;
 
+import javax.annotation.Resource;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -38,13 +38,13 @@ import static com.fire.dto.enums.RedisKey.GLOBAL_ID_INCR;
 @Slf4j
 public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, ChannelSupplier> implements SupplierService {
 
-    @Autowired
+    @Resource
     private BankCardService bankCardService;
 
-    @Autowired
+    @Resource
     private RocketMQTemplate rocketMQTemplate;
 
-    @Autowired
+    @Resource
     private JedisCluster jedisCluster;
 
     @Override
@@ -74,8 +74,10 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
 
     @Override
     public void updateSupplierById(ChannelSupplier channelSupplier) {
-        channelSupplier.setUpdator("admin");
-        channelSupplier.setUpdateTime(new Date());
+        if (channelSupplier != null) {
+            channelSupplier.setUpdator("admin");
+            channelSupplier.setUpdateTime(new Date());
+        }
         LambdaUpdateWrapper<ChannelSupplier> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
         lambdaUpdateWrapper.eq(channelSupplier.getSupplierId() != null, ChannelSupplier::getSupplierId, channelSupplier.getSupplierId());
         int result = baseMapper.update(channelSupplier, lambdaUpdateWrapper);
@@ -91,20 +93,26 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
                 bankCard.setRelationId(channelSupplier.getSupplierId());
             });
 
-            bankCardService.saveBankCards(channelSupplier.getBankCards());
+            bankCardService.saveOrUpdateBankCards(channelSupplier.getBankCards());
         }
 
     }
 
     @Override
     public void saveSupplier(ChannelSupplier channelSupplier) {
-        channelSupplier.setCreator("admin");
-        channelSupplier.setCreateTime(new Date());
-        channelSupplier.setSupplierId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
-        int result = baseMapper.insert(channelSupplier);
-        if (result > 0) {
-            rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
-            log.info("添加的供应商是:【{}】", channelSupplier);
+        if (channelSupplier != null) {
+            if (channelSupplier.getSupplierId() == null) {
+                channelSupplier.setSupplierId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
+            }
+            channelSupplier.setCreator("admin");
+            channelSupplier.setCreateTime(new Date());
+            int result = baseMapper.insert(channelSupplier);
+            if (result > 0) {
+                rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
+                log.info("添加的供应商是:【{}】", channelSupplier);
+            }
+        } else {
+            throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
         }
     }
 
@@ -126,11 +134,24 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
         if (bankId != null) {
             Map<String, Object> map = new HashMap<>();
             map.put("id", bankId);
-
             baseMapper.deleteByMap(map);
-
         } else {
             throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
         }
     }
+
+    @Override
+    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);
+            }
+        }
+    }
 }

+ 4 - 2
modules/admin/src/main/java/com/fire/admin/vo/AdditionalPaymentVo.java

@@ -88,6 +88,8 @@ public class AdditionalPaymentVo {
      */
     private String customerName;
 
-
-
+    /**
+     * 供应商名称
+     */
+    private String supplierName;
 }

+ 24 - 5
modules/admin/src/main/resources/mapper/AdditionalPaymentMapper.xml

@@ -33,10 +33,14 @@
         <result column="distinguish" property="distinguish"/>
         <result column="undo" property="undo"/>
         <result column="customer_name" property="customerName"/>
+        <result column="supplier_name" property="supplierName"/>
     </resultMap>
 
     <sql id="customerPayment">
-        pay .id,
+        pay
+        .
+        id
+        ,
         pay.card_no,
         pay.bank_deposit,
         pay.account,
@@ -48,7 +52,8 @@
         pay.relation_id,
         pay.distinguish,
         pay.undo,
-        c.customer_name
+        c.customer_name,
+        cs.supplier_name
     </sql>
 
     <select id="selectAddiPayCustomerPageInfo" resultMap="ResultMap">
@@ -60,11 +65,25 @@
         <where>
             <if test="select.relationId !=null and select.relationId !='' and  select.relationId !='string'">
                 and pay.relation_id =#{select.relationId}
-          </if>
-                and pay.distinguish=2
+            </if>
+            and pay.distinguish=2
         </where>
-        ORDER BY  pay.time DESC
+        ORDER BY pay.time DESC
     </select>
 
+    <select id="getSupplierAddPayPageInfo" resultMap="ResultMap">
+        SELECT
+        <include refid="customerPayment"/>
+        FROM
+        additional_payment AS pay
+        LEFT JOIN channel_supplier AS cs ON pay.relation_id=cs.supplier_id
+        <where>
+            <if test="info.relationId !=null and info.relationId.trim() !='' and  info.relationId !='string'">
+                and pay.relation_id = #{info.relationId}
+            </if>
+            and pay.distinguish=1
+        </where>
+        ORDER BY pay.time DESC
+    </select>
 
 </mapper>