luodangjia
2024-12-16 a8d2cb07f6440dc54dc4005b0b06d5a47cb1517d
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
package com.ruoyi.other.controller;
 
 
import com.ruoyi.account.api.model.AppUser;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.other.api.domain.RedPackegeSet;
import com.ruoyi.other.service.RedPackegeSetService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
 
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author luodangjia
 * @since 2024-11-20
 */
@RestController
@RequestMapping("/red-packege-set")
public class RedPackegeSetController {
    @Resource
    private RedPackegeSetService redPackegeSetService;
    //获取当前生效的红包设置
    @ResponseBody
    @GetMapping("/get")
    public R<BigDecimal> get(){
        LocalDateTime now = LocalDateTime.now();
        RedPackegeSet one = redPackegeSetService.lambdaQuery().le(RedPackegeSet::getStartTime, now).ge(RedPackegeSet::getEndTime, now).one();
        if (one!=null){
            return R.ok(one.getPackegeAmount());
        }else {
            return R.ok(BigDecimal.ZERO);
 
        }
    }
 
}