소스 검색

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

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java
yonge 4 년 전
부모
커밋
d6b47b067d
30개의 변경된 파일484개의 추가작업 그리고 148개의 파일을 삭제
  1. 1 1
      mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/web/controller/UserController.java
  2. 18 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java
  3. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java
  4. 32 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CloseMusicGroupDto.java
  5. 6 4
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderStudentDetail.java
  6. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/MusicGroupStatusEnum.java
  7. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/SporadicChargeTypeEnum.java
  8. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentPaymentOrderQueryInfo.java
  9. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupService.java
  10. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupStudentMapperService.java
  11. 14 12
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupService.java
  12. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java
  13. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentRegistrationService.java
  14. 73 76
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java
  15. 90 5
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java
  16. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java
  17. 4 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  18. 64 13
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  19. 5 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupSubjectPlanServiceImpl.java
  20. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SporadicChargeInfoImpl.java
  21. 26 6
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
  22. 39 18
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  23. 14 0
      mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  24. 4 0
      mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml
  25. 3 0
      mec-biz/src/main/resources/config/mybatis/StudentPaymentRouteOrderMapper.xml
  26. 2 1
      mec-biz/src/main/resources/config/mybatis/StudentRegistrationMapper.xml
  27. 12 3
      mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java
  28. 1 1
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/Payment.java
  29. 8 0
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupController.java
  30. 12 0
      mec-web/src/main/java/com/ym/mec/web/controller/StudentRegistrationController.java

+ 1 - 1
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/web/controller/UserController.java

@@ -243,7 +243,7 @@ public class UserController extends BaseController {
 				throw new BizException("出生日期不可超过当前时间");
 			}
 
-			if(!debugMode){
+			if(!debugMode&&StringUtils.isNotBlank(sysUser.getCertificateType())&&"IDENTITY".equals(sysUser.getCertificateType())){
 				realnameAuthenticationPluginContext.getRealnameAuthenticationPlugin(LinkfaceRealnameAuthenticationPlugin.getName()).verify(sysUser.getRealName(), sysUser.getIdCardNo());
 			}
 

+ 18 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -9,6 +9,7 @@ import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -1678,6 +1679,15 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
     List<Map<String, Integer>> querySubCourseNumMap(@Param("classGroupId") Integer classGroupId);
 
     /**
+     * 获取班级剩余的课程类型和课程总时长
+     *
+     * @param classGroupId
+     * @return
+     * @author zouxuan
+     */
+    List<Map<String, BigDecimal>> querySubCourseTimeMap(@Param("classGroupId") Integer classGroupId);
+
+    /**
      * 获取所选班级最大剩余课时
      *
      * @param classGroupIds
@@ -1731,4 +1741,12 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @author zouxuan
      */
     int countStudentNoStartCourse(Map<String, Object> params);
+
+    /**
+     * 根据班级编号和课程编号获取课程列表
+     * @param classGroupId
+     * @param allLockCourseIds
+     * @return
+     */
+    List<CourseSchedule> findCoursesByClassGroupIdAndCourseIds(@Param("classGroupId") Long classGroupId, @Param("allLockCourseIds") List<Long> allLockCourseIds);
 }

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

@@ -383,9 +383,19 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
 
     /**
      * 获取学生的报名订单
+     *
      * @param userId
      * @param musicGroupId
      * @return
      */
     List<StudentPaymentOrderExportDto> getUserApplyOrders(@Param("userId") Integer userId, @Param("musicGroupId") String musicGroupId);
+
+    /**
+     * 获取成功的汇付支付的订单
+     *
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<StudentPaymentOrder> getAdaPayOrdersByTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
 }

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

@@ -0,0 +1,32 @@
+package com.ym.mec.biz.dal.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+public class CloseMusicGroupDto {
+
+    @ApiModelProperty(value = "乐团id", required = true)
+    private String musicGroupId;
+
+
+    @ApiModelProperty(value = "用户退的金额", required = true)
+    private Map<Integer, BigDecimal> userReBack;
+
+    public String getMusicGroupId() {
+        return musicGroupId;
+    }
+
+    public void setMusicGroupId(String musicGroupId) {
+        this.musicGroupId = musicGroupId;
+    }
+
+    public Map<Integer, BigDecimal> getUserReBack() {
+        return userReBack;
+    }
+
+    public void setUserReBack(Map<Integer, BigDecimal> userReBack) {
+        this.userReBack = userReBack;
+    }
+}

+ 6 - 4
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderStudentDetail.java

@@ -29,7 +29,7 @@ public class MusicGroupPaymentCalenderStudentDetail {
 	private String courseType;
 	
 	/** 课程时长 */
-	private Long courseTime;
+	private Integer courseTime;
 	
 	/** 班级编号 */
 	private Integer classGroupId;
@@ -99,11 +99,11 @@ public class MusicGroupPaymentCalenderStudentDetail {
 		return this.courseType;
 	}
 
