|
@@ -11,20 +11,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.account.entity.account.dto.AccountPaymentDto;
|
|
|
import com.fjhx.account.entity.account.dto.AccountRequestFundsSelectDto;
|
|
|
import com.fjhx.account.entity.account.enums.PaymentStatusEnum;
|
|
|
-import com.fjhx.account.entity.account.po.AccountManagement;
|
|
|
-import com.fjhx.account.entity.account.po.AccountPayment;
|
|
|
-import com.fjhx.account.entity.account.po.AccountRemainder;
|
|
|
-import com.fjhx.account.entity.account.po.AccountRunningWater;
|
|
|
+import com.fjhx.account.entity.account.po.*;
|
|
|
import com.fjhx.account.entity.account.vo.AccountPaymentVo;
|
|
|
import com.fjhx.account.mapper.account.AccountPaymentMapper;
|
|
|
-import com.fjhx.account.service.account.AccountManagementService;
|
|
|
-import com.fjhx.account.service.account.AccountPaymentService;
|
|
|
-import com.fjhx.account.service.account.AccountRemainderService;
|
|
|
-import com.fjhx.account.service.account.AccountRunningWaterService;
|
|
|
+import com.fjhx.account.service.account.*;
|
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
|
import com.fjhx.common.service.corporation.CorporationService;
|
|
|
+import com.fjhx.common.utils.Assert;
|
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
|
-import com.ruoyi.common.core.domain.BasePo;
|
|
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.system.service.ISysDeptService;
|
|
@@ -32,6 +26,7 @@ import com.ruoyi.system.utils.UserUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
@@ -63,6 +58,9 @@ public class AccountPaymentServiceImpl extends ServiceImpl<AccountPaymentMapper,
|
|
|
@Autowired
|
|
|
private AccountManagementService accountManagementService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AccountPaymentRecordsService accountPaymentRecordsService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<AccountPaymentVo> getPage(AccountRequestFundsSelectDto dto) {
|
|
|
|
|
@@ -165,6 +163,7 @@ public class AccountPaymentServiceImpl extends ServiceImpl<AccountPaymentMapper,
|
|
|
@Override
|
|
|
@DSTransactional
|
|
|
public void add(AccountPaymentDto accountPaymentDto) {
|
|
|
+ Assert.notEmpty(accountPaymentDto.getId(), "打款id不能为空");
|
|
|
|
|
|
AccountRemainder accountRemainder = accountRemainderService.getOne(Wrappers.<AccountRemainder>lambdaQuery()
|
|
|
.eq(AccountRemainder::getAccountManagementId, accountPaymentDto.getAccountManagementId())
|
|
@@ -180,9 +179,31 @@ public class AccountPaymentServiceImpl extends ServiceImpl<AccountPaymentMapper,
|
|
|
throw new ServiceException("账户余额不足");
|
|
|
}
|
|
|
|
|
|
- // TODO 只要发起就是已打款(后期可能要修改)
|
|
|
- accountPaymentDto.setStatus(PaymentStatusEnum.REJECT.getKey());
|
|
|
- updateById(accountPaymentDto);
|
|
|
+ //刷新打款信息
|
|
|
+ AccountPayment oldAccountPayment = this.getById(accountPaymentDto.getId());
|
|
|
+ //如果是未打款把已打款金额改成0(修复旧数据)
|
|
|
+ if (oldAccountPayment.getStatus().equals(PaymentStatusEnum.UNDER_REVIEW.getKey())) {
|
|
|
+ oldAccountPayment.setAmount(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ BigDecimal add = oldAccountPayment.getAmount().add(accountPaymentDto.getAmount());
|
|
|
+ if (add.compareTo(oldAccountPayment.getIncomeAmount()) > 0) {
|
|
|
+ throw new ServiceException("打款金额不能大于待打款金额");
|
|
|
+ }
|
|
|
+ //修改打款状态
|
|
|
+ if (add.compareTo(oldAccountPayment.getIncomeAmount()) >= 0) {
|
|
|
+ oldAccountPayment.setStatus(PaymentStatusEnum.REJECT.getKey());
|
|
|
+ } else {
|
|
|
+ oldAccountPayment.setStatus(PaymentStatusEnum.PARTIAL.getKey());
|
|
|
+ }
|
|
|
+ //赋值已打款金额
|
|
|
+ oldAccountPayment.setAmount(add);
|
|
|
+ updateById(oldAccountPayment);
|
|
|
+
|
|
|
+ //创建打款记录
|
|
|
+ AccountPaymentRecords accountPaymentRecords = new AccountPaymentRecords();
|
|
|
+ accountPaymentRecords.setAccountPaymentId(accountPaymentDto.getId());
|
|
|
+ accountPaymentRecords.setAmount(accountPaymentDto.getAmount());
|
|
|
+ accountPaymentRecordsService.save(accountPaymentRecords);
|
|
|
|
|
|
// 赋值变更金额
|
|
|
accountRemainder.setChangeRemainder(accountPaymentDto.getAmount());
|