瀏覽代碼

1、网管课初始类型
2、网管试听课

Joburgess 5 年之前
父節點
當前提交
c8d1556e53

+ 23 - 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.*;
 import com.ym.mec.biz.dal.entity.ClassGroup;
+import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.CourseScheduleEvaluate;
 import com.ym.mec.biz.dal.entity.PracticeGroup;
 import com.ym.mec.biz.dal.enums.GroupStatusEnum;
@@ -282,4 +283,26 @@ public interface PracticeGroupDao extends com.ym.mec.common.dal.BaseDAO<Long, Pr
      */
     List<PracticeGroup> findStudentTrialPractices(@Param("studentId") Integer studentId);
     int countStudentTrialPractices(@Param("studentId") Integer studentId);
+
+    /**
+     * @describe 获取老师
+     * @author Joburgess
+     * @date 2020/4/24
+     * @param studentId:
+     * @param teacherId:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.CourseSchedule>
+     */
+    List<CourseSchedule> findStudentAndTeacherTrialPractices(@Param("studentId") Integer studentId,
+                                                             @Param("teacherId") Integer teacherId);
+
+    /**
+     * @describe 统计指定老师和学生是否存在关联的试听课
+     * @author Joburgess
+     * @date 2020/4/24
+     * @param studentId:
+     * @param teacherId:
+     * @return int
+     */
+    int countStudentAndTeacherTrialPractices(@Param("studentId") Integer studentId,
+                                             @Param("teacherId") Integer teacherId);
 }

+ 28 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TeacherCourseRewardDao.java

@@ -1,8 +1,35 @@
 package com.ym.mec.biz.dal.dao;
 
+import com.ym.mec.biz.dal.dto.CourseTeacherSalaryStatisticsDto;
 import com.ym.mec.biz.dal.entity.TeacherCourseReward;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
 
 public interface TeacherCourseRewardDao extends BaseDAO<Long, TeacherCourseReward> {
 
-}
+    /**
+     * @describe 统计老师指定月份的奖励
+     * @author Joburgess
+     * @date 2020/4/24
+     * @param teacherId: 教师编号
+     * @param month: 月份
+     * @return com.ym.mec.biz.dal.dto.CourseTeacherSalaryStatisticsDto
+     */
+    CourseTeacherSalaryStatisticsDto teacherCourseRewardStatWithMonth(@Param("teacherId") Integer teacherId,
+                                                                      @Param("month") String month);
+    /**
+     * @describe 获取老师指定日期的转结奖励
+     * @author Joburgess
+     * @date 2020/4/24
+     * @param params:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.TeacherCourseReward>
+     */
+    List<TeacherCourseReward> findTeacherCourseRewards(Map<String, Object> params);
+    int countTeacherCourseRewards(Map<String, Object> params);
+
+//    TeacherCourseReward findTeacherCourseRewardWith
+
+}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CourseTeacherSalaryStatisticsDto.java

