Browse Source

老师课程统计

刘俊驰 5 months ago
parent
commit
4fd2839f9d

+ 59 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/teacher/controller/HomeController.java

@@ -0,0 +1,59 @@
+package com.yonge.cooleshow.teacher.controller;
+
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.dto.SubjectHomeSearch;
+import com.yonge.cooleshow.biz.dal.dto.req.TotalReq;
+import com.yonge.cooleshow.biz.dal.service.HomeService;
+import com.yonge.cooleshow.biz.dal.service.MusicSheetService;
+import com.yonge.cooleshow.biz.dal.service.SysUserService;
+import com.yonge.cooleshow.biz.dal.vo.CourseHomeVo;
+import com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo;
+import com.yonge.cooleshow.biz.dal.vo.SubjectHomeVo;
+import com.yonge.cooleshow.biz.dal.vo.res.HomeTotalStudent;
+import com.yonge.cooleshow.biz.dal.vo.res.HomeTotalTeacher;
+import com.yonge.cooleshow.biz.dal.vo.res.HomeUserToDoNum;
+import com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.toolset.base.page.PageInfo;
+import com.yonge.toolset.mybatis.support.PageUtil;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("${app-config.url.teacher:}/home")
+@Api(value = "首页", tags = "首页")
+public class HomeController extends BaseController {
+
+
+    @Autowired
+    private HomeService homeService;
+
+    @Autowired
+    private SysUserService sysUserService;
+
+    @ApiOperation(value = "课程统计")
+    @PostMapping("/totalCourse")
+    public HttpResponseResult<List<TeacherHomeWrapper.TeacherTotalCourse>> totalCourse(@RequestBody TeacherHomeWrapper.TeacherTotalCourseQuery query) {
+        SysUser sysUser = sysUserService.getUser();
+        if (sysUser == null  || sysUser.getId() == null) {
+
+            return failed("用户信息获取失败");
+        }
+        query.setTeacherId(sysUser.getId());
+
+        return succeed(homeService.teacherTotalCourse(query));
+    }
+}

+ 1 - 0
cooleshow-common/src/main/java/com/yonge/cooleshow/common/constant/SysConfigConstant.java

@@ -122,6 +122,7 @@ public interface SysConfigConstant {
      */
     String GOOD_LOGO_VIP = "good_logo_vip";
     String GOOD_LOGO_SVIP = "good_logo_svip";
+    String GOOD_LOGO_DISCOUNT = "good_logo_discount";
     /***
      * 商品视频课图片
      * @author liweifan

+ 10 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/HomeDao.java

@@ -8,6 +8,7 @@ import com.yonge.cooleshow.biz.dal.vo.TagTotalTeacher;
 import com.yonge.cooleshow.biz.dal.vo.res.HomeTotalStudent;
 import com.yonge.cooleshow.biz.dal.vo.res.HomeTotalTeacher;
 import com.yonge.cooleshow.biz.dal.vo.res.HomeUserToDoNum;
+import com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -64,4 +65,13 @@ public interface HomeDao {
      * @return
      */
     IPage<SubjectHomeVo> selectSubjectHome(@Param("page") IPage<SubjectHomeVo> page, @Param("query") SubjectHomeSearch query);
+
+
+    /**
+     * 老师端首页统计课程
+     *
+     * @param query 参数
+     * @return TeacherHomeWrapper.TeacherTotalCourse
+     */
+    List<TeacherHomeWrapper.TeacherTotalCourse> teacherTotalCourse(@Param("param") TeacherHomeWrapper.TeacherTotalCourseQuery query);
 }

+ 10 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/HomeService.java

@@ -8,9 +8,11 @@ import com.yonge.cooleshow.biz.dal.vo.SubjectHomeVo;
 import com.yonge.cooleshow.biz.dal.vo.res.HomeTotalStudent;
 import com.yonge.cooleshow.biz.dal.vo.res.HomeTotalTeacher;
 import com.yonge.cooleshow.biz.dal.vo.res.HomeUserToDoNum;
