zouxuan 5 years ago
parent
commit
63d23284a4

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/PracticeGroupDao.java

@@ -2,6 +2,7 @@ package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.dto.PracticeCourseDto;
 import com.ym.mec.biz.dal.dto.PracticeGroupDto;
+import com.ym.mec.biz.dal.dto.StudentBuyPracticeDto;
 import com.ym.mec.biz.dal.entity.ClassGroup;
 import com.ym.mec.biz.dal.entity.CourseScheduleEvaluate;
 import com.ym.mec.biz.dal.entity.PracticeGroup;
@@ -209,4 +210,18 @@ public interface PracticeGroupDao extends com.ym.mec.common.dal.BaseDAO<Long, Pr
      * @return
      */
     PracticeCourseDto findByGroupId(@Param("id") Integer id);
+
+    /**
+     * COUNT网管课购买列表
+     * @param params
+     * @return
+     */
+    int countStudentBuys(Map<String, Object> params);
+
+    /**
+     * query网管课购买列表
+     * @param params
+     * @return
+     */
+    List<StudentBuyPracticeDto> queryStudentBuys(Map<String, Object> params);
 }

+ 95 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentBuyPracticeDto.java

@@ -0,0 +1,95 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.enums.YesOrNoEnum;
+
+import java.util.Date;
+
+public class StudentBuyPracticeDto {
+    //学员编号
+    private Long studentId;
+
+    //学员名称
+    private String studentName;
+
+    //分部
+    private String organName;
+
+    //手机
+    private String phone;
+
+    //是否购买
+    private YesOrNoEnum buyPractice;
+
+    //结束日期
+    private Date lastClassDate;
+
+    //购买日期
+    private Date firstBuyTime;
+
+    //时间差
+    private int intervalDay;
+
+    public Long getStudentId() {
+        return studentId;
+    }
+
+    public void setStudentId(Long studentId) {
+        this.studentId = studentId;
+    }
+
+    public String getStudentName() {
+        return studentName;
+    }
+
+    public void setStudentName(String studentName) {
+        this.studentName = studentName;
+    }
+
+    public String getOrganName() {
+        return organName;
+    }
+
+    public void setOrganName(String organName) {
+        this.organName = organName;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public YesOrNoEnum getBuyPractice() {
+        return buyPractice;
+    }
+
+    public void setBuyPractice(YesOrNoEnum buyPractice) {
+        this.buyPractice = buyPractice;
+    }
+
+    public Date getLastClassDate() {
+        return lastClassDate;
+    }
+
+    public void setLastClassDate(Date lastClassDate) {
+        this.lastClassDate = lastClassDate;
+    }
+
+    public Date getFirstBuyTime() {
+        return firstBuyTime;
+    }
+
+    public void setFirstBuyTime(Date firstBuyTime) {
+        this.firstBuyTime = firstBuyTime;
+    }
+
+    public int getIntervalDay() {
+        return intervalDay;
+    }
+
+    public void setIntervalDay(int intervalDay) {
+        this.intervalDay = intervalDay;
+    }
+}

+ 27 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentBuyPracticeQueryInfo.java

@@ -0,0 +1,27 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+
+public class StudentBuyPracticeQueryInfo extends QueryInfo {
+    //分部编号
+    private String organId;
+
+    //是否购买
+    private Boolean buyPractice;
+
+    public String getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(String organId) {
+        this.organId = organId;
+    }
+
+    public Boolean getBuyPractice() {
+        return buyPractice;
+    }
+
+    public void setBuyPractice(Boolean buyPractice) {
+        this.buyPractice = buyPractice;
+    }
+}

+ 7 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/PracticeGroupService.java

@@ -4,6 +4,7 @@ import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.PracticeGroup;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.page.PracticeGroupQueryInfo;
+import com.ym.mec.biz.dal.page.StudentBuyPracticeQueryInfo;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
@@ -270,6 +271,10 @@ public interface PracticeGroupService extends BaseService<Long, PracticeGroup> {
 	 */
 	PageInfo<PracticeGroupDto> findPracticeGroupReviews(PracticeGroupQueryInfo queryInfo);
 
-
-
+	/**
+	 * 购买过网管课的学员列表
+	 * @param queryInfo
+	 * @return
+	 */
+	PageInfo<StudentBuyPracticeDto> studentBuys(StudentBuyPracticeQueryInfo queryInfo);
 }

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

@@ -10,6 +10,7 @@ import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.PracticeGroupQueryInfo;
+import com.ym.mec.biz.dal.page.StudentBuyPracticeQueryInfo;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.constant.CommonConstants;
 import com.ym.mec.common.controller.BaseController;
@@ -3566,4 +3567,23 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         pageInfo.setRows(dataList);
         return pageInfo;
     }
