浏览代码

增加学生端我的课程分页查询

hgw 3 年之前
父节点
当前提交
bffd97977c

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/CourseScheduleDao.java

@@ -109,6 +109,6 @@ public interface CourseScheduleDao extends BaseMapper<CourseSchedule> {
      *              <p> - subjectId 声部id
      *              <p> - type PRACTICE 陪练课 LIVE 直播课
      */
-    List<CourseStudent> queryStudentLiveCourse(@Param("param") Map<String, Object> param);
+    <T> IPage<T> queryStudentLiveCourse(Page<T> page, @Param("param") Map<String, Object> param);
 }
 

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

@@ -176,6 +176,6 @@ public interface CourseScheduleService extends IService<CourseSchedule> {
      *              <p> - classDate 查询时间-年月
      *              <p> - subjectId 声部id
      */
-    List<CourseStudent> queryStudentLiveCourse(Map<String, Object> param);
+    PageInfo<CourseStudent> queryStudentLiveCourse(Map<String, Object> param);
 }
 

+ 3 - 18
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseGroupServiceImpl.java

@@ -638,8 +638,10 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
         //查询直播课服务费
         String liveServiceRateStr = sysConfigService.findConfigValue(SysConfigConstant.LIVE_SERVICE_RATE);
         BigDecimal liveServiceRate = new BigDecimal(liveServiceRateStr).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP);
+        //总课酬  1 - (1 * 手续费率)
+        BigDecimal totalRatePrice = expectPrice.subtract(expectPrice.multiply(liveServiceRate)).setScale(2, RoundingMode.HALF_UP);
         //获取每节课的课酬 key 课堂数  value 课酬
-        Map<Integer, BigDecimal> singerCourseSalary = getSingerCourseSalary(expectPrice, courseGroup.getCourseNum(), liveServiceRate);
+        Map<Integer, BigDecimal> singerCourseSalary =  getCourseAveragePrice(courseGroup.getCourseNum(), totalRatePrice);
         //写入课酬表计算-根据课程组总金额计算分配到每节课的金额
         Date now = new Date();
         List<CourseScheduleTeacherSalary> teacherSalaryList = new ArrayList<>();
@@ -660,23 +662,6 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
         courseScheduleTeacherSalaryService.getDao().insertBatch(teacherSalaryList);
     }
 
-
-    /**
-     * 学生购买直播课程,计算每节课课酬
-     *
-     * @param totalPrice     课酬总金额
-     * @param totalCourseNum 课程总数
-     * @param rate           课酬费率
-     * @return key 课堂数  value 课酬
-     */
-    private Map<Integer, BigDecimal> getSingerCourseSalary(BigDecimal totalPrice, Integer totalCourseNum, BigDecimal rate) {
-        //1 - (1 * 手续费率)
-        BiFunction<BigDecimal, BigDecimal, BigDecimal> getPrice = (p, r) -> p.subtract(p.multiply(r)).setScale(2, RoundingMode.HALF_UP);
-        //总课酬
-        BigDecimal totalRatePrice = getPrice.apply(totalPrice, rate);
-        return getCourseAveragePrice(totalCourseNum, totalRatePrice);
-    }
-
     /**
      * 计算课堂每节课价格
      *

+ 4 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java

@@ -772,7 +772,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      *              <p> - subjectId 声部id
      */
     @Override
-    public List<CourseStudent> queryStudentLiveCourse(Map<String, Object> param) {
+    public PageInfo<CourseStudent> queryStudentLiveCourse(Map<String, Object> param) {
         String classDate = WrapperUtil.toStr(param, "classDate");
         String[] classDateSp = classDate.split("-");
         LocalDate firstDay;
@@ -786,7 +786,9 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         param.put("type", CourseScheduleEnum.LIVE.getCode());
         param.put("startDate", firstDay.toString());
         param.put("endDate", lastDay.toString());
-       return baseMapper.queryStudentLiveCourse(param);
+        Page<CourseStudent> pageInfo = PageUtil.getPageInfo(param);
+        pageInfo.setAsc(" cs.start_time_");
+       return PageUtil.pageInfo(baseMapper.queryStudentLiveCourse(pageInfo,param));
     }
 
 }

+ 0 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -426,7 +426,6 @@
         <if test="param.courseState != null">
             and cs.status_ = #{param.courseState}
         </if>
-        ORDER BY cs.start_time_
     </select>
 
 </mapper>

+ 3 - 1
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/StudentCourseScheduleController.java

@@ -120,10 +120,12 @@ public class StudentCourseScheduleController extends BaseController {
             @ApiImplicitParam(name = "classDate", dataType = "String", required = true, value = "年月"),
             @ApiImplicitParam(name = "courseState", dataType = "String", value = "课程状态 NOT_START未开始 ING进行中 COMPLETE已完成 CANCEL已取消"),
             @ApiImplicitParam(name = "subjectId", dataType = "Long", value = "声部id"),
+            @ApiImplicitParam(name = "page", dataType = "Integer", value = "页数"),
+            @ApiImplicitParam(name = "rows", dataType = "Integer", value = "每页数量"),
     })
     @ApiOperation("学生-查询直播课")
     @PostMapping("/queryStudentLiveCourse")
-    public HttpResponseResult<List<CourseStudent>> queryStudentLiveCourse(@RequestBody Map<String, Object> param) {
+    public HttpResponseResult<PageInfo<CourseStudent>> queryStudentLiveCourse(@RequestBody Map<String, Object> param) {
         return succeed(courseScheduleService.queryStudentLiveCourse(param));
     }