puzhibing
2024-03-15 cf8524f0eeb0e897e31077695a410fc97633c3f5
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/controller/WorldCupController.java
@@ -10,10 +10,12 @@
import com.dsh.communityWorldCup.feignclient.account.model.TStudent;
import com.dsh.communityWorldCup.feignclient.competition.ParticipantClient;
import com.dsh.communityWorldCup.feignclient.competition.model.Participant;
import com.dsh.communityWorldCup.feignclient.other.GameClient;
import com.dsh.communityWorldCup.feignclient.other.SiteClient;
import com.dsh.communityWorldCup.feignclient.other.StoreClient;
import com.dsh.communityWorldCup.feignclient.other.model.Site;
import com.dsh.communityWorldCup.feignclient.other.model.Store;
import com.dsh.communityWorldCup.feignclient.other.model.TGame;
import com.dsh.communityWorldCup.model.*;
import com.dsh.communityWorldCup.service.*;
import com.dsh.communityWorldCup.util.GDMapGeocodingUtil;
@@ -26,6 +28,7 @@
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -91,8 +94,43 @@
    @Autowired
    private IWorldCupPaymentService worldCupPaymentService;
    @Resource
    private GameClient gameClient;
    /**
     * 根据门店id获取门店关系数据
     * @param storeId
     * @return
     */
    @ResponseBody
    @PostMapping("/worldCup/getWorldCupStoreListByStoreId")
    public List<WorldCupStoreVO> getWorldCupStoreListByStoreId(@RequestBody Integer storeId){
        List<WorldCupStoreVO> res = new ArrayList<>();
        List<WorldCupStore> storeId1 = worldCupStoreService.list(new QueryWrapper<WorldCupStore>().eq("storeId", storeId));
        for (WorldCupStore worldCupStore : storeId1) {
            WorldCupStoreVO worldCupStoreVO = new WorldCupStoreVO();
            BeanUtils.copyProperties(worldCupStore,worldCupStoreVO);
            // 查询世界杯活动名称
            WorldCup byId = worldCupService.getById(worldCupStore.getWorldCupId());
            worldCupStoreVO.setName(byId.getName());
            res.add(worldCupStoreVO);
        }
        return res;
    }
    /**
     * 根据门店id修改门店关系数据
     * @param worldCupStores
     * @return
     */
    @ResponseBody
    @PostMapping("/worldCup/updateWorldCupStoreListById")
    public Boolean updateWorldCupStoreListById(@RequestBody List<WorldCupStore> worldCupStores){
        return worldCupStoreService.updateBatchById(worldCupStores);
    }
    @ResponseBody
    @PostMapping("/api/worldCup/getWorldCupStore")
