100 lines
3.2 KiB
Java
100 lines
3.2 KiB
Java
![]() |
package com.ruoyi.web.bst;
|
||
|
|
||
|
import java.math.BigDecimal;
|
||
|
import java.util.List;
|
||
|
import javax.servlet.http.HttpServletResponse;
|
||
|
|
||
|
import com.ruoyi.bst.withdraw.utils.WithdrawUtil;
|
||
|
import com.ruoyi.common.core.domain.vo.UserVO;
|
||
|
import com.ruoyi.system.user.service.UserService;
|
||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
import org.springframework.validation.annotation.Validated;
|
||
|
import org.springframework.web.bind.annotation.*;
|
||
|
import com.ruoyi.common.annotation.Log;
|
||
|
import com.ruoyi.common.core.controller.BaseController;
|
||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||
|
import com.ruoyi.common.enums.BusinessType;
|
||
|
import com.ruoyi.bst.withdraw.domain.Withdraw;
|
||
|
import com.ruoyi.bst.withdraw.domain.WithdrawVO;
|
||
|
import com.ruoyi.bst.withdraw.domain.WithdrawQuery;
|
||
|
import com.ruoyi.bst.withdraw.service.WithdrawService;
|
||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||
|
|
||
|
/**
|
||
|
* 提现Controller
|
||
|
*
|
||
|
* @author ruoyi
|
||
|
* @date 2025-04-07
|
||
|
*/
|
||
|
@RestController
|
||
|
@RequestMapping("/bst/withdraw")
|
||
|
public class WithdrawController extends BaseController
|
||
|
{
|
||
|
@Autowired
|
||
|
private WithdrawService withdrawService;
|
||
|
|
||
|
@Autowired
|
||
|
private UserService userService;
|
||
|
|
||
|
/**
|
||
|
* 查询提现列表
|
||
|
*/
|
||
|
@PreAuthorize("@ss.hasPermi('bst:withdraw:list')")
|
||
|
@GetMapping("/list")
|
||
|
public TableDataInfo list(WithdrawQuery query)
|
||
|
{
|
||
|
startPage();
|
||
|
startOrderBy();
|
||
|
List<WithdrawVO> list = withdrawService.selectWithdrawList(query);
|
||
|
return getDataTable(list);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 导出提现列表
|
||
|
*/
|
||
|
@PreAuthorize("@ss.hasPermi('bst:withdraw:export')")
|
||
|
@Log(title = "提现", businessType = BusinessType.EXPORT)
|
||
|
@PostMapping("/export")
|
||
|
public void export(HttpServletResponse response, WithdrawQuery query)
|
||
|
{
|
||
|
List<WithdrawVO> list = withdrawService.selectWithdrawList(query);
|
||
|
ExcelUtil<WithdrawVO> util = new ExcelUtil<WithdrawVO>(WithdrawVO.class);
|
||
|
util.exportExcel(response, list, "提现数据");
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 获取提现详细信息
|
||
|
*/
|
||
|
@PreAuthorize("@ss.hasPermi('bst:withdraw:query')")
|
||
|
@GetMapping(value = "/{id}")
|
||
|
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||
|
{
|
||
|
return success(withdrawService.selectWithdrawById(id));
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 申请提现
|
||
|
*/
|
||
|
@PreAuthorize("@ss.hasPermi('bst:withdraw:add')")
|
||
|
@Log(title = "提现", businessType = BusinessType.INSERT)
|
||
|
@PostMapping
|
||
|
public AjaxResult add(@RequestBody @Validated Withdraw withdraw) {
|
||
|
return toAjax(withdrawService.insertWithdraw(withdraw));
|
||
|
}
|
||
|
|
||
|
@PreAuthorize("@ss.hasPermi('bst:withdraw:add')")
|
||
|
@Log(title = "查询提现服务费", businessType = BusinessType.OTHER)
|
||
|
@GetMapping("/calcAmount")
|
||
|
public AjaxResult calcAmount(BigDecimal amount, @RequestParam(required = false) Long userId) {
|
||
|
// 若是不是系统管理员,则无权查询他人的提现服务费
|
||
|
if (!isSysAdmin() || userId == null) {
|
||
|
userId = getUserId();
|
||
|
}
|
||
|
UserVO user = userService.selectUserById(userId);
|
||
|
return success(WithdrawUtil.calcAmount(user, amount));
|
||
|
}
|
||
|
|
||
|
}
|