+
+    @Override
+    public PageInfo<StudentBuyPracticeDto> studentBuys(StudentBuyPracticeQueryInfo queryInfo) {
+        PageInfo pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Map<String, Object> params = new HashMap<>();
+        MapUtil.populateMap(params, queryInfo);
+        List<StudentBuyPracticeDto> dataList = null;
+        int count = practiceGroupDao.countStudentBuys(params);
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            params.put("offset", pageInfo.getOffset());
+            dataList = practiceGroupDao.queryStudentBuys(params);
+        }
+        if (count == 0) {
+            dataList = new ArrayList<>();
+        }
+        pageInfo.setRows(dataList);
+        return pageInfo;
+    }
 }

+ 52 - 0
mec-biz/src/main/resources/config/mybatis/PracticeGroupMapper.xml

@@ -388,4 +388,56 @@
         LEFT JOIN sys_user su on pg.educational_teacher_id_ = su.id_
         WHERE pg.id_ = #{id}
     </select>
+
+    <select id="countStudentBuys" resultType="java.lang.Integer">
+        SELECT COUNT(a.student_id_) FROM
+        (SELECT pg.`student_id_` ,max(concat(cs.`class_date_`,' ',cs.`end_class_time_` )) lastClassDate
+        FROM `practice_group` pg
+        LEFT JOIN `course_schedule` cs on cs.`music_group_id_` = pg.`id_`
+        WHERE cs.`group_type_` = 'PRACTICE' AND pg.`buy_months_` IS NULL
+        GROUP BY pg.`student_id_` ) a
+        left join (SELECT pg.`student_id_` ,min(pg.`create_time_`) firstBuyTime  FROM `practice_group` pg WHERE pg.`buy_months_` IS NOT NULL GROUP BY pg.`student_id_` ) b
+        on a.student_id_ = b.student_id_
+        left join `sys_user` u on u.`id_` = a.student_id_
+        <include refid="queryStudentBuysSql"/>
+    </select>
+    <resultMap id="queryStudentBuysMap" type="com.ym.mec.biz.dal.dto.StudentBuyPracticeDto">
+        <result property="organName" column="organ_name_"/>
+        <result property="phone" column="phone_"/>
+        <result property="studentId" column="student_id_"/>
+        <result property="studentName" column="student_name_"/>
+        <result property="firstBuyTime" column="first_buy_time_"/>
+        <result property="intervalDay" column="interval_day_"/>
+        <result property="lastClassDate" column="last_class_date_"/>
+        <result property="buyPractice" column="buy_practice_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+    </resultMap>
+    <select id="queryStudentBuys" resultMap="queryStudentBuysMap">
+        SELECT o.`name_` organ_name_,a.student_id_,u.`username_` student_name_,u.phone_,a.lastClassDate last_class_date_,
+        b.firstBuyTime first_buy_time_,DATEDIFF(b.firstBuyTime,a.lastClassDate) interval_day_,
+        CASE WHEN b.firstBuyTime IS NULL THEN 0 ELSE 1 END buy_practice_ FROM
+        (SELECT pg.`student_id_` ,max(concat(cs.`class_date_`,' ',cs.`end_class_time_` )) lastClassDate
+        FROM `practice_group` pg
+        LEFT JOIN `course_schedule` cs on cs.`music_group_id_` = pg.`id_`
+        WHERE cs.`group_type_` = 'PRACTICE' AND pg.`buy_months_` IS NULL
+        GROUP BY pg.`student_id_` ) a
+        left join (SELECT pg.`student_id_` ,min(pg.`create_time_`) firstBuyTime  FROM `practice_group` pg WHERE pg.`buy_months_` IS NOT NULL GROUP BY pg.`student_id_` ) b
+        on a.student_id_ = b.student_id_
+        left join `sys_user` u on u.`id_` = a.student_id_
+        left join `organization` o on o.`id_` = u.`organ_id_`
+        <include refid="queryStudentBuysSql"/>
+        <include refid="global.limit"/>
+    </select>
+    <sql id="queryStudentBuysSql">
+        <where>
+            <if test="search != null and search != ''">
+                (u.id_ = #{search} OR u.`username_` LIKE CONCAT('%',#{search},'%'))
+            </if>
+            <if test="buyPractice != null and buyPractice == false">
+                AND b.firstBuyTime IS NULL
+            </if>
+            <if test="buyPractice != null and buyPractice == true">
+                AND b.firstBuyTime IS NOT NULL
+            </if>
+        </where>
+    </sql>
 </mapper>

+ 22 - 0
mec-im/src/main/java/com/ym/controller/RoomController.java

@@ -4,6 +4,15 @@ import com.alibaba.fastjson.JSONObject;
 import com.ym.common.ApiException;
 import com.ym.common.BaseResponse;
 import com.ym.common.ErrorEnum;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.CourseScheduleDao;
+import com.ym.mec.biz.dal.dao.CoursesGroupDao;
+import com.ym.mec.biz.dal.dao.TeacherDao;
+import com.ym.mec.biz.dal.entity.CourseSchedule;
+import com.ym.mec.biz.dal.entity.CoursesGroup;
+import com.ym.mec.biz.dal.entity.Teacher;
+import com.ym.mec.biz.dal.enums.SignStatusEnum;
+import com.ym.mec.biz.dal.enums.StudentAttendanceStatusEnum;
 import com.ym.pojo.*;
 import com.ym.service.RoomService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -19,6 +28,10 @@ import java.util.List;
 public class RoomController{
     @Autowired
     RoomService roomService;
+    @Autowired
+    private TeacherDao teacherDao;
+    @Autowired
+    private CourseScheduleDao courseScheduleDao;
 
     @RequestMapping(value = "/join", method = RequestMethod.POST)
     public Object joinRoom(@RequestBody ReqUserData data)
@@ -40,6 +53,15 @@ public class RoomController{
         boolean result = false;
         if(notify.getEvent() == 12 || notify.getEvent() == 3){
             result = roomService.statusSync(notify.getChannelId(), notify.getUserId());
+        }else if(notify.getEvent() == 11){
+            Teacher teacher = teacherDao.get(Integer.parseInt(notify.getUserId()));
+            Long roomId = Long.parseLong(notify.getChannelId().substring(1));
+            CourseSchedule courseSchedule = courseScheduleDao.get(roomId);
+            if(teacher != null && teacher.getId().equals(courseSchedule.getActualTeacherId())){
+                roomService.joinRoom(teacher.getRealName(),roomId.toString(),false,false);
+            }else {
+                roomService.joinRoom(teacher.getUsername(),roomId.toString(),false,false);
+            }
         }
         return new BaseResponse<>(result);
     }

+ 38 - 3
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -73,6 +73,44 @@ public class ExportController extends BaseController {
     @Autowired
     private TenantPaymentOrderService tenantPaymentOrderService;
 
+    @ApiOperation(value = "网管课购买列表")
+    @PostMapping("export/studentBuyPractice")
+    @PreAuthorize("@pcs.hasPermissions('export/studentBuyPractice')")
+    public void studentBuyPractice(HttpServletResponse response, StudentBuyPracticeQueryInfo queryInfo) {
+        queryInfo.setRows(49999);
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new BizException("用户信息获取失败");
+        }
+        if (!sysUser.getIsSuperAdmin()) {
+            Employee employee = employeeDao.get(sysUser.getId());
+            if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+                queryInfo.setOrganId(employee.getOrganIdList());
+            } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
+                throw new BizException("用户所在分部异常");
+            } else {
+                List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+                if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
+                    throw new BizException("非法请求");
+                }
+            }
+        }
+        List<StudentBuyPracticeDto> rows = practiceGroupService.studentBuys(queryInfo).getRows();
+        try {
+            HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"学员编号", "学员名称", "所属分部", "联系电话", "购买网管课",
+                    "免费课结束日期", "首次购买日期", "时间差"}, new String[]{
+                    "studentId", "studentName", "organName", "phone", "buyPractice.msg",
+                    "lastClassDate", "firstBuyTime", "intervalDay"}, rows);
+            response.setContentType("application/octet-stream");
+            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");
+            response.flushBuffer();
+            workbook.write(response.getOutputStream());
+            workbook.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
     @ApiOperation(value = "导出对外订单列表")
     @PostMapping("export/tenantPaymentOrder")
     @PreAuthorize("@pcs.hasPermissions('export/tenantPaymentOrder')")
