瀏覽代碼

老师首页统计

刘俊驰 4 月之前
父節點
當前提交
e5629e1b37

+ 30 - 1
cooleshow-app/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherHomeController.java

@@ -112,7 +112,7 @@ public class TeacherHomeController extends BaseController {
     }
 
 
-    @ApiOperation(value = "我的乐谱")
+    @ApiOperation(value = "我的乐谱统计")
     @GetMapping("/musicSheetTotal")
     public HttpResponseResult<TeacherHomeWrapper.MusicSheetTotal> musicSheetTotal() {
         SysUser sysUser = sysUserService.getUser();
@@ -123,4 +123,33 @@ public class TeacherHomeController extends BaseController {
 
         return succeed(homeService.musicSheetTotal(sysUser.getId()));
     }
+
+    @ApiOperation(value = "我的乐谱分页")
+    @PostMapping("/musicSheetPage")
+    public HttpResponseResult<List<TeacherHomeWrapper.MusicSheetTotal>> musicSheetPage(@RequestBody TeacherHomeWrapper.MusicSheetQuery query) {
+        SysUser sysUser = sysUserService.getUser();
+        if (sysUser == null  || sysUser.getId() == null) {
+
+            return failed("用户信息获取失败");
+        }
+        query.setTeacherId(sysUser.getId());
+
+        return succeed(homeService.musicSheetPage(query));
+    }
+
+
+
+    @ApiOperation(value = "课程曝光/购买")
+    @PostMapping("/courseExposure")
+    public HttpResponseResult<List<TeacherHomeWrapper.MusicSheetTotal>> courseExposure(@RequestBody TeacherHomeWrapper.MusicSheetQuery query) {
+        SysUser sysUser = sysUserService.getUser();
+        if (sysUser == null  || sysUser.getId() == null) {
+
+            return failed("用户信息获取失败");
+        }
+        query.setTeacherId(sysUser.getId());
+
+        return succeed(homeService.musicSheetPage(query));
+    }
+
 }

+ 5 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/MusicSheetDao.java

@@ -13,6 +13,7 @@ import com.yonge.cooleshow.biz.dal.vo.*;
 import com.yonge.cooleshow.biz.dal.wrapper.MusicSheetWrapper;
 import com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper;
 import com.yonge.cooleshow.biz.dal.wrapper.music.MusicCompareWrapper;
+import com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper;
 import com.yonge.cooleshow.common.enums.YesOrNoEnum;
 import org.apache.ibatis.annotations.Param;
 
@@ -229,4 +230,8 @@ public interface MusicSheetDao extends BaseMapper<MusicSheet> {
     void delPractice(@Param("musicSheetId") Long musicSheetId, @Param("userId") Long userId, @Param("clientEnum") ClientEnum clientEnum);
 
     int countTeacherEnable(@Param("userId") Long userId);
+
+    TeacherHomeWrapper.MusicSheetTotal musicSheetTotal(@Param("teacherId") Long teacherId);
+
+    List<TeacherHomeWrapper.MusicSheetTotal> musicSheetPage(@Param("param") TeacherHomeWrapper.MusicSheetQuery query);
 }

+ 3 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/UserAccountRecordDao.java

@@ -9,6 +9,7 @@ import com.yonge.cooleshow.biz.dal.enums.AccountBizTypeEnum;
 import com.yonge.cooleshow.biz.dal.vo.TeacherEarningVo;
 import com.yonge.cooleshow.biz.dal.vo.UserAccountVo;
 import com.yonge.cooleshow.biz.dal.vo.UserOrderDetailVo;
+import com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper;
 import org.apache.ibatis.annotations.Param;
 import com.yonge.cooleshow.biz.dal.entity.UserAccountRecord;
 import com.yonge.cooleshow.biz.dal.vo.UserAccountRecordVo;
