44323
2024-05-16 8d90d3f271a9c28bf46f755b1561f07c163d8823
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
package com.ruoyi.study.controller;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.study.domain.TUser;
import com.ruoyi.study.dto.AppUserQuery;
import com.ruoyi.study.dto.UserInfoQuery;
import com.ruoyi.study.service.ITUserService;
import com.ruoyi.study.service.IVipOrderService;
import com.ruoyi.study.vo.AppUserVO;
import com.ruoyi.study.vo.UserGameRecordVO;
import com.ruoyi.study.vo.UserInfoVO;
import com.ruoyi.study.vo.VipOrderVO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
 
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * <p>
 * 用户管理 控制器
 * </p>
 *
 * @author 无关风月
 * @since 2024-04-26
 */
@RestController
@RequestMapping("/base/user")
public class TUserController {
    @Autowired
    private ITUserService userService;
 
    @Autowired
    private IVipOrderService vipOrderService;
    @PostMapping("/userList")
    @ApiOperation(value = "用户列表", tags = {"用户管理"})
    public R<PageInfo<AppUserVO>> couponReceive(AppUserQuery query) {
        PageInfo<AppUserVO> res = new PageInfo<>(query.getPageNumber(), query.getPageSize());
        List<AppUserVO> list =  userService.listAll(query);
        for (AppUserVO appUserVO : list) {
            if (appUserVO.getVipEndTime() == null){
                appUserVO.setIsVip(0);
            }else{
                if (appUserVO.getVipEndTime().getTime() > System.currentTimeMillis()){
                    appUserVO.setIsVip(1);
                }else{
                    appUserVO.setIsVip(0);
                }
            }
        }
        res.setRecords(list);
        res.setTotal(list.size());
        return R.ok(res);
    }
 
    @PostMapping("/getUserInfo")
    @ApiOperation(value = "查看用户详情", tags = {"用户管理"})
    public R<UserInfoVO> getUserInfo(UserInfoQuery dto) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
        UserInfoVO res = new UserInfoVO();
        PageInfo<UserGameRecordVO> list = new PageInfo<>(dto.getPageNumber(), dto.getPageSize());
 
 
        TUser byId = userService.getById(dto.getId());
        String name = byId.getName();
        String phone = byId.getPhone();
        Date insertTime = byId.getInsertTime();
        Date vipPayTime = byId.getVipPayTime();
        Date vipEndTime = byId.getVipEndTime();
        if (vipEndTime == null){
            res.setIsVip(0);
        }else{
            if (vipEndTime.getTime() > System.currentTimeMillis()){
                res.setIsVip(1);
            }else{
                res.setIsVip(0);
            }
        }
        if (vipPayTime!=null){
            res.setVipPayTime(format.format(vipPayTime));
        }
        res.setState(byId.getState());
        res.setName(name);
        res.setPhone(phone);
        res.setInsertTime(format.format(insertTime));
        res.setIntegral(byId.getIntegral());
        // todo 查询进度
        res.setCurrent(0);
        res.setSurplus(0);
        res.setTotalHours(0d);
        res.setTodayHours(0d);
        res.setWeekHours(0d);
        res.setMonthHours(0d);
        // todo 查询用户的游戏记录
        List<UserGameRecordVO> userGameRecordVOS = new ArrayList<>();
        list.setRecords(userGameRecordVOS);
        list.setTotal(0);
        res.setGameRecords(list);
        return R.ok(res);
    }
    @PostMapping("/freeze")
    @ApiOperation(value = "冻结/解冻", tags = {"用户管理"})
    public R freeze(Integer id) {
        TUser byId = userService.getById(id);
        if (byId.getState() == 1) {
            byId.setState(2);
            return R.ok("冻结成功");
        }else {
            byId.setState(1);
            return R.ok("解冻成功");
        }
    }
 
 
    @PostMapping("/vipOrderList")
    @ApiOperation(value = "列表查询", tags = {"会员管理"})
    public R<PageInfo<VipOrderVO>> vipOrderList(AppUserQuery query) {
        PageInfo<VipOrderVO> res = new PageInfo<>(query.getPageNumber(), query.getPageSize());
        List<VipOrderVO> list =  vipOrderService.listAll(query);
        res.setRecords(list);
        res.setTotal(list.size());
        return R.ok(res);
    }
}