Kaynağa Gözat

功能提交,完成客户账户撤销,支持客户产品小数

杨六六 4 yıl önce
ebeveyn
işleme
07072e0c68

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

@@ -36,15 +36,17 @@ public class AdditionalPayment {
      */
     @ApiModelProperty(value = "银行卡")
     String cardNo;
+
     /**
      * 开户行
      */
     private String bankDeposit;
+
     /**
-     * 账户
+     * 全称  : 银行回执单的全称,数据来源从该供应商或者客户的银行卡列表中获取
      */
-    @ApiModelProperty(value = "开户行")
-    private BigInteger account;
+    @ApiModelProperty(value = "全称【加款对应的公司主体名称】")
+    private String account;
 
     /**
      * 加款人
@@ -86,7 +88,7 @@ public class AdditionalPayment {
     private Integer distinguish;
 
     /**
-     * 撤销
+     * 撤销 撤销 0: 正常  1: 撤销
      */
     @ApiModelProperty(value = "撤销")
     private Integer undo;

+ 2 - 2
modules/admin/src/main/java/com/fire/admin/dto/AdditionalPaymentDto.java

@@ -29,8 +29,8 @@ public class AdditionalPaymentDto  {
     /**
      * 账户
      */
-    @ApiModelProperty(value = "开户行")
-    private BigInteger account;
+    @ApiModelProperty(value = "全称【加款对应的公司主体名称】")
+    private String account;
 
     /**
      * 加款人

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

@@ -38,18 +38,30 @@ public class AdditionalPaymentController {
 
     @ApiOperation("分页获取客户加款信息")
     @PostMapping("/info")
-    public BaseRestResponse makeGetAdditionalPaymentPage( @RequestBody AdditionalPaymentDto additionalPaymentDto) {
+    public BaseRestResponse makeGetAdditionalPaymentPage(@RequestBody AdditionalPaymentDto additionalPaymentDto) {
         return new BaseRestResponse(additionalPaymentService.getAdditionalPaymentPage(additionalPaymentDto));
     }
 
     @ApiOperation("更改加款记录,只能更改凭证,其余的都不能修改")
     @PostMapping("/update")
-    public BaseResponse makeUpdateAdditionalPayment(@RequestBody AdditionalPaymentDto additionalPaymentDto){
+    public BaseResponse makeUpdateAdditionalPayment(@RequestBody AdditionalPaymentDto additionalPaymentDto) {
         additionalPaymentService.updAdditionPayment(additionalPaymentDto);
         return new BaseResponse();
     }
 
 
+    /**
+     * @Description: TODO 对客户的加款进行撤销
+     * @Param:
+     * @return:
+     * @Author: liuliu
+     * @Date: 2021/6/8 14:55
+     */
+    @ApiOperation("客户加款撤销")
+    @PostMapping("/cancel")
+    public BaseRestResponse additionalPayment(@RequestBody AdditionalPaymentDto additionalPaymentDto) {
+        return new BaseRestResponse(additionalPaymentService.cancelAdditionalPayment(additionalPaymentDto));
+    }
 
 
 }

+ 3 - 0
modules/admin/src/main/java/com/fire/admin/rest/CustomerController.java

@@ -63,4 +63,7 @@ public class CustomerController {
     return  new BaseRestResponse<>(customerService.queryCustomerInfo(customerName));
     }
 
+
+
+
 }

+ 3 - 9
modules/admin/src/main/java/com/fire/admin/rest/TestController.java