@@ -108,4 +109,6 @@ public interface UserAccountRecordDao extends BaseMapper<UserAccountRecord> {
      * @return
      */
     List<UserAccountRecord> queryCanAccountByBizType(@Param("bizTypes")List<String> bizTypes);
+
+    TeacherHomeWrapper.MusicSheetTotal musicSheetTotal(@Param("teacherId") Long teacherId);
 }

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

@@ -78,4 +78,6 @@ public interface HomeService {
      * @return TeacherHomeWrapper.MusicSheetTotal 乐谱统计
      */
     TeacherHomeWrapper.MusicSheetTotal musicSheetTotal(Long teacherId);
+
+    List<TeacherHomeWrapper.MusicSheetTotal> musicSheetPage(TeacherHomeWrapper.MusicSheetQuery query);
 }

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

@@ -3,6 +3,8 @@ package com.yonge.cooleshow.biz.dal.service.impl;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.yonge.cooleshow.biz.dal.dao.CourseScheduleDao;
 import com.yonge.cooleshow.biz.dal.dao.HomeDao;
+import com.yonge.cooleshow.biz.dal.dao.MusicSheetDao;
+import com.yonge.cooleshow.biz.dal.dao.UserAccountRecordDao;
 import com.yonge.cooleshow.biz.dal.dto.SubjectHomeSearch;
 import com.yonge.cooleshow.biz.dal.dto.req.TotalReq;
 import com.yonge.cooleshow.biz.dal.entity.MusicSheet;
@@ -13,6 +15,7 @@ import com.yonge.cooleshow.biz.dal.enums.TeacherTagEnum;
 import com.yonge.cooleshow.biz.dal.service.CourseScheduleService;
 import com.yonge.cooleshow.biz.dal.service.HomeService;
 import com.yonge.cooleshow.biz.dal.service.MusicSheetService;
+import com.yonge.cooleshow.biz.dal.service.UserAccountRecordService;
 import com.yonge.cooleshow.biz.dal.support.WrapperUtil;
 import com.yonge.cooleshow.biz.dal.vo.CourseHomeVo;
 import com.yonge.cooleshow.biz.dal.vo.SubjectHomeVo;