-	public Long getCourseTime() {
+	public Integer getCourseTime() {
 		return courseTime;
 	}
 
-	public void setCourseTime(Long courseTime) {
+	public void setCourseTime(Integer courseTime) {
 		this.courseTime = courseTime;
 	}
 
@@ -143,6 +143,7 @@ public class MusicGroupPaymentCalenderStudentDetail {
 	public String toString() {
 		return "MusicGroupPaymentCalenderStudentDetail{" +
 				"userId=" + userId +
+				", courseOriginalPrice=" + courseOriginalPrice +
 				", courseCurrentPrice=" + courseCurrentPrice +
 				", courseType='" + courseType + '\'' +
 				", classGroupId=" + classGroupId +
@@ -155,6 +156,7 @@ public class MusicGroupPaymentCalenderStudentDetail {
 		if (o == null || getClass() != o.getClass()) return false;
 		MusicGroupPaymentCalenderStudentDetail that = (MusicGroupPaymentCalenderStudentDetail) o;
 		return userId.equals(that.userId) &&
+				courseOriginalPrice.equals(that.courseOriginalPrice) &&
 				courseCurrentPrice.equals(that.courseCurrentPrice) &&
 				courseType.equals(that.courseType) &&
 				classGroupId.equals(that.classGroupId);
@@ -162,6 +164,6 @@ public class MusicGroupPaymentCalenderStudentDetail {
 
 	@Override
 	public int hashCode() {
-		return Objects.hash(userId, courseCurrentPrice, courseType, classGroupId);
+		return Objects.hash(userId, courseOriginalPrice, courseCurrentPrice, courseType, classGroupId);
 	}
 }

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/MusicGroupStatusEnum.java

@@ -6,7 +6,8 @@ public enum MusicGroupStatusEnum implements BaseEnum<String, MusicGroupStatusEnu
 	DRAFT("DRAFT", "草稿"), FEE_AUDIT("FEE_AUDIT","费用审核中"), AUDIT("AUDIT", "审核中"),
 	AUDIT_FAILED("AUDIT_FAILED", "审核失败"), APPLY("APPLY", "报名中"),
 	PAY("PAY", "缴费中"), PREPARE("PREPARE", "筹备中"),
-	PROGRESS("PROGRESS", "进行中"), CANCELED("CANCELED", "取消"), PAUSE("PAUSE", "暂停");
+	PROGRESS("PROGRESS", "进行中"), CANCELED("CANCELED", "取消"), PAUSE("PAUSE", "暂停"),
+	CLOSE("CLOSE", "关闭");
 
 	private String code;
 	private String msg;

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/SporadicChargeTypeEnum.java

@@ -14,7 +14,8 @@ public enum SporadicChargeTypeEnum implements BaseEnum<Integer, SporadicChargeTy
     RECHARGE(9,"账户充值"),
     MUSIC_UPKEEP(10,"乐保服务"),
     OTHER(11,"其他"),
-    DOUBLE_ELEVEN2020(12,"2020双十一活动");
+    DOUBLE_ELEVEN2020(12,"2020双十一活动"),
+    HIGH_ONLINE_ACTIVITY(13,"网基课活动");
 
     private Integer code;
 

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentPaymentOrderQueryInfo.java

@@ -61,6 +61,10 @@ public class StudentPaymentOrderQueryInfo extends QueryInfo {
 
     private List<Integer> userIds;
 
+    //不包含淘气
+    @ApiModelProperty(value = "传时不包含淘气",required = false)
+    private Integer noneTqType;//TQ 1-不包含淘气
+
     private boolean isExport = false;
 
     public boolean getIsExport() {
@@ -214,4 +218,12 @@ public class StudentPaymentOrderQueryInfo extends QueryInfo {
     public void setLessBalancePaymentAmount(BigDecimal lessBalancePaymentAmount) {
         this.lessBalancePaymentAmount = lessBalancePaymentAmount;
     }
+
+    public Integer getNoneTqType() {
+        return noneTqType;
+    }
+
+    public void setNoneTqType(Integer noneTqType) {
+        this.noneTqType = noneTqType;
+    }
 }

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

@@ -543,5 +543,5 @@ public interface ClassGroupService extends BaseService<Integer, ClassGroup> {
      * @param courseIds
      * @param classGroupStudents
      */
-    void spanGroupClassAdjustPass(Integer masterClassGroupId,List<Integer> studentIds,List<Long> courseIds,List<Map<Integer, String>> classGroupStudents);
+    void spanGroupClassAdjustPass(Integer masterClassGroupId,List<Integer> studentIds,List<Long> courseIds,List<Map<Integer, String>> classGroupStudents,List<Long> allLockCourseIds,String batchNo);
 }

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

@@ -89,4 +89,14 @@ public interface ClassGroupStudentMapperService extends BaseService<Long, ClassG
      */
     void updateClassGroupStudents(Long classGroupId, Set<Integer> studentIds);
 
+    /**
+     * @describe 更新班级学员
+     * @author Joburgess
+     * @date 2020.11.04
+     * @param classGroupId:
+     * @param studentIds:
+     * @return void
+     */
+    void updateClassGroupStudents1(Long classGroupId, List<Integer> studentIds,List<Long> allLockCourseIds,String batchNo);
+
 }

+ 14 - 12
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupService.java

@@ -7,13 +7,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import com.ym.mec.biz.dal.dto.BasicUserDto;
-import com.ym.mec.biz.dal.dto.CourseScheduleTeachersDto;
-import com.ym.mec.biz.dal.dto.MusicCardDto;
-import com.ym.mec.biz.dal.dto.RegisterPayDto;
-import com.ym.mec.biz.dal.dto.SporadicPayDto;
-import com.ym.mec.biz.dal.dto.SubFeeSettingDto;
-import com.ym.mec.biz.dal.dto.UpdateExpectedNumDto;
+import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.ApprovalStatus;
 import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
@@ -77,7 +71,7 @@ public interface MusicGroupService extends BaseService<String, MusicGroup> {
 	 * @param musicGroupId 乐团编号
 	 */
 	boolean cancelMusicGroup(String musicGroupId);
-	
+
 	/**
 	 * 删除乐团
 	 * @param musicGroupId 乐团编号
@@ -120,7 +114,7 @@ public interface MusicGroupService extends BaseService<String, MusicGroup> {
 	 * @return
 	 */
 	boolean applyQuitMusicGroup(String musicGroupId, String reason);
-	
+
 	/**
 	 * 取消退团
 	 * @param userId
@@ -320,9 +314,17 @@ public interface MusicGroupService extends BaseService<String, MusicGroup> {
 
 	/**
 	 * 给乐团添加报名学生
-	 * @param musicGroupId
-	 * @param registerIds
-	 * @return
+	 * @param musicGroupId 乐团id
+	 * @param registerIds 学员注册id
+	 * @return 添加学员记录
 	 */
 	List<StudentRegistration> addMusicGroupRegs(String musicGroupId,List<Long> registerIds);
+
+
+	/**
+	 * 关闭乐团
+	 * @param closeMusicGroupDto 乐团关闭信息
+	 * @return 关闭结果
+	 */
+	Boolean closeMusicGroup(CloseMusicGroupDto closeMusicGroupDto);
 }

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java

@@ -131,4 +131,12 @@ public interface StudentPaymentOrderService extends BaseService<Long, StudentPay
 	 */
 	List<StudentPaymentOrder> getUserOrderByType(Integer userId, OrderTypeEnum type, DealStatusEnum status);
 
+
+	/**
+	 * 从新提交分账信息
+	 * @param startTime
+	 * @param endTime
+	 * @return
+	 */
+	List<StudentPaymentOrder> reConfirmOrder(Date startTime,Date endTime);
 }

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentRegistrationService.java

@@ -328,4 +328,12 @@ public interface StudentRegistrationService extends BaseService<Long, StudentReg
      */
     List<StudentMusicGroupDto> queryStudentMusicGroupInfo(Integer userId);
 
+
+    /**
+     * 删除学生报名
+     * @param id
+     * @return
+     */
+    Boolean delReg(Long id);
+
 }

+ 73 - 76
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -3492,7 +3492,6 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         if (noRepeatTeacherIds.size() != classGroupTeacherMapperList.size()) {
             throw new BizException("主教与助教存在冲突");
         }
-        //所选班级不能有未开始的临时合并课程
         List<Integer> classGroupIds = mergeClassSplitClassAffirmDto.getClassGroupIds();
         if (classGroupIds == null || classGroupIds.size() == 0) {
             throw new BizException("请填写班级信息");
@@ -3572,9 +3571,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     }
 
     @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public List<MusicGroupPaymentCalenderStudentDetail> queryStudentPaymentCalenders(Integer masterClassGroupId,List<Map<Integer, String>> classGroupStudents,List<Integer> studentIds) {
-        //获取主班剩余时长
-        Map<String, Long> masterMap = MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseNumMap(masterClassGroupId));
+        //获取主班剩余课程时长
+        Map<String, BigDecimal> masterMap = MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseTimeMap(masterClassGroupId));
         if(masterMap.size() <= 0){
             throw new BizException("所选主班没有剩余课程,请重新选择");
         }
@@ -3609,13 +3609,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             if (unitPrice == null) {
                 throw new BizException("分部默认课程类型单价不存在,请设置");
             }
-            Long courseTime = masterMap.get(s);
+            BigDecimal courseTime = masterMap.get(s);
             //获取主班剩余课程价值,按分部默认单价计算
-            if(courseTime == 0l){
-                masterTotalPriceMap.put(s,BigDecimal.ZERO);
-            }
             //总价四舍五入取整
-            BigDecimal totalPrice = unitPrice.multiply(new BigDecimal(courseTime)).setScale(0, BigDecimal.ROUND_HALF_UP);
+            BigDecimal totalPrice = unitPrice.multiply(courseTime).setScale(0, BigDecimal.ROUND_HALF_UP);
             masterTotalPriceMap.put(s,totalPrice);
             //课程余额转移
             for (Integer studentId : studentCLassMap.keySet()) {
@@ -3641,7 +3638,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 //                    bigDecimal = bigDecimal.subtract(totalPrice);
                     surplusCourseFeeMap.put(studentId,bigDecimal.subtract(totalPrice));
                 }
-                calenderDto.setCourseTime(courseTime);
+                calenderDto.setCourseTime(courseTime.intValue());
                 calenderDto.setCourseType(s);
 
                 calenderDto.setPhone(phoneMaps.get(studentId));
@@ -3657,7 +3654,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     @Override
     public BigDecimal getMasterTotalPrice(Integer masterClassGroupId) {
         //获取主班剩余时长
-        Map<String, Long> masterMap = MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseNumMap(masterClassGroupId));
+        Map<String, BigDecimal> masterMap = MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseTimeMap(masterClassGroupId));
         if(masterMap.size() <= 0){
             throw new BizException("所选主班没有剩余课程,请重新选择");
         }
@@ -3672,10 +3669,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             if (unitPrice == null) {
                 throw new BizException("分部默认课程类型单价不存在,请设置");
             }
-            Long courseTime = masterMap.get(s);
+            BigDecimal courseTime = masterMap.get(s);
             //获取主班剩余课程价值,按分部默认单价计算
             //总价四舍五入取整
-            BigDecimal totalPrice = unitPrice.multiply(new BigDecimal(courseTime)).setScale(0, BigDecimal.ROUND_HALF_UP);
+            BigDecimal totalPrice = unitPrice.multiply(courseTime).setScale(0, BigDecimal.ROUND_HALF_UP);
             masterTotalPrice = masterTotalPrice.add(totalPrice);
         }
         return masterTotalPrice;
@@ -3691,7 +3688,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     public void spanGroupMergeClassSplitClassAffirm(MergeClassSplitClassAffirmDto mergeClassSplitClassAffirmDto) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         //缴费项目
-        List<MusicGroupPaymentCalenderDto> paymentCalenderDtos = mergeClassSplitClassAffirmDto.getMusicGroupPaymentCalenderDtos();
+        MusicGroupPaymentCalenderDto paymentCalenderDto = mergeClassSplitClassAffirmDto.getMusicGroupPaymentCalenderDtos().get(0);
         //主班
         Integer masterClassGroupId = mergeClassSplitClassAffirmDto.getMasterClassGroupId();
         //学员列表
@@ -3701,6 +3698,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         if(hasStudent){
             throw new BizException("操作失败: 主班包含部分已选学员");
         }
+        
         //学员列表
         List<Integer> classGroupIds = mergeClassSplitClassAffirmDto.getClassGroupIds();
         //班级和学员关联
@@ -3711,75 +3709,74 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                 studentIds);
         //创建缴费项目
         MusicGroup musicGroup = musicGroupDao.findByClassGroupId(masterClassGroupId);
