🎨 我的钱包展示效果优化

This commit is contained in:
ronger 2021-06-28 12:00:11 +08:00
parent 62d67e70b6
commit f4b776a903
7 changed files with 45 additions and 16 deletions

View File

@ -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;
/** 交易类型 */

View File

@ -32,4 +32,11 @@ public interface BankAccountMapper extends Mapper<BankAccount> {
* @return
*/
String selectMaxBankAccount();
/**
* 根据卡号获取银行账号信息
* @param bankAccount
* @return
*/
BankAccountDTO selectByBankAccount(@Param("bankAccount") String bankAccount);
}

View File

@ -31,7 +31,7 @@ public interface BankAccountService extends Service<BankAccount> {
* @param bankAccount
* @return
*/
BankAccount findByBankAccount(String bankAccount);
BankAccountDTO findByBankAccount(String bankAccount);
/**
* 查询系统社区银行

View File

@ -61,10 +61,8 @@ public class BankAccountServiceImpl extends AbstractService<BankAccount> 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

View File

@ -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<TransactionRec
@Override
public List<TransactionRecordDTO> findTransactionRecords(String bankAccount) {
return transactionRecordMapper.selectTransactionRecords(bankAccount);
List<TransactionRecordDTO> 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<TransactionRec
}
private boolean checkFormAccountStatus(String formBankAccount, BigDecimal money) {
BankAccount bankAccount = bankAccountService.findByBankAccount(formBankAccount);
BankAccountDTO bankAccount = bankAccountService.findByBankAccount(formBankAccount);
if (Objects.nonNull(bankAccount)) {
if (bankAccount.getAccountBalance().compareTo(money) > 0) {
return true;

View File

@ -12,24 +12,30 @@
<result column="created_time" property="createdTime"></result>
</resultMap>
<select id="selectBankAccounts" resultMap="DTOResultMap">
select vb.bank_name, vu.nickname as account_owner_name, vba.* from forest_bank_account vba
join forest_bank vb on vba.id_bank = vb.id
join forest_user vu on vba.account_owner = vu.id where vba.account_type = 0
select fb.bank_name, ifnull(fu.nickname, '系统') as account_owner_name, fba.* from forest_bank_account fba
join forest_bank fb on fba.id_bank = fb.id
left join forest_user fu on fba.account_owner = fu.id where fba.account_type = 0
<if test="bankName != null and bankName != ''">
and vb.bank_name = #{bankName}
and fb.bank_name = #{bankName}
</if>
<if test="accountOwnerName != null and accountOwnerName != ''">
and vu.nickname = #{accountOwnerName}
and fu.nickname = #{accountOwnerName}
</if>
<if test="bankAccount != null and bankAccount != ''">
and vba.bank_account = #{bankAccount}
and fba.bank_account = #{bankAccount}
</if>
</select>
<select id="selectBankAccount" resultMap="DTOResultMap">
select vb.bank_name, vba.* from forest_bank_account vba
join forest_bank vb on vba.id_bank = vb.id where vba.id = #{idBank}
select fb.bank_name, fu.nickname as account_owner_name, fba.* from forest_bank_account fba
join forest_bank fb on fba.id_bank = fb.id
join forest_user fu on fba.account_owner = fu.id where fba.id = #{idBank}
</select>
<select id="selectMaxBankAccount" resultType="java.lang.String">
select max(bank_account) as max_bank_account from forest_bank_account where account_type = 0
</select>
<select id="selectByBankAccount" resultMap="DTOResultMap">
select fb.bank_name, ifnull(fu.nickname, '系统') as account_owner_name, fba.bank_account from forest_bank_account fba
join forest_bank fb on fba.id_bank = fb.id
left join forest_user fu on fba.account_owner = fu.id where fba.bank_account = #{bankAccount}
</select>
</mapper>

View File

@ -16,7 +16,7 @@
update forest_bank_account set account_balance = account_balance + #{money} where bank_account = #{toBankAccount};
</update>
<select id="selectTransactionRecords" resultMap="DTOResultMap">
select * from forest_transaction_record where form_bank_account = #{bankAccount} or to_bank_account = #{bankAccount} order by transaction_time desc
select * from forest_transaction_record ftr where form_bank_account = #{bankAccount} or to_bank_account = #{bankAccount} order by transaction_time desc
</select>
<select id="existsWithBankAccountAndFunds" resultType="java.lang.Boolean">
select ifnull((select false from forest_transaction_record where to_bank_account = #{bankAccount}