+import com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.toolset.base.page.PageInfo;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -60,4 +62,12 @@ public interface HomeService {
      * @return
      */
     PageInfo<SubjectHomeVo> subjectHome(IPage<SubjectHomeVo> page, SubjectHomeSearch query);
+
+    /**
+     * 老师端首页统计课程
+     *
+     * @param query 参数
+     * @return TeacherHomeWrapper.TeacherTotalCourse
+     */
+    List<TeacherHomeWrapper.TeacherTotalCourse> teacherTotalCourse(TeacherHomeWrapper.TeacherTotalCourseQuery query);
 }

+ 35 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/HomeServiceImpl.java

@@ -6,6 +6,7 @@ import com.yonge.cooleshow.biz.dal.dao.HomeDao;
 import com.yonge.cooleshow.biz.dal.dto.SubjectHomeSearch;
 import com.yonge.cooleshow.biz.dal.dto.req.TotalReq;
 import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
+import com.yonge.cooleshow.biz.dal.enums.GoodTypeEnum;
 import com.yonge.cooleshow.biz.dal.enums.TeacherTagEnum;
 import com.yonge.cooleshow.biz.dal.service.CourseScheduleService;
 import com.yonge.cooleshow.biz.dal.service.HomeService;
@@ -16,6 +17,7 @@ import com.yonge.cooleshow.biz.dal.vo.TagTotalTeacher;
 import com.yonge.cooleshow.biz.dal.vo.res.HomeTotalStudent;
 import com.yonge.cooleshow.biz.dal.vo.res.HomeTotalTeacher;
 import com.yonge.cooleshow.biz.dal.vo.res.HomeUserToDoNum;
+import com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.toolset.base.page.PageInfo;
 import com.yonge.toolset.mybatis.support.PageUtil;
@@ -288,4 +290,37 @@ public class HomeServiceImpl implements HomeService {
         return subjectHomeVoPageInfo;
     }
 
+
+    /**
+     * 老师端首页统计课程
+     *
+     * @param query 参数
+     * @return TeacherHomeWrapper.TeacherTotalCourse
+     */
+    @Override
+    public List<TeacherHomeWrapper.TeacherTotalCourse> teacherTotalCourse(TeacherHomeWrapper.TeacherTotalCourseQuery query) {
+
+        // VIP定制课 趣纠课 直播课 视频课
+
+        List<TeacherHomeWrapper.TeacherTotalCourse> result = new ArrayList<>();
+        result.add(TeacherHomeWrapper.TeacherTotalCourse.builder().goodType(GoodTypeEnum.LIVE).build());
+        result.add(TeacherHomeWrapper.TeacherTotalCourse.builder().goodType(GoodTypeEnum.VIDEO).build());
+        result.add(TeacherHomeWrapper.TeacherTotalCourse.builder().goodType(GoodTypeEnum.VIP_COURSE).build());
+        result.add(TeacherHomeWrapper.TeacherTotalCourse.builder().goodType(GoodTypeEnum.PRACTICE).build());
+
+
+
+        List<TeacherHomeWrapper.TeacherTotalCourse> teacherTotalCourses = baserMapper.teacherTotalCourse(query);
+        Map<GoodTypeEnum, TeacherHomeWrapper.TeacherTotalCourse> collect = teacherTotalCourses.stream()
+                .collect(Collectors.toMap(TeacherHomeWrapper.TeacherTotalCourse::getGoodType, Function.identity(), (key1, key2) -> key2));
+        for (TeacherHomeWrapper.TeacherTotalCourse teacherTotalCourse : result) {
+            TeacherHomeWrapper.TeacherTotalCourse totalCourse = collect.get(teacherTotalCourse.getGoodType());
+            if (totalCourse != null) {
+                teacherTotalCourse.setBuyNum(totalCourse.getBuyNum());
+                teacherTotalCourse.setClassHourNum(totalCourse.getClassHourNum());
+            }
+        }
+        return result;
+    }
+
 }

+ 1 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/StudentServiceImpl.java

