Browse Source

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

zouxuan 5 years ago
parent
commit
757c434446

+ 10 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentPaymentDao.java

@@ -1,11 +1,11 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.dto.StudentAttendanceStatisticsResponse;
+import com.ym.mec.biz.dal.dto.VipGroupGiveCourseSortDto;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.common.dal.BaseDAO;
-
 import org.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
@@ -185,4 +185,13 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
      * @return java.util.List<com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment>
      */
     List<CourseScheduleStudentPayment> findByCourseSchedule(@Param("courseScheduleId") Long courseScheduleId);
+
+    /**
+     * @describe 获取小课需要调整的缴费记录
+     * @author Joburgess
+     * @date 2020/1/10
+     * @param groupId:
+     * @return java.util.List<com.ym.mec.biz.dal.dto.VipGroupGiveCourseSortDto>
+     */
+    List<VipGroupGiveCourseSortDto> findVipGroupSortCourseByGroup(@Param("groupId") String groupId);
 }

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java

@@ -204,4 +204,11 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
     int countSporadicPage(Map<String, Object> params);
 
     List<OrderStatisDto> getLuckStatis();
+    
+    /**
+     * 统计收入信息
+     * @param organId
+     * @return
+     */
+    Map<String, Object> queryIncomeStatistics(String organId);
 }

+ 32 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/VipGroupGiveCourseSortDto.java

@@ -0,0 +1,32 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
+
+import java.util.Date;
+
+/**
+ * @Author Joburgess
+ * @Date 2020/1/10
+ */
+public class VipGroupGiveCourseSortDto extends CourseScheduleStudentPayment {
+
+    private Date courseStartTime;
+
+    private Date courseEndTime;
+
+    public Date getCourseStartTime() {
+        return courseStartTime;
+    }
+
+    public void setCourseStartTime(Date courseStartTime) {
+        this.courseStartTime = courseStartTime;
+    }
+
+    public Date getCourseEndTime() {
+        return courseEndTime;
+    }
+
+    public void setCourseEndTime(Date courseEndTime) {
+        this.courseEndTime = courseEndTime;
+    }
+}

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleStudentPaymentService.java

@@ -45,4 +45,13 @@ public interface CourseScheduleStudentPaymentService extends BaseService<Long, C
 	 */
 	int batchInsert(List<CourseScheduleStudentPayment> courseScheduleStudentPayments);
 
+	/**
+	 * @describe 更新VIP课赠送课顺序
+	 * @author Joburgess
+	 * @date 2020/1/10
+	 * @param vipGroupId: 小课编号
+	 * @return void
+	 */
+	void updateVipGiveCourse(Long vipGroupId);
+
 }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysConfigService.java

