积分系统基础功能实现

This commit is contained in:
ronger 2020-11-30 20:44:38 +08:00
parent 293a99b6fb
commit 047697ecd9
25 changed files with 859 additions and 1 deletions

2
.gitignore vendored
View File

@ -18,6 +18,7 @@ target/
*.iws *.iws
*.iml *.iml
*.ipr *.ipr
/.mvn/
### NetBeans ### ### NetBeans ###
/nbproject/private/ /nbproject/private/
@ -29,4 +30,3 @@ build/
### VS Code ### ### VS Code ###
.vscode/ .vscode/
/.mvn/

View File

@ -0,0 +1,35 @@
package com.rymcu.forest.dto;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @author ronger
*/
@Data
public class BankAccountDTO {
private Integer idBankAccount;
/** 所属银行 */
private Integer idBank;
/** 所属银行名称 */
private String bankName;
/** 银行账户 */
private String bankAccount;
/** 账户余额 */
private BigDecimal accountBalance;
/** 账户所有者 */
private Integer accountOwner;
/** 账户所有者姓名 */
private String accountOwnerName;
/** 创建时间 */
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date createdTime;
private List<TransactionRecordDTO> transactionRecords;
}

View File

@ -0,0 +1,17 @@
package com.rymcu.forest.dto;
import lombok.Data;
/**
* @author ronger
*/
@Data
public class BankAccountSearchDTO {
/** 所属银行名称 */
private String bankName;
/** 银行账户 */
private String bankAccount;
/** 账户所有者姓名 */
private String accountOwnerName;
}

View File

@ -0,0 +1,33 @@
package com.rymcu.forest.dto;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author ronger
*/
@Data
public class BankDTO {
private Integer idBank;
/** 银行名称 */
private String bankName;
/** 银行负责人 */
private Integer bankOwner;
/** 银行负责人 */
private String bankOwnerName;
/** 银行账户 */
private String bankAccount;
/** 账户余额 */
private BigDecimal accountBalance;
/** 银行描述 */
private String bankDescription;
/** 创建人 */
private Integer createdBy;
/** 创建时间 */
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date createdTime;
}

View File

@ -0,0 +1,32 @@
package com.rymcu.forest.dto;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author ronger
*/
@Data
public class TransactionRecordDTO {
private Integer idTransactionRecord;
/** 交易流水号 */
private String transactionNo;
/** 款项 */
private String funds;
/** 交易发起方 */
private String formBankAccount;
/** 交易收款方 */
private String toBankAccount;
/** 交易金额 */
private BigDecimal money;
/** 交易类型 */
private String transactionType;
/** 交易时间 */
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date transactionTime;
}

View File

@ -0,0 +1,37 @@
package com.rymcu.forest.entity;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/**
* 银行
* @author ronger
*/
@Table(name = "vertical_bank")
@Data
public class Bank {
/** 主键 */
@Id
@Column(name = "id")
@GeneratedValue(generator = "JDBC")
private Integer idBank;
/** 银行名称 */
private String bankName;
/** 银行负责人 */
private Integer bankOwner;
/** 银行描述 */
private String bankDescription;
/** 创建人 */
private Integer createdBy;
/** 创建时间 */
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date createdTime;
}

View File

@ -0,0 +1,38 @@
package com.rymcu.forest.entity;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;
/**
* 银行账户
* @author ronger
*/
@Table(name = "vertical_bank_account")
@Data
public class BankAccount {
/** 主键 */
@Id
@Column(name = "id")
@GeneratedValue(generator = "JDBC")
private Integer idBankAccount;
/** 所属银行 */
private Integer idBank;
/** 银行账户 */
private String bankAccount;
/** 账户余额 */
private BigDecimal accountBalance;
/** 账户所有者 */
private Integer accountOwner;
/** 创建时间 */
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private Date createdTime;
/** 账户类型 */
private String accountType;
}

View File