@@ -244,6 +244,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
         studentHomeVo.setMusicSheetNum(null == total.getMusicSheetNum() ? 0 : total.getMusicSheetNum());
 
         // 设置会员信息
+        studentHomeVo.setDiscountCardFlag(studentHomeVo.getDiscountEndTime() !=null && studentHomeVo.getDiscountEndTime().after(new Date()));
 
 
         studentHomeVo.setUserVip(vipCardRecordService.userVipInfo(user.getId(), ClientEnum.STUDENT));

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderServiceImpl.java

@@ -1118,7 +1118,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
         } else if (GoodTypeEnum.SVIP.equals(goodTypeEnum)) {
             configValue = sysConfigService.findConfigValue(SysConfigConstant.GOOD_LOGO_SVIP);
         } else if (GoodTypeEnum.DISCOUNT.equals(goodTypeEnum)) {
-            configValue = sysConfigService.findConfigValue(SysConfigConstant.GOOD_LOGO_SVIP);
+            configValue = sysConfigService.findConfigValue(SysConfigConstant.GOOD_LOGO_DISCOUNT);
 
         }
         return configValue;

+ 3 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/StudentHomeVo.java

@@ -62,6 +62,9 @@ public class StudentHomeVo extends Student {
     @ApiModelProperty(value = "是否会员 0否 1是 弃用")
     private YesOrNoEnum isVip;
 
+    @ApiModelProperty(value = "畅学卡是否生效中 true:生效中 false:未生效")
+    private boolean discountCardFlag;
+
     @ApiModelProperty(value = "会员信息")
     private VipCardRecordWrapper.UserVip userVip;
 

+ 46 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/teacher/TeacherHomeWrapper.java

@@ -0,0 +1,46 @@
+package com.yonge.cooleshow.biz.dal.wrapper.teacher;
+
+import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
+import com.yonge.cooleshow.biz.dal.enums.GoodTypeEnum;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+public class TeacherHomeWrapper {
+
+
+    @Data
+    public static class TeacherTotalCourseQuery{
+
+        @ApiModelProperty("老师ID")
+        private Long teacherId;
+
+        @ApiModelProperty("开始时间")
+        private Date startTime;
+
+        @ApiModelProperty("结束时间")
+        private Date endTime;
+
+    }
+
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    public static class TeacherTotalCourse{
+
+
+        @ApiModelProperty("购买数量")
+        private Integer buyNum =0;
+
+        @ApiModelProperty("课时数量")
+        private Integer classHourNum = 0;
+
+        @ApiModelProperty("类型 PRACTICE:趣纠课,VIP_COURSE:VIP课,LIVE:直播课,VIDEO:视频课")
+        private GoodTypeEnum goodType;
+    }
+}

+ 23 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/HomeMapper.xml

@@ -503,4 +503,27 @@
 
 	</select>
 
+	<select id="teacherTotalCourse"
+			resultType="com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper$TeacherTotalCourse">
+		select t.good_type_ as goodType,
+			count(distinct t.id_) as buyNum,
+			if(good_type_ ='VIDEO',sum(t2.lesson_count_),sum(t1.course_num_)) as classHourNum
+		from user_order_detail t
+		left join user_order t0 on t0.order_no_ = t.order_no_
+		left join course_group t1 on t1.id_ = t.biz_id_ and t.good_type_ in ('PRACTICE','LIVE','VIP_COURSE')
+		left join video_lesson_group t2 on t2.id_ = t.biz_id_ and t.good_type_ = 'VIDEO'
+		<where>
+			t.good_type_ in ('PRACTICE','LIVE','VIDEO','VIP_COURSE') and t0.status_ = 'PAID'
+			<if test="param.startTime != null">
+				and t.create_time_ >= #{param.startTime}
+			</if>
+			<if test="param.endTime != null">
+				and t.create_time_ &lt;= #{param.endTime}
+			</if>
+			<if test="param.teacherId != null">
+				and t.merch_id_ = #{param.teacherId}
+			</if>
+		</where>
+		group by t.good_type_
+	</select>
 </mapper>