@@ -149,19 +187,24 @@
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<WorldCupPeopleVo> getWorldCupPeople(WorldCupPeople worldCupPeople){
        WorldCupPaymentParticipant worldCupPaymentParticipant = worldCupPaymentParticipantService.getById(worldCupPeople.getCode());
        if(null == worldCupPaymentParticipant){
            return ResultUtil.error("无效二维码");
        JSONObject jsonObject = JSON.parseObject(worldCupPeople.getCode());
        Long id = jsonObject.getLong("id");
        Integer isStudent = jsonObject.getInteger("isStudent");
        if(0 == isStudent){
            isStudent = 2;
        }
        if(worldCupPaymentParticipant.getWorldCupId().compareTo(worldCupPeople.getWorldCupId()) != 0){
        WorldCupPaymentParticipant worldCupPaymentParticipant = worldCupPaymentParticipantService.getOne(new QueryWrapper<WorldCupPaymentParticipant>()
                .eq("worldCupId", worldCupPeople.getWorldCupId()).eq("participantId", id).eq("participantType", isStudent)
                .orderByDesc("createTime").last(" limit 0, 1"));
        if(null == worldCupPaymentParticipant){
            return ResultUtil.error("报名失败,当前用户未报名当前比赛");
        }
        WorldCupPeopleVo worldCupPeopleVo = new WorldCupPeopleVo();
        worldCupPeopleVo.setId(worldCupPaymentParticipant.getId());
        worldCupPeopleVo.setId(worldCupPaymentParticipant.getParticipantId());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        if(worldCupPaymentParticipant.getParticipantType() == 1){
            //学员
            TStudent tStudent = studentClient.queryById(worldCupPaymentParticipant.getParticipantId());
            TStudent tStudent = studentClient.queryById(worldCupPaymentParticipant.getParticipantId().intValue());
            worldCupPeopleVo.setName(tStudent.getName());
            worldCupPeopleVo.setAge(null == tStudent.getBirthday() ? 0 : Integer.valueOf(sdf.format(new Date())) -Integer.valueOf(sdf.format(tStudent.getBirthday())));
            worldCupPeopleVo.setAvatar(tStudent.getHeadImg());
@@ -172,7 +215,7 @@
            Participant participant = participantClient.getParticipant(worldCupPaymentParticipant.getParticipantId());
            worldCupPeopleVo.setName(participant.getName());
            worldCupPeopleVo.setAge(null == participant.getBirthday() ? 0 : Integer.valueOf(sdf.format(new Date())) -Integer.valueOf(sdf.format(participant.getBirthday())));
            worldCupPeopleVo.setAvatar(appUser.getHeadImg());
            worldCupPeopleVo.setAvatar(participant.getHeadImg());
            worldCupPeopleVo.setParticipantType(2);
        }
        return ResultUtil.success(worldCupPeopleVo);
@@ -206,6 +249,11 @@
            return ResultUtil.error("无法获取场地信息");
        }
        Store store = storeClient.queryStoreById(site.getStoreId());
        String sutu_id = jsonObject.getString("sutu_id");
        TGame tGame = gameClient.getTGameBySutuId(sutu_id);
        if(null == tGame){
            return ResultUtil.error("无效的游戏二维码");
        }
        Map<String, String> map = new HashMap<>();
        map.put("name", store.getName());
        map.put("address", site.getName());
@@ -363,11 +411,10 @@
            if(null != map){
                String code = map.get("out_trade_no");
                String transaction_id = map.get("trade_no");
                String result = map.get("result");
                ResultUtil resultUtil = worldCupService.paymentWorldCupCallback(code, transaction_id);
                if(resultUtil.getCode() == 200){
                    PrintWriter out = response.getWriter();
                    out.println(result);
                    out.println("success");
                    out.flush();
                    out.close();
                }else{
@@ -391,7 +438,11 @@
    public List<WorldCupStore> getWorldCupStoreList(@RequestBody Integer storeId){
        List<WorldCup> worldCupList = worldCupService.list(new QueryWrapper<WorldCup>().in("status", Arrays.asList(1, 2)));
        List<Integer> collect = worldCupList.stream().map(WorldCup::getId).collect(Collectors.toList());
        return worldCupStoreService.list(new QueryWrapper<WorldCupStore>().eq("storeId", storeId).in("worldCupId", collect));
        if(collect.size() == 0){
            return new ArrayList<>();
        }
        return worldCupStoreService.list(new QueryWrapper<WorldCupStore>().eq("storeId", storeId).in("worldCupId", collect)
                .eq("isOpen", 1));
    }
@@ -460,14 +511,25 @@
    @PostMapping("/api/worldCup/getMyWorldCupInfo")
    @ApiOperation(value = "获取已报名世界杯详情【2.0】", tags = {"APP-个人中心"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "列表中的id", required = true, dataType = "String"),
            @ApiImplicitParam(name = "id", value = "列表中的id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "lon", value = "经度", required = true, dataType = "string"),
            @ApiImplicitParam(name = "lat", value = "纬度", required = true, dataType = "string"),
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<MyWorldCupInfo> getMyWorldCupInfo(String id, String lon, String lat){
    public ResultUtil<MyWorldCupInfo> getMyWorldCupInfo(Long id, String lon, String lat){
        MyWorldCupInfo myWorldCupInfo = worldCupPaymentParticipantService.getMyWorldCupInfo(id, lon, lat);
        return ResultUtil.success(myWorldCupInfo);
    }
    @ResponseBody
    @PostMapping("/api/worldCup/cancelMyWorldCup")
    @ApiOperation(value = "取消已报名的世界杯【2.0】", tags = {"APP-个人中心"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "列表中的id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil cancelMyWorldCup(Long id){
        return worldCupPaymentService.cancelMyWorldCup(id);
    }
@@ -493,8 +555,18 @@
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<List<WorldCupRankVo>> getWorldCupRank(WorldCupRank worldCupRank){
        List<WorldCupRankVo> worldCupRank1 = worldCupCompetitorService.getWorldCupRank(worldCupRank);
        return ResultUtil.success(worldCupRank1);
        try {
            Integer uid = tokenUtil.getUserIdFormRedis();
            if(null == uid){
                return ResultUtil.tokenErr();
            }
            worldCupRank.setAppUserId(uid);
            List<WorldCupRankVo> worldCupRank1 = worldCupCompetitorService.getWorldCupRank(worldCupRank);
            return ResultUtil.success(worldCupRank1);
        }catch (Exception e){
            e.printStackTrace();
            return ResultUtil.runErr();
        }
    }
@@ -584,9 +656,10 @@
     */
    @ResponseBody
    @PostMapping("/worldCup/editWorldCup")
    public Integer editWorldCup(@RequestBody WorldCup worldCup){
        String lon = worldCup.getLon();
        String lat = worldCup.getLat();
    public Integer editWorldCup(@RequestBody String worldCup){
        WorldCup worldCup2 = JSON.parseObject(worldCup, WorldCup.class);
        String lon = worldCup2.getLon();
        String lat = worldCup2.getLat();
        Map<String, String> geocode = null;
        try {
            geocode = gdMapGeocodingUtil.geocode(lon, lat);
@@ -597,12 +670,15 @@
        String provinceCode = geocode.get("provinceCode");
        String city = geocode.get("city");
        String cityCode = geocode.get("cityCode");
        worldCup.setProvince(province.replace("省", ""));
        worldCup.setProvinceCode(provinceCode);
        worldCup.setCity(city.replace("市", ""));
        worldCup.setCityCode(cityCode);
        worldCupService.updateById(worldCup);
        return worldCup.getId();
        worldCup2.setProvince(province.replace("省", ""));
        worldCup2.setProvinceCode(provinceCode);
        worldCup2.setCity(city.replace("市", ""));
        worldCup2.setCityCode(cityCode);
        WorldCup worldCup1 = worldCupService.getById(worldCup2.getId());
        worldCup2.setCreateTime(worldCup1.getCreateTime());
        worldCup2.setMatchNumber(worldCup1.getMatchNumber());
        worldCupService.updateWorldCupAll(worldCup2);
        return worldCup2.getId();
    }
@@ -657,8 +733,8 @@
     */
    @ResponseBody
    @PostMapping("/base/worldCup/endWorldCupCallback")
    public void endWorldCupCallback(String custom, Integer red_score, Integer blue){
        worldCupCompetitorService.endWorldCupCallback(custom, red_score, blue);
    public void endWorldCupCallback(String custom, Integer red_score, Integer blue_score){
        worldCupCompetitorService.endWorldCupCallback(custom, red_score, blue_score);
    }
@@ -679,6 +755,7 @@
            worldCupPayment.setRefundOrderNo(refund_id);
            worldCupPayment.setRefundTime(new Date());
            worldCupPayment.setPayStatus(3);
            worldCupPayment.setWorldCupId(null);
            worldCupPaymentService.updateById(worldCupPayment);
            PrintWriter out = null;
            try {
@@ -703,4 +780,117 @@
    public Map<String, Object> getRegisteredPersonnel(@RequestBody RegisteredPersonnel registeredPersonnel){
        return worldCupPaymentParticipantService.getRegisteredPersonnel(registeredPersonnel);
    }
    /**
     * 获取比赛排行榜列表数据
     * @param worldCupRecords
     * @return
     */
    @ResponseBody
    @PostMapping("/worldCup/worldCupRecordsList")
    public Map<String, Object> worldCupRecordsList(@RequestBody WorldCupRecords worldCupRecords){
        return worldCupCompetitorService.worldCupRecordsList(worldCupRecords);
    }
    /**
     * 获取比赛统计
     * @param worldCupGameStatistics
     * @return
     */
    @ResponseBody
    @PostMapping("/worldCup/worldCupGameStatistics")
    public Map<String, Object> worldCupGameStatistics(@RequestBody WorldCupGameStatistics worldCupGameStatistics){
        return worldCupService.worldCupGameStatistics(worldCupGameStatistics);
    }
    /**
     * 获取比赛统计详情列表
     * @param worldCupGameStatisticsInfoList
     * @return
     */
    @ResponseBody
    @PostMapping("/worldCup/worldCupGameStatisticsInfoList")
    public Map<String, Object> worldCupGameStatisticsInfoList(@RequestBody WorldCupGameStatisticsInfoList worldCupGameStatisticsInfoList){
        return worldCupCompetitorService.worldCupGameStatisticsInfoList(worldCupGameStatisticsInfoList);
    }
    /**
     * 获取单场参赛详情列表
     * @return
     */
    @ResponseBody
    @PostMapping("/worldCup/worldCupGameStatisticsListInfo")
    public Map<String, Object> worldCupGameStatisticsListInfo(@RequestBody WorldCupGameStatisticsListInfo worldCupGameStatisticsListInfo){
        return worldCupCompetitorService.worldCupGameStatisticsListInfo(worldCupGameStatisticsListInfo);
    }
    /**
     * 修改比分
     * @param changeScore
     */
    @ResponseBody
    @PostMapping("/worldCup/changeScore")
    public void changeScore(@RequestBody ChangeScore changeScore){
        worldCupCompetitorService.changeScore(changeScore);
    }
    @ResponseBody
    @PostMapping("/worldCup/getUserGameRecordList")
    public Map<String, Object> getUserGameRecordList(@RequestBody WorldCupGameStatisticsInfoList worldCupGameStatisticsInfoList){
        return worldCupPaymentParticipantService.getUserGameRecordList(worldCupGameStatisticsInfoList);
    }
    /**
     * 获取用户比赛记录明细
     * @param userGameRecordList
     * @return
     */
    @ResponseBody
    @PostMapping("/worldCup/userGameRecordList")
    public Map<String, Object> userGameRecordList(@RequestBody UserGameRecordList userGameRecordList){
        return worldCupCompetitorService.userGameRecordList(userGameRecordList);
    }
    /**
     * 获取已报名人数
     * @param worldCupId
     * @return
     */
    @ResponseBody
    @PostMapping("/worldCup/getRegisteredNumber")
    public int getRegisteredNumber(@RequestBody Integer worldCupId){
        List<WorldCupPayment> list = worldCupPaymentService.list(new QueryWrapper<WorldCupPayment>().eq("worldCupId", worldCupId)
                .eq("payStatus", 2).eq("state", 1));
        List<Long> collect = list.stream().map(WorldCupPayment::getId).collect(Collectors.toList());
        if(collect.size() == 0){
            return 0;
        }
        return worldCupPaymentParticipantService.getCount(worldCupId, collect);
    }
    /**
     * 获取支付记录
     * @param getWorldCupPayment
     * @return
     */
    @ResponseBody
    @PostMapping("/worldCup/getWorldCupPayment")
    public List<WorldCupPayment> getWorldCupPayment(@RequestBody GetWorldCupPayment getWorldCupPayment){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String payType = getWorldCupPayment.getPayType();
        List<WorldCupPayment> list = worldCupPaymentService.list(new QueryWrapper<WorldCupPayment>().eq("appUserId", getWorldCupPayment.getAppUserId())
                .in("payType", Arrays.asList(payType.split(","))).ne("payStatus", 1).eq("state", 1)
                .last(" and createTime between '" + sdf.format(getWorldCupPayment.getStartTime()) + "' and  '" + sdf.format(getWorldCupPayment.getEndTime()) + "' order by createTime desc"));
        return list;
    }
}