-        MusicGroupPaymentCalender.PaymentCalenderStatusEnum status = null;
-        StringBuffer batchNos = new StringBuffer();
-        List<String> batchNoList = new ArrayList<>();
-        if (paymentCalenderDtos != null && paymentCalenderDtos.size() > 0) {
-            BigDecimal masterTotalPrice = getMasterTotalPrice(masterClassGroupId);
-            //是否有需要审核的缴费项目
-            for (MusicGroupPaymentCalenderDto calenderDto : paymentCalenderDtos) {
-                //将学员加入新乐团、扣除原乐团剩余课程余额、补充到现有乐团
-                studentRegistrationService.insertStudent(calenderDto.getStudentIds(),calenderDto.getMusicGroupId(),musicGroup.getId(),masterTotalPrice);
-                calenderDto.setMusicGroupId(musicGroup.getId());
-                List<MusicGroupPaymentCalenderStudentDetail> calenderStudentDetails = calenderDto.getMusicGroupPaymentCalenderStudentDetails();
-                boolean containsAll = musicGroupPaymentCalenderStudentDetails.containsAll(calenderStudentDetails);
-                if(!containsAll){
-                    calenderDto.setStatus(AUDITING);
-                }else {
-                    calenderDto.setStatus(NO);
-                }
-                calenderDto.setPaymentType(SPAN_GROUP_CLASS_ADJUST);
-                //生成缴费项目
-                calenderDto.setMasterTotalPrice(masterTotalPrice);
-                musicGroupPaymentCalenderService.create(calenderDto);
-                if (batchNos.length() > 0) {
-                    batchNos.append(",");
-                }
-                batchNoList.add(calenderDto.getBatchNo());
-                batchNos.append(calenderDto.getBatchNo());
-                if (status == null || status != AUDITING) {
-                    if(!containsAll){
-                        status = AUDITING;
-                    }
-                }
-            }
-            //记录申请信息
-            MusicGroupStudentClassAdjust musicGroupStudentClassAdjust = new MusicGroupStudentClassAdjust();
-            musicGroupStudentClassAdjust.setMasterClassGroupId(masterClassGroupId);
-            musicGroupStudentClassAdjust.setBatchNo(batchNos.toString());
-            musicGroupStudentClassAdjust.setMusicGroupId(musicGroup.getId());
-            musicGroupStudentClassAdjust.setOperatorId(sysUser.getId());
-            musicGroupStudentClassAdjust.setClassGroupIds(JSON.toJSONString(classGroupIds));
-            musicGroupStudentClassAdjust.setStudentIds(JSON.toJSONString(studentIds));
-            if (classGroupStudents != null && classGroupStudents.size() > 0) {
-                musicGroupStudentClassAdjust.setClassGroupStudents(JSON.toJSONString(mergeClassSplitClassAffirmDto.getClassGroupStudents()));
-            }
-            //获取需要删除的学员关联的课程
-            List<Long> courseIds = courseScheduleDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds, studentIds);
-            musicGroupStudentClassAdjust.setSubLockCourseIds(JSON.toJSONString(courseIds));
-            //获取关联的学员缴费信息
-            List<Long> studentPaymentIds = courseScheduleStudentPaymentDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds, studentIds);
-            musicGroupStudentClassAdjust.setStudentPaymentIds(JSON.toJSONString(studentPaymentIds));
-            //获取需要冻结的课程
-            classGroupIds.add(masterClassGroupId);
-            List<Long> allLockCourseIds = courseScheduleDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds, null);
-            musicGroupStudentClassAdjust.setAllLockCourseIds(JSON.toJSONString(allLockCourseIds));
-            musicGroupStudentClassAdjustDao.insert(musicGroupStudentClassAdjust);
-            //没有需要审核的缴费项目
-            if (status == null) {
-                spanGroupClassAdjustPass(masterClassGroupId,studentIds,courseIds,classGroupStudents);
-            }else {
+        BigDecimal masterTotalPrice = getMasterTotalPrice(masterClassGroupId);
+        //是否有需要审核的缴费项目
+        //将学员加入新乐团、扣除原乐团剩余课程余额、补充到现有乐团
+        for (Map<Integer, String> classGroupStudent : classGroupStudents) {
+            Integer classGroupId = classGroupStudent.keySet().iterator().next();
+            studentRegistrationService.insertStudent(classGroupStudent.get(classGroupId),musicGroupDao.findByClassGroupId(classGroupId).getId(),musicGroup.getId(),masterTotalPrice);
+        }
+
+        paymentCalenderDto.setMusicGroupId(musicGroup.getId());
+        List<MusicGroupPaymentCalenderStudentDetail> calenderStudentDetails = paymentCalenderDto.getMusicGroupPaymentCalenderStudentDetails();
+        boolean containsAll = musicGroupPaymentCalenderStudentDetails.containsAll(calenderStudentDetails);
+        if(!containsAll){
+            paymentCalenderDto.setStatus(AUDITING);
+        }else {
+            paymentCalenderDto.setStatus(NO);
+        }
+        paymentCalenderDto.setPayUserType(MusicGroupPaymentCalender.PayUserType.STUDENT);
+        paymentCalenderDto.setPaymentType(SPAN_GROUP_CLASS_ADJUST);
+        //生成缴费项目
+        paymentCalenderDto.setMasterTotalPrice(masterTotalPrice);
+        paymentCalenderDto.setStudentIds(StringUtils.join(studentIds,","));
+        musicGroupPaymentCalenderService.create(paymentCalenderDto);
+        //记录申请信息
+        MusicGroupStudentClassAdjust musicGroupStudentClassAdjust = new MusicGroupStudentClassAdjust();
+        musicGroupStudentClassAdjust.setMasterClassGroupId(masterClassGroupId);
+        musicGroupStudentClassAdjust.setBatchNo(paymentCalenderDto.getBatchNo());
+        musicGroupStudentClassAdjust.setMusicGroupId(musicGroup.getId());
+        musicGroupStudentClassAdjust.setOperatorId(sysUser.getId());
+        musicGroupStudentClassAdjust.setClassGroupIds(JSON.toJSONString(classGroupIds));
+        musicGroupStudentClassAdjust.setStudentIds(JSON.toJSONString(studentIds));
+        if (classGroupStudents != null && classGroupStudents.size() > 0) {
+            musicGroupStudentClassAdjust.setClassGroupStudents(JSON.toJSONString(mergeClassSplitClassAffirmDto.getClassGroupStudents()));
+        }
+        //获取需要删除的学员关联的课程
+        List<Long> courseIds = courseScheduleDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds, studentIds);
+        musicGroupStudentClassAdjust.setSubLockCourseIds(JSON.toJSONString(courseIds));
+        //获取关联的学员缴费信息
+        List<Long> studentPaymentIds = courseScheduleStudentPaymentDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds, studentIds);
+        musicGroupStudentClassAdjust.setStudentPaymentIds(JSON.toJSONString(studentPaymentIds));
+        //获取需要冻结的课程
+        classGroupIds.add(masterClassGroupId);
+        //所选班级列表,是否包含已冻结的班级
+        List<ClassGroup> lockClassGroupIds = classGroupDao.findByClassGroupIds(classGroupIds, 1);
+        if (lockClassGroupIds != null && lockClassGroupIds.size() > 0) {
+            throw new BizException("所选班级包含审核中的学员班级调整申请");
+        }
+        //所选班级不能有未开始的临时合并课程
+        int courseNum = courseScheduleDao.findNoStartMasterCourseNum(classGroupIds);
+        if (courseNum > 0) {
+            throw new BizException("所选班级不能有未开始的临时合并课程");
+        }
+        List<Long> allLockCourseIds = courseScheduleDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds, null);
+        musicGroupStudentClassAdjust.setAllLockCourseIds(JSON.toJSONString(allLockCourseIds));
+        musicGroupStudentClassAdjustDao.insert(musicGroupStudentClassAdjust);
+        //没有需要审核的缴费项目
+        if (paymentCalenderDto.getStatus() != AUDITING) {
+            spanGroupClassAdjustPass(masterClassGroupId,studentIds,courseIds,classGroupStudents,allLockCourseIds,paymentCalenderDto.getBatchNo());
+        }else {
 //                冻结班级
-                classGroupDao.batchUpdateLockByClassGroupIds(classGroupIds, 1);
+            classGroupDao.batchUpdateLockByClassGroupIds(classGroupIds, 1);
 //                冻结所选班级的课程
-                courseScheduleDao.batchUpdateLockByCourseIds(allLockCourseIds, 1);
-            }
+            courseScheduleDao.batchUpdateLockByCourseIds(allLockCourseIds, 1);
         }
     }
 
