✨ 新增了一些功能
1. 银行卡管理-增加交易记录查看功能 2. 我的钱包-交易记录增加时间段检索功能
This commit is contained in:
commit
862ab8c80a
@ -24,9 +24,11 @@ public interface TransactionRecordMapper extends Mapper<TransactionRecord> {
|
||||
/**
|
||||
* 查询指定账户的交易记录
|
||||
* @param bankAccount
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
List<TransactionRecordDTO> selectTransactionRecords(@Param("bankAccount") String bankAccount);
|
||||
List<TransactionRecordDTO> selectTransactionRecords(@Param("bankAccount") String bankAccount, @Param("startDate") String startDate, @Param("endDate") String endDate);
|
||||
|
||||
/**
|
||||
* 校验今日是否已发放答题奖励
|
||||
|
@ -3,8 +3,8 @@ 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.dto.TransactionRecordDTO;
|
||||
import com.rymcu.forest.entity.BankAccount;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -45,4 +45,6 @@ public interface BankAccountService extends Service<BankAccount> {
|
||||
* @return
|
||||
*/
|
||||
BankAccount findInfoByBankAccount(String formBankAccount);
|
||||
|
||||
List<TransactionRecordDTO> findUserTransactionRecords(String bankAccount, String startDate, String endDate);
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import com.rymcu.forest.dto.TransactionRecordDTO;
|
||||
import com.rymcu.forest.entity.TransactionRecord;
|
||||
import com.rymcu.forest.enumerate.TransactionEnum;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -23,9 +22,11 @@ public interface TransactionRecordService extends Service<TransactionRecord> {
|
||||
/**
|
||||
* 查询指定账户的交易记录
|
||||
* @param bankAccount
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
List<TransactionRecordDTO> findTransactionRecords(String bankAccount);
|
||||
List<TransactionRecordDTO> findTransactionRecords(String bankAccount, String startDate, String endDate);
|
||||
|
||||
/**
|
||||
* 根据用户主键进行交易
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.rymcu.forest.service.impl;
|
||||
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import com.rymcu.forest.core.service.AbstractService;
|
||||
import com.rymcu.forest.dto.BankAccountDTO;
|
||||
import com.rymcu.forest.dto.BankAccountSearchDTO;
|
||||
@ -13,6 +14,8 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -54,12 +57,21 @@ public class BankAccountServiceImpl extends AbstractService<BankAccount> impleme
|
||||
bankAccountMapper.insertSelective(bankAccount);
|
||||
bankAccountDTO = bankAccountMapper.selectBankAccount(bankAccount.getIdBankAccount());
|
||||
}
|
||||
// 查询交易记录
|
||||
List<TransactionRecordDTO> records = transactionRecordService.findTransactionRecords(bankAccountDTO.getBankAccount());
|
||||
bankAccountDTO.setTransactionRecords(records);
|
||||
return bankAccountDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TransactionRecordDTO> findUserTransactionRecords(String bankAccount, String startDate, String endDate) {
|
||||
if (StringUtils.isBlank(startDate)) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
endDate = LocalDateTimeUtil.format(now, "yyyy-MM-dd");
|
||||
startDate = LocalDateTimeUtil.format(now.minus(30, ChronoUnit.DAYS), "yyyy-MM-dd");
|
||||
}
|
||||
// 查询交易记录
|
||||
List<TransactionRecordDTO> records = transactionRecordService.findTransactionRecords(bankAccount, startDate, endDate);
|
||||
return records;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BankAccountDTO findByBankAccount(String bankAccount) {
|
||||
return bankAccountMapper.selectByBankAccount(bankAccount);
|
||||
|
@ -23,12 +23,11 @@ public class NotificationServiceImpl extends AbstractService<Notification> imple
|
||||
@Resource
|
||||
private NotificationMapper notificationMapper;
|
||||
|
||||
private final static String unRead = "0";
|
||||
private final static String UN_READ = "0";
|
||||
|
||||
@Override
|
||||
public List<Notification> findUnreadNotifications(Integer idUser) {
|
||||
List<Notification> list = notificationMapper.selectUnreadNotifications(idUser);
|
||||
return list;
|
||||
return notificationMapper.selectUnreadNotifications(idUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -41,7 +40,7 @@ public class NotificationServiceImpl extends AbstractService<Notification> imple
|
||||
BeanCopierUtil.copy(notificationDTO, notification);
|
||||
} else {
|
||||
// 关联数据已删除,且未读
|
||||
if (unRead.equals(notification.getHasRead())) {
|
||||
if (UN_READ.equals(notification.getHasRead())) {
|
||||
notificationMapper.readNotification(notification.getIdNotification());
|
||||
}
|
||||
NotificationDTO dto = new NotificationDTO();
|
||||
|
@ -4,19 +4,15 @@ 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;
|
||||
|
||||
@ -59,8 +55,8 @@ public class TransactionRecordServiceImpl extends AbstractService<TransactionRec
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TransactionRecordDTO> findTransactionRecords(String bankAccount) {
|
||||
List<TransactionRecordDTO> list = transactionRecordMapper.selectTransactionRecords(bankAccount);
|
||||
public List<TransactionRecordDTO> findTransactionRecords(String bankAccount, String startDate, String endDate) {
|
||||
List<TransactionRecordDTO> list = transactionRecordMapper.selectTransactionRecords(bankAccount, startDate, endDate);
|
||||
list.forEach(transactionRecordDTO -> genTransactionRecord(transactionRecordDTO));
|
||||
return list;
|
||||
}
|
||||
|
@ -4,16 +4,15 @@ 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.dto.TransactionRecordDTO;
|
||||
import com.rymcu.forest.service.BankAccountService;
|
||||
import com.rymcu.forest.service.BankService;
|
||||
import com.rymcu.forest.util.Utils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -49,4 +48,19 @@ public class BankAccountController {
|
||||
return GlobalResultGenerator.genSuccessResult(bankAccount);
|
||||
}
|
||||
|
||||
@GetMapping("/transaction-records")
|
||||
public GlobalResult transactionRecords(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "20") Integer rows, HttpServletRequest request) {
|
||||
String bankAccount = request.getParameter("bankAccount");
|
||||
String startDate = request.getParameter("startDate");
|
||||
String endDate = request.getParameter("endDate");
|
||||
PageHelper.startPage(page, rows);
|
||||
List<TransactionRecordDTO> list = bankAccountService.findUserTransactionRecords(bankAccount, startDate, endDate);
|
||||
PageInfo<TransactionRecordDTO> pageInfo = new PageInfo(list);
|
||||
Map map = new HashMap(2);
|
||||
map.put("records", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,10 +36,7 @@ public class BankController {
|
||||
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 pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
|
@ -1,16 +1,21 @@
|
||||
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.core.service.security.annotation.SecurityInterceptor;
|
||||
import com.rymcu.forest.dto.BankAccountDTO;
|
||||
import com.rymcu.forest.dto.TransactionRecordDTO;
|
||||
import com.rymcu.forest.service.BankAccountService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.rymcu.forest.util.Utils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created on 2021/12/10 19:25.
|
||||
@ -32,4 +37,21 @@ public class WalletController {
|
||||
BankAccountDTO bankAccount = bankAccountService.findBankAccountByIdUser(idUser);
|
||||
return GlobalResultGenerator.genSuccessResult(bankAccount);
|
||||
}
|
||||
|
||||
@GetMapping("/transaction-records")
|
||||
@SecurityInterceptor
|
||||
public GlobalResult transactionRecords(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "20") Integer rows, HttpServletRequest request) {
|
||||
String idUser = request.getParameter("idUser");
|
||||
String startDate = request.getParameter("startDate");
|
||||
String endDate = request.getParameter("endDate");
|
||||
BankAccountDTO bankAccount = bankAccountService.findBankAccountByIdUser(Integer.valueOf(idUser));
|
||||
PageHelper.startPage(page, rows);
|
||||
List<TransactionRecordDTO> list = bankAccountService.findUserTransactionRecords(bankAccount.getBankAccount(), startDate, endDate);
|
||||
PageInfo<TransactionRecordDTO> pageInfo = new PageInfo(list);
|
||||
Map map = new HashMap(2);
|
||||
map.put("records", pageInfo.getList());
|
||||
Map pagination = Utils.getPagination(pageInfo);
|
||||
map.put("pagination", pagination);
|
||||
return GlobalResultGenerator.genSuccessResult(map);
|
||||
}
|
||||
}
|
||||
|
@ -11,11 +11,13 @@ import com.rymcu.forest.service.NotificationService;
|
||||
import com.rymcu.forest.util.UserUtils;
|
||||
import com.rymcu.forest.util.Utils;
|
||||
import com.rymcu.forest.web.api.exception.BaseApiException;
|
||||
import com.rymcu.forest.web.api.exception.ErrorCode;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 消息通知
|
||||
@ -31,6 +33,9 @@ public class NotificationController {
|
||||
@GetMapping("/all")
|
||||
public GlobalResult notifications(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) throws BaseApiException {
|
||||
User user = UserUtils.getCurrentUserByToken();
|
||||
if (Objects.isNull(user)) {
|
||||
throw new BaseApiException(ErrorCode.TOKEN_);
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<NotificationDTO> list = notificationService.findNotifications(user.getIdUser());
|
||||
PageInfo<NotificationDTO> pageInfo = new PageInfo(list);
|
||||
@ -41,6 +46,9 @@ public class NotificationController {
|
||||
@GetMapping("/unread")
|
||||
public GlobalResult unreadNotification(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer rows) throws BaseApiException {
|
||||
User user = UserUtils.getCurrentUserByToken();
|
||||
if (Objects.isNull(user)) {
|
||||
throw new BaseApiException(ErrorCode.TOKEN_);
|
||||
}
|
||||
PageHelper.startPage(page, rows);
|
||||
List<Notification> list = notificationService.findUnreadNotifications(user.getIdUser());
|
||||
PageInfo<Notification> pageInfo = new PageInfo(list);
|
||||
|
@ -16,7 +16,10 @@
|
||||
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 ftr 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}
|
||||
and transaction_time between str_to_date(#{startDate}, '%Y-%m-%d') and str_to_date(#{endDate}, '%Y-%m-%d') + 1
|
||||
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}
|
||||
|
Loading…
Reference in New Issue
Block a user