@@ -46,16 +46,10 @@ public class TestController {
 
 
     public static void main(String[] args) {
-       Integer a=5;
 
-       Long l=5L;
-
-       if(a.longValue()==l.longValue()){
-           System.out.println(" = ============");
-       }else {
-           System.out.println(" heehee");
-
-       }
+        BigDecimal b=new BigDecimal(10);
+        BigDecimal c=new BigDecimal(3);
+        System.out.println("b = " +b.divide(c,2 ,BigDecimal.ROUND_DOWN));
 
     }
 

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

@@ -45,5 +45,15 @@ public interface AdditionalPaymentService extends IService<AdditionalPayment> {
     * @Date: 2021/6/7 16:50
     */
     void  updAdditionPayment(AdditionalPaymentDto additionalPaymentDto);
-    
+
+
+    /**
+    * @Description:  TODO 客户加款撤销
+    * @Param: [additionalPaymentDto]
+    * @return: void
+    * @Author: liuliu
+    * @Date: 2021/6/8 14:58
+    */
+    String cancelAdditionalPayment(AdditionalPaymentDto additionalPaymentDto);
+
 }

+ 9 - 0
modules/admin/src/main/java/com/fire/admin/service/CustomerService.java

@@ -67,4 +67,13 @@ public interface CustomerService extends IService<CustomerInfo> {
     */
     List<CustomerInfo> queryCustomerInfo(String customerName);
 
+    /**
+    * @Description:  TODO 根据客户的id获取客户信息,用于客户账户撤销获取客户的授信
+    * @Param: [customerId]
+    * @return: com.fire.dto.CustomerInfo
+    * @Author: liuliu
+    * @Date: 2021/6/8 16:21
+    */
+    CustomerInfo getcustomerOne(Long customerId);
+
 }

+ 59 - 6
modules/admin/src/main/java/com/fire/admin/service/impl/AdditionalPaymentServiceImpl.java

@@ -8,12 +8,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fire.admin.dto.AdditionalPaymentDto;
 import com.fire.admin.mapper.AdditionalPaymentMapper;
 import com.fire.admin.service.AdditionalPaymentService;
+import com.fire.admin.service.CustomerService;
 import com.fire.admin.util.AliyunOSSUtil;
 import com.fire.admin.util.SecurityUtil;
 import com.fire.admin.vo.AdditionalPaymentVo;
 import com.fire.common.exception.BaseException;
 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;
@@ -37,11 +39,13 @@ public class AdditionalPaymentServiceImpl extends ServiceImpl<AdditionalPaymentM
 
     private AliyunOSSUtil aliyunOSSUtil;
     private RedisAmountScript redisAmountScript;
+    private CustomerService customerService;
 
     @Autowired
-    public AdditionalPaymentServiceImpl(AliyunOSSUtil aliyunOSSUtil, RedisAmountScript redisAmountScript) {
+    public AdditionalPaymentServiceImpl(AliyunOSSUtil aliyunOSSUtil, RedisAmountScript redisAmountScript,CustomerService customerService) {
         this.aliyunOSSUtil = aliyunOSSUtil;
         this.redisAmountScript = redisAmountScript;
+        this.customerService=customerService;
     }
 
     /**
@@ -77,13 +81,20 @@ public class AdditionalPaymentServiceImpl extends ServiceImpl<AdditionalPaymentM
      * @Date: 2021/6/7 16:12
      */
     private int additionalPayment(AdditionalPaymentDto additionalPaymentDto) {
+
         if (ObjectUtil.isNotEmpty(additionalPaymentDto.getType()) && ObjectUtil.isNotEmpty(additionalPaymentDto.getRelationId())) {
-            AdditionalPayment payment = new AdditionalPayment();
-            BeanUtil.copyProperties(additionalPaymentDto, payment);
-            payment.setTime(DateUtils.strformatDatetime(LocalDateTime.now()));
-            payment.setPayer(SecurityUtil.getUser().getUsername());
+            AdditionalPayment payment = AdditionalPayment.builder().cardNo(additionalPaymentDto.getCardNo())
+                    .bankDeposit(additionalPaymentDto.getBankDeposit())
+                    .account(additionalPaymentDto.getAccount())
+                    .payer(SecurityUtil.getUser().getUsername())
+                    .amount(additionalPaymentDto.getAmount().multiply(new BigDecimal(10000)).longValue())
+                    .certificate(additionalPaymentDto.getCertificate())
+                    .time(SecurityUtil.getUser().getUsername())
+                    .paymentAccount(additionalPaymentDto.getPaymentAccount())
+                    .relationId(additionalPaymentDto.getRelationId())
+                    .distinguish(additionalPaymentDto.getDistinguish())
+                    .undo(0).build();
             return baseMapper.insert(payment);
-
         } else {
             // TODO 请求参数不合法抛异常
             throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
@@ -126,4 +137,46 @@ public class AdditionalPaymentServiceImpl extends ServiceImpl<AdditionalPaymentM
         AdditionalPayment payment = AdditionalPayment.builder().id(additionalPaymentDto.getId()).certificate(additionalPaymentDto.getCertificate()).build();
         baseMapper.updateById(payment);
     }
+
+    /**
+    * @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")){
+            additionalPaymentDto.setUndo(1);
+            // TODO  实例化对象
+            AdditionalPayment payment = this.formatAdditionalPaymentDto(additionalPaymentDto);
+            // TODO 修改记录的撤销状态
+            int count = baseMapper.updateById(payment);
+            // TODO 获取客户授信金额
+            CustomerInfo customerInfo = customerService.getcustomerOne(Long.parseLong(payment.getRelationId()));
+            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;
+
+    }
+
+    private AdditionalPayment formatAdditionalPaymentDto(AdditionalPaymentDto additionalPaymentDto){
+       return AdditionalPayment.builder()
+                .id(additionalPaymentDto.getId())
+                .relationId(additionalPaymentDto.getRelationId())
+                .amount(additionalPaymentDto.getAmount().multiply(new BigDecimal(10000)).longValue())
+                .undo(additionalPaymentDto.getUndo())
+                .build();
+    }
+
+
 }

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

@@ -92,7 +92,7 @@ public class CustomerProductInfoServiceImpl extends ServiceImpl<CustomerProductI
                         .customerId(dto.getCustomerId())
                         .packageId(dto.getPackageId())
                         .type(dto.getType())
-                        .price(Long.parseLong(String.valueOf((dto.getPrice().multiply(new BigDecimal(10000))))))
+                        .price(Long.parseLong(String.valueOf((dto.getPrice().multiply(new BigDecimal(10000))).intValue())))
                         .facePrice(Long.parseLong(String.valueOf(dto.getFacePrice().multiply(new BigDecimal(10000)))))
                         .isEffective(dto.getIsEffective())
                         .disCount(dto.getPrice().divide(dto.getFacePrice())).build();

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

@@ -13,9 +13,11 @@ import com.fire.admin.service.BankCardService;
 import com.fire.admin.service.CustomerService;
 import com.fire.admin.util.SecurityUtil;
 import com.fire.admin.vo.CustomerInfoVo;
+import com.fire.common.exception.BaseException;
 import com.fire.dto.BankCard;
 import com.fire.dto.CustomerInfo;
 import com.fire.dto.FlowAppInfo;
+import com.fire.dto.enums.Status;
 import com.fire.utils.date.DateUtils;
 import com.google.common.collect.Lists;
 import lombok.extern.slf4j.Slf4j;
@@ -196,5 +198,25 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, CustomerInf
 
     }
 
+    /**
+     * @Description:  TODO 根据客户的id获取客户信息,用于客户账户撤销获取客户的授信
+     * @Param: [customerId]
+     * @return: com.fire.dto.CustomerInfo
+     * @Author: liuliu
+     * @Date: 2021/6/8 16:19
+     */
+    @Override
+    public CustomerInfo getcustomerOne(Long customerId) {
+        if (ObjectUtil.isNotEmpty(customerId)) {
+        LambdaQueryWrapper<CustomerInfo> wrapper = new LambdaQueryWrapper<>();
+        wrapper.select(CustomerInfo::getCustomerId,CustomerInfo::getCreditAmount)
+                .eq(CustomerInfo::getCustomerId,customerId);
+        return baseMapper.selectOne(wrapper);
+        }else {
+            log.info("查询客户授信请传入正确的客户编号,当前传入编号为:【{}】",customerId);
+            throw new BaseException(Status.PARAM_LOSS.status(),Status.PARAM_LOSS.message());
+        }
+    }
+
 
 }

+ 2 - 2
modules/admin/src/main/resources/bootstrap.yml

@@ -28,7 +28,7 @@ spring:
         service: admin
 
 
-oos:
+oss:
   endpoint: http://oss-cn-chengdu.aliyuncs.com
   keyid: LTAI4FyxwFmsGEESaa7tiB6z # 填写刚刚生成的AccessKey
   keysecret: dG701ohwFU28pT84ZpEmIn7EcLOzzu  # 填写刚刚生成的Accesssecret
@@ -60,7 +60,7 @@ spring:
         namespace: fire
         service: admin
 
-oos:
+oss:
   endpoint: http://oss-cn-chengdu.aliyuncs.com
   keyid: LTAI4FyxwFmsGEESaa7tiB6z # 填写刚刚生成的AccessKey
   keysecret: dG701ohwFU28pT84ZpEmIn7EcLOzzu  # 填写刚刚生成的Accesssecret