123
This commit is contained in:
@@ -191,7 +191,15 @@ public class BorrowServiceImpl extends ServiceImpl<BorrowMapper, Borrow> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void withdraw(Double withdrawAmount, Long customerId) {
|
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);
|
Borrow borrow = this.getByCustomerId(customerId);
|
||||||
if(borrow == null){
|
if(borrow == null){
|
||||||
throw new CustomException(MessageUtils.message("dk.withdraw.account.error"));
|
throw new CustomException(MessageUtils.message("dk.withdraw.account.error"));
|
||||||
@@ -204,13 +212,6 @@ public class BorrowServiceImpl extends ServiceImpl<BorrowMapper, Borrow> 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));
|
Borrow one = this.getOne(Wrappers.lambdaQuery(Borrow.class).eq(Borrow::getCustomerId,customerId));
|
||||||
if(one == null){
|
if(one == null){
|
||||||
throw new CustomException(MessageUtils.message("dk.withdraw.fail"));
|
throw new CustomException(MessageUtils.message("dk.withdraw.fail"));
|
||||||
|
|||||||
Reference in New Issue
Block a user