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};