From f4b776a9038d46f675c59cc6f9b5a03c342f97b6 Mon Sep 17 00:00:00 2001 From: ronger Date: Mon, 28 Jun 2021 12:00:11 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=88=91=E7=9A=84=E9=92=B1=E5=8C=85?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E6=95=88=E6=9E=9C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../forest/dto/TransactionRecordDTO.java | 4 ++++ .../forest/mapper/BankAccountMapper.java | 7 ++++++ .../forest/service/BankAccountService.java | 2 +- .../service/impl/BankAccountServiceImpl.java | 6 ++--- .../impl/TransactionRecordServiceImpl.java | 18 +++++++++++++-- src/main/java/mapper/BankAccountMapper.xml | 22 ++++++++++++------- .../java/mapper/TransactionRecordMapper.xml | 2 +- 7 files changed, 45 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/rymcu/forest/dto/TransactionRecordDTO.java b/src/main/java/com/rymcu/forest/dto/TransactionRecordDTO.java index 14148d8..349dbb9 100644 --- a/src/main/java/com/rymcu/forest/dto/TransactionRecordDTO.java +++ b/src/main/java/com/rymcu/forest/dto/TransactionRecordDTO.java @@ -19,8 +19,12 @@ public class TransactionRecordDTO { private String funds; /** 交易发起方 */ private String formBankAccount; + /** 交易发起方 */ + private BankAccountDTO formBankAccountInfo; /** 交易收款方 */ private String toBankAccount; + /** 交易收款方 */ + private BankAccountDTO toBankAccountInfo; /** 交易金额 */ private BigDecimal money; /** 交易类型 */ diff --git a/src/main/java/com/rymcu/forest/mapper/BankAccountMapper.java b/src/main/java/com/rymcu/forest/mapper/BankAccountMapper.java index a71f580..a067c76 100644 --- a/src/main/java/com/rymcu/forest/mapper/BankAccountMapper.java +++ b/src/main/java/com/rymcu/forest/mapper/BankAccountMapper.java @@ -32,4 +32,11 @@ public interface BankAccountMapper extends Mapper { * @return */ String selectMaxBankAccount(); + + /** + * 根据卡号获取银行账号信息 + * @param bankAccount + * @return + */ + BankAccountDTO selectByBankAccount(@Param("bankAccount") String bankAccount); } diff --git a/src/main/java/com/rymcu/forest/service/BankAccountService.java b/src/main/java/com/rymcu/forest/service/BankAccountService.java index fa355e7..f8b1b54 100644 --- a/src/main/java/com/rymcu/forest/service/BankAccountService.java +++ b/src/main/java/com/rymcu/forest/service/BankAccountService.java @@ -31,7 +31,7 @@ public interface BankAccountService extends Service { * @param bankAccount * @return */ - BankAccount findByBankAccount(String bankAccount); + BankAccountDTO findByBankAccount(String bankAccount); /** * 查询系统社区银行 diff --git a/src/main/java/com/rymcu/forest/service/impl/BankAccountServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/BankAccountServiceImpl.java index 5721464..370b7a9 100644 --- a/src/main/java/com/rymcu/forest/service/impl/BankAccountServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/BankAccountServiceImpl.java @@ -61,10 +61,8 @@ public class BankAccountServiceImpl extends AbstractService impleme } @Override - public BankAccount findByBankAccount(String bankAccount) { - BankAccount searchBankAccount = new BankAccount(); - searchBankAccount.setBankAccount(bankAccount); - return bankAccountMapper.selectOne(searchBankAccount); + public BankAccountDTO findByBankAccount(String bankAccount) { + return bankAccountMapper.selectByBankAccount(bankAccount); } @Override diff --git a/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java b/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java index a832bf3..eaef498 100644 --- a/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java +++ b/src/main/java/com/rymcu/forest/service/impl/TransactionRecordServiceImpl.java @@ -4,15 +4,19 @@ import com.rymcu.forest.core.exception.TransactionException; import com.rymcu.forest.core.service.AbstractService; import com.rymcu.forest.core.service.redis.RedisService; import com.rymcu.forest.dto.BankAccountDTO; +import com.rymcu.forest.dto.BankAccountSearchDTO; import com.rymcu.forest.dto.TransactionRecordDTO; import com.rymcu.forest.entity.BankAccount; import com.rymcu.forest.entity.TransactionRecord; +import com.rymcu.forest.entity.User; import com.rymcu.forest.enumerate.TransactionCode; import com.rymcu.forest.enumerate.TransactionEnum; import com.rymcu.forest.mapper.TransactionRecordMapper; import com.rymcu.forest.service.BankAccountService; import com.rymcu.forest.service.TransactionRecordService; import com.rymcu.forest.util.DateUtil; +import com.rymcu.forest.util.UserUtils; +import com.rymcu.forest.web.api.exception.BaseApiException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -56,7 +60,17 @@ public class TransactionRecordServiceImpl extends AbstractService findTransactionRecords(String bankAccount) { - return transactionRecordMapper.selectTransactionRecords(bankAccount); + List list = transactionRecordMapper.selectTransactionRecords(bankAccount); + list.forEach(transactionRecordDTO -> genTransactionRecord(transactionRecordDTO)); + return list; + } + + private TransactionRecordDTO genTransactionRecord(TransactionRecordDTO transactionRecordDTO) { + BankAccountDTO toBankAccount = bankAccountService.findByBankAccount(transactionRecordDTO.getToBankAccount()); + BankAccountDTO formBankAccount = bankAccountService.findByBankAccount(transactionRecordDTO.getFormBankAccount()); + transactionRecordDTO.setFormBankAccountInfo(formBankAccount); + transactionRecordDTO.setToBankAccountInfo(toBankAccount); + return transactionRecordDTO; } @Override @@ -122,7 +136,7 @@ public class TransactionRecordServiceImpl extends AbstractService 0) { return true; diff --git a/src/main/java/mapper/BankAccountMapper.xml b/src/main/java/mapper/BankAccountMapper.xml index 2cc2765..ff935f7 100644 --- a/src/main/java/mapper/BankAccountMapper.xml +++ b/src/main/java/mapper/BankAccountMapper.xml @@ -12,24 +12,30 @@ + \ No newline at end of file diff --git a/src/main/java/mapper/TransactionRecordMapper.xml b/src/main/java/mapper/TransactionRecordMapper.xml index effeafe..0ae14b6 100644 --- a/src/main/java/mapper/TransactionRecordMapper.xml +++ b/src/main/java/mapper/TransactionRecordMapper.xml @@ -16,7 +16,7 @@ update forest_bank_account set account_balance = account_balance + #{money} where bank_account = #{toBankAccount};