Explorar o código

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

zouxuan %!s(int64=5) %!d(string=hai) anos
pai
achega
b3e467da85

+ 8 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDetailDao.java

@@ -1,9 +1,16 @@
 package com.ym.mec.biz.dal.dao;
 
+import java.util.List;
+
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
 import com.ym.mec.common.dal.BaseDAO;
 
 public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicGroupPaymentCalenderDetail> {
 
-	
+	/**
+	 * 批量新增
+	 * @param musicGroupPaymentCalenderDetailList
+	 * @return
+	 */
+	int batchInsert(List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList);
 }

+ 6 - 16
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupStudentFeeDao.java

@@ -1,16 +1,15 @@
 package com.ym.mec.biz.dal.dao;
 
-import com.ym.mec.biz.dal.dto.SimpleUserDto;
-import com.ym.mec.biz.dal.dto.UpdateStudentFeeDto;
-import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
-import com.ym.mec.common.dal.BaseDAO;
-import org.apache.ibatis.annotations.Param;
-
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
+
+import org.apache.ibatis.annotations.Param;
+
+import com.ym.mec.biz.dal.dto.UpdateStudentFeeDto;
+import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
+import com.ym.mec.common.dal.BaseDAO;
 
 public interface MusicGroupStudentFeeDao extends BaseDAO<Long, MusicGroupStudentFee> {
 
@@ -104,15 +103,6 @@ public interface MusicGroupStudentFeeDao extends BaseDAO<Long, MusicGroupStudent
 	Integer countStudentNoPayNum(String musicGroupId);
 
 	/**
-	 * 获取当前乐团对应缴费状态的学院
-	 * @param musicGroupId
-	 * @param paymentStatus
-	 * @return
-	 */
-	List<SimpleUserDto> findStudentWithMusicGroupAndPaymentStatus(@Param("musicGroupId") String musicGroupId,
-																  @Param("paymentStatus")MusicGroupStudentFee.PaymentStatus paymentStatus);
-
-	/**
 	 * 根据乐团声部修改学员课程费用
 	 * @param musicGroupId
 	 * @param subjectId

+ 3 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderDetail.java

@@ -16,7 +16,7 @@ public class MusicGroupPaymentCalenderDetail {
 	private Long musicGroupPaymentCalenderId;
 	
 	/**  */
-	private Long userId;
+	private Integer userId;
 	
 	/**  */
 	private java.math.BigDecimal expectAmount;
@@ -55,11 +55,11 @@ public class MusicGroupPaymentCalenderDetail {
 		return this.musicGroupPaymentCalenderId;
 	}
 			
-	public void setUserId(Long userId){
+	public void setUserId(Integer userId){
 		this.userId = userId;
 	}
 	
-	public Long getUserId(){
+	public Integer getUserId(){
 		return this.userId;
 	}
 			

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupStudentMapperService.java

@@ -27,7 +27,7 @@ public interface ClassGroupStudentMapperService extends BaseService<Long, ClassG
      * @param classGroupId
      * @return
      */
-    boolean delClassGroupStudent(Integer userId, Integer classGroupId) throws Exception;
+    boolean delClassGroupStudent(Integer userId, Integer classGroupId);
 
 
     /**

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

@@ -8,6 +8,13 @@ import java.util.Date;
 import java.util.List;
 
 public interface MusicGroupPaymentCalenderService extends BaseService<Long, MusicGroupPaymentCalender> {
+	
+	/**
+	 * 创建缴费信息
+	 * @param musicGroupPaymentCalender
+	 * @return
+	 */
+	boolean create(MusicGroupPaymentCalender musicGroupPaymentCalender);
 
 	/**
 	 * 批量新增、修改乐团缴费周期

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -67,11 +67,11 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public boolean delClassGroupStudent(Integer userId, Integer classGroupId) throws Exception {
+    public boolean delClassGroupStudent(Integer userId, Integer classGroupId) {
         ClassGroup classGroup = classGroupService.get(classGroupId);
         Integer studentNum = classGroupStudentMapperDao.countClassGroupNormalStudentNum(classGroupId);
         if (classGroup.getType().equals(ClassGroupTypeEnum.HIGH_ONLINE) && studentNum <= 3) {
-            throw new BizException("线上基础技能课班级人数不能少于3");
+            throw new BizException(classGroup.getName()+"线上基础技能课班级人数不能少于3,请调整");
         }
 
         ClassGroupStudentMapper classStudentMapper = findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupId, "NORMAL");

+ 75 - 13
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -1,34 +1,45 @@
 package com.ym.mec.biz.service.impl;
 
+import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.NO;
+
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
-import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
-import com.ym.mec.common.exception.BizException;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
+import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
+import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
+import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.date.DateUtil;
 
-import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.NO;
-
 @Service
 public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalender> implements MusicGroupPaymentCalenderService {
 
 	@Autowired
 	private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
 
+	@Autowired
+	private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
+
+	@Autowired
+	private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
+
 	@Override
 	public BaseDAO<Long, MusicGroupPaymentCalender> getDAO() {
 		return musicGroupPaymentCalenderDao;
@@ -36,6 +47,57 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
+	public boolean create(MusicGroupPaymentCalender musicGroupPaymentCalender) {
+		Date date = new Date();
+		List<MusicGroupStudentFee> list = null;
+
+		musicGroupPaymentCalender.setCreateTime(date);
+		musicGroupPaymentCalender.setUpdateTime(date);
+		musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
+		if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
+			musicGroupPaymentCalender.setPaymentStatus(PaymentStatusEnum.YES);
+		} else if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
+			musicGroupPaymentCalender.setPaymentStatus(PaymentStatusEnum.OPEN);
+			// 统计缴费人数
+			list = musicGroupStudentFeeDao.queryByMusicGroupId(musicGroupPaymentCalender.getMusicGroupId());
+			if (list == null) {
+				list = new ArrayList<MusicGroupStudentFee>();
+			}
+			musicGroupPaymentCalender.setExpectNum(list.size());
+		} else {
+			musicGroupPaymentCalender.setPaymentStatus(PaymentStatusEnum.NO);
+		}
+
+		this.insert(musicGroupPaymentCalender);
+
+		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
+		if (musicGroupPaymentCalender.getPaymentStatus() == PaymentStatusEnum.OPEN) {
+			if (list != null && list.size() > 0) {
+				MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
+				// 创建缴费明细
+				for (MusicGroupStudentFee mgsf : list) {
+					musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
+					musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+					musicGroupPaymentCalenderDetail.setCreateTime(date);
+					musicGroupPaymentCalenderDetail.setExpectAmount(mgsf.getCourseFee());
+					musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
+					musicGroupPaymentCalenderDetail.setUpdateTime(date);
+					musicGroupPaymentCalenderDetail.setUserId(mgsf.getUserId());
+
+					musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
+				}
+			}
+		}
+
+		if (musicGroupPaymentCalenderDetailList.size() > 0) {
+			musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
+		}
+
+		return true;
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public void batchInsert(List<MusicGroupPaymentCalender> musicGroupPaymentCalenders) {
 		if (musicGroupPaymentCalenders != null && musicGroupPaymentCalenders.size() > 0) {
 			musicGroupPaymentCalenderDao.delByGroupId(musicGroupPaymentCalenders.get(0).getMusicGroupId());
@@ -48,15 +110,15 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	@Override
 	public Date getNextPaymentDate(String musicGroupId, Date latestPaidDate, MusicGroupStudentFee fee) {
 		List<Integer> months = null;
-		if(fee != null){
+		if (fee != null) {
 			String paymentPeriodList = fee.getPaymentPeriodList();
-			if(StringUtils.isEmpty(paymentPeriodList)){
+			if (StringUtils.isEmpty(paymentPeriodList)) {
 				return null;
 			} else {
 				months = Arrays.asList(paymentPeriodList.split(",")).stream().map(x -> Integer.parseInt(x)).collect(Collectors.toList());
 				Collections.sort(months);
 			}
-		}else {
+		} else {
 			List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
 			if (musicGroupPaymentCalenderList != null && musicGroupPaymentCalenderList.size() > 0) {
 				months = musicGroupPaymentCalenderList.stream().map(e -> e.getPaymentMonth()).sorted().collect(Collectors.toList());
@@ -93,14 +155,14 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void updateStartTime(Date startTime, Long id) {
-		if(startTime == null || id == null){
+		if (startTime == null || id == null) {
 			throw new BizException("参数校验失败");
 		}
 		MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(id);
-		if(calender == null){
+		if (calender == null) {
 			throw new BizException("缴费信息不存在");
 		}
-		if(calender.getPaymentStatus() == null || calender.getPaymentStatus() != NO){
+		if (calender.getPaymentStatus() == null || calender.getPaymentStatus() != NO) {
 			throw new BizException("修改失败,缴费状态不匹配");
 		}
 		calender.setStartPaymentDate(startTime);
@@ -111,14 +173,14 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void del(Long id) {
-		if(id == null){
+		if (id == null) {
 			throw new BizException("参数校验失败");
 		}
 		MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(id);
-		if(calender == null){
+		if (calender == null) {
 			throw new BizException("缴费信息不存在");
 		}
-		if(calender.getPaymentStatus() == null || calender.getPaymentStatus() != NO){
+		if (calender.getPaymentStatus() == null || calender.getPaymentStatus() != NO) {
 			throw new BizException("删除失败,缴费状态不匹配");
 		}
 		musicGroupPaymentCalenderDao.delete(id);

+ 7 - 47
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -146,6 +146,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     private MusicGroupSubjectGoodsGroupService musicGroupSubjectGoodsGroupService;
     @Autowired
     private GoodsService goodsService;
+    @Autowired
+    private ClassGroupStudentMapperService classGroupStudentMapperService;
 
     @Autowired
     private ImFeignService imFeignService;
@@ -1355,31 +1357,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             if (studentRegistration == null) {
                 throw new BizException("用户注册信息不存在");
             }
-            //更新学员在班级的状态
-            classGroupStudentMapperDao.deleteStudentByMusicGroupId(musicGroupId, userId);
 
             List<Integer> classGroupIdList = classGroupStudentMapperDao.queryClassGroupIdList(musicGroupId, userId, GroupType.MUSIC);
-            if (classGroupIdList != null && classGroupIdList.size() > 0) {
-                //更新班级人数
-                //classGroupDao.batchUpdateStudentNumMinusOne(classGroupIdList);
-
-                List<ImGroupModel> imGroupModels = new ArrayList<>();
-                ImGroupMember[] imGroupMember = {new ImGroupMember(userId.toString())};
-                for (Integer classGroupId : classGroupIdList) {
-                    imGroupModels.add(new ImGroupModel(classGroupId + "", imGroupMember, ""));
-                }
-                imFeignService.groupBatchQuit(imGroupModels);
-            }
-
-            List<CourseSchedule> musicGroupCourseSchedules = courseScheduleDao.findMusicGroupCourseSchedulesWithStudent(musicGroupId, GroupType.MUSIC.getCode(), CourseStatusEnum.NOT_START.getCode(), userId);
-            if (!CollectionUtils.isEmpty(musicGroupCourseSchedules)) {
-                List<Long> courseScheduleIds = musicGroupCourseSchedules.stream().map(courseSchedule -> courseSchedule.getId()).collect(Collectors.toList());
-
-                // 删除未上课
-                courseScheduleDao.deleteMusicGroupCourseSchedulesWithStudent(courseScheduleIds, userId);
-
-                //删除学生缴费表
-                courseScheduleStudentPaymentDao.deleteStudentCourseSchedule(userId, musicGroupCourseSchedules);
+            //更新学员在班级的状态
+            for (Integer classGroupId : classGroupIdList) {
+                classGroupStudentMapperService.delClassGroupStudent(userId,classGroupId);
             }
 
             //删除续费周期
@@ -1472,32 +1454,10 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (studentRegistration == null) {
             throw new BizException("用户注册信息不存在");
         }
-        //更新学员在班级的状态
-        classGroupStudentMapperDao.deleteStudentByMusicGroupId(musicGroupId, userId);
 
         List<Integer> classGroupIdList = classGroupStudentMapperDao.queryClassGroupIdList(musicGroupId, userId, GroupType.MUSIC);
-        if (classGroupIdList != null && classGroupIdList.size() > 0) {
-            //更新班级人数
-            //classGroupDao.batchUpdateStudentNumMinusOne(classGroupIdList);
-
-            //删除融云群
-            List<ImGroupModel> imGroupModels = new ArrayList<ImGroupModel>();
-            ImGroupMember[] imGroupMember = {new ImGroupMember(userId.toString())};
-            for (Integer classGroupId : classGroupIdList) {
-                imGroupModels.add(new ImGroupModel(classGroupId + "", imGroupMember, ""));
-            }
-            imFeignService.groupBatchQuit(imGroupModels);
-        }
-
-        List<CourseSchedule> musicGroupCourseSchedules = courseScheduleDao.findMusicGroupCourseSchedulesWithStudent(musicGroupId, GroupType.MUSIC.getCode(), CourseStatusEnum.NOT_START.getCode(), userId);
-        if (!CollectionUtils.isEmpty(musicGroupCourseSchedules)) {
-            List<Long> courseScheduleIds = musicGroupCourseSchedules.stream().map(courseSchedule -> courseSchedule.getId()).collect(Collectors.toList());
-
-            // 删除未上课
-            courseScheduleDao.deleteMusicGroupCourseSchedulesWithStudent(courseScheduleIds, userId);
-
-            // 删除学生缴费表
-            courseScheduleStudentPaymentDao.deleteStudentCourseSchedule(userId, musicGroupCourseSchedules);
+        for (Integer classGroupId : classGroupIdList) {
+            classGroupStudentMapperService.delClassGroupStudent(userId,classGroupId);
         }
 
         //删除续费周期

+ 9 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml

@@ -38,6 +38,15 @@
 		VALUES(#{id},#{musicGroupPaymentCalenderId},#{userId},#{expectAmount},#{actualAmount},#{paymentStatus},#{userStatus},#{payTime},#{updateTime},#{createTime})
 	</insert>
 
+    <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail">
+        INSERT INTO music_group_payment_calender_detail
+		(id_,music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,payment_status_,user_status_,pay_time_,update_time_,create_time_)
+		VALUES
+		<foreach collection="list" item="item" separator=",">
+            (#{item.id},#{item.musicGroupPaymentCalenderId},#{item.userId},#{item.expectAmount},#{item.actualAmount},#{item.paymentStatus},#{item.userStatus},#{item.payTime},#{item.updateTime},#{item.createTime})
+        </foreach>
+    </insert>
+
 	<!-- 根据主键查询一条记录 -->
 	<update id="update"
 		parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail">

+ 0 - 10
mec-biz/src/main/resources/config/mybatis/MusicGroupStudentFeeMapper.xml

@@ -194,16 +194,6 @@
         SELECT * FROM music_group_student_fee_ WHERE music_group_id_ = #{musicGroupId}
     </select>
 
-    <select id="findStudentWithMusicGroupAndPaymentStatus" resultType="com.ym.mec.biz.dal.dto.SimpleUserDto">
-        SELECT
-            DISTINCT su.id_ userId,
-            su.real_name_ userName,
-            su.avatar_ avatar
-        FROM music_group_student_fee_ mgsf
-        LEFT JOIN sys_user su ON su.id_=mgsf.user_id_
-        WHERE music_group_id_='19120116225600001' AND payment_status_='PAID_COMPLETED'
-    </select>
-
     <update id="batchUpdate" parameterType="java.util.List">
     	<foreach collection="list" item="item" index="index" open="" close="" separator=";">
         UPDATE music_group_student_fee_

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

@@ -25,7 +25,7 @@ public class MusicGroupPaymentCalenderController extends BaseController {
     @PostMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/add')")
     public Object add(MusicGroupPaymentCalender musicGroupPaymentCalender) {
-        musicGroupPaymentCalenderService.insert(musicGroupPaymentCalender);
+        musicGroupPaymentCalenderService.create(musicGroupPaymentCalender);
         return succeed();
     }