ソースを参照

add 网管课统计

周箭河 5 年 前
コミット
d7e9d6a7b1

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleEvaluateDao.java

@@ -1,5 +1,7 @@
 package com.ym.mec.biz.dal.dao;
 
+import com.ym.mec.biz.dal.dto.PracticeGroupsDto;
+import com.ym.mec.biz.dal.entity.ClassGroup;
 import com.ym.mec.biz.dal.entity.CourseScheduleEvaluate;
 import com.ym.mec.biz.dal.entity.TeacherCourseStatistics;
 import com.ym.mec.common.dal.BaseDAO;
@@ -14,4 +16,14 @@ public interface CourseScheduleEvaluateDao extends BaseDAO<Long, CourseScheduleE
     CourseScheduleEvaluate findByClassGroupId(@Param("classGroupId") Integer classGroupId);
 
     List<CourseScheduleEvaluate> findByClassGroupIds(@Param("classGroupIds") List<Integer> classGroupIds);
+
+    List<PracticeGroupsDto> getPracticeGroupsFree();
+
+    List<PracticeGroupsDto> getPracticeGroupsBuy();
+
+    List<PracticeGroupsDto> getHasReportNums();
+
+    List<PracticeGroupsDto> getOrganPracticeGroups();
+
+    List<PracticeGroupsDto> getOrganMoney();
 }

+ 78 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/PracticeGroupsDto.java

@@ -0,0 +1,78 @@
+package com.ym.mec.biz.dal.dto;
+
+import java.math.BigDecimal;
+
+public class PracticeGroupsDto {
+    private String organName;
+    private Integer organId;
+    private Integer totalNums = 0;
+    private Integer overNums = 0;
+    private Integer reportNums = 0;
+    private Integer buyNums = 0;
+    private BigDecimal totalMoney = BigDecimal.ZERO;
+    private Double buyScale =  0.00;
+
+    public String getOrganName() {
+        return organName;
+    }
+
+    public void setOrganName(String organName) {
+        this.organName = organName;
+    }
+
+    public Integer getTotalNums() {
+        return totalNums;
+    }
+
+    public void setTotalNums(Integer totalNums) {
+        this.totalNums = totalNums;
+    }
+
+    public Integer getOverNums() {
+        return overNums;
+    }
+
+    public void setOverNums(Integer overNums) {
+        this.overNums = overNums;
+    }
+
+    public Integer getBuyNums() {
+        return buyNums;
+    }
+
+    public void setBuyNums(Integer buyNums) {
+        this.buyNums = buyNums;
+    }
+
+    public BigDecimal getTotalMoney() {
+        return totalMoney;
+    }
+
+    public void setTotalMoney(BigDecimal totalMoney) {
+        this.totalMoney = totalMoney;
+    }
+
+    public Integer getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(Integer organId) {
+        this.organId = organId;
+    }
+
+    public Integer getReportNums() {
+        return reportNums;
+    }
+
+    public void setReportNums(Integer reportNums) {
+        this.reportNums = reportNums;
+    }
+
+    public Double getBuyScale() {
+        return buyScale;
+    }
+
+    public void setBuyScale(Double buyScale) {
+        this.buyScale = buyScale;
+    }
+}

+ 73 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/practiceGroupStatisDto.java

@@ -0,0 +1,73 @@
+package com.ym.mec.biz.dal.dto;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+public class practiceGroupStatisDto {
+    private List<PracticeGroupsDto> practiceGroupsDtoList;
+    private BigDecimal totalMoney;
+    private Integer totalNum = 0;
+    private Integer buyNum = 0;
+    private Integer overNum = 0;
+    private Integer reportNum = 0;
+    private BigDecimal buyScale;
+
+    public practiceGroupStatisDto() {
+    }
+
+    public List<PracticeGroupsDto> getPracticeGroupsDtoList() {
+        return practiceGroupsDtoList;
+    }
+
+    public void setPracticeGroupsDtoList(List<PracticeGroupsDto> practiceGroupsDtoList) {
+        this.practiceGroupsDtoList = practiceGroupsDtoList;
+    }
+
+    public BigDecimal getTotalMoney() {
+        return totalMoney;
+    }
+
+    public void setTotalMoney(BigDecimal totalMoney) {
+        this.totalMoney = totalMoney;
+    }
+
+    public Integer getTotalNum() {
+        return totalNum;
+    }
+
+    public void setTotalNum(Integer totalNum) {
+        this.totalNum = totalNum;
+    }
+
+    public Integer getBuyNum() {
+        return buyNum;
+    }
+
+    public void setBuyNum(Integer buyNum) {
+        this.buyNum = buyNum;
+    }
+
+    public Integer getOverNum() {
+        return overNum;
+    }
+
+    public void setOverNum(Integer overNum) {
+        this.overNum = overNum;
+    }
+
+    public Integer getReportNum() {
+        return reportNum;
+    }
+
+    public void setReportNum(Integer reportNum) {
+        this.reportNum = reportNum;
+    }
+
+    public BigDecimal getBuyScale() {
+        return buyScale;
+    }
+
+    public void setBuyScale(BigDecimal buyScale) {
+        this.buyScale = buyScale;
+    }
+}

