From 8a5c145c49d777a89c3304614e42842a9818c356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=89=AF=28004796=29?= Date: Mon, 6 May 2024 16:45:54 +0800 Subject: [PATCH] 123 --- .../bashi/dk/service/impl/BorrowServiceImpl.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bashi-dk/src/main/java/com/bashi/dk/service/impl/BorrowServiceImpl.java b/bashi-dk/src/main/java/com/bashi/dk/service/impl/BorrowServiceImpl.java index 776d8c9..d91d32b 100644 --- a/bashi-dk/src/main/java/com/bashi/dk/service/impl/BorrowServiceImpl.java +++ b/bashi-dk/src/main/java/com/bashi/dk/service/impl/BorrowServiceImpl.java @@ -191,7 +191,15 @@ public class BorrowServiceImpl extends ServiceImpl impleme } @Override + @Transactional(rollbackFor = Exception.class) public void withdraw(Double withdrawAmount, Long customerId) { + Customer customer = customerService.getById(customerId); + if(customer.getAccount().doubleValue() < withdrawAmount){ + throw new CustomException(MessageUtils.message("dk.withdraw.balance.not.enough.error")); + } + if(BooleanUtils.isNotTrue(customer.getAllowWithdrawFlag())){ + throw new CustomException(MessageUtils.message("dk.withdraw.account.error")); + } Borrow borrow = this.getByCustomerId(customerId); if(borrow == null){ throw new CustomException(MessageUtils.message("dk.withdraw.account.error")); @@ -204,13 +212,6 @@ public class BorrowServiceImpl extends ServiceImpl impleme } } } - Customer customer = customerService.getById(customerId); - if(BooleanUtils.isNotTrue(customer.getAllowWithdrawFlag())){ - throw new CustomException(MessageUtils.message("dk.withdraw.account.error")); - } - if(customer.getAccount().doubleValue() < withdrawAmount){ - throw new CustomException(MessageUtils.message("dk.withdraw.balance.not.enough.error")); - } Borrow one = this.getOne(Wrappers.lambdaQuery(Borrow.class).eq(Borrow::getCustomerId,customerId)); if(one == null){ throw new CustomException(MessageUtils.message("dk.withdraw.fail"));