lisy
2023-07-04 667a99dbf880c05f0a01509189dcf6da1b333241
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
package com.dsh.account.controller;
 
 
import com.dsh.account.entity.TAppUser;
import com.dsh.account.model.vo.userBenefitDetail.AppUserDetailsVo;
import com.dsh.account.model.vo.userBenefitDetail.BillingDetailsVo;
import com.dsh.account.model.vo.userBenefitDetail.IndexOfUserBenefirVo;
import com.dsh.account.service.TAppUserService;
import com.dsh.account.util.ResultUtil;
import com.dsh.account.util.TokenUtil;
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.web.bind.annotation.*;
 
import java.text.SimpleDateFormat;
 
@RestController
@RequestMapping("")
public class UseBenefitsController {
 
 
    @Autowired
    private TAppUserService tauService;
 
    @Autowired
    private TokenUtil tokenUtil;
 
    private final SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
 
 
    @ResponseBody
    @PostMapping("/api/useBenefit/indexOfAppUser")
    @ApiOperation(value = "福利主页", tags = {"APP-使用福利"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    public ResultUtil<IndexOfUserBenefirVo> queryAppUserUser(){
        try {
            Integer appUserId = tokenUtil.getUserIdFormRedis();
            if(null == appUserId){
                return ResultUtil.tokenErr();
            }
            return ResultUtil.success(tauService.queryBenefitDetails(appUserId));
        }catch (Exception e){
            return ResultUtil.runErr();
        }
    }
 
 
    @ResponseBody
    @PostMapping("/api/useBenefit/userDetails")
    @ApiOperation(value = "用户个人信息", tags = {"APP-使用福利"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
    })
    public ResultUtil<AppUserDetailsVo> queryAppUserDetails(){
        try {
            AppUserDetailsVo detailsVo = new AppUserDetailsVo();
            Integer appUserId = tokenUtil.getUserIdFormRedis();
            if(null == appUserId){
                return ResultUtil.tokenErr();
            }
            TAppUser tAppUser = tauService.getBaseMapper().selectById(appUserId);
            if (null != tAppUser){
                detailsVo.setUserImage(tAppUser.getHeadImg());
                detailsVo.setUserName(tAppUser.getName());
                detailsVo.setUserPhone(tAppUser.getPhone());
                detailsVo.setSex(tAppUser.getGender() == 1 ? "男" : "女");
                detailsVo.setBirthday(format1.format(tAppUser.getBirthday()));
                detailsVo.setAddress(tAppUser.getProvince()+tAppUser.getCity());
                detailsVo.setMemberLifespan(format1.format(tAppUser.getVipEndTime()));
            }
            return ResultUtil.success(detailsVo);
        }catch (Exception e){
            return ResultUtil.runErr();
        }
    }
 
    @ResponseBody
    @PostMapping("/api/useBenefit/userBilling")
    @ApiOperation(value = "账单", tags = {"APP-使用福利"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(value = "年月", name = "yearMonth", required = true, dataType = "string"),
            @ApiImplicitParam(value = "记录id", name = "recordId", required = true, dataType = "int"),
    })
    public ResultUtil<BillingDetailsVo> getUserBillingDetails(@RequestBody String yearMonth,@RequestBody Integer recordId){
        try {
            Integer appUserId = tokenUtil.getUserIdFormRedis();
            if(null == appUserId){
                return ResultUtil.tokenErr();
            }
            return ResultUtil.success(tauService.queryUserBillingDetails(yearMonth,recordId));
        }catch (Exception e){
            return ResultUtil.runErr();
        }
    }
 
 
 
 
}