@@ -47,6 +50,11 @@ public class HomeServiceImpl implements HomeService {
 
     @Autowired
     private MusicSheetService musicSheetService;
+    @Autowired
+    private MusicSheetDao musicSheetDao;
+
+    @Autowired
+    private UserAccountRecordDao userAccountRecordDao;
 
     @Override
     public HomeUserToDoNum getUserToDoNum() {
@@ -352,15 +360,25 @@ public class HomeServiceImpl implements HomeService {
 
         收益:售卖曲目累计收益金额
          */
-        TeacherHomeWrapper.MusicSheetTotal musicSheetTotal = new TeacherHomeWrapper.MusicSheetTotal();
-//        musicSheetService.lambdaQuery()
-//                .eq(MusicSheet::getUserId, teacherId)
-//                .eq(MusicSheet::getDelFlag,0)
-//                .eq(MusicSheet::getAuditStatus, AuthStatusEnum.PASS)
-//                .eq(MusicSheet::getState,1)
+        TeacherHomeWrapper.MusicSheetTotal musicSheetTotal = musicSheetDao.musicSheetTotal(teacherId);
+        if (musicSheetTotal == null) {
+            musicSheetTotal = new TeacherHomeWrapper.MusicSheetTotal();
+        }
+        // 收益
+        TeacherHomeWrapper.MusicSheetTotal musicSheetTotal1 = userAccountRecordDao.musicSheetTotal(teacherId);
+        if (musicSheetTotal1 != null) {
+            musicSheetTotal.setMusicSheetIncome(musicSheetTotal1.getMusicSheetIncome());
+            musicSheetTotal.setMusicSheetPayNum(musicSheetTotal1.getMusicSheetPayNum());
+        }
+
 
         return musicSheetTotal;
 
     }
 
+    @Override
+    public List<TeacherHomeWrapper.MusicSheetTotal> musicSheetPage(TeacherHomeWrapper.MusicSheetQuery query) {
+        return musicSheetDao.musicSheetPage(query);
+    }
+
 }

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

@@ -2,6 +2,7 @@ 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 com.yonge.toolset.base.page.QueryInfo;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
@@ -57,6 +58,12 @@ public class TeacherHomeWrapper {
         @ApiModelProperty("曲目审核中")
         private Integer musicSheetAuditNum = 0;
 
+        @ApiModelProperty("曲目名")
+        private String musicSheetName;
+
+        @ApiModelProperty("上传时间")
+        private Date createTime;
+
         @ApiModelProperty("曲目曝光数")
         private Integer musicSheetExposureNum = 0;
 
@@ -68,4 +75,34 @@ public class TeacherHomeWrapper {
     }
 
 
+    @Data
+    public static class MusicSheetQuery {
+
+        @ApiModelProperty("老师ID")
+        private Long teacherId;
+
+
+        @ApiModelProperty("数量")
+        private Integer rows = 5;
+
+    }
+
+
+    @Data
+    public static class CourseExposureQuery {
+
+        @ApiModelProperty("老师ID")
+        private Long teacherId;
+
+
+        @ApiModelProperty("开始时间")
+        private Date startTime;
+
+        @ApiModelProperty("结束时间")
+        private Date endTime;
+
+        @ApiModelProperty("类型MUSIC:乐谱,LIVE:直播课,VIDEO:视频课")
+        private String type;
+
+    }
 }

+ 31 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetMapper.xml

@@ -1333,5 +1333,36 @@
         set hidden_flag_ = 1
         where user_id_ = #{userId} and music_sheet_id_ = #{musicSheetId} and client_id_ = #{clientEnum}
     </update>
+
+    <select id="musicSheetTotal"
+            resultType="com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper$MusicSheetTotal">
+        select
+        if(t.audit_status_ = 'PASS' and t.state_ = 1,1,0) as musicSheetNum,
+        if(t.audit_status_ = 'DOING' ,1,0) musicSheetAuditNum,
+        t.exposure_num_ musicSheetExposureNum
+        from music_sheet t
+        where t.del_flag_=0 and t.user_id_ = #{teacherId}
+    </select>
+
+    <select id="musicSheetPage"
+            resultType="com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper$MusicSheetTotal">
+        select
+        t.music_sheet_name_ musicSheetName,
+        t.create_time_ createTime,
+        t.exposure_num_ musicSheetExposureNum,
+        count(distinct t1.buy_user_) musicSheetPayNum,
+        sum(t1.trans_amount_) as musicSheetIncome
+        from music_sheet t
+         left join user_cash_account_record t1 on t.id_ = t1.biz_id_
+        where t1.account_id_ =  #{param.teacherId}
+        and t1.biz_type_ = 'MUSIC_SHARE'
+        and t1.post_status_ = 'RECORDED'
+        and t1.in_or_out_ = 'IN'
+        and  t.del_flag_=0 and t.user_id_ = #{param.teacherId}
+        group by t.id_
+        order by t.create_time_ desc
+        limit #{param.rows}
+
+    </select>
     <!--单曲专辑数量统计-->
 </mapper>

+ 12 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/UserAccountRecordMapper.xml

@@ -314,4 +314,16 @@
             #{item}
         </foreach>
     </select>
+
+    <select id="musicSheetTotal"
+            resultType="com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper$MusicSheetTotal">
+        select
+            count(distinct (t.buy_user_)) as musicSheetPayNum,
+        sum(t.trans_amount_) as musicSheetIncome
+        from user_cash_account_record t
+        where t.account_id_ = #{teacherId}
+        and t.biz_type_ = 'MUSIC_SHARE'
+        and t.post_status_ = 'RECORDED'
+        and t.in_or_out_ = 'IN'
+    </select>
 </mapper>