+ 61 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleEvaluateMapper.xml

@@ -37,4 +37,65 @@
             #{classGroupId}
         </foreach>
     </select>
+
+    <resultMap id="PracticeGroupsOrgan" type="com.ym.mec.biz.dal.dto.PracticeGroupsDto">
+        <result column="organ_id_" jdbcType="INTEGER" property="organId"/>
+        <result column="total_nums_" jdbcType="INTEGER" property="totalNums"/>
+        <result column="buy_nums_" jdbcType="INTEGER" property="buyNums"/>
+        <result column="report_nums_" jdbcType="INTEGER" property="reportNums"/>
+        <result column="total_money_" jdbcType="DECIMAL" property="totalMoney"/>
+    </resultMap>
+
+    <!-- 体验人数 -->
+    <select id="getPracticeGroupsFree" resultMap="PracticeGroupsOrgan">
+        SELECT pg.organ_id_, count(*) total_nums_
+        FROM class_group cg
+                 LEFT JOIN practice_group pg on cg.music_group_id_ = pg.id_
+        WHERE cg.group_type_ = 'PRACTICE'
+          AND pg.buy_months_ IS NULL
+          AND pg.group_status_ != 'LOCK'
+        GROUP BY pg.organ_id_
+    </select>
+
+    <!-- 已购买人数 -->
+    <select id="getPracticeGroupsBuy" resultMap="PracticeGroupsOrgan">
+        SELECT pg.organ_id_, count(*) buy_nums_
+        FROM class_group cg
+                 LEFT JOIN practice_group pg on cg.music_group_id_ = pg.id_
+        WHERE cg.group_type_ = 'PRACTICE'
+          AND pg.buy_months_ >= 1
+          AND pg.group_status_ != 'LOCK'
+        GROUP BY pg.organ_id_
+    </select>
+
+    <!-- 报告完成数 -->
+    <select id="getHasReportNums" resultMap="PracticeGroupsOrgan">
+        SELECT pg.organ_id_, count(*) report_nums_
+        FROM course_schedule_evaluate cse
+                 LEFT JOIN practice_group pg on cse.music_group_id_ = pg.id_
+            AND pg.buy_months_ IS NULL
+            AND pg.group_status_ != 'LOCK'
+        GROUP BY pg.organ_id_
+    </select>
+
+    <!-- 已完成课程数统计 -->
+    <select id="getOrganPracticeGroups" resultMap="PracticeGroupsOrgan">
+        SELECT COUNT(class_group_id_) buy_nums_,cg.total_class_times_ total_nums_, pg.organ_id_
+        FROM course_schedule cs
+                 LEFT JOIN class_group cg on cg.id_ = cs.class_group_id_
+                 LEFT JOIN practice_group pg ON cs.music_group_id_ = pg.id_
+        WHERE cs.group_type_ = 'PRACTICE'
+          AND cs.status_ != 'NOT_START'
+          AND cs.del_flag_ = 0
+          AND pg.buy_months_ IS NULL
+          AND pg.group_status_ != 'LOCK'
+        GROUP BY cs.class_group_id_, pg.organ_id_
+    </select>
+
+    <!-- 成交金额 -->
+    <select id="getOrganMoney" resultMap="PracticeGroupsOrgan">
+        SELECT SUM(actual_amount_) total_money_,organ_id_ FROM student_payment_order
+        WHERE group_type_='PRACTICE' AND status_='SUCCESS'
+        GROUP BY organ_id_
+    </select>
 </mapper>

+ 97 - 7
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -1,10 +1,7 @@
 package com.ym.mec.student.controller;
 
-import com.ym.mec.biz.dal.dao.OrganizationDao;
-import com.ym.mec.biz.dal.dao.SysConfigDao;
-import com.ym.mec.biz.dal.dao.TeacherCourseStatisticsDao;
-import com.ym.mec.biz.dal.dto.LuckStatisDto;
-import com.ym.mec.biz.dal.dto.OrderStatisDto;
+import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.util.date.DateUtil;
@@ -15,6 +12,7 @@ import io.swagger.annotations.ApiOperation;
 
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.net.URLEncoder;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -36,8 +34,6 @@ import org.springframework.web.bind.annotation.RestController;
 import com.alibaba.fastjson.JSON;
 import com.huifu.adapay.model.payment.PayChannelEnum;
 import com.huifu.adapay.model.payment.Payment;
