puzhibing
2024-03-05 abce69e057001d9899db3bc54b073bfa52705821
修改接口
7个文件已修改
180 ■■■■■ 已修改文件
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/controller/WorldCupController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/entity/WorldCupCompetitor.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/IWorldCupCompetitorService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/IWorldCupService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/util/TaskUtil.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/controller/WorldCupController.java
@@ -657,8 +657,8 @@
     */
    @ResponseBody
    @PostMapping("/base/worldCup/endWorldCupCallback")
    public void endWorldCupCallback(){
    public void endWorldCupCallback(String custom, Integer red_score, Integer blue){
        worldCupCompetitorService.endWorldCupCallback(custom, red_score, blue);
    }
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/entity/WorldCupCompetitor.java
@@ -56,6 +56,16 @@
    @TableField("matchResult")
    private Integer matchResult;
    /**
     * 我方分数
     */
    @TableField("ourScore")
    private Integer ourScore;
    /**
     * 对手分数
     */
    @TableField("opponentScore")
    private Integer opponentScore;
    /**
     * 参赛奖励
     */
    @TableField("participationIntegral")
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/IWorldCupCompetitorService.java
@@ -35,4 +35,13 @@
     * @return
     */
    List<WorldCupRankVo> getWorldCupRank(WorldCupRank worldCupRank);
    /**
     * 比赛结束后通知处理逻辑
     * @param custom
     * @param red_score
     * @param blue
     */
    void endWorldCupCallback(String custom, Integer red_score, Integer blue);
}
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/IWorldCupService.java
@@ -93,4 +93,10 @@
     * @return
     */
    Map<String, Object> getWorldCupListAll(WorldCupListAll worldCupListAll);
    /**
     * 定时任务修改状态
     */
    void taskUpdateStatus();
}
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java
@@ -1,7 +1,9 @@
package com.dsh.communityWorldCup.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsh.communityWorldCup.entity.WorldCup;
import com.dsh.communityWorldCup.entity.WorldCupCompetitor;
import com.dsh.communityWorldCup.feignclient.account.AppUserClient;
import com.dsh.communityWorldCup.feignclient.account.StudentClient;
@@ -13,6 +15,8 @@
import com.dsh.communityWorldCup.mapper.WorldCupCompetitorMapper;
import com.dsh.communityWorldCup.model.*;
import com.dsh.communityWorldCup.service.IWorldCupCompetitorService;
import com.dsh.communityWorldCup.service.IWorldCupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -20,6 +24,7 @@
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -38,6 +43,9 @@
    @Resource
    private AppUserClient appUserClient;
    @Autowired
    private IWorldCupService worldCupService;