@ -0,0 +1,29 @@
package com.rymcu.forest.entity;
import lombok.Data;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;
/**
* 货币发行记录
* @author ronger
*/
@Table(name = "vertical_currency_issue")
@Data
public class CurrencyIssue {
/** 主键 */
@Id
@GeneratedValue(generator = "JDBC")
private Integer id;
/** 发行数额 */
private BigDecimal issueValue;
/** 发行人 */
private Integer createdBy;
/** 发行时间 */
private Date createdTime;
}

View File

@ -0,0 +1,38 @@
package com.rymcu.forest.entity;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;
/**
* 交易记录
* @author ronger
*/
@Table(name = "vertical_transaction_record")
@Data
public class TransactionRecord {
/** 主键 */
@Id
@Column(name = "id")
@GeneratedValue(generator = "JDBC")
private Integer idTransactionRecord;
/** 交易流水号 */
private String transactionNo;
/** 款项 */
private String funds;
/** 交易发起方 */
private String formBankAccount;
/** 交易收款方 */
private String toBankAccount;
/** 交易金额 */
private BigDecimal money;
/** 交易类型 */
private String transactionType;
/** 交易时间 */
private Date transactionTime;
}

View File

@ -0,0 +1,35 @@
package com.rymcu.forest.mapper;
import com.rymcu.forest.core.mapper.Mapper;
import com.rymcu.forest.dto.BankAccountDTO;
import com.rymcu.forest.entity.BankAccount;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author ronger
*/
public interface BankAccountMapper extends Mapper<BankAccount> {
/**
* 查询银行账户
* @param bankName
* @param accountOwnerName
* @param bankAccount
* @return
*/
List<BankAccountDTO> selectBankAccounts(@Param("bankName") String bankName, @Param("accountOwnerName") String accountOwnerName, @Param("bankAccount") String bankAccount);
/**
* 获取银行账户信息
* @param idBank
* @return
*/
BankAccountDTO selectBankAccount(@Param("idBank") Integer idBank);
/**
* 获取当前最大卡号
* @return
*/
String selectMaxBankAccount();
}

View File

@ -0,0 +1,18 @@
package com.rymcu.forest.mapper;
import com.rymcu.forest.core.mapper.Mapper;
import com.rymcu.forest.dto.BankDTO;
import com.rymcu.forest.entity.Bank;
import java.util.List;
/**
* @author ronger
*/
public interface BankMapper extends Mapper<Bank> {
/**
* 查询银行列表数据
* @return
*/
List<BankDTO> selectBanks();
}

View File

@ -0,0 +1,30 @@
package com.rymcu.forest.mapper;
import com.rymcu.forest.core.mapper.Mapper;
import com.rymcu.forest.dto.TransactionRecordDTO;
import com.rymcu.forest.entity.TransactionRecord;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
/**
* @author ronger
*/
public interface TransactionRecordMapper extends Mapper<TransactionRecord> {
/**
* 交易
* @param formBankAccount
* @param toBankAccount
* @param money
* @return
*/
Integer transfer(@Param("formBankAccount") String formBankAccount, @Param("toBankAccount") String toBankAccount, @Param("money") BigDecimal money);
/**
* 查询指定账户的交易记录
* @param bankAccount
* @return
*/
List<TransactionRecordDTO> selectTransactionRecords(@Param("bankAccount") String bankAccount);
}

View File

@ -0,0 +1,35 @@
package com.rymcu.forest.service;
import com.rymcu.forest.core.service.Service;
import com.rymcu.forest.dto.BankAccountDTO;
import com.rymcu.forest.dto.BankAccountSearchDTO;
import com.rymcu.forest.entity.BankAccount;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author ronger
*/
public interface BankAccountService extends Service<BankAccount> {
/**
* 查询银行账户列表
* @param bankAccountSearchDTO
* @return
*/
List<BankAccountDTO> findBankAccounts(BankAccountSearchDTO bankAccountSearchDTO);
/**
* 查询用户银行账户
* @param idUser
* @return
*/
BankAccountDTO findBankAccountByIdUser(Integer idUser);
/**
* 根据账户查询银行账户信息
* @param bankAccount
* @return
*/
BankAccount findByBankAccount(String bankAccount);
}