-import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
-import com.ym.mec.biz.dal.dto.VipBuyResultDto;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.common.controller.BaseController;
@@ -80,6 +76,8 @@ public class StudentOrderController extends BaseController {
     private OrganizationDao organizationDao;
     @Autowired
     private TeacherCourseStatisticsDao teacherCourseStatisticsDao;
+    @Autowired
+    private CourseScheduleEvaluateDao courseScheduleEvaluateDao;
 
     @PostMapping("/notify")
     public Msg notify(@ModelAttribute Msg msg) throws Exception {
@@ -341,4 +339,96 @@ public class StudentOrderController extends BaseController {
         luckStatisDto.setTotalMoney(totalMoney);
         return succeed(luckStatisDto);
     }
+
+    @GetMapping("/getPracticeGroupStatis")
+    public HttpResponseResult getPracticeGroupStatis() {
+        List<Organization> organs = organizationDao.findAllOrgans();
+        List<PracticeGroupsDto> hasReportNums = courseScheduleEvaluateDao.getHasReportNums();
+        List<PracticeGroupsDto> organMoneys = courseScheduleEvaluateDao.getOrganMoney();
+        List<PracticeGroupsDto> organPracticeGroups = courseScheduleEvaluateDao.getOrganPracticeGroups();
+        List<PracticeGroupsDto> practiceGroupsFrees = courseScheduleEvaluateDao.getPracticeGroupsFree();
+        List<PracticeGroupsDto> practiceGroupsBuys = courseScheduleEvaluateDao.getPracticeGroupsBuy();
+
+        List<PracticeGroupsDto> practiceGroups = new ArrayList<>();
+        for (Organization organ : organs) {
+            PracticeGroupsDto practiceGroupsDto = new PracticeGroupsDto();
+            practiceGroupsDto.setOrganName(organ.getName());
+            practiceGroupsDto.setOrganId(organ.getId());
+            //体验人数
+            for (PracticeGroupsDto practiceGroupsFree : practiceGroupsFrees) {
+                if (organ.getId().equals(practiceGroupsFree.getOrganId())) {
+                    practiceGroupsDto.setTotalNums(practiceGroupsFree.getTotalNums());
+                    break;
+                }
+            }
+            //购买人数
+            for (PracticeGroupsDto practiceGroupsBuy : practiceGroupsBuys) {
+                if (organ.getId().equals(practiceGroupsBuy.getOrganId())) {
+                    practiceGroupsDto.setBuyNums(practiceGroupsBuy.getBuyNums());
+                    break;
+                }
+            }
+            //已完成人数
+            for (PracticeGroupsDto organPracticeGroup : organPracticeGroups) {
+                if (organ.getId().equals(organPracticeGroup.getOrganId()) && organPracticeGroup.getBuyNums() >= organPracticeGroup.getTotalNums()) {
+                    practiceGroupsDto.setOverNums(practiceGroupsDto.getOverNums() + 1);
+                }
+            }
+
+            //已提交报告人数
+            for (PracticeGroupsDto hasReportNum : hasReportNums) {
+                if (organ.getId().equals(hasReportNum.getOrganId())) {
+                    practiceGroupsDto.setReportNums(hasReportNum.getReportNums());
+                    break;
+                }
+            }
+            //成交金额
+            for (PracticeGroupsDto organMoney : organMoneys) {
+                practiceGroupsDto.setTotalMoney(organMoney.getTotalMoney());
+            }
+
+            if(practiceGroupsDto.getTotalNums() >0 ){
+                double scale = new BigDecimal(practiceGroupsDto.getBuyNums()).multiply(new BigDecimal(100)).divide(new BigDecimal(practiceGroupsDto.getTotalNums()),2, BigDecimal.ROUND_HALF_UP).doubleValue();
+                practiceGroupsDto.setBuyScale(scale);
+            }
+
+            practiceGroups.add(practiceGroupsDto);
+        }
+
+        BigDecimal totalMoney = BigDecimal.ZERO;
+        Integer totalNum = 0;
+        Integer buyNum = 0;
+        Integer overNum = 0;
+        Integer reportNum = 0;
+
+        Iterator<PracticeGroupsDto> iterator = practiceGroups.iterator();
+        while (iterator.hasNext()) {
+            PracticeGroupsDto next = iterator.next();
+            if (next.getOrganName().equals("总部国际") || next.getOrganName().equals("阳光总部国际") || next.getOrganName().equals("武汉小学")) {
+                iterator.remove();
+                continue;
+            }
+            totalMoney = totalMoney.add(next.getTotalMoney());
+            totalNum += next.getTotalNums();
+            overNum += next.getOverNums();
+            buyNum += next.getBuyNums();
+            reportNum += next.getReportNums();
+        }
+        practiceGroups = practiceGroups.stream().sorted(Comparator.comparingDouble(PracticeGroupsDto::getBuyScale).reversed()).collect(Collectors.toList());
+
+        practiceGroupStatisDto practiceGroupStatisDto = new practiceGroupStatisDto();
+        practiceGroupStatisDto.setPracticeGroupsDtoList(practiceGroups);
+        practiceGroupStatisDto.setTotalMoney(totalMoney);
+        practiceGroupStatisDto.setTotalNum(totalNum);
+        practiceGroupStatisDto.setBuyNum(buyNum);
+        practiceGroupStatisDto.setOverNum(overNum);
+        practiceGroupStatisDto.setReportNum(reportNum);
+
+        if(totalNum >0 ){
+            BigDecimal scale = new BigDecimal(buyNum).multiply(new BigDecimal(100)).divide(new BigDecimal(totalNum), 2, BigDecimal.ROUND_HALF_UP);
+            practiceGroupStatisDto.setBuyScale(scale);
+        }
+
+        return succeed(practiceGroupStatisDto);
+    }
 }