@@ -245,4 +253,51 @@
        }
        return list;
    }
    /**
     * 比赛结束后通知处理逻辑
     * @param custom        开始比赛接口上传的自定义参数
     * @param red_score     红方分数
     * @param blue          蓝方分数
     */
    @Override
    public void endWorldCupCallback(String custom, Integer red_score, Integer blue) {
        List<Long> ids = JSON.parseArray(custom, Long.class);
        List<WorldCupCompetitor> worldCupCompetitors = this.listByIds(ids);
        WorldCupCompetitor worldCupCompetitor1 = worldCupCompetitors.get(0);
        WorldCup worldCup = worldCupService.getById(worldCupCompetitor1.getWorldCupId());
        for (WorldCupCompetitor worldCupCompetitor : worldCupCompetitors) {
            //蓝方
            if(worldCupCompetitor.getParticipant() == 1){
                worldCupCompetitor.setMatchResult(blue.compareTo(red_score));
                worldCupCompetitor.setOurScore(blue);
                worldCupCompetitor.setOpponentScore(red_score);
                worldCupCompetitor.setEndTime(new Date());
                worldCupCompetitor.setWinIntegral(0);
                if(null != worldCup.getWinIntegral() && 0 < worldCup.getWinIntegral() && blue.compareTo(red_score) >= 0){
                    worldCupCompetitor.setWinIntegral(worldCup.getWinIntegral());
                    AppUser appUser = appUserClient.getAppUser(worldCupCompetitor.getAppUserId());
                    appUser.setIntegral(appUser.getIntegral() + worldCup.getWinIntegral());
                    appUserClient.updateAppUser(appUser);
                }
            }
            //红方
            if(worldCupCompetitor.getParticipant() == 2){
                worldCupCompetitor.setMatchResult(red_score.compareTo(blue));
                worldCupCompetitor.setOurScore(red_score);
                worldCupCompetitor.setOpponentScore(blue);
                worldCupCompetitor.setEndTime(new Date());
                worldCupCompetitor.setWinIntegral(0);
                if(null != worldCup.getWinIntegral() && 0 < worldCup.getWinIntegral() && red_score.compareTo(blue) >= 0){
                    worldCupCompetitor.setWinIntegral(worldCup.getWinIntegral());
                    AppUser appUser = appUserClient.getAppUser(worldCupCompetitor.getAppUserId());
                    appUser.setIntegral(appUser.getIntegral() + worldCup.getWinIntegral());
                    appUserClient.updateAppUser(appUser);
                }
            }
        }
        this.updateBatchById(worldCupCompetitors);
    }
}
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java
@@ -143,6 +143,14 @@
            worldCupCompetitor.setParticipantId(id);
            worldCupCompetitor.setParticipant("blue".equals(type) ? 1 : 2);
            worldCupCompetitor.setStartTime(new Date());
            //添加参赛奖励
            if(null != worldCup.getParticipationIntegral() && 0 < worldCup.getParticipationIntegral()){
                worldCupCompetitor.setParticipationIntegral(worldCup.getParticipationIntegral());
                AppUser appUser = appUserClient.getAppUser(worldCupCompetitor.getAppUserId());
                appUser.setIntegral(appUser.getIntegral() + worldCup.getParticipationIntegral());
                appUserClient.updateAppUser(appUser);
            }
            worldCupCompetitorService.save(worldCupCompetitor);
            ids.add(worldCupCompetitor.getId());
            //已参赛
@@ -516,7 +524,6 @@
                    DeductionClassHourList deductionClassHourList = new DeductionClassHourList();
                    deductionClassHourList.setDeductionClassHourList(list);
                    DeductionClassHourList deductionClassHourList1 = coursePackageOrderStudentClient.deductionClassHour(deductionClassHourList);
                    List<DeductionClassHour> deductionClassHourList2 = deductionClassHourList1.getDeductionClassHourList();
                    WorldCupPaymentParticipant worldCupPaymentParticipant = new WorldCupPaymentParticipant();
                    worldCupPaymentParticipant.setWorldCupId(paymentWorldCup.getId());
@@ -526,7 +533,7 @@
                    worldCupPaymentParticipant.setParticipantId(id);
                    worldCupPaymentParticipant.setAlreadyEntered(0);
                    worldCupPaymentParticipant.setCreateTime(new Date());
                    worldCupPaymentParticipant.setContent(JSON.toJSONString(deductionClassHourList2));
                    worldCupPaymentParticipant.setContent(JSON.toJSONString(deductionClassHourList1));
                    worldCupPaymentParticipantService.save(worldCupPaymentParticipant);
                }
