|
@@ -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())
|