luodangjia
2024-12-19 60f70f7409ec1ece8905e088fb43e0cb0258a70b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.ruoyi.account.controller;
 
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.account.api.model.BalanceChangeRecord;
import com.ruoyi.account.api.model.WithdrawalRequests;
import com.ruoyi.account.dto.WithQuery;
import com.ruoyi.account.dto.WithdrawalRequestsDTO;
import com.ruoyi.account.service.AppUserService;
import com.ruoyi.account.service.WithdrawalRequestsService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author luodangjia
 * @since 2024-11-21
 */
@RestController
@RequestMapping("/withdrawal-requests")
@Api(tags = "提现申请")
public class WithdrawalRequestsController {
 
    @Resource
    private WithdrawalRequestsService withdrawalRequestsService;
    @Resource
    private AppUserService appUserService;
 
    /**
     * 提现申请
     */
    @PostMapping("/withdrawalApply")
    @ApiOperation(value = "提现申请", tags = {"提现申请-小程序"})
    public AjaxResult withdrawalApply(@RequestBody WithdrawalRequestsDTO params){
        withdrawalRequestsService.withdrawalApply(params);
        return AjaxResult.success();
    }
 
    @PostMapping("/page")
    @ApiOperation(value = "提现申请列表", tags = {"后台"})
    public R<IPage<WithdrawalRequests>> page(@RequestBody WithQuery withQuery){
        IPage<WithdrawalRequests> withdrawalRequestsIPage = withdrawalRequestsService.pageList(withQuery);
        for (WithdrawalRequests record : withdrawalRequestsIPage.getRecords()) {
            record.setIdStr(record.getId().toString());
        }
        return R.ok(withdrawalRequestsIPage);
    }
    @PostMapping("/auth")
    @ApiOperation(value = "提现申请审批", tags = {"后台"})
    public R<IPage<WithdrawalRequests>> auth(@RequestParam Long id,@ApiParam("2'审核通过',3'审核拒绝'") Integer auditStatus){
        WithdrawalRequests byId = withdrawalRequestsService.getById(id);
        if (auditStatus==2){
 
            //将用户待审核金额减少,已提现金额增加
            AppUser byId1 = appUserService.getById(byId.getAppUserId());
            byId1.setWithdrawnAmount(byId1.getWithdrawnAmount().add(byId.getWithdrawalAmount()));
            appUserService.updateById(byId1);
            //执行对应的第三方提现 todo
        }
        //通过
        byId.setAuditStatus(auditStatus);
        withdrawalRequestsService.updateById(byId);
        return R.ok();
    }
 
 
}