View File

@ -0,0 +1,14 @@
package com.rymcu.forest.service;
import com.rymcu.forest.core.service.Service;
import com.rymcu.forest.dto.BankDTO;
import com.rymcu.forest.entity.Bank;
import java.util.List;
/**
* @author ronger
*/
public interface BankService extends Service<Bank> {
List<BankDTO> findBanks();
}

View File

@ -0,0 +1,27 @@
package com.rymcu.forest.service;
import com.rymcu.forest.core.exception.ServiceException;
import com.rymcu.forest.core.service.Service;
import com.rymcu.forest.dto.TransactionRecordDTO;
import com.rymcu.forest.entity.TransactionRecord;
import java.util.List;
/**
* @author ronger
*/
public interface TransactionRecordService extends Service<TransactionRecord> {
/**
* 交易
* @param transactionRecord
* @return
*/
TransactionRecord transfer(TransactionRecord transactionRecord);
/**
* 查询指定账户的交易记录
* @param bankAccount
* @return
*/
List<TransactionRecordDTO> findTransactionRecords(String bankAccount);
}

View File

@ -0,0 +1,79 @@
package com.rymcu.forest.service.impl;
import com.rymcu.forest.core.service.AbstractService;
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.mapper.BankAccountMapper;
import com.rymcu.forest.service.BankAccountService;
import com.rymcu.forest.service.TransactionRecordService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* @author ronger
*/
@Service
public class BankAccountServiceImpl extends AbstractService<BankAccount> implements BankAccountService {
private static String DEFAULT_ACCOUNT_TYPE = "0";
@Resource
BankAccountMapper bankAccountMapper;
@Resource
TransactionRecordService transactionRecordService;
@Override
public List<BankAccountDTO> findBankAccounts(BankAccountSearchDTO bankAccountSearchDTO) {
List<BankAccountDTO> bankAccounts = bankAccountMapper.selectBankAccounts(bankAccountSearchDTO.getBankName(), bankAccountSearchDTO.getAccountOwnerName(), bankAccountSearchDTO.getBankAccount());
return bankAccounts;
}
@Override
public BankAccountDTO findBankAccountByIdUser(Integer idUser) {
BankAccount bankAccount = new BankAccount();
bankAccount.setAccountOwner(idUser);
bankAccount.setAccountType(DEFAULT_ACCOUNT_TYPE);
List<BankAccount> bankAccounts = bankAccountMapper.select(bankAccount);
BankAccountDTO bankAccountDTO;
if (Objects.nonNull(bankAccounts) && bankAccounts.size() > 0) {
bankAccountDTO = bankAccountMapper.selectBankAccount(bankAccounts.get(0).getIdBankAccount());
} else {
bankAccount.setAccountBalance(new BigDecimal("0"));
// 默认为社区发展与改革银行
bankAccount.setIdBank(2);
bankAccount.setBankAccount(nextBankAccount());
bankAccount.setCreatedTime(new Date());
bankAccountMapper.insertSelective(bankAccount);
bankAccountDTO = bankAccountMapper.selectBankAccount(bankAccount.getIdBankAccount());
}
// 查询交易记录
List<TransactionRecordDTO> records = transactionRecordService.findTransactionRecords(bankAccountDTO.getBankAccount());
bankAccountDTO.setTransactionRecords(records);
return bankAccountDTO;
}
@Override
public BankAccount findByBankAccount(String bankAccount) {
BankAccount searchBankAccount = new BankAccount();
searchBankAccount.setBankAccount(bankAccount);
return bankAccountMapper.selectOne(searchBankAccount);
}
private String nextBankAccount() {
String bankAccount = "600000001";
String maxBankAccount = bankAccountMapper.selectMaxBankAccount();
if (StringUtils.isNotBlank(maxBankAccount)) {
BigDecimal bigDecimal = new BigDecimal(maxBankAccount).add(new BigDecimal("1"));
return bigDecimal.toString();
}
return bankAccount;
}
}