@@ -85,6 +85,8 @@ public interface SysConfigService extends BaseService<Long, SysConfig> {
      * vip课程可更新学生签到状态时间限制,课程结束后{}分钟
      */
     String ENABLE_STUDENT_ATTENDANCE_TIME_RANGE_VIP = "enable_student_attendance_time_range_vip";
+
+    String ENABLE_STUDENT_ATTENDANCE_BEFOR_COURSE_START_TIME_RANGE_VIP = "enable_student_attendance_befor_course_start_time_range_vip";
     
     /**
      * 十分钟内最大可发送的短信次数

+ 18 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -1,12 +1,14 @@
 package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dto.VipGroupGiveCourseSortDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.TeachModeEnum;
 import com.ym.mec.biz.dal.enums.VipGroupActivityTypeEnum;
 import com.ym.mec.biz.dal.enums.VipGroupStatusEnum;
 import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
+import com.ym.mec.biz.service.SysUserCashAccountService;
 import com.ym.mec.common.constant.CommonConstants;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
@@ -33,6 +35,8 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	private CourseScheduleDao courseScheduleDao;
 	@Autowired
 	private ClassGroupStudentMapperDao classGroupStudentMapperDao;
+	@Autowired
+	private SysUserCashAccountService sysUserCashAccountService;
 
 	@Override
 	public BaseDAO<Long, CourseScheduleStudentPayment> getDAO() {
@@ -191,6 +195,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 						if(Objects.isNull(courseScheduleStudentPayment.getExpectPrice())){
 							courseScheduleStudentPayment.setExpectPrice(zeroPrice);
 						}
+						sysUserCashAccountService.appendCourseBalance(classGroupStudent.getUserId(), courseScheduleStudentPayment.getExpectPrice().negate());
 						courseScheduleStudentPayments.add(courseScheduleStudentPayment);
 					}else{
 						CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment(
@@ -214,4 +219,17 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	public int batchInsert(List<CourseScheduleStudentPayment> courseScheduleStudentPayments) {
 		return courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
 	}
+
+	@Override
+	public void updateVipGiveCourse(Long vipGroupId) {
+		List<VipGroupGiveCourseSortDto> vipGroupSortCourseByGroup = courseScheduleStudentPaymentDao.findVipGroupSortCourseByGroup(vipGroupId.toString());
+		Map<BigDecimal, Long> expectPriceCountMap = vipGroupSortCourseByGroup.stream()
+				.collect(Collectors.groupingBy(VipGroupGiveCourseSortDto::getExpectPrice, Collectors.counting()));
+		BigDecimal zero = new BigDecimal(0);
+		int zeroPriceNum = expectPriceCountMap.get(zero).intValue();
+		if(zeroPriceNum<=0){
+			return;
+		}
+		
+	}
 }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentAttendanceServiceImpl.java

@@ -88,6 +88,11 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
 		if(courseSchedule.getGroupType().equals(GroupType.MUSIC)){
 			attendanceTimeRange = sysConfigService.findByParamName(SysConfigService.ENABLE_STUDENT_ATTENDANCE_TIME_RANGE);
 		}else{
+			SysConfig beforeAttendanceTimeRange=sysConfigService.findByParamName(SysConfigService.ENABLE_STUDENT_ATTENDANCE_BEFOR_COURSE_START_TIME_RANGE_VIP);
+			int courseStartTime = DateUtil.minutesBetween(date, courseSchedule.getStartClassTime());
+			if(date.before(courseSchedule.getStartClassTime())&&courseStartTime>beforeAttendanceTimeRange.getParanValue(Integer.class)){
+				throw new BizException("VIP课开课前{}分钟禁止点名",beforeAttendanceTimeRange.getParanValue(Integer.class));
+			}
 			attendanceTimeRange = sysConfigService.findByParamName(SysConfigService.ENABLE_STUDENT_ATTENDANCE_TIME_RANGE_VIP);
 		}
 		int courseEndTime = DateUtil.minutesBetween(courseSchedule.getEndClassTime(), date);

+ 15 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -233,6 +233,21 @@
 		SELECT * FROM course_schedule_student_payment WHERE  course_schedule_id_ = #{courseScheduleId}
 	</select>
 
+	<resultMap id="VipGroupGiveCourseSortDto" type="com.ym.mec.biz.dal.dto.VipGroupGiveCourseSortDto" extends="CourseScheduleStudentPayment">
+		<result property="courseStartTime" column="course_start_time_"/>
+		<result property="courseEndTime" column="course_end_time_"/>
+	</resultMap>
+	<select id="findVipGroupSortCourseByGroup" resultMap="VipGroupGiveCourseSortDto">
+		SELECT
+			 cssp.*,
+			 CONCAT(cs.class_date_,' ',cs.start_class_time_) course_start_time_
+			 CONCAT(cs.class_date_,' ',cs.end_class_time_) course_end_time_
+		FROM course_schedule_student_payment cssp
+			LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
+		WHERE cssp.music_group_id_=#{groupId} AND cssp.group_type_='VIP' AND course_start_time_ &gt; NOW()
+		ORDER BY course_start_time_
+	</select>
+
 	<delete id="deleteStudentCourseSchedule">
 		DELETE FROM course_schedule_student_payment WHERE user_id_ = #{userId} AND course_schedule_id_ IN
 		<foreach collection="courseScheduleList" item="courseSchedule" index="index" open="(" close=")" separator=",">

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

@@ -337,7 +337,7 @@
     </select>
     
   	<select id="queryOrganMusicGroupNum" resultType="map">
-    	select count(*) total,sum(case when status_ = 'PROGRESS' then 1 else 0 end) progress_num_,sum(case when status_ = 'PAUSE' then 1 else 0 end) pause_num_ from music_group
+    	select count(*) total,sum(case when status_ = 'PREPARE' then 1 else 0 end) prepare_num_,sum(case when status_ = 'PROGRESS' then 1 else 0 end) progress_num_,sum(case when status_ = 'PAUSE' then 1 else 0 end) pause_num_ from music_group
     	<where>
     		<if test="organId != null">
     			FIND_IN_SET(organ_id_,#{organId})

+ 3 - 2
mec-biz/src/main/resources/config/mybatis/StudentAttendanceMapper.xml

@@ -360,7 +360,9 @@
         AND cssp.course_schedule_id_ = #{courseScheduleId}
     </select>
     <select id="countStudentAttendenceNum" resultType="int">
-        SELECT COUNT(*) FROM student_attendance sa WHERE course_schedule_id_ = #{courseScheduleId} AND status_='NORMAL'
+        SELECT COUNT(*) FROM student_attendance sa
+        WHERE course_schedule_id_ = #{courseScheduleId}
+        AND (update_time_!='1970-01-01 00:00:00' OR update_time_ IS NULL)
     </select>
     <select id="countStudentAttendancesByCourses" resultType="java.util.Map">
         SELECT
@@ -373,7 +375,6 @@
             <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
                 #{courseScheduleId}
             </foreach>
-            AND update_time_!='1970-01-01 00:00:00'
         GROUP BY
             course_schedule_id_
     </select>

+ 8 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -500,4 +500,12 @@
         SELECT o.name_ organName, SUM(spo.actual_amount_) money ,COUNT(spo.id_) nums FROM student_payment_order spo LEFT JOIN organization o ON o.id_=spo.organ_id_
         WHERE spo.type_='LUCK' AND spo.status_='SUCCESS' GROUP BY spo.organ_id_ ORDER BY nums DESC;
     </select>
+    
+    <select id="queryIncomeStatistics" resultType="map">
+    	select count(*) total,sum(actual_amount_) total_num_ from student_payment_order
+    	where actual_amount_ &gt; 0
+   		<if test="organId != null">
+   			and FIND_IN_SET(organ_id_,#{organId})
+   		</if>
+  	</select>
 </mapper>

+ 2 - 3
mec-biz/src/main/resources/config/mybatis/TeacherMapper.xml

@@ -558,11 +558,10 @@
     <select id="queryOrganTeacherNum" resultType="map">
         select count(*) total,sum(case when job_nature_ = 'PART_TIME' then 1 else 0 end) part_time_num_,sum(case when
         job_nature_ = 'FULL_TIME' then 1 else 0 end) full_time_num_ from teacher
-        <where>
+        where demission_date_ is not null
             <if test="organId != null">
-                FIND_IN_SET(organ_id_,#{organId})
+                and FIND_IN_SET(organ_id_,#{organId})
             </if>
-        </where>
     </select>
     <select id="findByFlowOrganRange" resultMap="Teacher">
         SELECT id_,CONCAT(IF(flow_organ_range_ IS NULL OR flow_organ_range_ = '',0,flow_organ_range_),",",

+ 6 - 0
mec-web/src/main/java/com/ym/mec/web/controller/IndexController.java

@@ -47,6 +47,9 @@ public class IndexController extends BaseController {
 	
 	@Autowired
 	private SysUserCashAccountDetailDao sysUserCashAccountDetailDao;
+	
+	@Autowired
+	private StudentPaymentOrderDao studentPaymentOrderDao;
 
 	@ApiOperation(value = "获取首页数据")
 	@GetMapping("/index")
@@ -83,6 +86,8 @@ public class IndexController extends BaseController {
 		
 		Map<String, Object> incomeExpendMap = sysUserCashAccountDetailDao.queryStatistics(organId);
 		
+		Map<String, Object> incomeMap = studentPaymentOrderDao.queryIncomeStatistics(organId);
+		
 		ModelMap model = new ModelMap();
 		model.put("musicDatas", musicDatas);
 		model.put("teacherDatas", teacherDatas);
@@ -93,6 +98,7 @@ public class IndexController extends BaseController {
 		model.put("vipGroupNum", vipGroupNum);
 		model.put("demoGroupNum", demoGroupNum);
 		model.put("incomeExpendMap", incomeExpendMap);
+		model.put("incomeMap", incomeMap);
 
 		return succeed(model);
 	}