@@ -12,6 +12,8 @@ public class CourseTeacherSalaryStatisticsDto {
 
     private GroupType groupType;
 
+    private String statType;
+
     private String month;
 
     private Integer courseTimes;
@@ -20,6 +22,14 @@ public class CourseTeacherSalaryStatisticsDto {
 
     private BigDecimal totalReduceSalary;
 
+    public String getStatType() {
+        return statType;
+    }
+
+    public void setStatType(String statType) {
+        this.statType = statType;
+    }
+
     public Integer getCourseTimes() {
         return courseTimes;
     }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/TeacherCourseSalaryDetail4WebDto.java

@@ -27,6 +27,8 @@ public class TeacherCourseSalaryDetail4WebDto {
 
     private Date endClassTime;
 
+    private Integer courseTimes;
+
     private String courseName;
 
     private Integer teacherId;
@@ -55,6 +57,15 @@ public class TeacherCourseSalaryDetail4WebDto {
 
     private String memo;
 
+
+    public Integer getCourseTimes() {
+        return courseTimes;
+    }
+
+    public void setCourseTimes(Integer courseTimes) {
+        this.courseTimes = courseTimes;
+    }
+
     public String getSignInStatusStr() {
         return signInStatusStr;
     }

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/TeacherCourseRewardService.java

@@ -1,8 +1,30 @@
 package com.ym.mec.biz.service;
 
+import com.ym.mec.biz.dal.dto.TeacherCourseSalaryDetail4WebDto;
 import com.ym.mec.biz.dal.entity.TeacherCourseReward;
+import com.ym.mec.biz.dal.page.CourseSalaryQueryInfo4Web;
+import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
 public interface TeacherCourseRewardService extends BaseService<Long, TeacherCourseReward> {
 
+    /**
+     * @describe 增加转化奖励
+     * @author Joburgess
+     * @date 2020/4/24
+     * @param studentId:
+     * @param teacherId:
+     * @return void
+     */
+    void addConvertReward(Integer studentId, Integer teacherId);
+
+    /**
+     * @describe 获取教师奖励结算记录
+     * @author Joburgess
+     * @date 2020/4/24
+     * @param queryInfo:
+     * @return com.ym.mec.common.page.PageInfo<com.ym.mec.biz.dal.dto.TeacherCourseSalaryDetail4WebDto>
+     */
+    PageInfo<TeacherCourseSalaryDetail4WebDto> findTeacherRewards(CourseSalaryQueryInfo4Web queryInfo);
+
 }

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java

@@ -78,6 +78,8 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
     private TeacherSalaryComplaintsDao teacherSalaryComplaintsDao;
     @Autowired
     private SysMessageService sysMessageService;
+    @Autowired
+    private TeacherCourseRewardDao teacherCourseRewardDao;
 
     private static final Logger LOGGER = LoggerFactory
             .getLogger(CourseScheduleTeacherSalaryServiceImpl.class);
@@ -883,6 +885,11 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
         List<CourseTeacherSalaryStatisticsDto> teacherGroupTypeSalary = new ArrayList<>();
         if(queryInfo4Web.getPage()<=1){
             teacherGroupTypeSalary = courseScheduleTeacherSalaryDao.getTeacherGroupTypeSalary(queryInfo4Web.getMonth(), queryInfo4Web.getTeacherId());
+            CourseTeacherSalaryStatisticsDto courseTeacherSalaryStatisticsDto = teacherCourseRewardDao.teacherCourseRewardStatWithMonth(queryInfo4Web.getTeacherId(), queryInfo4Web.getMonth());
+            if(Objects.isNull(courseTeacherSalaryStatisticsDto)){
+                courseTeacherSalaryStatisticsDto=new CourseTeacherSalaryStatisticsDto();
+            }
+            courseTeacherSalaryStatisticsDto.setStatType("REWARD");
         }
         result.put("stat", teacherGroupTypeSalary);
         if(!CollectionUtils.isEmpty(pageInfo.getRows())){

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/EduPracticeGroupServiceImpl.java

@@ -645,6 +645,9 @@ public class EduPracticeGroupServiceImpl implements EduPracticeGroupService{
         if (Objects.isNull(teacherId)) {
             throw new BizException("请选择教师");
         }
+        if(StringUtils.isBlank(mondayStr)){
+            throw new BizException("请指定周一");
+        }
         SysUser student = sysUserFeignService.queryUserById(userId);
         if (Objects.isNull(student)) {
             throw new BizException("用户不存在");
@@ -720,6 +723,9 @@ public class EduPracticeGroupServiceImpl implements EduPracticeGroupService{
         ZoneId zoneId = ZoneId.systemDefault();
 
         LocalDate monday = LocalDate.parse(mondayStr, ddf);
+        if(monday.isBefore(LocalDate.now())){
+            monday=LocalDate.now();
+        }
         LocalDate sunday = monday.with(weekFields.dayOfWeek(), DayOfWeek.SUNDAY.getValue());
 
         Map<Integer, List<String>> weekNumApplyTimesMap = getEnableApplyDatesWithWeek();
@@ -891,6 +897,11 @@ public class EduPracticeGroupServiceImpl implements EduPracticeGroupService{
             return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "指定的学生已存在三组试听课");
         }
 
+        int stn = practiceGroupDao.countStudentAndTeacherTrialPractices(practiceGroupBuyParams.getStudentId(), practiceGroupBuyParams.getUserId());
+        if(stn>0){
+            return BaseController.failed(HttpStatus.EXPECTATION_FAILED, "请给该学生分配不同的指导老师");
+        }
+
         SysUser student = teacherDao.getUser(practiceGroupBuyParams.getStudentId());
 
         Subject subject = subjectDao.get(practiceGroupBuyParams.getSubjectId());

+ 50 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherCourseRewardServiceImpl.java

@@ -1,21 +1,71 @@
 package com.ym.mec.biz.service.impl;
 
+import com.ym.mec.biz.dal.dao.PracticeGroupDao;
 import com.ym.mec.biz.dal.dao.TeacherCourseRewardDao;
+import com.ym.mec.biz.dal.dto.TeacherCourseSalaryDetail4WebDto;
+import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.TeacherCourseReward;
+import com.ym.mec.biz.dal.page.CourseSalaryQueryInfo4Web;
 import com.ym.mec.biz.service.TeacherCourseRewardService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.util.collection.MapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import java.util.*;
 
 @Service
 public class TeacherCourseRewardServiceImpl extends BaseServiceImpl<Long, TeacherCourseReward> implements TeacherCourseRewardService {
 
     @Autowired
     private TeacherCourseRewardDao teacherCourseRewardDao;
+    @Autowired
+    private PracticeGroupDao practiceGroupDao;
 
     @Override
     public BaseDAO<Long, TeacherCourseReward> getDAO() {
         return teacherCourseRewardDao;
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
+    public void addConvertReward(Integer studentId, Integer teacherId) {
+        List<CourseSchedule> studentAndTeacherTrialPractices = practiceGroupDao.findStudentAndTeacherTrialPractices(studentId, teacherId);
+        if(CollectionUtils.isEmpty(studentAndTeacherTrialPractices)){
+            return;
+        }
+
+    }
+
+    @Override
+    public PageInfo<TeacherCourseSalaryDetail4WebDto> findTeacherRewards(CourseSalaryQueryInfo4Web queryInfo) {
+        PageInfo<TeacherCourseSalaryDetail4WebDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Map<String, Object> params = new HashMap<>();
+        MapUtil.populateMap(params, queryInfo);
+
+        List<TeacherCourseSalaryDetail4WebDto> dataList = new ArrayList<>();
+        int count = teacherCourseRewardDao.countTeacherCourseRewards(params);
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            params.put("offset", pageInfo.getOffset());
+            List<TeacherCourseReward> teacherCourseRewards = teacherCourseRewardDao.findTeacherCourseRewards(params);
+            for (TeacherCourseReward teacherCourseReward : teacherCourseRewards) {
+                TeacherCourseSalaryDetail4WebDto t=new TeacherCourseSalaryDetail4WebDto();
+                t.setCourseName(teacherCourseReward.getCourseGroupName());
+                t.setCourseTimes(teacherCourseReward.getCourseScheduleIdList().split(",").length);
+                t.setMemo(teacherCourseReward.getMemo());
+                t.setActualSalary(teacherCourseReward.getActualRewardAmount());
+                t.setReduceSalary(teacherCourseReward.getExpectRewardAmount().subtract(teacherCourseReward.getActualRewardAmount()));
+                t.setFinalSalary(teacherCourseReward.getActualRewardAmount().subtract(teacherCourseReward.getActualRewardAmount()));
+                dataList.add(t);
+            }
+        }
+        pageInfo.setRows(dataList);
+        return pageInfo;
+    }
 }

+ 1 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleTeacherSalaryMapper.xml

@@ -847,6 +847,7 @@
 
 	<resultMap id="CourseTeacherSalaryStatisticsDto" type="com.ym.mec.biz.dal.dto.CourseTeacherSalaryStatisticsDto">
 		<result property="groupType" column="group_type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+		<result property="statType" column="group_type_"/>
 		<result property="month" column="month_"/>
 		<result property="courseTimes" column="course_times_"/>
 		<result property="totalActualSalary" column="total_actual_salary_"/>

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

@@ -596,4 +596,46 @@
             pg.student_id_ = #{studentId}
             AND pg.type_ = 'TRIAL'
     </select>
+    <select id="findStudentAndTeacherTrialPractices" resultMap="com.ym.mec.biz.dal.dao.CourseScheduleDao.CourseSchedule">
+        SELECT
+            cs.id_,
+            cs.music_group_id_,
+            cs.group_type_,
+            cs.class_group_id_,
+            cs.status_,
+            cs.subsidy_,
+            cs.class_date_,
+            CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
+            CONCAT(cs.class_date_, ' ', cs.end_class_time_)   end_class_time_,
+            cs.teacher_id_,
+            cs.actual_teacher_id_,
+            cs.create_time_,
+            cs.update_time_,
+            cs.teach_mode_,
+            cs.type_,
+            cs.name_,
+            cs.student_num_,
+            cs.leave_student_num_,
+            cs.teaching_content_,
+            cs.note_,
+            cs.schoole_id_
+        FROM
+            practice_group pg
+            LEFT JOIN course_schedule cs ON cs.music_group_id_ = pg.id_
+        WHERE
+            pg.type_ = 'TRIAL'
+            AND pg.user_id_ = #{teacherId}
+            AND pg.student_id_ = #{studentId}
+            AND cs.group_type_ = 'PRACTICE'
+    </select>
+
+    <select id="countStudentAndTeacherTrialPractices" resultType="int">
+        SELECT COUNT(id_)
+        FROM practice_group pg
+        WHERE
+            pg.type_ = 'TRIAL'
+            AND pg.user_id_ = #{teacherId}
+            AND pg.student_id_ = #{studentId}
+            AND cs.group_type_ = 'PRACTICE'
+    </select>
 </mapper>

+ 36 - 1
mec-biz/src/main/resources/config/mybatis/TeacherCourseRewardDao.xml

@@ -115,4 +115,39 @@
         <include refid="queryCondition"/>
     </select>
 
-</mapper>
+    <select id="teacherCourseRewardStatWithMonth" resultMap="com.ym.mec.biz.dal.dao.CourseScheduleTeacherSalaryDao.CourseTeacherSalaryStatisticsDto">
+        SELECT
+            COUNT( music_group_id_ ) course_times_,
+            SUM( actual_reward_amount_ ) total_actual_salary_,
+            SUM( expect_reward_amount_ ) - SUM( actual_reward_amount_ ) total_reduce_salary_
+        FROM
+            teacher_course_reward
+        WHERE
+            teacher_id_ = #{teacherId}
+            AND DATE_FORMAT( settlement_date_, '%Y-%m-%d' ) = #{month}
+        GROUP BY
+            teacher_id_
+    </select>
+
+    <select id="findTeacherCourseRewards" resultMap="teacherCourseReward">
+        SELECT
+            *
+        FROM
+            teacher_course_reward
+        WHERE
+            teacher_id_ = #{teacherId}
+            AND DATE_FORMAT( settlement_date_, '%Y-%m-%d' ) = #{month}
+        ORDER BY id_ DESC
+        <include refid="global.limit"/>
+    </select>
+    <select id="countTeacherCourseRewards" resultType="int">
+        SELECT
+            COUNT(id_)
+        FROM
+            teacher_course_reward
+        WHERE
+            teacher_id_ = #{teacherId}
+            AND DATE_FORMAT( settlement_date_, '%Y-%m-%d' ) = #{month}
+    </select>
+
+</mapper>

+ 15 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/CourseScheduleTeacherSalaryController.java

@@ -4,6 +4,7 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.page.CourseSalaryQueryInfo4Web;
 import com.ym.mec.biz.service.CourseScheduleTeacherSalaryService;
+import com.ym.mec.biz.service.TeacherCourseRewardService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import io.swagger.annotations.Api;
@@ -29,6 +30,9 @@ public class CourseScheduleTeacherSalaryController extends BaseController {
     @Autowired
     private SysUserFeignService sysUserFeignService;
 
+    @Autowired
+    private TeacherCourseRewardService teacherCourseRewardService;
+
     @ApiOperation(value = "确定教师指定月份的课酬")
     @PostMapping("confirmTeacherMonthSalary")
     public HttpResponseResult confirmTeacherMonthSalary(String month){
@@ -61,4 +65,15 @@ public class CourseScheduleTeacherSalaryController extends BaseController {
         return succeed(courseScheduleTeacherSalaryService.findTeacherYearSalarys(sysUser.getId(), year));
     }
 
+    @ApiOperation(value = "分页查询结转奖励")
+    @GetMapping("/findTeacherRewards")
+    public HttpResponseResult findTeacherRewards(CourseSalaryQueryInfo4Web queryInfo){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        queryInfo.setTeacherId(sysUser.getId());
+        return succeed(teacherCourseRewardService.findTeacherRewards(queryInfo));
+    }
+
 }

+ 4 - 6
mec-web/src/main/java/com/ym/mec/web/controller/TeacherCourseRewardController.java

@@ -4,19 +4,17 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.entity.Employee;
-import com.ym.mec.biz.dal.entity.Teacher;
-import com.ym.mec.biz.dal.page.*;
-import com.ym.mec.biz.service.ClassGroupService;
+import com.ym.mec.biz.dal.page.CourseSalaryQueryInfo4Web;
+import com.ym.mec.biz.dal.page.TeacherCourseRewardQueryInfo;
 import com.ym.mec.biz.service.TeacherCourseRewardService;
-import com.ym.mec.biz.service.TeacherService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
-import io.swagger.annotations.*;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;