puzhibing
2024-08-28 8c9ad0bd2fc6591fe606c793d6e11e2cfbe5a165
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
package com.ruoyi.account.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.account.api.model.TAppUserVipDetail;
import com.ruoyi.account.api.vo.GetAppUserVipDetail;
import com.ruoyi.account.service.TAppUserVipDetailService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.service.TokenService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.List;
 
/**
 * @author zhibing.pu
 * @Date 2024/8/21 10:35
 */
@RestController
@RequestMapping("/appUserVipDetail")
public class TAppUserVipDetailController {
    
    @Resource
    private TAppUserVipDetailService appUserVipDetailService;
    @Resource
    private TokenService tokenService;
    
    /**
     * 获取用户当前有效的vip明细
     * @param getAppUserVipDetail
     * @return
     */
    @PostMapping("/getAppUserVipDetail")
    public R<TAppUserVipDetail> getAppUserVipDetail(@RequestBody GetAppUserVipDetail getAppUserVipDetail){
        TAppUserVipDetail one = appUserVipDetailService.getOne(new LambdaQueryWrapper<TAppUserVipDetail>()
                .eq(TAppUserVipDetail::getAppUserId, getAppUserVipDetail.getAppUserId())
                .eq(TAppUserVipDetail::getVipId, getAppUserVipDetail.getVipId())
                .last(" and now() between start_time and end_time"));
        return R.ok(one);
    }
 
    @GetMapping("/getVipUseDetail")
    @ApiOperation(value = "生效会员列表", tags = {"小程序-个人中心"})
    public R<List<TAppUserVipDetail>> getVipUseDetail(){
        Long userId = tokenService.getLoginUserApplet().getUserId();
        List<TAppUserVipDetail> list = appUserVipDetailService.lambdaQuery().eq(TAppUserVipDetail::getAppUserId, userId).last(" and now() between start_time and end_time order by start_time desc").list();
        return R.ok(list);
    }
 
    
}