View File

@ -0,0 +1,27 @@
package com.rymcu.forest.service.impl;
import com.rymcu.forest.core.service.AbstractService;
import com.rymcu.forest.dto.BankDTO;
import com.rymcu.forest.entity.Bank;
import com.rymcu.forest.mapper.BankMapper;
import com.rymcu.forest.service.BankService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @author ronger
*/
@Service
public class BankServiceImpl extends AbstractService<Bank> implements BankService {
@Resource
private BankMapper bankMapper;
@Override
public List<BankDTO> findBanks() {
List<BankDTO> banks = bankMapper.selectBanks();
return banks;
}
}

View File

@ -0,0 +1,91 @@
package com.rymcu.forest.service.impl;
import com.rymcu.forest.core.exception.ServiceException;
import com.rymcu.forest.core.service.AbstractService;
import com.rymcu.forest.core.service.redis.RedisService;
import com.rymcu.forest.dto.TransactionRecordDTO;
import com.rymcu.forest.entity.BankAccount;
import com.rymcu.forest.entity.TransactionRecord;
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 org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* @author ronger
*/
@Service
public class TransactionRecordServiceImpl extends AbstractService<TransactionRecord> implements TransactionRecordService {
@Resource
private TransactionRecordMapper transactionRecordMapper;
@Resource
private BankAccountService bankAccountService;
@Resource
private RedisService redisService;
@Override
@Transactional(rollbackFor = Exception.class)
public TransactionRecord transfer(TransactionRecord transactionRecord) {
// 判断发起者账户状态
boolean formAccountStatus = checkFormAccountStatus(transactionRecord.getFormBankAccount(), transactionRecord.getMoney());
if (formAccountStatus) {
Integer result = transactionRecordMapper.transfer(transactionRecord.getFormBankAccount(), transactionRecord.getToBankAccount(), transactionRecord.getMoney());
if (result > 0) {
transactionRecord.setTransactionNo(nextTransactionNo());
transactionRecord.setTransactionTime(new Date());
transactionRecordMapper.insertSelective(transactionRecord);
}
}
return transactionRecord;
}
@Override
public List<TransactionRecordDTO> findTransactionRecords(String bankAccount) {
return transactionRecordMapper.selectTransactionRecords(bankAccount);
}
private String nextTransactionNo() {
String orderNo = "E";
String key = "orderId";
int timeout = 60;
//根据时间获取前缀
String prefix = getPrefix(new Date());
//使用redis获取自增ID
long id = redisService.incrBy(key, timeout);
return orderNo + prefix + DateUtil.getNowDateNum() + String.format("%1$05d", id);
}
private static String getPrefix(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
int year = c.get(Calendar.YEAR);
int day = c.get(Calendar.DAY_OF_YEAR);
int hour = c.get(Calendar.HOUR_OF_DAY);
//天数转为3位字符串,不满3位用0补齐
String dayFmt = String.format("%1$03d", day);
//小时转为2位字符串,不满2位用0补齐
String hourFmt = String.format("%1$02d", hour);
//2位年份+3位天数+2位小时
return (year - 2000) + dayFmt + hourFmt;
}
private boolean checkFormAccountStatus(String formBankAccount, BigDecimal money) {
BankAccount bankAccount = bankAccountService.findByBankAccount(formBankAccount);
if (Objects.nonNull(bankAccount)) {
if (bankAccount.getAccountBalance().compareTo(money) > 0) {
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,38 @@
package com.rymcu.forest.util;
import org.apache.commons.lang.StringUtils;
import java.util.Calendar;
/**
* @author ronger
*/
public class DateUtil {
public static String strLen(String s, int len) {
if (StringUtils.isBlank(s)) {
s = "";
}
for (int i = 0; i < len - s.length(); ++i) {
s = "0" + s;
}
return s;
}
public static String getYear(Calendar cal) {
return String.valueOf(cal.get(1));
}
public static String getMonth(Calendar cal) {
return strLen(String.valueOf(cal.get(2) + 1), 2);
}
public static String getDay(Calendar cal) {
return strLen(String.valueOf(cal.get(5)), 2);
}
public static String getNowDateNum() {
Calendar cal = Calendar.getInstance();
return getYear(cal) + getMonth(cal) + getDay(cal);
}
}

View File

@ -0,0 +1,52 @@
package com.rymcu.forest.web.api.bank;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rymcu.forest.core.result.GlobalResult;
import com.rymcu.forest.core.result.GlobalResultGenerator;
import com.rymcu.forest.dto.ArticleDTO;
import com.rymcu.forest.dto.BankAccountDTO;
import com.rymcu.forest.dto.BankAccountSearchDTO;
import com.rymcu.forest.entity.Bank;
import com.rymcu.forest.entity.BankAccount;
import com.rymcu.forest.service.BankAccountService;
import com.rymcu.forest.service.BankService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author ronger
*/
@RestController
@RequestMapping("/api/v1/admin/bank-account")
public class BankAccountController {
@Resource
private BankAccountService bankAccountService;
@GetMapping("/list")
public GlobalResult banks(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows, BankAccountSearchDTO bankAccountSearchDTO) {
PageHelper.startPage(page, rows);
List<BankAccountDTO> list = bankAccountService.findBankAccounts(bankAccountSearchDTO);
PageInfo<BankAccountDTO> pageInfo = new PageInfo(list);
Map map = new HashMap(2);
map.put("bankAccounts", pageInfo.getList());
Map pagination = new HashMap(4);
pagination.put("pageSize", pageInfo.getPageSize());
pagination.put("total", pageInfo.getTotal());
pagination.put("currentPage", pageInfo.getPageNum());
map.put("pagination", pagination);
return GlobalResultGenerator.genSuccessResult(map);
}
@GetMapping("/{idUser}")
public GlobalResult detail(@PathVariable Integer idUser) {
BankAccountDTO bankAccount = bankAccountService.findBankAccountByIdUser(idUser);
return GlobalResultGenerator.genSuccessResult(bankAccount);
}
}

View File

@ -0,0 +1,47 @@
package com.rymcu.forest.web.api.bank;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rymcu.forest.core.result.GlobalResult;
import com.rymcu.forest.core.result.GlobalResultGenerator;
import com.rymcu.forest.dto.ArticleDTO;
import com.rymcu.forest.dto.BankDTO;
import com.rymcu.forest.entity.Bank;
import com.rymcu.forest.service.BankService;
import com.rymcu.forest.util.Utils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author ronger
*/
@RestController
@RequestMapping("/api/v1/admin/bank")
public class BankController {
@Resource
private BankService bankService;
@GetMapping("/list")
public GlobalResult banks(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) {
PageHelper.startPage(page, rows);
List<BankDTO> list = bankService.findBanks();
PageInfo<BankDTO> pageInfo = new PageInfo(list);
Map map = new HashMap(2);
map.put("banks", pageInfo.getList());
Map pagination = new HashMap(4);
pagination.put("pageSize", pageInfo.getPageSize());
pagination.put("total", pageInfo.getTotal());
pagination.put("currentPage", pageInfo.getPageNum());
map.put("pagination", pagination);
return GlobalResultGenerator.genSuccessResult(map);
}
}

View File

@ -0,0 +1,31 @@
package com.rymcu.forest.web.api.bank;
import com.rymcu.forest.core.exception.ServiceException;
import com.rymcu.forest.core.result.GlobalResult;
import com.rymcu.forest.core.result.GlobalResultGenerator;
import com.rymcu.forest.entity.TransactionRecord;
import com.rymcu.forest.service.TransactionRecordService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @author ronger
*/
@RestController
@RequestMapping("/api/v1/transaction")
public class TransactionRecordController {
@Resource
private TransactionRecordService transactionRecordService;
@PostMapping("/transfer")
public GlobalResult transfer(@RequestBody TransactionRecord transactionRecord) {
transactionRecord = transactionRecordService.transfer(transactionRecord);
return GlobalResultGenerator.genSuccessResult(transactionRecord);
}
}

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.rymcu.forest.mapper.BankAccountMapper">
<resultMap id="DTOResultMap" type="com.rymcu.forest.dto.BankAccountDTO">
<result column="id" property="idBankAccount"></result>
<result column="id_bank" property="idBank"></result>
<result column="bank_name" property="bankName"></result>
<result column="bank_account" property="bankAccount"></result>
<result column="account_balance" property="accountBalance"></result>
<result column="account_owner" property="accountOwner"></result>
<result column="account_owner_name" property="accountOwnerName"></result>
<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 vertical_bank_account vba
join vertical_bank vb on vba.id_bank = vb.id
join vertical_user vu on vba.account_owner = vu.id where vba.account_type = 0
<if test="bankName != null and bankName != ''">
and vb.bank_name = #{bankName}
</if>
<if test="accountOwnerName != null and accountOwnerName != ''">
and vu.nickname = #{accountOwnerName}
</if>
<if test="bankAccount != null and bankAccount != ''">
and vba.bank_account = #{bankAccount}
</if>
</select>
<select id="selectBankAccount" resultMap="DTOResultMap">
select vb.bank_name, vba.* from vertical_bank_account vba
join vertical_bank vb on vba.id_bank = vb.id where vba.id = #{idBank}
</select>
<select id="selectMaxBankAccount" resultType="java.lang.String">
select max(bank_account) as max_bank_account from vertical_bank_account where account_type = 0
</select>
</mapper>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.rymcu.forest.mapper.BankMapper">
<resultMap id="DTOResultMap" type="com.rymcu.forest.dto.BankDTO">
<result column="id" property="idBank"></result>
<result column="bank_name" property="bankName"></result>
<result column="bank_owner" property="bankOwner"></result>
<result column="bank_owner_name" property="bankOwnerName"></result>
<result column="bank_account" property="bankAccount"></result>
<result column="account_balance" property="accountBalance"></result>
<result column="created_by" property="createdBy"></result>
<result column="created_time" property="createdTime"></result>
<result column="bank_description" property="bankDescription"></result>
</resultMap>
<select id="selectBanks" resultMap="DTOResultMap">
select vb.*, vba.bank_account, vba.account_balance from vertical_bank_account vba
join vertical_bank vb on vba.account_owner = vb.id where vba.account_type = 1
</select>
</mapper>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.rymcu.forest.mapper.TransactionRecordMapper">
<resultMap id="DTOResultMap" type="com.rymcu.forest.dto.TransactionRecordDTO">
<result column="id" property="idTransactionRecord"></result>
<result column="transaction_no" property="transactionNo"></result>
<result column="funds" property="funds"></result>
<result column="form_bank_account" property="formBankAccount"></result>
<result column="to_bank_account" property="toBankAccount"></result>
<result column="money" property="money"></result>
<result column="transaction_type" property="transactionType"></result>
<result column="transaction_time" property="transactionTime"></result>
</resultMap>
<update id="transfer">
update vertical_bank_account set account_balance = account_balance - #{money} where bank_account = #{formBankAccount};
update vertical_bank_account set account_balance = account_balance + #{money} where bank_account = #{toBankAccount};
</update>
<select id="selectTransactionRecords" resultMap="DTOResultMap">
select * from vertical_transaction_record where form_bank_account = #{bankAccount} or to_bank_account = #{bankAccount}
</select>
</mapper>