-    public void spanGroupClassAdjustPass(Integer masterClassGroupId,List<Integer> studentIds,List<Long> courseIds,List<Map<Integer, String>> classGroupStudents){
+    public void spanGroupClassAdjustPass(Integer masterClassGroupId,List<Integer> studentIds,List<Long> courseIds,List<Map<Integer, String>> classGroupStudents,List<Long> allLockCourseIds,String batchNo){
         //将学员加进班级未开始的课程,以及班级关联、加群
-        classGroupStudentMapperService.updateClassGroupStudents(masterClassGroupId.longValue(),new HashSet<>(studentIds));
+        classGroupStudentMapperService.updateClassGroupStudents1(masterClassGroupId.longValue(),studentIds,allLockCourseIds,batchNo);
         //删除学员课程
         courseScheduleDao.deleteMusicGroupCourseSchedulesWithStudents(courseIds, studentIds);
         //删除班级关联的学员

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

@@ -14,10 +14,6 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.stream.Collectors;
 
-import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.entity.*;
-import com.ym.mec.biz.dal.enums.*;
-
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
@@ -25,7 +21,31 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import com.alibaba.fastjson.JSON;
+import com.ym.mec.biz.dal.dao.ClassGroupDao;
+import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
+import com.ym.mec.biz.dal.dao.CourseScheduleTeacherSalaryDao;
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
+import com.ym.mec.biz.dal.dao.OrganizationCourseUnitPriceSettingsDao;
+import com.ym.mec.biz.dal.dao.StudentDao;
 import com.ym.mec.biz.dal.dto.ClassGroupStudentInfoDto;
+import com.ym.mec.biz.dal.entity.ClassGroup;
+import com.ym.mec.biz.dal.entity.ClassGroupRelation;
+import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
+import com.ym.mec.biz.dal.entity.ClassGroupTeacherMapper;
+import com.ym.mec.biz.dal.entity.CourseSchedule;
+import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
+import com.ym.mec.biz.dal.entity.CourseScheduleTeacherSalary;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.StudentRegistration;
+import com.ym.mec.biz.dal.entity.TeacherDefaultMusicGroupSalary;
+import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
+import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
+import com.ym.mec.biz.dal.enums.CourseStatusEnum;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
+import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.biz.service.ClassGroupRelationService;
 import com.ym.mec.biz.service.ClassGroupService;
 import com.ym.mec.biz.service.ClassGroupStudentMapperService;
@@ -41,7 +61,8 @@ import com.ym.mec.common.entity.ImGroupMember;
 import com.ym.mec.common.entity.ImGroupModel;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
-import com.ym.mec.im.ImFeignService;
+import com.ym.mec.util.collection.MapUtil;
+import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.http.HttpUtil;
 
 @Service
@@ -75,6 +96,8 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
     @Autowired
     private CourseScheduleDao courseScheduleDao;
     @Autowired
+    private OrganizationCourseUnitPriceSettingsDao organizationCourseUnitPriceSettingsDao;
+    @Autowired
     private ClassGroupDao classGroupDao;
     @Autowired
     private MusicGroupDao musicGroupDao;
@@ -523,4 +546,66 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
             imGroupMemberService.join(classGroup.getId().longValue(), userRoleMap);
         }
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateClassGroupStudents1(Long classGroupId, List<Integer> studentIds,List<Long> allLockCourseIds,String batchNo) {
+        ClassGroup classGroup = classGroupDao.lockClassGroup(classGroupId.intValue());
+        if (Objects.isNull(classGroup)) {
+            throw new BizException("班级信息错误");
+        }
+        List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
+        //获取冻结的课程列表
+        List<CourseSchedule> classGroupNotStartCourse = courseScheduleDao.findCoursesByClassGroupIdAndCourseIds(classGroupId,allLockCourseIds);
+
+        Date now = new Date();
+        List<ClassGroupStudentMapper> classGroupStudentMappers = new ArrayList<>();
+        //获取分布默认的课程类型单价
+        MusicGroup musicGroup = musicGroupDao.findByClassGroupId(classGroupId.intValue());
+        Map<String, BigDecimal> unitPriceMap = MapUtil.convertIntegerMap(organizationCourseUnitPriceSettingsDao.queryMapByOrganIdAndChargeTypeId(musicGroup.getChargeTypeId(), musicGroup.getOrganId()));
+
+        //生成班级关联
+        for (Integer studentId : studentIds) {
+            ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
+            classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
+            classGroupStudentMapper.setClassGroupId(classGroupId.intValue());
+            classGroupStudentMapper.setUserId(studentId);
+            classGroupStudentMapper.setCreateTime(now);
+            classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+            classGroupStudentMapper.setGroupType(GroupType.MUSIC);
+            classGroupStudentMappers.add(classGroupStudentMapper);
+            //生成课程关联
+            for (CourseSchedule courseSchedule : classGroupNotStartCourse) {
+                //获取课程时长
+                int minutesBetween = DateUtil.minutesBetween(courseSchedule.getStartClassTime(), courseSchedule.getEndClassTime());
+                BigDecimal multiply = unitPriceMap.get(courseSchedule.getType().getCode()).multiply(new BigDecimal(minutesBetween));
+                CourseScheduleStudentPayment cssp = new CourseScheduleStudentPayment();
+                cssp.setGroupType(courseSchedule.getGroupType());
+                cssp.setMusicGroupId(courseSchedule.getMusicGroupId());
+                cssp.setCourseScheduleId(courseSchedule.getId());
+                cssp.setClassGroupId(courseSchedule.getClassGroupId());
+                cssp.setBatchNo(batchNo);
+                cssp.setUserId(studentId);
+                cssp.setOriginalPrice(multiply);
+                cssp.setExpectPrice(multiply);
+                cssp.setActualPrice(BigDecimal.ZERO);
+                courseScheduleStudentPayments.add(cssp);
+            }
+        }
+        if (classGroupStudentMappers.size() > 0) {
+            classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentMappers);
+        }
+        if (courseScheduleStudentPayments.size() > 0) {
+            courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
+        }
+        //修改班级人数
+        classGroupService.updateClassStudentNum(classGroupId.intValue(), classGroup.getStudentNum() + studentIds.size());
+
+        //添加进IM群组
+        Map<Integer,String> userRoleMap = new HashMap<Integer, String>();
+        for (Integer studentId : studentIds) {
+        	userRoleMap.put(studentId, null);
+        }
+        imGroupMemberService.join(classGroupId.longValue(), userRoleMap);
+    }
 }

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

