|
@@ -1,6 +1,5 @@
|
|
|
package com.jy.business.capital.service.impl;
|
|
|
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.jy.business.capital.dao.CapitalAccountDao;
|
|
|
import com.jy.business.capital.dao.CapitalTransactionsDao;
|
|
@@ -14,7 +13,6 @@ import jakarta.annotation.Resource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -61,20 +59,13 @@ public class CapitalTransactionsServiceImpl implements CapitalTransactionsServic
|
|
|
CapitalTransactions oldCapitalTransactions = capitalTransactionsDao.getById(dto.getId());
|
|
|
AssertUtil.notNull(oldCapitalTransactions, "未知资金流水");
|
|
|
|
|
|
- BigDecimal amount;
|
|
|
- Integer type = dto.getType();
|
|
|
- if (ObjectUtil.equal(type, oldCapitalTransactions.getType())) {
|
|
|
- amount = dto.getAmount().subtract(oldCapitalTransactions.getAmount());
|
|
|
- } else {
|
|
|
- amount = dto.getAmount().add(oldCapitalTransactions.getAmount());
|
|
|
- }
|
|
|
+ boolean updateOldAmount = capitalAccountDao.updateAmount(
|
|
|
+ oldCapitalTransactions.getCapitalAccountId(),
|
|
|
+ oldCapitalTransactions.getType() == 1 ? 0 : 1,
|
|
|
+ oldCapitalTransactions.getAmount());
|
|
|
+ AssertUtil.eqTrue(updateOldAmount, "账户余额不足");
|
|
|
|
|
|
- if (type == 1 && amount.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
- amount = amount.abs();
|
|
|
- type = 0;
|
|
|
- }
|
|
|
-
|
|
|
- boolean updateAmount = capitalAccountDao.updateAmount(dto.getCapitalAccountId(), type, amount);
|
|
|
+ boolean updateAmount = capitalAccountDao.updateAmount(dto.getCapitalAccountId(), dto.getType(), dto.getAmount());
|
|
|
AssertUtil.eqTrue(updateAmount, "账户余额不足");
|
|
|
|
|
|
capitalTransactionsDao.updateById(dto);
|