huliguo
16 小时以前 60e726c81966b042db4f7b108d06bd36109794de
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
package com.ruoyi.goods.controller.management;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.goods.api.domain.LotteryEvent;
import com.ruoyi.goods.domain.dto.*;
import com.ruoyi.goods.domain.vo.*;
import com.ruoyi.goods.service.lottery.ILotteryEventService;
import com.ruoyi.goods.service.lottery.IUserLotteryEventQuestionsAnswersService;
import com.ruoyi.goods.service.lottery.IUserLotteryEventService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Collections;
import java.util.List;
 
/**
 * @author hlg
 * @Date 2025/6/16
 */
@RestController
@Api(value = "管理后台抽奖相关接口", tags = "管理后台抽奖相关接口", description = "管理后台抽奖相关接口")
@RequestMapping("/mgt/lotteryEvent")
public class MgtLotteryEventController {
    @Resource
    private ILotteryEventService lotteryEventService;
    @Resource
    private IUserLotteryEventService userLotteryEventService;
    @Resource
    private IUserLotteryEventQuestionsAnswersService userLotteryEventQuestionsAnswersService;
 
    @RequestMapping(value = "/editLotteryEvent", method = RequestMethod.POST)
    @Log(title = "抽奖管理", businessType = BusinessType.UPDATE,operContent = "编辑抽奖活动")
    @ApiOperation(value = "平台添加/修改抽奖活动【2.0】")
    public R<ShopLotteryDrawVo> editLotteryEvent(@Valid  @RequestBody MgtLotteryEventEditDTO dto) {
        return  lotteryEventService.editLotteryEvent(dto);
    }
    @RequestMapping(value = "/pageMgtLotteryEvent", method = RequestMethod.POST)
    @ApiOperation(value = "分页获取抽奖列表【2.0】")
    public R<Page<MgtLotteryEventPageVo>> pageMgtLotteryEvent(@RequestBody MgtLotteryEventPageDto dto) {
        Page<MgtLotteryEventPageVo> page = new Page<>();
        page.setSize(dto.getPageSize());
        page.setCurrent(dto.getPageNum());
        page.setOptimizeCountSql(false);
        List<MgtLotteryEventPageVo> mgtGoodsPageVoList = lotteryEventService.pageMgtLotteryEvent(page,dto);
        return R.ok(page.setRecords(mgtGoodsPageVoList));
    }
 
    @RequestMapping(value = "/getLotteryEventDetailById/{id}", method = RequestMethod.POST)
    @ApiOperation(value = "查看抽奖活动详情【2.0】")
    public R<MgtLotteryEventDetailVO> getLotteryEventDetailById(@PathVariable("id") String id) {
        return  lotteryEventService.getLotteryEventDetailById(id);
    }
 
    //查看-参与人信息
    @RequestMapping(value = "/getLotteryEventJoinUserPageById/{id}", method = RequestMethod.POST)
    @ApiOperation(value = "查看抽奖活动-参与人信息【2.0】")
    public R<Page<ShopWinningRecordVo>> getLotteryEventJoinUserPageById(@RequestBody MgtLotteryEventJoinUserPageDTO dto) {
        Page<ShopWinningRecordVo> page = new Page<>();
        page.setSize(dto.getPageSize());
        page.setCurrent(dto.getPageNum());
        List<ShopWinningRecordVo> shopWinningRecordVoList = userLotteryEventService.getShopWinningRecord(page, dto.getId());
        return R.ok(page.setRecords(shopWinningRecordVoList));
    }
    //查看-答题情况
    @RequestMapping(value = "/getUserAnswersPage", method = RequestMethod.POST)
    @ApiOperation(value = "查看抽奖活动-答题情况【2.0】")
    public R<Page<MgtUserAnswersPageVO>> getUserAnswersPage(@RequestBody MgtUserAnswersPageDTO dto) {
        //检查是否答题类型
        LotteryEvent lotteryEvent = lotteryEventService.getById(dto.getLotteryEventId());
        if (null == lotteryEvent || lotteryEvent.getDelFlag()!=0 ){
            return R.fail("该抽奖活动不存在");
        }
        if ( lotteryEvent.getActivityType()!=5){
            return R.fail("请选择答题抽奖类型的活动");
        }
        Page<MgtUserAnswersPageVO> page = new Page<>();
        page.setSize(dto.getPageSize());
        page.setCurrent(dto.getPageNum());
        List<MgtUserAnswersPageVO> shopWinningRecordVoList = userLotteryEventQuestionsAnswersService.getUserAnswersPage(page, dto.getLotteryEventId(),dto.getUserId());
        return R.ok(page.setRecords(shopWinningRecordVoList));
    }
 
    //删除
    @RequestMapping(value = "/deleteMgtLotteryEvent/{id}", method = RequestMethod.POST)
    @Log(title = "抽奖管理", businessType = BusinessType.DELETE,operContent = "删除抽奖活动")
    @ApiOperation(value = "删除抽奖活动【2.0】")
    public R deleteMgtLotteryEvent(@PathVariable("id") String id) {
        return lotteryEventService.deleteMgtLotteryEvent(id);
    }
 
    //立即结束
    @RequestMapping(value = "/endImmediatelyLotteryEvent/{id}", method = RequestMethod.POST)
    @Log(title = "抽奖管理", businessType = BusinessType.UPDATE,operContent = "立即结束")
    @ApiOperation(value = "立即结束【2.0】")
    public R endImmediatelyLotteryEvent(@PathVariable("id") String id) {
        return lotteryEventService.endImmediatelyLotteryEvent(id);
    }
 
 
}