44323
2024-04-23 16b704d18a875d1fb63827aaa507790ba2bef5be
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
package com.stylefeng.guns.modular.code.controller;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.vo.MoneyDetailVO;
import com.stylefeng.guns.modular.system.vo.RechargeListVO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
 
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
 
/**
 * @author 无关风月
 * @Date 2024/2/6 18:25
 */
 
/**
 * 财务管理
 */
@Slf4j
@RestController
@RequestMapping("")
public class MoneyController {
    @Autowired
    private IFitnessTypeService fitnessTypeService;
    @Autowired
    private IFitnessPositionService fitnessPositionService;
    @Autowired
    private IAppUserService appUserService;
    @Autowired
    private ICourseService courseService;
    @Autowired
    private ICourseVideoService courseVideoService;
    @Autowired
    private IOrderService orderService;
    @Autowired
    private IOrderCourseService orderCourseService;
    @Autowired
    private ICouponService couponService;
    @Autowired
    private IPackageService packageService;
    @Autowired
    private IProtocolService protocolService;
    @Autowired
    private IWithdrawalService withdrawalService;
    @Autowired
    private IBannerService bannerService;
    @Autowired
    private IMessageService messageService;
 
    @ResponseBody
    @PostMapping("/base/money/list")
    @ApiOperation(value = "提现申请列表", tags = {"财务管理"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "申请用户", name = "userName"),
            @ApiImplicitParam(value = "联系电话", name = "phone"),
            @ApiImplicitParam(value = "状态状态1待审核 2 已通过 3已拒绝", name = "state"),
            @ApiImplicitParam(value = "开始时间", name = "startTime"),
            @ApiImplicitParam(value = "结束时间", name = "endTime"),
            @ApiImplicitParam(value = "打款状态", name = "payment"),
            @ApiImplicitParam(value = "页码,首页1", name = "pageNum", dataType = "int"),
            @ApiImplicitParam(value = "页条数", name = "pageSize", dataType = "int"),
    })
    public ResultUtil<PageInfo<MoneyVO>> list(String userName, String phone,Integer state,Integer payment
            , Date startTime, Date endTime, Integer pageNum, Integer pageSize) {
        String startTime1 = "";
        String endTime1 = "";
        if (endTime!=null){
            endTime.setHours(23);
            endTime.setMinutes(59);
            endTime.setSeconds(59);
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
             startTime1 = format.format(startTime);
             endTime1 = format.format(endTime);
        }
 
        List<MoneyVO> res = withdrawalService.list(userName,phone,state,payment,startTime,endTime,startTime1,endTime1);
//        PageHelper.startPage(pageNum,pageSize);
        PageInfo<MoneyVO> info=new PageInfo<>(res);
        return ResultUtil.success(info);
    }
 
 
    @Autowired
    private ITurnService turnService;
    @ResponseBody
    @PostMapping("/base/money/detail")
    @ApiOperation(value = "提现详情", tags = {"财务管理"})
    public ResultUtil<MoneyDetailVO> getModel(Integer id) {
        Withdrawal withdrawal = withdrawalService.selectById(id);
        MoneyDetailVO moneyDetailVO = new MoneyDetailVO();
        AppUser appUser = appUserService.selectById(withdrawal.getUserId());
        moneyDetailVO.setUserName(appUser.getName());
        moneyDetailVO.setPhone(appUser.getPhone());
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
        moneyDetailVO.setInsertTime(format.format(withdrawal.getInsertTime()));
        moneyDetailVO.setAmount(withdrawal.getAmount());
        moneyDetailVO.setApplyAmount(withdrawal.getApplyAmount());
        moneyDetailVO.setAccountName(appUser.getAccountName());
        moneyDetailVO.setBankCard(appUser.getBankCard());
        moneyDetailVO.setBankName(appUser.getBankName());
        moneyDetailVO.setBankPhone(appUser.getBankPhone());
        moneyDetailVO.setBankCardImg(appUser.getBankCardImg());
        moneyDetailVO.setState(withdrawal.getState());
        moneyDetailVO.setPayment(withdrawal.getPayment());
        return ResultUtil.success(moneyDetailVO);
    }
    @ResponseBody
    @PostMapping("/base/money/rechargeList")
    @ApiOperation(value = "充值记录", tags = {"财务管理"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "申请用户", name = "userName"),
            @ApiImplicitParam(value = "联系电话", name = "phone"),
            @ApiImplicitParam(value = "开始时间", name = "startTime"),
            @ApiImplicitParam(value = "结束时间", name = "endTime"),
            @ApiImplicitParam(value = "页码,首页1", name = "pageNum", dataType = "int"),
            @ApiImplicitParam(value = "页条数", name = "pageSize", dataType = "int"),
    })
    public ResultUtil<PageInfo<RechargeListVO>> list(String userName, String phone,Date startTime, Date endTime, Integer pageNum, Integer pageSize) {
        if (endTime!=null){
            endTime.setHours(23);
            endTime.setMinutes(59);
            endTime.setSeconds(59);
        }
        List<RechargeListVO> res = withdrawalService.rechargeList(userName,phone,startTime,endTime);
//        PageHelper.startPage(pageNum,pageSize);
        PageInfo<RechargeListVO> info=new PageInfo<>(res);
        return ResultUtil.success(info);
    }
 
    @ResponseBody
    @PostMapping("/base/money/changeState")
    @ApiOperation(value = "审核", tags = {"财务管理"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "主键", name = "id"),
            @ApiImplicitParam(value = "状态 2=通过 3=拒绝", name = "state"),
            @ApiImplicitParam(value = "拒绝理由", name = "reason"),
 
    })
    public ResultUtil<MoneyDetailVO> getModel(Integer id,Integer state,String reason) {
        Withdrawal withdrawal = withdrawalService.selectById(id);
        if (state==2){
//            /// 还需要发送一条消息给用户
//            Message message = new Message();
//            message.setUserId(withdrawal.getUserId());
//            message.setType(1);
//            message.setContent("您的提现申请已通过");
//            message.setInsertTime(new Date());
//            message.setIsRead(0);
//            messageService.insert(message);
        }else{
            // 把钱退回用户余额
            AppUser appUser = appUserService.selectById(withdrawal.getUserId());
            BigDecimal subtract = appUser.getBalance().add(withdrawal.getAmount());
            appUser.setBalance(subtract);
            // 扣钱
            appUserService.updateById(appUser);
            withdrawal.setReason(reason);
            withdrawal.setRefuseTime(new Date());
            Message message = new Message();
            message.setUserId(withdrawal.getUserId());
            message.setType(1);
            message.setContent("您的提现申请被驳回,原因:"+reason);
            message.setInsertTime(new Date());
            message.setIsRead(0);
            messageService.insert(message);
        }
        withdrawal.setState(state);
        withdrawalService.updateById(withdrawal);
        return ResultUtil.success();
    }
    @ResponseBody
    @PostMapping("/base/money/payment")
    @ApiOperation(value = "打款", tags = {"财务管理"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "主键", name = "id"),
 
    })
    public ResultUtil<MoneyDetailVO> payment(Integer id) {
        Withdrawal withdrawal = withdrawalService.selectById(id);
            /// 还需要发送一条消息给用户
            Message message = new Message();
            message.setUserId(withdrawal.getUserId());
            message.setType(1);
            message.setContent("您的提现申请已通过");
            message.setInsertTime(new Date());
            message.setIsRead(0);
            messageService.insert(message);
        withdrawal.setPayment(2);
        withdrawal.setComplete(new Date());
        withdrawalService.updateById(withdrawal);
        return ResultUtil.success();
    }
 
 
}