@@ -83,9 +121,6 @@ public class ExportController extends BaseController {
             throw new BizException("用户信息获取失败");
         }
         List<TenantPaymentOrder> paymentOrders = tenantPaymentOrderService.queryPage(queryInfo).getRows();
-//        if (paymentOrders.size() > 50000) {
-//            throw new BizException("数据集太大,不能导出.最大数据集不能超过50000");
-//        }
         try {
             HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"交易流水号", "订单号", "订单日期", "交易类型", "应付金额",
                     "实付金额", "用户姓名", "交易方式", "收款账户", "交易状态", "备注", "交易方式"}, new String[]{

+ 8 - 0
mec-web/src/main/java/com/ym/mec/web/controller/PracticeGroupManageController.java

@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.page.PracticeGroupQueryInfo;
+import com.ym.mec.biz.dal.page.StudentBuyPracticeQueryInfo;
 import com.ym.mec.biz.service.CourseScheduleEvaluateService;
 import com.ym.mec.biz.service.GroupClassService;
 import com.ym.mec.biz.service.PracticeGroupService;
@@ -128,4 +129,11 @@ public class PracticeGroupManageController extends BaseController {
     public Object getReviewsInfo(Integer id) {
         return succeed(courseScheduleEvaluateService.findById(id));
     }
+
+    @ApiOperation(value = "网管课购买列表")
+    @GetMapping("studentBuys")
+    @PreAuthorize("@pcs.hasPermissions('practiceGroupManage/studentBuys')")
+    public Object studentBuys(StudentBuyPracticeQueryInfo queryInfo) {
+        return succeed(practiceGroupService.studentBuys(queryInfo));
+    }
 }