@@ -661,7 +668,6 @@
                .eq("worldCupId", id).eq("alreadyEntered", 0));
        Set<Long> collect = list.stream().map(WorldCupPaymentParticipant::getWorldCupPaymentId).collect(Collectors.toSet());
        for (Long worldCupPaymentId : collect) {
            List<WorldCupPaymentParticipant> list1 = worldCupPaymentParticipantService.list(new QueryWrapper<WorldCupPaymentParticipant>()
                    .eq("worldCupPaymentId", worldCupPaymentId).eq("alreadyEntered", 0));
            WorldCupPayment worldCupPayment = worldCupPaymentService.getById(worldCupPaymentId);
@@ -701,58 +707,41 @@
                worldCupPayment.setRefundOrderNo("");
                worldCupPayment.setPayStatus(3);
                worldCupPaymentService.updateById(worldCupPayment);
            }//课时支付
            }
            //课时支付
            if(worldCupPayment.getPayType() == 4){
                for (WorldCupPaymentParticipant worldCupPaymentParticipant : list1) {
                    Integer studentId = worldCupPaymentParticipant.getParticipantId();//构建扣减课时数据
                    String content = worldCupPaymentParticipant.getContent();
                    List<DeductionClassHour> list2 = JSON.parseArray(content, DeductionClassHour.class);
//                    Integer classHour = worldCup.getClassHour();
//                    for (CoursePackageOrderStudent packageOrderStudent : coursePackageOrderStudent) {
//                        Integer laveClassHours = packageOrderStudent.getLaveClassHours();
//
//                        DeductionClassHour deductionClassHour = new DeductionClassHour();
//                        if(classHour.compareTo(laveClassHours) > 0){
//                            //不够扣除,轮询直到扣除完
//                            classHour = classHour - laveClassHours;
//                            deductionClassHour.setId(packageOrderStudent.getId());
//                            deductionClassHour.setClassHour(laveClassHours);
//                            deductionClassHour.setStudentId(packageOrderStudent.getStudentId());
//                            deductionClassHour.setCoursePackageId(packageOrderStudent.getCoursePackageId());
//                            list.add(deductionClassHour);
//                        }else{
//                            //够扣除直接跳出进行下个学员
//                            deductionClassHour.setId(packageOrderStudent.getId());
//                            deductionClassHour.setClassHour(classHour);
//                            deductionClassHour.setStudentId(packageOrderStudent.getStudentId());
//                            deductionClassHour.setCoursePackageId(packageOrderStudent.getCoursePackageId());
//                            list.add(deductionClassHour);
//                            break;
//                        }
//                    }
                    DeductionClassHourList deductionClassHourList = JSON.parseObject(content, DeductionClassHourList.class);
                    coursePackageOrderStudentClient.backspaceClassHour(deductionClassHourList);
                }
                //扣减课时操作
                DeductionClassHourList deductionClassHourList = new DeductionClassHourList();
//                deductionClassHourList.setDeductionClassHourList(list);
                coursePackageOrderStudentClient.deductionClassHour(deductionClassHourList);
                worldCupPayment.setRefundTime(new Date());
                worldCupPayment.setRefundOrderNo("");
                worldCupPayment.setPayStatus(3);
                worldCupPaymentService.updateById(worldCupPayment);
            }
        }
    }
        for (WorldCupPaymentParticipant worldCupPaymentParticipant : list) {
    /**
     * 定时任务修改状态
     */
    @Override
    public void taskUpdateStatus() {
        List<WorldCup> worldCups = this.list(new QueryWrapper<WorldCup>().eq("status", 1).last(" and startTime <= now()"));
        for (WorldCup worldCup : worldCups) {
            worldCup.setStatus(2);
        }
        if(worldCups.size() > 0){
            this.updateBatchById(worldCups);
        }
        worldCups = this.list(new QueryWrapper<WorldCup>().eq("status", 2).last(" and endTime <= now()"));
        for (WorldCup worldCup : worldCups) {
            worldCup.setStatus(3);
        }
        if(worldCups.size() > 0){
            this.updateBatchById(worldCups);
        }
    }
}
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/util/TaskUtil.java
@@ -1,5 +1,6 @@
package com.dsh.communityWorldCup.util;
import com.dsh.communityWorldCup.service.IWorldCupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -11,6 +12,9 @@
@Component
public class TaskUtil {
    @Autowired
    private IWorldCupService worldCupService;
    /**
@@ -19,16 +23,11 @@
    @Scheduled(fixedRate = 60000)
    public void taskMinute() {
        try {
            worldCupService.taskUpdateStatus();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @Scheduled(fixedRate = 60000)
    public void money() {
        try {
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}