From 1bd8c0b433feb8d950ffde6265ca64e76f3e3416 Mon Sep 17 00:00:00 2001 From: pikaqiudeshujia Date: Sat, 11 May 2024 15:12:12 +0800 Subject: [PATCH] =?UTF-8?q?release-=20=E7=94=A8=E6=88=B7=E7=9A=84=E6=8F=90?= =?UTF-8?q?=E7=8E=B0=E5=8F=8A=E9=93=B6=E8=A1=8C=E5=8D=A1=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/constants/ErrorConstants.java | 6 + .../main/java/enums/UserBankStateEnum.java | 27 ++++ .../main/java/enums/WithdrawStateEnum.java | 38 +++++ .../luoo/user/controller/MyController.java | 51 ++++++- .../user/dao/{TbBankDao.java => BankDao.java} | 4 +- .../java/com/luoo/user/dao/TbUserBankDao.java | 16 -- .../java/com/luoo/user/dao/TbWithdrawDao.java | 16 -- .../java/com/luoo/user/dao/UserBankDao.java | 28 ++++ .../java/com/luoo/user/dao/WithdrawDao.java | 23 +++ .../luoo/user/dto/bank/UserBankAddDto.java | 33 ++++ .../luoo/user/pojo/{TbBank.java => Bank.java} | 2 +- .../pojo/{TbUserBank.java => UserBank.java} | 2 +- .../pojo/{TbWithdraw.java => Withdraw.java} | 7 +- .../luoo/user/service/UserInfoService.java | 144 +++++++++++++++++- 14 files changed, 358 insertions(+), 39 deletions(-) create mode 100644 luoo_common/src/main/java/enums/UserBankStateEnum.java create mode 100644 luoo_common/src/main/java/enums/WithdrawStateEnum.java rename luoo_user/src/main/java/com/luoo/user/dao/{TbBankDao.java => BankDao.java} (70%) delete mode 100644 luoo_user/src/main/java/com/luoo/user/dao/TbUserBankDao.java delete mode 100644 luoo_user/src/main/java/com/luoo/user/dao/TbWithdrawDao.java create mode 100644 luoo_user/src/main/java/com/luoo/user/dao/UserBankDao.java create mode 100644 luoo_user/src/main/java/com/luoo/user/dao/WithdrawDao.java create mode 100644 luoo_user/src/main/java/com/luoo/user/dto/bank/UserBankAddDto.java rename luoo_user/src/main/java/com/luoo/user/pojo/{TbBank.java => Bank.java} (91%) rename luoo_user/src/main/java/com/luoo/user/pojo/{TbUserBank.java => UserBank.java} (97%) rename luoo_user/src/main/java/com/luoo/user/pojo/{TbWithdraw.java => Withdraw.java} (87%) diff --git a/luoo_common/src/main/java/constants/ErrorConstants.java b/luoo_common/src/main/java/constants/ErrorConstants.java index cd9e21c..65daa0d 100644 --- a/luoo_common/src/main/java/constants/ErrorConstants.java +++ b/luoo_common/src/main/java/constants/ErrorConstants.java @@ -42,4 +42,10 @@ public class ErrorConstants { public final static String REAL_NAME_ERROR = "实名认证错误"; public final static String REASONS_FOR_REFUSAL_MUST_BE_GIVEN = "必须填写拒绝理由"; + + public final static String THE_BANK_CARD_HAS_BEEN_BOUND = "该银行卡已绑定"; + + public final static String NO_BANK_CARD = "没有绑定银行卡"; + + public final static String AMOUNT_MUST_BE_GREATER_THAN_0 = "金额必须大于0"; } diff --git a/luoo_common/src/main/java/enums/UserBankStateEnum.java b/luoo_common/src/main/java/enums/UserBankStateEnum.java new file mode 100644 index 0000000..4bba5da --- /dev/null +++ b/luoo_common/src/main/java/enums/UserBankStateEnum.java @@ -0,0 +1,27 @@ +package enums; + +import lombok.Getter; + +/** + * @Author: yawei.huang + * @Package: enums + * @Project: luoo_parent + * @Date: 2024/5/11 11:19 + * @Filename: UserBankStateEnum + * @Describe: + */ +@Getter +public enum UserBankStateEnum { + + BIND(1, "绑定"), + + UNBIND(2, "解绑"); + + private Integer code; + private String desc; + + UserBankStateEnum(Integer code, String desc) { + this.code = code; + this.desc = desc; + } +} diff --git a/luoo_common/src/main/java/enums/WithdrawStateEnum.java b/luoo_common/src/main/java/enums/WithdrawStateEnum.java new file mode 100644 index 0000000..81365a3 --- /dev/null +++ b/luoo_common/src/main/java/enums/WithdrawStateEnum.java @@ -0,0 +1,38 @@ +package enums; + +import lombok.Getter; + +/** + * @Author: yawei.huang + * @Package: enums + * @Project: luoo_parent + * @Date: 2024/5/11 14:01 + * @Filename: WithdrawStateEnum + * @Describe: + */ +@Getter +public enum WithdrawStateEnum { + + INITIATED(1, "已发起"), + + SUCCESS(2, "已成功"), + + FAIL(3, "失败"); + + private Integer code; + private String desc; + + WithdrawStateEnum(Integer code, String desc) { + this.code = code; + this.desc = desc; + } + + public static WithdrawStateEnum getByCode(Integer code) { + for (WithdrawStateEnum item : WithdrawStateEnum.values()) { + if (item.getCode().equals(code)) { + return item; + } + } + return null; + } +} diff --git a/luoo_user/src/main/java/com/luoo/user/controller/MyController.java b/luoo_user/src/main/java/com/luoo/user/controller/MyController.java index 7d6757f..cddc65f 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/MyController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/MyController.java @@ -8,6 +8,7 @@ import api.StatusCode; import com.github.houbb.sensitive.word.bs.SensitiveWordBs; import com.luoo.user.dao.UserMessageDao; import com.luoo.user.dto.*; +import com.luoo.user.dto.bank.UserBankAddDto; import com.luoo.user.dto.request.LoginReq; import com.luoo.user.dto.request.LogoffReq; import com.luoo.user.dto.response.UserRespDTO; @@ -42,6 +43,7 @@ import util.ScaleFilter; import util.StringTools; import java.io.IOException; +import java.math.BigDecimal; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -579,7 +581,7 @@ public class MyController extends BaseController { @GetMapping("/get/real/name/{id}") public Result getUserRealName( @RequestHeader(value = "Authorization", required = true) String authorization, - @ApiParam(value = "实名认证的id" ,required = true)@PathVariable String id) { + @ApiParam(value = "实名认证的id", required = true) @PathVariable String id) { return Result.success(userInfoService.getUserRealName(id)); } @@ -607,5 +609,52 @@ public class MyController extends BaseController { return userInfoService.getRealNameInfo(userId); } + @ApiOperation(value = "16.1 用户绑定银行卡号") + @PostMapping("/add/bank") + @GlobalInterceptor(checkAppUserLogin = true) + public Result addUserBank(@ApiParam(value = "用户token", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, + @ApiParam(value = "添加用户银行卡绑定对象", required = true) @Validated @RequestBody UserBankAddDto userBankAddDto + ) { + + userInfoService.addUserBank(authorization, userBankAddDto); + return Result.success(); + } + + @ApiOperation(value = "16.2 用户解绑银行卡") + @PostMapping("/del/bank/{id}") + @GlobalInterceptor(checkAppUserLogin = true) + public Result delUserBank(@ApiParam(value = "用户token", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, + @ApiParam(value = "用户绑定银行卡id", required = true) @PathVariable String id) { + userInfoService.untieCard(authorization, id); + return Result.success(); + } + + @ApiOperation(value = "16.3 查看用户已绑定的银行卡号") + @GetMapping("/bank/info") + @GlobalInterceptor(checkAppUserLogin = true) + public Result getUserBankInfo(@ApiParam(value = "用户token", required = true) @RequestHeader(value = "Authorization", required = true) String authorization) { + return Result.success(userInfoService.getUserBank(authorization)); + } + + @ApiOperation(value = "17.1 发出提现申请") + @PostMapping("/approve/withdraw") + @GlobalInterceptor(checkAppUserLogin = true) + public Result approveWithdraw(@ApiParam(value = "用户token", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, + @ApiParam(value = "金额", required = true) BigDecimal amount) { + userInfoService.approveWithdraw(authorization, amount); + return Result.success(); + } + + @ApiOperation(value = "17.2 查询提现记录") + @GetMapping("/withdraw/{pageNum}/{pageSize}") + @GlobalInterceptor(checkAppUserLogin = true) + public Result> pageResultResult( + @RequestHeader(value = "Authorization", required = true) String authorization, + @PathVariable @VerifyParam(required = true) Integer pageNum, + @PathVariable @VerifyParam(required = true) Integer pageSize) { + + return Result.success(userInfoService.withdrawPageResult(authorization, pageNum, pageSize)); + } + } diff --git a/luoo_user/src/main/java/com/luoo/user/dao/TbBankDao.java b/luoo_user/src/main/java/com/luoo/user/dao/BankDao.java similarity index 70% rename from luoo_user/src/main/java/com/luoo/user/dao/TbBankDao.java rename to luoo_user/src/main/java/com/luoo/user/dao/BankDao.java index 28fc047..82c68d3 100644 --- a/luoo_user/src/main/java/com/luoo/user/dao/TbBankDao.java +++ b/luoo_user/src/main/java/com/luoo/user/dao/BankDao.java @@ -1,6 +1,6 @@ package com.luoo.user.dao; -import com.luoo.user.pojo.TbBank; +import com.luoo.user.pojo.Bank; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; @@ -12,5 +12,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; * @Filename: TbBankDao * @Describe: */ -public interface TbBankDao extends JpaRepository, JpaSpecificationExecutor { +public interface BankDao extends JpaRepository, JpaSpecificationExecutor { } diff --git a/luoo_user/src/main/java/com/luoo/user/dao/TbUserBankDao.java b/luoo_user/src/main/java/com/luoo/user/dao/TbUserBankDao.java deleted file mode 100644 index 3599db7..0000000 --- a/luoo_user/src/main/java/com/luoo/user/dao/TbUserBankDao.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.luoo.user.dao; - -import com.luoo.user.pojo.TbUserBank; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; - -/** - * @Author: yawei.huang - * @Package: com.luoo.user.dao - * @Project: luoo_parent - * @Date: 2024/5/11 10:59 - * @Filename: TbUserBankDao - * @Describe: - */ -public interface TbUserBankDao extends JpaRepository, JpaSpecificationExecutor { -} diff --git a/luoo_user/src/main/java/com/luoo/user/dao/TbWithdrawDao.java b/luoo_user/src/main/java/com/luoo/user/dao/TbWithdrawDao.java deleted file mode 100644 index 233f4f0..0000000 --- a/luoo_user/src/main/java/com/luoo/user/dao/TbWithdrawDao.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.luoo.user.dao; - -import com.luoo.user.pojo.TbWithdraw; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; - -/** - * @Author: yawei.huang - * @Package: com.luoo.user.dao - * @Project: luoo_parent - * @Date: 2024/5/11 11:00 - * @Filename: TbWithdrawDao - * @Describe: - */ -public interface TbWithdrawDao extends JpaRepository, JpaSpecificationExecutor { -} diff --git a/luoo_user/src/main/java/com/luoo/user/dao/UserBankDao.java b/luoo_user/src/main/java/com/luoo/user/dao/UserBankDao.java new file mode 100644 index 0000000..45d4056 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/dao/UserBankDao.java @@ -0,0 +1,28 @@ +package com.luoo.user.dao; + +import com.luoo.user.pojo.UserBank; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; + +import java.util.List; + +/** + * @Author: yawei.huang + * @Package: com.luoo.user.dao + * @Project: luoo_parent + * @Date: 2024/5/11 10:59 + * @Filename: TbUserBankDao + * @Describe: + */ +public interface UserBankDao extends JpaRepository, JpaSpecificationExecutor { + + public List findAllByBankCardAndStateAndUserId(String bankCard, Integer state, String userId); + + @Modifying + @Query(value = "update tb_user_bank set state = 2 where user_id = ?") + public void untieAllCard(String userId); + + public UserBank findAllByUserIdAndState(String userId, Integer state); +} diff --git a/luoo_user/src/main/java/com/luoo/user/dao/WithdrawDao.java b/luoo_user/src/main/java/com/luoo/user/dao/WithdrawDao.java new file mode 100644 index 0000000..626f0e0 --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/dao/WithdrawDao.java @@ -0,0 +1,23 @@ +package com.luoo.user.dao; + +import com.luoo.user.pojo.Withdraw; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Query; + +/** + * @Author: yawei.huang + * @Package: com.luoo.user.dao + * @Project: luoo_parent + * @Date: 2024/5/11 11:00 + * @Filename: TbWithdrawDao + * @Describe: + */ +public interface WithdrawDao extends JpaRepository, JpaSpecificationExecutor { + + + @Query(value = "select * from tb_withdraw t1 where t1.user_id = ?1", countProjection = "t1.id", nativeQuery = true) + public Page findListByUserId(String userId, Pageable pageable); +} diff --git a/luoo_user/src/main/java/com/luoo/user/dto/bank/UserBankAddDto.java b/luoo_user/src/main/java/com/luoo/user/dto/bank/UserBankAddDto.java new file mode 100644 index 0000000..c7ff7dd --- /dev/null +++ b/luoo_user/src/main/java/com/luoo/user/dto/bank/UserBankAddDto.java @@ -0,0 +1,33 @@ +package com.luoo.user.dto.bank; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author: yawei.huang + * @Package: com.luoo.user.dto.bank + * @Project: luoo_parent + * @Date: 2024/5/11 11:06 + * @Filename: UserBankAddDto + * @Describe: 用户绑定银行卡 + */ +@Data +public class UserBankAddDto implements Serializable { + @ApiModelProperty(value = "银行卡号") + @NotBlank + private String bankCard; + + @ApiModelProperty(value = "银行id") + private String bankId; + + @ApiModelProperty(value = "银行名称") + private String bankName; + + @ApiModelProperty(value = "手机号") + @NotBlank + private String phone; + +} diff --git a/luoo_user/src/main/java/com/luoo/user/pojo/TbBank.java b/luoo_user/src/main/java/com/luoo/user/pojo/Bank.java similarity index 91% rename from luoo_user/src/main/java/com/luoo/user/pojo/TbBank.java rename to luoo_user/src/main/java/com/luoo/user/pojo/Bank.java index 52ccfe3..078700a 100644 --- a/luoo_user/src/main/java/com/luoo/user/pojo/TbBank.java +++ b/luoo_user/src/main/java/com/luoo/user/pojo/Bank.java @@ -16,7 +16,7 @@ import java.io.Serializable; @ToString @Entity @Table(name = "tb_bank") -public class TbBank implements Serializable { +public class Bank implements Serializable { @Id private String id; diff --git a/luoo_user/src/main/java/com/luoo/user/pojo/TbUserBank.java b/luoo_user/src/main/java/com/luoo/user/pojo/UserBank.java similarity index 97% rename from luoo_user/src/main/java/com/luoo/user/pojo/TbUserBank.java rename to luoo_user/src/main/java/com/luoo/user/pojo/UserBank.java index 0bae552..6e666e1 100644 --- a/luoo_user/src/main/java/com/luoo/user/pojo/TbUserBank.java +++ b/luoo_user/src/main/java/com/luoo/user/pojo/UserBank.java @@ -21,7 +21,7 @@ import java.time.Instant; @ToString @Entity @Table(name = "tb_user_bank") -public class TbUserBank implements Serializable { +public class UserBank implements Serializable { @Id private String id; diff --git a/luoo_user/src/main/java/com/luoo/user/pojo/TbWithdraw.java b/luoo_user/src/main/java/com/luoo/user/pojo/Withdraw.java similarity index 87% rename from luoo_user/src/main/java/com/luoo/user/pojo/TbWithdraw.java rename to luoo_user/src/main/java/com/luoo/user/pojo/Withdraw.java index ba94a70..7bcd7ea 100644 --- a/luoo_user/src/main/java/com/luoo/user/pojo/TbWithdraw.java +++ b/luoo_user/src/main/java/com/luoo/user/pojo/Withdraw.java @@ -10,6 +10,7 @@ import org.springframework.format.annotation.DateTimeFormat; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; +import javax.persistence.Transient; import java.io.Serializable; import java.math.BigDecimal; import java.time.Instant; @@ -22,7 +23,7 @@ import java.time.Instant; @ToString @Entity @Table(name = "tb_withdraw") -public class TbWithdraw implements Serializable { +public class Withdraw implements Serializable { @Id private String id; @@ -49,4 +50,8 @@ public class TbWithdraw implements Serializable { private String updateUser; + @Transient + @ApiModelProperty(value = "提现状态字符串") + private String stateStr; + } \ No newline at end of file diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java b/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java index 868b9d0..f2ed7d5 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java @@ -1,20 +1,28 @@ package com.luoo.user.service; +import api.PageResult; import client.vo.SimpleUser; +import com.luoo.user.dao.UserBankDao; import com.luoo.user.dao.UserInfoDao; import com.luoo.user.dao.UserRealNameDao; +import com.luoo.user.dao.WithdrawDao; import com.luoo.user.dto.UserQueryReq; import com.luoo.user.dto.UserRealNameCheckDto; import com.luoo.user.dto.UserRealNameFormDto; +import com.luoo.user.dto.bank.UserBankAddDto; +import com.luoo.user.pojo.UserBank; import com.luoo.user.pojo.UserInfo; import com.luoo.user.pojo.UserRealName; +import com.luoo.user.pojo.Withdraw; import com.luoo.user.util.NickNameUtil; import com.luoo.user.util.NickNameUtil2; import constants.Constants; import constants.ErrorConstants; import dto.UserLoginDto; +import enums.UserBankStateEnum; import enums.UserRealNameStateEnum; import enums.UserStatusEnum; +import enums.WithdrawStateEnum; import exception.BizException; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; @@ -24,6 +32,7 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.domain.Specification; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; @@ -34,6 +43,7 @@ import util.JwtUtil; import javax.persistence.criteria.Predicate; import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -68,6 +78,12 @@ public class UserInfoService { @Autowired private UserRealNameDao userRealNameDao; + @Autowired + private UserBankDao userBankDao; + + @Autowired + private WithdrawDao withdrawDao; + /** * token解析示例 */ @@ -528,7 +544,7 @@ public class UserInfoService { /** * 查询实名认证列表 * - * @return 列表 + * @return 列表 */ public List getUserRealNameList() { return userRealNameDao.findAll(); @@ -554,4 +570,130 @@ public class UserInfoService { List userRealNames = userRealNameDao.passList(userId); return !userRealNames.isEmpty(); } + + /** + * 新增用户绑定银行卡 + * + * @param token token + * @param userBankAddDto 用户绑定银行卡对象 + */ + @Transactional(rollbackFor = Exception.class) + public void addUserBank(String token, UserBankAddDto userBankAddDto) { + UserBank userBank = new UserBank(); + BeanUtils.copyProperties(userBankAddDto, userBank); + + UserLoginDto user = jwtUtil.getUserLoginDto(token); + if (user != null) { + userBank.setUserId(user.getUserId()); + } else { + // 用户校验失败,请重新登录 + throw new BizException(ErrorConstants.USER_VERIFICATION_FAILURE); + } + userBank.setCreateUser(user.getUserId()); + userBank.setState(UserBankStateEnum.BIND.getCode()); + + List checkList = userBankDao.findAllByBankCardAndStateAndUserId(userBank.getBankCard(), userBank.getState(), userBank.getUserId()); + if (checkList.isEmpty()) { + // 先解绑所有已绑定的银行卡 + userBankDao.untieAllCard(user.getUserId()); + // 保存本次的银行卡信息 + userBankDao.save(userBank); + } else { + // 该银行卡已绑定 + throw new BizException(ErrorConstants.THE_BANK_CARD_HAS_BEEN_BOUND); + } + + } + + /** + * 用户解绑银行卡 + * + * @param token token + * @param id 用户绑定银行卡的id + */ + @Transactional(rollbackFor = Exception.class) + public void untieCard(String token, String id) { + UserLoginDto user = jwtUtil.getUserLoginDto(token); + if (user == null) { + // 用户校验失败,请重新登录 + throw new BizException(ErrorConstants.USER_VERIFICATION_FAILURE); + } + UserBank userBank = userBankDao.findById(id).get(); + userBank.setState(UserBankStateEnum.UNBIND.getCode()); + userBank.setUpdateUser(user.getUserId()); + userBankDao.save(userBank); + } + + /** + * 查询用户绑定的银行卡 + * + * @param token 查询人的token + * @return 绑定的银行卡对象 + */ + public UserBank getUserBank(String token) { + UserLoginDto user = jwtUtil.getUserLoginDto(token); + if (user == null) { + // 用户校验失败,请重新登录 + throw new BizException(ErrorConstants.USER_VERIFICATION_FAILURE); + } + + return userBankDao.findAllByUserIdAndState(user.getUserId(), UserBankStateEnum.BIND.getCode()); + } + + /** + * 发起提现申请 + * + * @param token 发起人的token + * @param amount 金额 + */ + @Transactional(rollbackFor = Exception.class) + public void approveWithdraw(String token, BigDecimal amount) { + UserBank userBank = getUserBank(token); + if (userBank == null) { + // 没有绑定银行卡 + throw new BizException(ErrorConstants.NO_BANK_CARD); + } + + if (amount.compareTo(BigDecimal.ZERO) <= 0) { + // 金额必须大于0 + throw new BizException(ErrorConstants.AMOUNT_MUST_BE_GREATER_THAN_0); + } + + UserLoginDto user = jwtUtil.getUserLoginDto(token); + Withdraw withdraw = Withdraw.builder() + .userId(user.getUserId()) + .createUser(user.getUserId()) + .amount(amount) + .state(WithdrawStateEnum.INITIATED.getCode()) + .build(); + withdrawDao.save(withdraw); + } + + /** + * 分页查询用户的提现记录 + * + * @param token 登录token + * @param page 页码 + * @param size 每页数量 + * @return 列表 + */ + public PageResult withdrawPageResult(String token, Integer page, Integer size) { + Pageable pageable = PageRequest.of(page - 1, size); + UserBank userBank = getUserBank(token); + UserLoginDto user = jwtUtil.getUserLoginDto(token); + if (user == null) { + // 用户校验失败,请重新登录 + throw new BizException(ErrorConstants.USER_VERIFICATION_FAILURE); + } + Page withdrawPage = withdrawDao.findListByUserId(user.getUserId(), pageable); + long totalElements = withdrawPage.getTotalElements(); + List content = withdrawPage.getContent(); + for (Withdraw withdraw : content) { + if(withdraw.getState() != null) { + withdraw.setStateStr(Objects.requireNonNull(WithdrawStateEnum.getByCode(withdraw.getState())).getDesc()); + } + } + return new PageResult<>(totalElements, content); + } + }