@@ -379,7 +379,7 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		Map<Integer, List<MusicGroupPaymentCalenderStudentDetail>> collect = musicGroupPaymentCalenderStudentDetails.stream().collect(Collectors.groupingBy(e -> e.getUserId()));
 		//生成music_group_payment_calender_detail
 //		List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<MusicGroupPaymentStudentCourseDetail>();
-		MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
+//		MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
 		MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
 		Long musicGroupPaymentCalenderId = musicGroupPaymentCalender.getId();
 		for (Integer studentId : collect.keySet()) {

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

@@ -757,8 +757,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				List<Map<Integer,String>> classGroupStudents = (List<Map<Integer,String>>)JSON.parse(adjust.getClassGroupStudents());
 				List<Integer> studentIds = JSON.parseArray(adjust.getStudentIds(), Integer.class);
 				List<Long> courseIds = JSON.parseArray(adjust.getSubLockCourseIds(), Long.class);
+				List<Long> allLockCourseIds = JSON.parseArray(adjust.getAllLockCourseIds(), Long.class);
 				classGroupService.spanGroupClassAdjustPass(adjust.getMasterClassGroupId()
-						,studentIds,courseIds,classGroupStudents);
+						,studentIds,courseIds,classGroupStudents,allLockCourseIds,batchNo);
 			}
 		}
 		return batchNo;
@@ -1071,8 +1072,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			List<Map<Integer,String>> classGroupStudents = (List<Map<Integer,String>>)JSON.parse(adjust.getClassGroupStudents());
 			List<Integer> studentIds = JSON.parseArray(adjust.getStudentIds(), Integer.class);
 			List<Long> courseIds = JSON.parseArray(adjust.getSubLockCourseIds(), Long.class);
+			List<Long> allLockCourseIds = JSON.parseArray(adjust.getAllLockCourseIds(), Long.class);
 			classGroupService.spanGroupClassAdjustPass(adjust.getMasterClassGroupId()
-					,studentIds,courseIds,classGroupStudents);
+					,studentIds,courseIds,classGroupStudents,allLockCourseIds,batchNo);
 		}
 		musicGroupPaymentCalenderDao.batchUpdate(musicGroupPaymentCalenders);
 	}

+ 64 - 13
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -19,6 +19,7 @@ import java.util.Set;
 import java.util.stream.Collectors;
 
 import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,16 +33,6 @@ import com.alibaba.fastjson.TypeReference;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.entity.SysUserRole;
-import com.ym.mec.biz.dal.dto.BasicUserDto;
-import com.ym.mec.biz.dal.dto.CourseFormDto;
-import com.ym.mec.biz.dal.dto.CourseScheduleTeachersDto;
-import com.ym.mec.biz.dal.dto.HighClassGroupDto;
-import com.ym.mec.biz.dal.dto.MusicCardDto;
-import com.ym.mec.biz.dal.dto.RegisterPayDto;
-import com.ym.mec.biz.dal.dto.SporadicPayDto;
-import com.ym.mec.biz.dal.dto.SubFeeSettingDto;
-import com.ym.mec.biz.dal.dto.SubjectRegisterDto;
-import com.ym.mec.biz.dal.dto.UpdateExpectedNumDto;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
 import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
