无关风月
2025-05-08 9486766c806fe1d9e082b2fd02ea1cc558f1b443
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
package com.dsh.other.controller;
 
import com.alibaba.nacos.api.config.filter.IFilterConfig;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.other.entity.*;
import com.dsh.other.feignclient.model.AdvertisementChangeStateDTO;
import com.dsh.other.feignclient.model.AdvertisementQuery;
import com.dsh.other.model.BannerVo;
import com.dsh.other.model.dto.siteDto.GameDataQuery;
import com.dsh.other.service.*;
import com.dsh.other.util.ResultUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.print.DocFlavor;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
/**
 * @author zhibing.pu
 * @date 2023/7/11 17:48
 */
@RestController
@RequestMapping("")
public class BallController {
    @Autowired
    private GameService gameService;
    @Autowired
    private TGameRecordService gameRecordService;
    @Autowired
    private ISiteService siteService;
 
    // 数据统计
    @ResponseBody
    @PostMapping("/student/getData")
    public List<TGameRecord> getData(@RequestBody GameDataQuery query){
        if (query.getStoreId()==null){
            // 获取到游戏ids
            List<Integer> gameIds = gameService.list(new QueryWrapper<Game>().eq("operationId", query.getObjectId()))
                    .stream().map(Game::getId).collect(Collectors.toList());
            // 根据游戏ids查询智慧球场支付记录
            QueryWrapper<TGameRecord> wrapper = new QueryWrapper<TGameRecord>().eq("status", 1)
                    .ne("payType", 3)
                    .ne("payType", 4);
            if(gameIds.size() > 0){
                wrapper.in("gameId", gameIds);
            }
            List<TGameRecord> list = gameRecordService.list(wrapper);
            return list;
        }else{
            List<Integer> gameIds = gameService.list(new QueryWrapper<Game>().eq("storeId", query.getStoreId()))
                    .stream().map(Game::getId).collect(Collectors.toList());
            QueryWrapper wrapper = new QueryWrapper<TGameRecord>().eq("status", 1).eq("payType", 1).eq("payType", 2);
            if(gameIds.size() > 0){
                wrapper.in("gameId", gameIds);
            }
            List<TGameRecord> list = gameRecordService.list(wrapper);
            return list;
        }
    }
 
 
    @ResponseBody
    @PostMapping("/student/webStudentList")
    public List<Game> list(@RequestBody BallQueryDto ballQueryDto) {
        List<Game> games = gameService.queryAll(ballQueryDto);
        return games;
    }
 
    // 根据门店ids 获取游戏记录
    @ResponseBody
    @PostMapping("/game/getGameByStoreIds")
    public List<Integer> getGameByStoreIds(@RequestBody List<Integer> storeIds) {
        // 游戏id
        List<Integer> gamesId = gameService.list(new QueryWrapper<Game>().in("storeId", storeIds))
                .stream().map(Game::getId).collect(Collectors.toList());
        if (gamesId.size() == 0) {
            return new ArrayList<>();
        } else {
            // 根据游戏id获取游戏记录 获取用户Ids
            List<Integer> userId = gameRecordService.list(new QueryWrapper<TGameRecord>().in("gameId", gamesId)
                            .eq("status",1))
                    .stream().map(TGameRecord::getUserId).collect(Collectors.toList());
            return userId;
        }
 
 
    }
 
    @Autowired
    private IRegionService regionService;
 
    @ResponseBody
    @PostMapping("/save")
    public Integer save(@RequestBody Game game) {
 
 
        if (game.getCityCode() != null) {
            Region city = regionService.getOne(new QueryWrapper<Region>().eq("code", game.getCityCode()));
            game.setCity(city.getName());
 
 
            Region province = regionService.getOne(new QueryWrapper<Region>().eq("code", game.getProvinceCode()));
            game.setProvince(province.getName());
 
        }
 
 
        gameService.saveOrUpdate(game);
        System.out.println("===========" + game);
        return game.getId();
    }
 
    @Autowired
    private TGameConfigService config;
 
 
    @ResponseBody
    @PostMapping("/saveConfig")
    public void saveConfig(@RequestBody List<TGameConfig> gameConfigList) {
        System.out.println("=======gameConfigList====" + gameConfigList);
        config.saveOrUpdateBatch(gameConfigList);
//        return  game.getId();
    }
 
    @ResponseBody
    @PostMapping("/queryGame")
    public Game queryGame(@RequestParam Integer id) {
        return gameService.getById(id);
//        return  game.getId();
    }
    @ResponseBody
    @PostMapping("/getSiteList")
    // 查询未配置智慧球场的场地 智慧球场添加使用
    public List<Site> getSiteList(@RequestParam("storeId") Integer storeId){
        List<Integer> collect = gameService.list().stream().map(Game::getSiteId).collect(Collectors.toList());
        if (collect.size() == 0 ){
            collect.add(-1);
        }
        List<Site> list = siteService.list(new QueryWrapper<Site>().select("id","name")
                .eq("storeId", storeId)
                .eq("state", 1)
                .notIn("id",collect)
        );
        return list;
    }
    // 查询未配置智慧球场的场地 包含当前配置的场地 智慧球场编辑使用
    @ResponseBody
    @PostMapping("/getSiteList1")
    public List<Site> getSiteList1(@RequestParam Integer id) {
        Game game = gameService.getById(id);
        List<Integer> collect = gameService.list().stream().map(Game::getSiteId).collect(Collectors.toList());
        Site byId = siteService.getById(game.getSiteId());
        List<Site> list = siteService.list(new QueryWrapper<Site>().select("id","name")
                .eq("state", 1)
                .eq("storeId",game.getStoreId())
                .notIn("id",collect)
        );
        list.add(byId);
        return list;
    }
    @ResponseBody
    @PostMapping("/listorder")
    public List<Map<String, Object>> listorder(@RequestBody BookingQuery bookingQuery) {
        System.out.println("===bookingQuery====" + bookingQuery);
        return gameService.orderlist(bookingQuery);
    }
 
 
}