From ec6d43aa07ee0e8faf34498057ebcfbb446aa015 Mon Sep 17 00:00:00 2001 From: hjl <1657978663@qq.com> Date: 星期二, 16 七月 2024 09:21:51 +0800 Subject: [PATCH] feat: 代码重构 --- ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/controller/WithdrawController.java | 47 +++++++++++++++++++++++++++++++++++------------ 1 files changed, 35 insertions(+), 12 deletions(-) diff --git a/ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/controller/WithdrawController.java b/ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/controller/WithdrawController.java index 0c89e0f..d6b83d1 100644 --- a/ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/controller/WithdrawController.java +++ b/ruoyi-service/ruoyi-user/src/main/java/com/ruoyi/user/controller/WithdrawController.java @@ -1,10 +1,13 @@ package com.ruoyi.user.controller; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.order.api.entity.Withdraw; +import com.ruoyi.order.api.entity.WithdrawDetailVO; +import com.ruoyi.order.api.feignClient.WithdrawClient; import com.ruoyi.system.api.model.LoginUserInfo; -import com.ruoyi.user.entity.Withdraw; import com.ruoyi.user.service.WithdrawService; import com.ruoyi.user.vo.WithdrawListVO; import io.swagger.annotations.Api; @@ -17,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; -import java.util.List; +import java.math.BigDecimal; /** * <p> @@ -29,30 +32,43 @@ */ @RestController @RequestMapping("/withdraw") -@Api(tags = {"用户端-提现"}) +@Api(tags = {"用户端-个人中心-提现"}) public class WithdrawController { @Resource private WithdrawService withdrawService; @Resource private TokenService tokenService; + @Resource + private WithdrawClient withdrawClient; @GetMapping("/withdrawList") - @ApiOperation(value = "提现列表", tags = {"用户端-个人中心"}) - public R<WithdrawListVO> withdrawList() { + @ApiOperation(value = "提现列表", tags = {"用户端-个人中心-提现"}) + public R<WithdrawListVO> withdrawList(@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { LoginUserInfo loginUser = tokenService.getLoginUserByUser(); if (null == loginUser) { return R.loginExpire("登录失效!"); } - return R.ok(withdrawService.withdrawList(loginUser.getUserid())); + return R.ok(withdrawService.withdrawList(loginUser.getUserid(), pageNum, pageSize)); + } + + @GetMapping("/withdrawDetail") + @ApiOperation(value = "提现详情", tags = {"用户端-个人中心-提现"}) + public R<WithdrawDetailVO> withdrawDetail(@RequestParam String orderId) { + LoginUserInfo loginUser = tokenService.getLoginUserByUser(); + if (null == loginUser) { + return R.loginExpire("登录失效!"); + } + return withdrawClient.withdrawDetailByUser(orderId); } @GetMapping("/confirmWithdraw") - @ApiOperation(value = "确认提现", tags = {"用户端-个人中心"}) + @ApiOperation(value = "确认提现", tags = {"用户端-个人中心-提现"}) @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "orderId", dataType = "Integer", required = true) }) - public R<Boolean> confirmWithdraw(@RequestParam Integer orderId) { + public R<Boolean> confirmWithdraw(@RequestParam String orderId) { LoginUserInfo loginUser = tokenService.getLoginUserByUser(); if (null == loginUser) { return R.loginExpire("登录失效!"); @@ -61,14 +77,21 @@ } @GetMapping("/withdrawRecord") - @ApiOperation(value = "提现记录", tags = {"用户端-个人中心"}) - public R<List<Withdraw>> withdrawRecord() { + @ApiOperation(value = "提现记录", tags = {"用户端-个人中心-提现"}) + public R<Page<Withdraw>> withdrawRecord(@RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { LoginUserInfo loginUser = tokenService.getLoginUserByUser(); if (null == loginUser) { return R.loginExpire("登录失效!"); } - return R.ok(withdrawService.lambdaQuery().eq(Withdraw::getUserId, loginUser.getUserid()) - .eq(Withdraw::getIsDelete, 0).orderByDesc(Withdraw::getCreateTime).list()); + Page<Withdraw> data = withdrawClient.withdrawRecordList(loginUser.getUserid(), pageNum, pageSize).getData(); + BigDecimal b = BigDecimal.ZERO; + if (null != data) { + for (Withdraw record : data.getRecords()) { + b = b.add(record.getApplyForMoney()); + } + } + return R.ok(data); } } -- Gitblit v1.7.1