@@ -411,8 +402,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         studentPaymentOrder.setVersion(0);
         BigDecimal balance = BigDecimal.ZERO;
         if (sporadicPayDto.getUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
-            if (chargeInfo.getChargeType().getCode().equals(9)) {
-                throw new BizException("账户充值不支持余额支付");
+            if (chargeInfo.getChargeType().getCode().equals(9)||chargeInfo.getChargeType().getCode().equals(13)) {
+                throw new BizException(chargeInfo.getChargeType().getMsg()+"不支持余额支付");
             }
             SysUserCashAccount userCashAccount = sysUserCashAccountService.get(userId);
 
@@ -2582,6 +2573,20 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             throw new BizException("获取用户信息失败");
         }
         List<StudentRegistration> studentRegistrations = studentRegistrationDao.findStudentListByIdList(registerIds);
+        List<StudentRegistration> oldRegs = studentRegistrationDao.getMusicGroupStu(musicGroupId);
+        Map<Integer, List<StudentRegistration>> oldRegMap = oldRegs.stream().collect(Collectors.groupingBy(StudentRegistration::getUserId));
+        //去掉相同的人
+        List<StudentRegistration> newRegs = new ArrayList<>();
+        Set<Integer> hasUsers = new HashSet<>();
+        for (StudentRegistration studentRegistration : studentRegistrations) {
+            if (oldRegMap.containsKey(studentRegistration.getUserId()) || hasUsers.contains(studentRegistration.getUserId())) {
+                continue;
+            }
+            hasUsers.add(studentRegistration.getUserId());
+            newRegs.add(studentRegistration);
+        }
+        studentRegistrations = newRegs;
+
         List<Integer> subjectIds = studentRegistrations.stream().map(StudentRegistration::getActualSubjectId).collect(Collectors.toList());
         List<Subject> subjects = subjectDao.findBySubjectIds(subjectIds);
         Map<Integer, List<Subject>> subjectMap = subjects.stream().collect(Collectors.groupingBy(Subject::getId));
@@ -2595,7 +2600,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             for (MusicGroupSubjectPlan musicGroupSubjectPlan : musicSubjectClassPlans) {
                 if (!subjectId.equals(musicGroupSubjectPlan.getSubjectId())) continue;
                 hasSubject = true;
-                musicGroupSubjectPlan.setApplyStudentNum(regs.size());
+                musicGroupSubjectPlan.setApplyStudentNum(musicGroupSubjectPlan.getApplyStudentNum() + regs.size());
                 subjectPlan = musicGroupSubjectPlan;
             }
             if (!hasSubject) {
@@ -2632,4 +2637,50 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         return studentRegistrationList;
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean closeMusicGroup(CloseMusicGroupDto closeMusicGroupDto) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new BizException("用户信息获取失败");
+        }
+        MusicGroup musicGroup = musicGroupDao.get(closeMusicGroupDto.getMusicGroupId());
+        if (musicGroup == null) {
+            throw new BizException("乐团找不到");
+        }
+
+        if (musicGroup.getStatus() != MusicGroupStatusEnum.PROGRESS) {
+            throw new BizException("乐团当前状态是{},不能关闭", musicGroup.getStatus().getMsg());
+        }
+
+        musicGroup.setStatus(MusicGroupStatusEnum.CLOSE);
+        musicGroup.setUpdateTime(new Date());
+        musicGroupDao.update(musicGroup);
+
+        musicGroupBuildLogDao.insert(new MusicGroupBuildLog(closeMusicGroupDto.getMusicGroupId(), "关闭乐团", sysUser.getId(), ""));
+
+        List<StudentRegistration> musicGroupRegs = studentRegistrationDao.findMusicGroupStudent(closeMusicGroupDto.getMusicGroupId(), null);
+        Map<Integer, BigDecimal> userReBackMap = closeMusicGroupDto.getUserReBack();
+        //退还没上课程费用
+        for (StudentRegistration musicGroupReg : musicGroupRegs) {
+            BigDecimal userReBack = userReBackMap.getOrDefault(musicGroupReg.getUserId(), BigDecimal.ZERO);
+
+            if (userReBack.compareTo(musicGroupReg.getSurplusCourseFee()) > 0) {
+                throw new BizException(musicGroupReg.getName() + "退费金额不能大于实际金额");
+            }
+            //退用户余额
+            if (userReBack.compareTo(BigDecimal.ZERO) > 0) {
+                sysUserCashAccountService.updateBalance(musicGroupReg.getUserId(), userReBack, PlatformCashAccountDetailTypeEnum.REFUNDS, "关闭乐团");
+            }
+            //清除剩余课程费用
+            if (musicGroupReg.getSurplusCourseFee().compareTo(BigDecimal.ZERO) > 0) {
+                studentRegistrationService.updateUserSurplusCourseFee(musicGroupReg.getUserId(), musicGroupReg.getMusicGroupId(), musicGroupReg.getSurplusCourseFee().negate(), "关闭乐团", sysUser.getId());
+            }
+        }
+
+        //删除未上课表
+        courseScheduleDao.logicDeleteCourseSchedulesByMusicGroupID(musicGroup.getId());
+        return true;
+    }
+
 }

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

@@ -148,6 +148,11 @@ public class MusicGroupSubjectPlanServiceImpl extends BaseServiceImpl<Integer, M
         boolean flag = false;
         for (int i = 10; i >= 1; i--) {
             MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, subjectId);
+            if(musicOneSubjectClassPlan == null){
+                MusicGroup musicGroup = musicGroupService.get(musicGroupId);
+                Subject subject = subjectService.get(subjectId);
+                throw new BizException("操作失败:{}乐团缺少{}声部",musicGroup.getName(),subject.getName());
+            }
             int applyNum = musicOneSubjectClassPlan.getApplyStudentNum() == null ? 0 : musicOneSubjectClassPlan.getApplyStudentNum();
             musicOneSubjectClassPlan.setApplyStudentNum(applyNum + num);
             musicOneSubjectClassPlan.setUpdateTime(new Date());

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

@@ -110,8 +110,8 @@ public class SporadicChargeInfoImpl extends BaseServiceImpl<Integer, SporadicCha
                 if (!appendCourseBalance) {
                     throw new BizException("增加用户课程余额失败");
                 }
