|
@@ -291,6 +291,40 @@ public class AccountRunningWaterServiceImpl extends ServiceImpl<AccountRunningWa
|
|
|
|
|
|
@Override
|
|
|
public void delete(Long id) {
|
|
|
+ AccountRunningWater accountRunningWater = getById(id);
|
|
|
+ Assert.notEmpty(accountRunningWater, "获取不到该流水信息");
|
|
|
+
|
|
|
+
|
|
|
+ // 修改账户余额表的余额
|
|
|
+ AccountRemainder accountRemainder = accountRemainderService.getOne(q -> q
|
|
|
+ .eq(AccountRemainder::getAccountManagementId, accountRunningWater.getAccountManagementId())
|
|
|
+ .eq(AccountRemainder::getCurrency, accountRunningWater.getCurrency())
|
|
|
+ );
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(accountRemainder)) {
|
|
|
+ throw new ServiceException("该账户不存在此币种,请前往资金账户添加");
|
|
|
+ }
|
|
|
+ BigDecimal amount = accountRunningWater.getAmount();
|
|
|
+ String status = accountRunningWater.getStatus();
|
|
|
+ BigDecimal remainder = accountRemainder.getRemainder();
|
|
|
+
|
|
|
+ accountRemainder.setStatus(status);
|
|
|
+ accountRemainder.setChangeRemainder(amount);
|
|
|
+
|
|
|
+ if (status.equals("10")) {
|
|
|
+ //收入 减余额
|
|
|
+ BigDecimal subtract = remainder.subtract(amount);
|
|
|
+ if (subtract.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ throw new ServiceException("账户余额不足");
|
|
|
+ }
|
|
|
+ accountRemainder.setRemainder(subtract);
|
|
|
+ //支出 加余额
|
|
|
+ } else if (status.equals("20")) {
|
|
|
+ accountRemainder.setRemainder(remainder.add(amount));
|
|
|
+ }
|
|
|
+ accountRemainderService.updateById(accountRemainder);
|
|
|
+
|
|
|
+
|
|
|
this.removeById(id);
|
|
|
}
|
|
|
|