-            } else if (info.getChargeType().getCode() == 9) { //零星收费账户充值
-                sysUserCashAccountService.updateBalance(userId, studentPaymentOrder.getActualAmount(), PlatformCashAccountDetailTypeEnum.RECHARGE, "零星收费账户充值", studentPaymentOrder.getTransNo());
+            } else if (info.getChargeType().getCode() == 9 || info.getChargeType().getCode() == 13) { //零星收费账户充值,网基课活动
+                sysUserCashAccountService.updateBalance(userId, studentPaymentOrder.getActualAmount(), PlatformCashAccountDetailTypeEnum.RECHARGE, "零星收费"+info.getChargeType().getMsg(), studentPaymentOrder.getTransNo());
             } else if (info.getOrganId().equals(42) && info.getChargeType().equals(SporadicChargeTypeEnum.LEVEL)) {
                 degreeRegistrationService.updateStatus(studentPaymentOrder);
                 return true;

+ 26 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -119,6 +119,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     public void queryOrderStatus() throws Exception {
         yqPayQuery(null);
         adaPayQuery(null);
+        reConfirmOrder(null, null);
     }
 
     private void yqPayQuery(List<StudentPaymentOrder> payingOrders) throws Exception {
@@ -254,19 +255,15 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         }
         order.setPaymentBusinessChannel(rpMap.get("channelType"));
 
+        callOrderCallBack(order);
+
         if (status.equals(DealStatusEnum.SUCCESS) && order.getPaymentChannel().equals("ADAPAY")
                 && !rpMap.containsKey("simulation")) {
             confirmOrder(order);
         }
-
-        callOrderCallBack(order);
     }
 
     private Boolean confirmOrder(StudentPaymentOrder order) {
-        String delayRouteStartDate = sysConfigDao.findConfigValue("delay_route_start_date");
-        if (order.getCreateTime().before(Objects.requireNonNull(DateUtil.stringToDate(delayRouteStartDate, "yyyy-MM-dd HH:mm:ss")))) {
-            return true;
-        }
         List<StudentPaymentRouteOrder> routeOrders = studentPaymentRouteOrderDao.getRouteOrders(order.getOrderNo());
         for (StudentPaymentRouteOrder routeOrder : routeOrders) {
             Map<String, Object> divMember = new HashMap<>();
@@ -472,4 +469,27 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     public List<StudentPaymentOrder> getUserOrderByType(Integer userId, OrderTypeEnum type, DealStatusEnum status) {
         return studentPaymentOrderDao.getUserOrderByType(userId, type, status);
     }
+
+    @Override
+    public List<StudentPaymentOrder> reConfirmOrder(Date startTime, Date endTime) {
+        if (startTime == null) {
+            endTime = new Date();
+            startTime = DateUtil.addMinutes(endTime, -20);
+        }
+
+        List<StudentPaymentOrder> orders = studentPaymentOrderDao.getAdaPayOrdersByTime(startTime, endTime);
+        String tips = "";
+        for (StudentPaymentOrder order : orders) {
+            try {
+                this.confirmOrder(order);
+            } catch (Exception e) {
+                tips += order.getOrderNo() + ":" + e.getMessage() + ",";
+                continue;
+            }
+        }
+        if (StringUtils.isNotBlank(tips)) {
+            throw new BizException(tips);
+        }
+        return orders;
+    }
 }

+ 39 - 18
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
@@ -839,8 +840,11 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public void insertStudent(String studentIds,String oldMusicGroupId,String newMusicGroupId,BigDecimal masterTotalPrice){
+        if(oldMusicGroupId == newMusicGroupId){
+            return;
+        }
         SysUser sysUser1 = sysUserFeignService.queryUserInfo();
         //获取旧乐团学员注册信息
         List<StudentRegistration> studentRegistrations = studentRegistrationDao.queryByUserIdsAndMusicGroupId(studentIds,oldMusicGroupId);
@@ -851,13 +855,14 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             if(studentRegistration.getSurplusCourseFee().doubleValue() > 0d && masterTotalPrice.doubleValue() > 0d){
                 StudentCourseFeeDetail studentCourseFeeDetail = new StudentCourseFeeDetail();
                 if(studentRegistration.getSurplusCourseFee().doubleValue() > masterTotalPrice.doubleValue()){
-                    studentCourseFeeDetail.setAmount(masterTotalPrice);
+                    amount = masterTotalPrice;
+                    studentCourseFeeDetail.setAmount(masterTotalPrice.negate());
                     studentCourseFeeDetail.setSurplusCourseFee(studentRegistration.getSurplusCourseFee().subtract(masterTotalPrice));
                 }else {
-                    studentCourseFeeDetail.setAmount(studentRegistration.getSurplusCourseFee());
+                    amount = studentRegistration.getSurplusCourseFee();
+                    studentCourseFeeDetail.setAmount(studentRegistration.getSurplusCourseFee().negate());
                     studentCourseFeeDetail.setSurplusCourseFee(BigDecimal.ZERO);
                 }
-                amount = studentCourseFeeDetail.getAmount();
                 studentCourseFeeDetail.setStudentRegistrationId(studentRegistration.getId());
                 studentRegistration.setSurplusCourseFee(studentCourseFeeDetail.getSurplusCourseFee());
                 studentCourseFeeDetail.setMemo("跨团合班消费");
@@ -874,31 +879,33 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentRegistrationDao.update(registration);
             }else {
                 //生成学员乐团注册表
+                studentRegistration.setOrganId(musicGroupDao.get(newMusicGroupId).getOrganId());
                 studentRegistration.setSurplusCourseFee(amount);
                 studentRegistration.setMusicGroupId(newMusicGroupId);
-                studentRegistrationDao.insertBasic(studentRegistration);
+                studentRegistrationDao.insert(studentRegistration);
                 registration = studentRegistration;
+
+                //增加报名学生数
+                musicGroupSubjectPlanService.addApplyStudentNum(newMusicGroupId, studentRegistration.getSubjectId(), 1);
+                //新增Fee表
+                MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(studentRegistration.getUserId(),newMusicGroupId);
+                if(musicGroupStudentFee == null){
+                    musicGroupStudentFee = new MusicGroupStudentFee(newMusicGroupId,
+                            studentRegistration.getUserId(), studentRegistration.getSubjectId(),BigDecimal.ZERO,
+                            null, studentRegistration.getTemporaryCourseFee(), studentRegistration.getPaymentStatus()==YES?PAID_COMPLETED:NON_PAYMENT);
+                    musicGroupStudentFeeDao.insert(musicGroupStudentFee);
+                }
             }
             //主班新增余额日志
-            if(studentRegistration.getSurplusCourseFee().doubleValue() > 0d && masterTotalPrice.doubleValue() > 0d){
+            if(amount.doubleValue() != 0d && masterTotalPrice.doubleValue() > 0d){
                 StudentCourseFeeDetail studentCourseFeeDetail = new StudentCourseFeeDetail();
                 studentCourseFeeDetail.setAmount(amount);
-                studentCourseFeeDetail.setSurplusCourseFee(registration.getSurplusCourseFee().add(amount));
-                studentCourseFeeDetail.setStudentRegistrationId(studentRegistration.getId());
+                studentCourseFeeDetail.setSurplusCourseFee(registration.getSurplusCourseFee());
+                studentCourseFeeDetail.setStudentRegistrationId(registration.getId());
                 studentCourseFeeDetail.setMemo("跨团合班费用转移");
                 studentCourseFeeDetail.setOperator(sysUser1.getId());
                 studentCourseFeeDetails.add(studentCourseFeeDetail);
             }
-            //增加报名学生数
-            musicGroupSubjectPlanService.addApplyStudentNum(newMusicGroupId, studentRegistration.getSubjectId(), 1);
-            //新增Fee表
-            MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(studentRegistration.getUserId(),oldMusicGroupId);
-            if(musicGroupStudentFee == null){
-                musicGroupStudentFee = new MusicGroupStudentFee(newMusicGroupId,
-                        studentRegistration.getUserId(), studentRegistration.getSubjectId(),BigDecimal.ZERO,
-                        null, studentRegistration.getTemporaryCourseFee(), studentRegistration.getPaymentStatus()==YES?PAID_COMPLETED:NON_PAYMENT);
-                musicGroupStudentFeeDao.insert(musicGroupStudentFee);
-            }
         }
         if(studentCourseFeeDetails.size() > 0){
             studentCourseFeeDetailDao.batchInsert(studentCourseFeeDetails);
@@ -1592,4 +1599,18 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 	public List<StudentMusicGroupDto> queryStudentMusicGroupInfo(Integer userId) {
 		return studentRegistrationDao.queryStudentMusicGroupInfo(userId);
 	}
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean delReg(Long id) {
+        StudentRegistration studentRegistration = studentRegistrationDao.get(id);
+        MusicGroupSubjectPlan subjectPlan = musicGroupSubjectPlanDao.findSubjectPlan(studentRegistration.getMusicGroupId(), studentRegistration.getSubjectId());
+        int delNum = studentRegistrationDao.delete(id);
+        subjectPlan.setApplyStudentNum(subjectPlan.getApplyStudentNum() - 1);
+        int updateNum = musicGroupSubjectPlanDao.update(subjectPlan);
+        if (delNum <= 0 || updateNum <= 0) {
+            throw new BizException("删除失败,请重试");
+        }
+        return true;
+    }
 }

+ 14 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -3384,6 +3384,12 @@
         WHERE cs.class_group_id_ = #{classGroupId}
         GROUP BY cs.type_
     </select>
+    <select id="querySubCourseTimeMap" resultType="java.util.Map">
+        SELECT cs.type_ 'key',SUM(ROUND((UNIX_TIMESTAMP(CONCAT(cs.class_date_,' ',cs.end_class_time_)) - UNIX_TIMESTAMP(CONCAT(cs.class_date_,' ',cs.start_class_time_)))/60)) 'value'
+        FROM course_schedule cs
+        WHERE cs.class_group_id_ = #{classGroupId} AND CONCAT(cs.class_date_,' ',cs.start_class_time_) > NOW()
+        GROUP BY cs.type_
+    </select>
     <select id="findClassMaxCourseNumMap" resultType="java.util.Map">
         SELECT c.type_ 'key',MAX(c.subCourseNum) 'value' FROM (SELECT cs.type_,COUNT(cs.id_) subCourseNum FROM course_schedule cs
         WHERE cs.class_group_id_ IN
@@ -3489,4 +3495,12 @@
         WHERE cssp.user_id_ = #{studentId} AND CONCAT(cs.class_date_,' ',cs.start_class_time_) > NOW()
         AND vg.educational_teacher_id_ = #{teacherId}
     </select>
+    <select id="findCoursesByClassGroupIdAndCourseIds" resultMap="CourseSchedule">
+        SELECT * FROM course_schedule WHERE class_group_id_ = #{classGroupId}
+        AND id_ IN
+        <foreach collection="allLockCourseIds" item="courseId" open="(" close=")" separator=",">
+            #{courseId}
+        </foreach>
+        ORDER BY class_date_,start_class_time_ ASC
+    </select>
 </mapper>

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

@@ -863,4 +863,8 @@
         WHERE spo.user_id_ = #{userId} AND spo.type_='APPLY' AND spo.music_group_id_=#{musicGroupId}
         ORDER BY spo.id_ desc
     </select>
+
+    <select id="getAdaPayOrdersByTime" resultMap="StudentPaymentOrder"><![CDATA[
+        SELECT * FROM student_payment_order WHERE create_time_ >= #{startTime} AND create_time_ <= #{endTime} AND payment_channel_='ADAPAY' AND status_ ='SUCCESS']]>
+    </select>
 </mapper>

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentRouteOrderMapper.xml

@@ -253,6 +253,9 @@
                 AND spo.group_type_='SPORADIC'
                 AND sci.charge_type_ = #{chargeType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
             </if>
+            <if test="noneTqType != null">
+                and spo.mer_no_ != '淘器微信'
+            </if>
         </where>
     </sql>
     <select id="getRouteOrders" resultMap="StudentPaymentRouteOrder">

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

@@ -488,7 +488,8 @@
         </foreach>
     </insert>
 
-    <insert id="insertBasic" parameterType="com.ym.mec.biz.dal.entity.StudentRegistration">
+    <insert id="insertBasic" parameterType="com.ym.mec.biz.dal.entity.StudentRegistration" useGeneratedKeys="true"
+            keyColumn="id" keyProperty="id">
         INSERT INTO student_registration
         (parents_phone_,user_id_,name_,music_group_id_,current_grade_,current_class_,subject_id_,
         create_time_,update_time_,parents_name_,payment_status_,actual_subject_id_,music_group_status_,temporary_course_fee_,class_group_id_)

+ 12 - 3
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -139,7 +139,7 @@ public class StudentOrderController extends BaseController {
             List<StudentPaymentOrderDetail> orderDetail1 = studentPaymentOrderDetailService.getOrderDetail(orderByOrderNo.getId());
             String kitGroupPurchaseType = orderDetail1.stream().filter(e -> e.getGoodsList() != null).filter(e -> e.getKitGroupPurchaseType() != null).map(e -> e.getKitGroupPurchaseType().getCode()).collect(Collectors.joining(","));
             orderDetail.put("goods", goodsList);
-            orderDetail.put("kitGroupPurchaseType",kitGroupPurchaseType);
+            orderDetail.put("kitGroupPurchaseType", kitGroupPurchaseType);
             orderDetail.put("course", musicGroup.getCourseForm());
             orderDetail.put("ownershipType", musicGroup.getOwnershipType());
             orderDetail.put("detailType", orderDetailType);
@@ -754,12 +754,21 @@ public class StudentOrderController extends BaseController {
     }
 
     @GetMapping("/getUserApplyOrders")
-    public HttpResponseResult<List<StudentPaymentOrderExportDto>> getUserApplyOrders(String musicGroupId){
+    public HttpResponseResult<List<StudentPaymentOrderExportDto>> getUserApplyOrders(String musicGroupId) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if (sysUser == null) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
-        return succeed(studentPaymentOrderDao.getUserApplyOrders(sysUser.getId(),musicGroupId));
+        return succeed(studentPaymentOrderDao.getUserApplyOrders(sysUser.getId(), musicGroupId));
     }
 
+    @GetMapping("/reConfirmOrder")
+    public HttpResponseResult<List<StudentPaymentOrder>> reConfirmOrder(Date startTime, Date endTime) {
+        if (!profiles.equals("prod")) {
+            return failed("测试环境不支持");
+        }
+        return succeed(studentPaymentOrderService.reConfirmOrder(startTime, endTime));
+    }
+
+
 }

+ 1 - 1
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/Payment.java

@@ -96,7 +96,7 @@ public class Payment {
         System.out.println("支付查询返回参数:" + JSON.toJSONString(payment));
 
         String error_code = (String) payment.get("error_code");
-        if (null == error_code) {
+        if (null != error_code) {
             String error_msg = (String) payment.get("error_msg");
             System.out.println("error_code:" + error_code + "............." + error_msg);
         }

+ 8 - 0
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupController.java

@@ -1,5 +1,6 @@
 package com.ym.mec.web.controller;
 
+import com.ym.mec.biz.dal.dto.CloseMusicGroupDto;
 import com.ym.mec.biz.dal.dto.MusicGroupRegsDto;
 import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -290,4 +291,11 @@ public class MusicGroupController extends BaseController {
 		return succeed(musicGroupService.addMusicGroupRegs(musicGroupRegsDto.getMusicGroupId(),musicGroupRegsDto.getRegisterIds()));
 	}
 
+	@ApiOperation(value = "关闭乐团")
+	@PostMapping("/closeMusicGroup")
+	@PreAuthorize("@pcs.hasPermissions('musicGroup/closeMusicGroup')")
+	public HttpResponseResult<Boolean> closeMusicGroup(CloseMusicGroupDto closeMusicGroupDto) {
+		return succeed(musicGroupService.closeMusicGroup(closeMusicGroupDto));
+	}
+
 }

+ 12 - 0
mec-web/src/main/java/com/ym/mec/web/controller/StudentRegistrationController.java

@@ -11,6 +11,7 @@ import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
 import com.ym.mec.biz.service.StudentRegistrationService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.exception.BizException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -179,4 +180,15 @@ public class StudentRegistrationController extends BaseController {
         return succeed(studentRegistrationService.getClassGroupCourseExpectPrice(classGroupIds));
     }
 
+    @ApiOperation(value = "删除报名的学生")
+    @PostMapping("/del")
+    @PreAuthorize("@pcs.hasPermissions('studentRegistration/del')")
+    public HttpResponseResult<Boolean> del(Long id) {
+        StudentRegistration studentRegistration = studentRegistrationService.get(id);
+        if(studentRegistration == null){
+            return failed("删除的报名信息不存在");
+        }
+        return succeed(studentRegistrationService.delReg(id));
+    }
+
 }