Browse Source

活动排课

zouxuan 4 years ago
parent
commit
b5222412a0

+ 16 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/PracticeGroupDao.java

@@ -388,4 +388,20 @@ public interface PracticeGroupDao extends com.ym.mec.common.dal.BaseDAO<Long, Pr
      * @return
      * @return
      */
      */
     String getStudentEduTeacher(@Param("studentId") Integer studentId);
     String getStudentEduTeacher(@Param("studentId") Integer studentId);
+
+    /**
+    * @description: 统计学员在指定活动上关联的次数
+     * @param vipGroupActivityId
+    * @param studentId
+    * @return int
+    * @author zx
+    * @date 2021/10/8 14:59
+    */
+    int countStudentUserActivityNum(@Param("vipGroupActivityId") Integer vipGroupActivityId, @Param("studentId") Integer studentId);
+
+
+
+    int countUserRepeatPracticeGroupInCourseStartEndTime(@Param("userId") Integer userId,
+                                                    @Param("courseStartDate") Date courseStartDate,
+                                                    @Param("courseEndDate") Date courseEndDate);
 }
 }

+ 38 - 34
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/PracticeGroupApplyBaseInfoDto.java

@@ -1,12 +1,12 @@
 package com.ym.mec.biz.dal.dto;
 package com.ym.mec.biz.dal.dto;
 
 
 import com.ym.mec.biz.dal.entity.PracticeGroup;
 import com.ym.mec.biz.dal.entity.PracticeGroup;
-import com.ym.mec.biz.dal.entity.VipGroup;
 import com.ym.mec.biz.dal.entity.VipGroupStudentCoursePrice;
 import com.ym.mec.biz.dal.entity.VipGroupStudentCoursePrice;
 import com.ym.mec.biz.dal.enums.ActivityCourseType;
 import com.ym.mec.biz.dal.enums.ActivityCourseType;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 
 
 public class PracticeGroupApplyBaseInfoDto extends PracticeGroup {
 public class PracticeGroupApplyBaseInfoDto extends PracticeGroup {
@@ -17,41 +17,61 @@ public class PracticeGroupApplyBaseInfoDto extends PracticeGroup {
     @ApiModelProperty(value = "课时总数")
     @ApiModelProperty(value = "课时总数")
     private Integer allCourseNum;
     private Integer allCourseNum;
 
 
-    @ApiModelProperty(value = "教师ID",required = false)
-    private Long teacherId;
-
     @ApiModelProperty(value = "课酬",required = false)
     @ApiModelProperty(value = "课酬",required = false)
     private BigDecimal salary;
     private BigDecimal salary;
 
 
-    @ApiModelProperty(value = "预计招生人数",hidden = true)
-    private Integer expectStudentNum;
-
     @ApiModelProperty(value = "教师线上课课酬")
     @ApiModelProperty(value = "教师线上课课酬")
     private BigDecimal onlineTeacherSalary;
     private BigDecimal onlineTeacherSalary;
 
 
     @ApiModelProperty(value = "课程组学员缴费设置")
     @ApiModelProperty(value = "课程组学员缴费设置")
     private List<VipGroupStudentCoursePrice> vipGroupStudentCoursePrices;
     private List<VipGroupStudentCoursePrice> vipGroupStudentCoursePrices;
 
 
-    @ApiModelProperty(value = "第一个选择的学员")
-    private Integer firstStudentId;
-
     @ApiModelProperty(value = "活动课程类型")
     @ApiModelProperty(value = "活动课程类型")
     private ActivityCourseType activityCourseType;
     private ActivityCourseType activityCourseType;
 
 
-    public ActivityCourseType getActivityCourseType() {
-        return activityCourseType;
+    /** 缴费截止时间 */
+    @ApiModelProperty(value = "缴费截止时间", required = false)
+    private java.util.Date paymentExpireDate;
+
+    /** 课程结束日期 */
+    @ApiModelProperty(value = "课程结束日期", required = false)
+    private java.util.Date coursesExpireDate;
+
+    @ApiModelProperty(value = "报名开始时间", required = false)
+    private Date registrationStartTime;
+
+    public Date getPaymentExpireDate() {
+        return paymentExpireDate;
     }
     }
 
 
-    public void setActivityCourseType(ActivityCourseType activityCourseType) {
-        this.activityCourseType = activityCourseType;
+    public void setPaymentExpireDate(Date paymentExpireDate) {
+        this.paymentExpireDate = paymentExpireDate;
+    }
+
+    @Override
+    public Date getCoursesExpireDate() {
+        return coursesExpireDate;
+    }
+
+    @Override
+    public void setCoursesExpireDate(Date coursesExpireDate) {
+        this.coursesExpireDate = coursesExpireDate;
+    }
+
+    public Date getRegistrationStartTime() {
+        return registrationStartTime;
+    }
+
+    public void setRegistrationStartTime(Date registrationStartTime) {
+        this.registrationStartTime = registrationStartTime;
     }
     }
 
 
-    public Integer getFirstStudentId() {
-        return firstStudentId;
+    public ActivityCourseType getActivityCourseType() {
+        return activityCourseType;
     }
     }
 
 
-    public void setFirstStudentId(Integer firstStudentId) {
-        this.firstStudentId = firstStudentId;
+    public void setActivityCourseType(ActivityCourseType activityCourseType) {
+        this.activityCourseType = activityCourseType;
     }
     }
 
 
     public List<VipGroupStudentCoursePrice> getVipGroupStudentCoursePrices() {
     public List<VipGroupStudentCoursePrice> getVipGroupStudentCoursePrices() {
@@ -86,22 +106,6 @@ public class PracticeGroupApplyBaseInfoDto extends PracticeGroup {
         this.allCourseNum = allCourseNum;
         this.allCourseNum = allCourseNum;
     }
     }
 
 
-    public Long getTeacherId() {
-        return teacherId;
-    }
-
-    public void setTeacherId(Long teacherId) {
-        this.teacherId = teacherId;
-    }
-
-    public Integer getExpectStudentNum() {
-        return expectStudentNum;
-    }
-
-    public void setExpectStudentNum(Integer expectStudentNum) {
-        this.expectStudentNum = expectStudentNum;
-    }
-
     public BigDecimal getSalary() {
     public BigDecimal getSalary() {
         return salary;
         return salary;
     }
     }

+ 1 - 11
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/PracticeGroupApplyDto.java

@@ -7,7 +7,7 @@ import java.util.List;
 
 
 public class PracticeGroupApplyDto {
 public class PracticeGroupApplyDto {
 
 
-    @ApiModelProperty(value = "vip课基本信息",required = false)
+    @ApiModelProperty(value = "网管课基本信息",required = false)
     private PracticeGroupApplyBaseInfoDto practiceGroupApplyBaseInfoDto;
     private PracticeGroupApplyBaseInfoDto practiceGroupApplyBaseInfoDto;
 
 
     @ApiModelProperty(value = "课程计划列表",required = false)
     @ApiModelProperty(value = "课程计划列表",required = false)
@@ -37,16 +37,6 @@ public class PracticeGroupApplyDto {
         this.singleClassPrice = singleClassPrice;
         this.singleClassPrice = singleClassPrice;
     }
     }
 
 
-    private String studentIds;
-
-    public String getStudentIds() {
-        return studentIds;
-    }
-
-    public void setStudentIds(String studentIds) {
-        this.studentIds = studentIds;
-    }
-
     public PracticeGroupApplyBaseInfoDto getPracticeGroupApplyBaseInfoDto() {
     public PracticeGroupApplyBaseInfoDto getPracticeGroupApplyBaseInfoDto() {
         return practiceGroupApplyBaseInfoDto;
         return practiceGroupApplyBaseInfoDto;
     }
     }

+ 16 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/PracticeGroup.java

@@ -1,7 +1,9 @@
 package com.ym.mec.biz.dal.entity;
 package com.ym.mec.biz.dal.entity;
 
 
+import com.ym.mec.biz.dal.enums.AuditStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupStatusEnum;
 import com.ym.mec.biz.dal.enums.PracticeGroupType;
 import com.ym.mec.biz.dal.enums.PracticeGroupType;
+import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 
 import java.util.Date;
 import java.util.Date;
@@ -21,10 +23,11 @@ public class PracticeGroup {
 	private Integer subjectId;
 	private Integer subjectId;
 	
 	
 	private PracticeGroupType type;
 	private PracticeGroupType type;
-	
-	/**  */
+
+	@ApiModelProperty(value = "教师ID",required = false)
 	private Integer userId;
 	private Integer userId;
 
 
+	@ApiModelProperty(value = "学员ID",required = false)
 	private Integer studentId;
 	private Integer studentId;
 	
 	
 	/**  */
 	/**  */
@@ -62,12 +65,23 @@ public class PracticeGroup {
 
 
 	private GroupStatusEnum groupStatus;
 	private GroupStatusEnum groupStatus;
 
 
+	@ApiModelProperty(value = "审批状态",required = false)
+	private AuditStatusEnum auditStatus;
+
 	private Long beRenewGroupId;
 	private Long beRenewGroupId;
 
 
 	private Integer educationalTeacherId;
 	private Integer educationalTeacherId;
 
 
 	private Integer vipGroupActivityId;
 	private Integer vipGroupActivityId;
 
 
+	public AuditStatusEnum getAuditStatus() {
+		return auditStatus;
+	}
+
+	public void setAuditStatus(AuditStatusEnum auditStatus) {
+		this.auditStatus = auditStatus;
+	}
+
 	public Integer getVipGroupActivityId() {
 	public Integer getVipGroupActivityId() {
 		return vipGroupActivityId;
 		return vipGroupActivityId;
 	}
 	}

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

@@ -23,7 +23,7 @@ public interface VipGroupActivityService extends BaseService<Integer, VipGroupAc
      * @Date: 2019/10/1
      * @Date: 2019/10/1
      * 修改vip课活动方案
      * 修改vip课活动方案
      */
      */
-    void updateVipGroupActivity(VipGroupActivityAddDto vipGroupActivityAddDto, Integer operatorId);
+    VipGroupActivityAddDto updateVipGroupActivity(VipGroupActivityAddDto vipGroupActivityAddDto, Integer operatorId);
 
 
     /**
     /**
      * @Author: Joburgess
      * @Author: Joburgess

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

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.auth.api.entity.SysUserRole;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.entity.*;
@@ -4309,13 +4310,239 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         //课程购买费用计算
         //课程购买费用计算
         BigDecimal totalPrice = onlineVipGroupCharge.add(onlineVipGroupCharge);
         BigDecimal totalPrice = onlineVipGroupCharge.add(onlineVipGroupCharge);
         totalPrice = totalPrice.multiply(vipGroupActivity.getDiscount()).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
         totalPrice = totalPrice.multiply(vipGroupActivity.getDiscount()).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
-        results.put("totalPrice",totalPrice.setScale(0,BigDecimal.ROUND_CEILING));
+        results.put("onlineTeacherSalary",totalPrice.setScale(0,BigDecimal.ROUND_CEILING));
         return results;
         return results;
     }
     }
 
 
     @Override
     @Override
-    public Object createPracticeGroup(PracticeGroupApplyDto practiceGroupApplyDto) {
+    public Object createPracticeGroup(PracticeGroupApplyDto practice) {
+        PracticeGroupApplyBaseInfoDto applyBaseInfoDto = practice.getPracticeGroupApplyBaseInfoDto();
+        if (Objects.isNull(applyBaseInfoDto.getUserId())){
+            throw new BizException("请选择指导老师");
+        }
+
+        List<CourseSchedule> courseSchedules = practice.getCourseSchedules();
+        if(courseSchedules.size() != applyBaseInfoDto.getAllCourseNum()){
+            throw new BizException("建课失败,当前课程存在未排课课程,请调整相关设置");
+        }
+
+        Integer studentId = applyBaseInfoDto.getStudentId();
+
+        Date now = new Date();
+
+        if(studentId == null){
+            throw new BizException("请选择学员");
+        }
+
+        Integer totalClassTimes = applyBaseInfoDto.getAllCourseNum();
+        //获取第一节课
+        CourseSchedule firstCourseSchedule = courseSchedules.stream().min(Comparator.comparing(CourseSchedule::getStartClassTime)).get();
+        //获取最后一节课
+        CourseSchedule latestCourseSchedule = courseSchedules.stream().max(Comparator.comparing(CourseSchedule::getEndClassTime)).get();
+
+        if(firstCourseSchedule.getStartClassTime().before(now)){
+            throw new BizException("开课时间不能小于当前时间");
+        }
+
+        if(applyBaseInfoDto.getRegistrationStartTime().after(applyBaseInfoDto.getPaymentExpireDate())){
+            throw new BizException("报名开始时间必须在报名截至时间之前");
+        }
+
+        if(applyBaseInfoDto.getPaymentExpireDate().after(firstCourseSchedule.getStartClassTime())
+                ||DateUtil.isSameDay(applyBaseInfoDto.getPaymentExpireDate(),firstCourseSchedule.getEndClassTime())){
+            throw new BizException("创建失败,报名截止时间必须在开课时间前一天");
+        }
+
+        List<VipGroupStudentCoursePrice> vscps = applyBaseInfoDto.getVipGroupStudentCoursePrices();
+
+        SysUser user = teacherDao.getUser(studentId);
+        String userName = StringUtils.isEmpty(user.getUsername()) ? user.getRealName() : user.getUsername();
+        //获取活动信息
+        VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(applyBaseInfoDto.getVipGroupActivityId());
+        if(Objects.nonNull(vipGroupActivity) && !practice.getAllowOverstepActivityStudentNum() &&
+                Objects.nonNull(vipGroupActivity.getStudentMaxUsedTimes())&&vipGroupActivity.getStudentMaxUsedTimes() != -1){
+            int useNum = practiceGroupDao.countStudentUserActivityNum(applyBaseInfoDto.getVipGroupActivityId(), studentId);
+            if(useNum >= vipGroupActivity.getStudentMaxUsedTimes()){
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return BaseController.failed(HttpStatus.PARTIAL_CONTENT,"该活动 "+userName+" 学员创建及成课之和已达上限,是否继续创建该课程?");
+            }
+        }
+        //判断课程安排是否超出范围
+        if(Objects.nonNull(vipGroupActivity) && (Objects.nonNull(vipGroupActivity.getCoursesEndTime())||
+                Objects.nonNull(vipGroupActivity.getCoursesStartTime()))){
+            if(latestCourseSchedule.getEndClassTime().after(vipGroupActivity.getCoursesEndTime())
+                    ||firstCourseSchedule.getStartClassTime().before(vipGroupActivity.getCoursesStartTime())){
+                throw new BizException("课时安排时间超出范围!");
+            }
+        }
+
+        if(Objects.nonNull(vipGroupActivity)&&Objects.nonNull(vipGroupActivity.getMinCourseNum())&&vipGroupActivity.getMinCourseNum()!=-1&&Objects.nonNull(vipGroupActivity.getMaxCourseNum())&&vipGroupActivity.getMaxCourseNum()!=-1){
+            if(totalClassTimes.compareTo(vipGroupActivity.getMinCourseNum())<0||totalClassTimes.compareTo(vipGroupActivity.getMaxCourseNum())>0){
+                throw new BizException("该活动课时数为{}节~{}节", vipGroupActivity.getMinCourseNum(), vipGroupActivity.getMaxCourseNum());
+            }
+        }
+
+        int repeatVipGroups = practiceGroupDao.countUserRepeatPracticeGroupInCourseStartEndTime(studentId, firstCourseSchedule.getStartClassTime(), latestCourseSchedule.getEndClassTime());
+        if(repeatVipGroups>0){
+            throw new BizException("请勿重复提交");
+        }
+
+        //生成网管课信息
+        List<String> bySubIds = subjectDao.findBySubIds(applyBaseInfoDto.getSubjectIdList());
+        StringBuffer className = new StringBuffer(StringUtils.join(bySubIds,","));
+        className.append("•").append(userName);
+        applyBaseInfoDto.setName(className.toString());
+
+        //计算课程相关费用信息
+        Map<String, BigDecimal> costInfo = countPracticeGroupPredictFee(applyBaseInfoDto,studentId, null);
+
+        applyBaseInfoDto.setAuditStatus(AuditStatusEnum.PASS);
+
+        //如果默认课酬与实际课酬不匹配则需要审批
+        if(costInfo.get("onlineTeacherSalary").compareTo(applyBaseInfoDto.getOnlineTeacherSalary()) < 0){
+            applyBaseInfoDto.setAuditStatus(AuditStatusEnum.ING);
+        }
 
 
+        applyBaseInfoDto.setOnlineTeacherSalary(costInfo.get("onlineTeacherSalary"));
+        applyBaseInfoDto.setGroupStatus(GroupStatusEnum.APPLYING);
+//        if(CollectionUtils.isEmpty(vscps)){
+//            vscps = new ArrayList<>();
+//            vscps.add(new VipGroupStudentCoursePrice(studentId, applyBaseInfoDto.getOfflineClassesUnitPrice(),
+//                    vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice(), vipGroupApplyBaseInfoDto.getTotalPrice()));
+//        }
+        Teacher teacher = teacherService.get(applyBaseInfoDto.getUserId());
+        if(Objects.isNull(teacher)){
+            throw new BizException("教师不存在");
+        }
+        if(Objects.isNull(teacher.getTeacherOrganId())){
+            throw new BizException("教师部门异常");
+        }
         return null;
         return null;
+//        vipGroupApplyBaseInfoDto.setOrganId(Integer.parseInt(teacher.getOrganId()));
+        //开课时间为排课的第一节课的开始时间
+//        vipGroupApplyBaseInfoDto.setCourseStartDate(firstCourseSchedule.getStartClassTime());
+//        //课程结束时间为排课的最后一节课的结束时间
+//        vipGroupApplyBaseInfoDto.setCoursesExpireDate(latestCourseSchedule.getEndClassTime());
+//
+//        vipGroupApplyBaseInfoDto.setPaymentExpireDate(DateUtil.getLastSecondWithDay(vipGroupApplyBaseInfoDto.getPaymentExpireDate()));
+//
+//        VipGroupDefaultClassesUnitPrice vipGroupDefaultClassesUnitPrice = vipGroupDefaultClassesUnitPriceDao.getByVipGroupCategory(vipGroup.getVipGroupApplyBaseInfo().getVipGroupCategoryId(), vipGroup.getVipGroupApplyBaseInfo().getOrganId());
+//
+//        if(Objects.isNull(vipGroupDefaultClassesUnitPrice)){
+//            vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.ING);
+//        }else{
+//            if(Objects.nonNull(vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice())
+//                    &&vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice().compareTo(vipGroupDefaultClassesUnitPrice.getOfflineClassesUnitPrice())!=0){
+//                vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.ING);
+//            }
+//            if(Objects.nonNull(vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice())
+//                    &&vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice().compareTo(vipGroupDefaultClassesUnitPrice.getOnlineClassesUnitPrice())!=0){
+//                vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.ING);
+//            }
+//        }
+//
+//        if(StringUtils.isBlank(vipGroupApplyBaseInfoDto.getStudentIdList())){
+//            vipGroupApplyBaseInfoDto.setStudentIdList(StringUtils.join(vscps.stream().map(VipGroupStudentCoursePrice::getStudentId).collect(Collectors.toList()), ","));
+//        }
+//
+//        if(vipGroup.getOnlyProgress()){
+//            vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.PASS);
+//        }
+//
+//        vipGroupDao.insert(vipGroupApplyBaseInfoDto);
+//
+//        vscps.forEach(e->e.setVipGroupId(vipGroupApplyBaseInfoDto.getId()));
+//        vipGroupStudentCoursePriceDao.batchInsert(vscps);
+//
+//        vipGroup.getVipGroupApplyBaseInfo().setId(vipGroupApplyBaseInfoDto.getId());
+//
+//        //创建班级信息
+//        ClassGroup classGroup=new ClassGroup();
+//        classGroup.setSubjectIdList(vipGroupApplyBaseInfoDto.getSubjectIdList());
+//        classGroup.setExpectStudentNum(vipGroupCategory.getStudentNum());
+//        if(StringUtils.isNotBlank(studentIds)){
+//            classGroup.setStudentNum(studentIdList.size());
+//        }
+//        classGroup.setName(vipGroupApplyBaseInfoDto.getName());
+//        classGroup.setExpectStudentNum(vipGroupApplyBaseInfoDto.getStudentNum());
+//        classGroup.setTotalClassTimes(totalClassTimes);
+//        classGroup.setType(ClassGroupTypeEnum.VIP);
+//        classGroup.setDelFlag(1);
+//        classGroup.setGroupType(GroupType.VIP);
+//        classGroup.setMusicGroupId(vipGroupApplyBaseInfoDto.getId().toString());
+//        classGroup.setCreateTime(now);
+//        classGroup.setUpdateTime(now);
+//        classGroupDao.insert(classGroup);
+//
+//        //创建班级老师关联记录
+//        ClassGroupTeacherMapper classGroupTeacherMapper=new ClassGroupTeacherMapper();
+//        classGroupTeacherMapper.setMusicGroupId(vipGroupApplyBaseInfoDto.getId().toString());
+//        classGroupTeacherMapper.setClassGroupId(classGroup.getId());
+//        classGroupTeacherMapper.setTeacherRole(TeachTypeEnum.BISHOP);
+//        classGroupTeacherMapper.setUserId(vipGroupApplyBaseInfoDto.getUserId());
+//        classGroupTeacherMapper.setGroupType(GroupType.VIP);
+//        classGroupTeacherMapper.setCreateTime(now);
+//        classGroupTeacherMapper.setUpdateTime(now);
+//        classGroupTeacherMapperDao.insert(classGroupTeacherMapper);
+//
+//        //创建班级与老师课酬记录
+//        ClassGroupTeacherSalary classGroupTeacherSalary=new ClassGroupTeacherSalary();
+//        classGroupTeacherSalary.setMusicGroupId(vipGroupApplyBaseInfoDto.getId().toString());
+//        classGroupTeacherSalary.setClassGroupId(classGroup.getId());
+//        classGroupTeacherSalary.setTeacherRole(TeachTypeEnum.BISHOP);
+//        classGroupTeacherSalary.setUserId(vipGroupApplyBaseInfoDto.getUserId());
+//        classGroupTeacherSalary.setSalary(vipGroupApplyBaseInfoDto.getOfflineTeacherSalary());
+//        classGroupTeacherSalary.setOnlineClassesSalary(vipGroupApplyBaseInfoDto.getOnlineTeacherSalary());
+//        classGroupTeacherSalary.setGroupType(GroupType.VIP);
+//        classGroupTeacherSalary.setCreateTime(now);
+//        classGroupTeacherSalary.setUpdateTime(now);
+//        classGroupTeacherSalaryDao.insert(classGroupTeacherSalary);
+//
+//        //课程信息调整
+//        vipGroup.getCourseSchedules().forEach(courseSchedule -> {
+//            courseSchedule.setGroupType(GroupType.VIP);
+//            courseSchedule.setMusicGroupId(vipGroupApplyBaseInfoDto.getId().toString());
+//            if(courseSchedule.getTeachMode().equals(TeachModeEnum.OFFLINE)){
+//                courseSchedule.setSchoolId(vipGroup.getVipGroupApplyBaseInfo().getTeacherSchoolId());
+//            }
+//            courseSchedule.setTeacherId(vipGroupApplyBaseInfoDto.getUserId());
+//            courseSchedule.setActualTeacherId(vipGroupApplyBaseInfoDto.getUserId());
+//            courseSchedule.setStatus(CourseStatusEnum.NOT_START);
+//            courseSchedule.setType(CourseSchedule.CourseScheduleType.VIP);
+//            courseSchedule.setClassGroupId(classGroup.getId());
+//            courseSchedule.setName(vipGroupApplyBaseInfoDto.getName());
+//            courseSchedule.setOrganId(vipGroupApplyBaseInfoDto.getOrganId());
+//        });
+//        courseScheduleService.checkNewCourseSchedules(vipGroup.getCourseSchedules(),false,false);
+//        vipGroupApplyBaseInfoDto.setCourseSchedulesJson(JSON.toJSONString(vipGroup.getCourseSchedules()));
+//        vipGroupDao.update(vipGroupApplyBaseInfoDto);
+//
+//        if(StringUtils.isNotBlank(studentIds)){
+//            List<Integer> collect = studentIdList.stream().mapToInt(Integer::parseInt).boxed().collect(Collectors.toList());
+//            classGroupService.addStudentIntoClassGroup(vipGroupApplyBaseInfoDto.getId().toString(),classGroup.getId(),collect);
+//            createVipGroupCourseScheInfo(vipGroupApplyBaseInfoDto.getId(),classGroup);
+//        }
+//
+//        Set<Integer> roleIds = new HashSet<>(1);
+//        roleIds.add(SysUserRole.SECTION_MANAGER);
+//        Map<String,Long> memo = new HashMap<>(1);
+//        memo.put("vipGroupId",vipGroupApplyBaseInfoDto.getId());
+////		SysUser sysUser = sysUserFeignService.queryUserById(vipGroup.getVipGroupApplyBaseInfo().getUserId());
+//        if(Objects.isNull(teacher)){
+//            throw new BizException("该用户不存在");
+//        }
+//        Set<Integer> userIds = musicGroupDao.queryUserIdByRoleId(roleIds,teacher.getTeacherOrganId());
+//        if(CollectionUtils.isEmpty(userIds)){
+//            throw new BizException("当前分部没有运营主管,无法创建,请联系总部工作人员!");
+//        }
+//        if(vipGroupApplyBaseInfoDto.getEducationalTeacherId() != null){
+//            userIds.add(vipGroupApplyBaseInfoDto.getEducationalTeacherId());
+//        }
+////		if (vipGroup.getVipGroupApplyBaseInfo().getUserId() != null){
+////			sysMessageService.batchSeoMessage(userIds,MessageTypeEnum.BACKSTAGE_VIP_COURSE_APPLY, JSONObject.toJSONString(memo),sysUser.getUsername(),sysUser.getUsername());
+////		}else {
+//        sysMessageService.batchSeoMessage(userIds,MessageTypeEnum.BACKSTAGE_TEACHER_APPLY_VIP, JSONObject.toJSONString(memo),teacher.getRealName());
+////		}
+//        return BaseController.succeed(vipGroupApplyBaseInfoDto.getAuditStatus().getCode());
     }
     }
 }
 }

+ 11 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupActivityServiceImpl.java

@@ -44,7 +44,7 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
 	}
 	}
 
 
 	private void checkSettlement(VipGroupSalarySettlementTypeDto settlementTypeDto){
 	private void checkSettlement(VipGroupSalarySettlementTypeDto settlementTypeDto){
-		if(Objects.nonNull(settlementTypeDto)){
+		if(Objects.nonNull(settlementTypeDto) && settlementTypeDto.getSalarySettlementType() != null){
 			switch (settlementTypeDto.getSalarySettlementType()){
 			switch (settlementTypeDto.getSalarySettlementType()){
 				case TEACHER_DEFAULT:
 				case TEACHER_DEFAULT:
 					break;
 					break;
@@ -116,7 +116,7 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
 
 
 	@Override
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	@Transactional(rollbackFor = Exception.class)
-	public void updateVipGroupActivity(VipGroupActivityAddDto vipGroupActivityAddDto, Integer operatorId) {
+	public VipGroupActivityAddDto updateVipGroupActivity(VipGroupActivityAddDto vipGroupActivityAddDto, Integer operatorId) {
 		VipGroupActivity oldVipGroupActivity = vipGroupActivityDao.get(vipGroupActivityAddDto.getId());
 		VipGroupActivity oldVipGroupActivity = vipGroupActivityDao.get(vipGroupActivityAddDto.getId());
 		if(Objects.isNull(oldVipGroupActivity)){
 		if(Objects.isNull(oldVipGroupActivity)){
 			throw new BizException("活动不存在!");
 			throw new BizException("活动不存在!");
@@ -125,13 +125,14 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
 			throw new BizException("请指定部门!");
 			throw new BizException("请指定部门!");
 		}
 		}
 		VipGroupSalarySettlementDto vipGroupSalarySettlement = vipGroupActivityAddDto.getVipGroupSalarySettlement();
 		VipGroupSalarySettlementDto vipGroupSalarySettlement = vipGroupActivityAddDto.getVipGroupSalarySettlement();
-		checkSettlement(vipGroupSalarySettlement.getVipOnlineSalarySettlement());
-		checkSettlement(vipGroupSalarySettlement.getVipOfflineSalarySettlement());
-		checkSettlement(vipGroupSalarySettlement.getGiveVipOnlineSalarySettlement());
-		checkSettlement(vipGroupSalarySettlement.getGiveVipOfflineSalarySettlement());
-		checkSettlement(vipGroupSalarySettlement.getPracticeSalarySettlement());
-		checkSettlement(vipGroupSalarySettlement.getGivePracticeSalarySettlement());
-
+		if(vipGroupSalarySettlement != null){
+			checkSettlement(vipGroupSalarySettlement.getVipOnlineSalarySettlement());
+			checkSettlement(vipGroupSalarySettlement.getVipOfflineSalarySettlement());
+			checkSettlement(vipGroupSalarySettlement.getGiveVipOnlineSalarySettlement());
+			checkSettlement(vipGroupSalarySettlement.getGiveVipOfflineSalarySettlement());
+			checkSettlement(vipGroupSalarySettlement.getPracticeSalarySettlement());
+			checkSettlement(vipGroupSalarySettlement.getGivePracticeSalarySettlement());
+		}
 		vipGroupActivityAddDto.setSalarySettlementJson(JSON.toJSONString(vipGroupActivityAddDto.getVipGroupSalarySettlement()));
 		vipGroupActivityAddDto.setSalarySettlementJson(JSON.toJSONString(vipGroupActivityAddDto.getVipGroupSalarySettlement()));
 		ActivityApplyStudentType applyToStudentType = getApplyToStudentType(vipGroupActivityAddDto.getApplyToStudentType());
 		ActivityApplyStudentType applyToStudentType = getApplyToStudentType(vipGroupActivityAddDto.getApplyToStudentType());
 //		vipGroupActivityAddDto.setApplyToStudentType(JSONObject.toJSONString(applyToStudentType));
 //		vipGroupActivityAddDto.setApplyToStudentType(JSONObject.toJSONString(applyToStudentType));
@@ -139,6 +140,7 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
 		applyToStudentType.setActivityId(vipGroupActivityAddDto.getId());
 		applyToStudentType.setActivityId(vipGroupActivityAddDto.getId());
 		activityApplyStudentTypeDao.updateByActivity(applyToStudentType);
 		activityApplyStudentTypeDao.updateByActivity(applyToStudentType);
 //		entityChangeEventSource.entityChange(oldVipGroupActivity, vipGroupActivityAddDto, operatorId);
 //		entityChangeEventSource.entityChange(oldVipGroupActivity, vipGroupActivityAddDto, operatorId);
+		return vipGroupActivityAddDto;
 	}
 	}
 
 
 	@Override
 	@Override

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

@@ -759,4 +759,16 @@
             AND pg.group_status_ IN ('NORMAL','FINISH')
             AND pg.group_status_ IN ('NORMAL','FINISH')
         ORDER BY pg.courses_start_date_ DESC LIMIT 1
         ORDER BY pg.courses_start_date_ DESC LIMIT 1
     </select>
     </select>
+    <select id="countStudentUserActivityNum" resultType="java.lang.Integer">
+        SELECT COUNT(DISTINCT pg.id_)
+        FROM practice_group pg
+        LEFT JOIN class_group_student_mapper cgsm ON pg.id_ = cgsm.music_group_id_ AND cgsm.group_type_='PRACTICE'
+        WHERE pg.vip_group_activity_id_ = #{vipGroupActivityId}
+        AND ((pg.group_status_ NOT IN ('CANCEL') AND #{studentId} = pg.student_id_) OR cgsm.user_id_=#{studentId})
+    </select>
+    <select id="countUserRepeatPracticeGroupInCourseStartEndTime" resultType="java.lang.Integer">
+        SELECT COUNT(id_)
+        FROM practice_group
+        WHERE student_id_ = #{userId} AND courses_start_date = #{courseStartDate} AND courses_expire_date_ = #{courseEndDate}
+    </select>
 </mapper>
 </mapper>

+ 21 - 21
mec-biz/src/main/resources/config/mybatis/VipGroupActivityMapper.xml

@@ -88,61 +88,61 @@
 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.VipGroupActivity">
 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.VipGroupActivity">
 		UPDATE vip_group_activity
 		UPDATE vip_group_activity
 		<set>
 		<set>
-			<if test="status_ != null">
+			<if test="status != null">
 				status_ = #{status},
 				status_ = #{status},
 			</if>
 			</if>
-			<if test="give_period_ != null">
-				give_period_ = #{givePeriodEnum},
+			<if test="givePeriodEnum != null">
+				give_period_ = #{givePeriodEnum,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 			</if>
 			</if>
-			<if test="period_ != null">
-				period_ = #{periodEnum},
+			<if test="periodEnum != null">
+				period_ = #{periodEnum,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 			</if>
 			</if>
-			<if test="give_teach_mode_ != null">
+			<if test="giveTeachMode != null">
 				give_teach_mode_ = #{giveTeachMode},
 				give_teach_mode_ = #{giveTeachMode},
 			</if>
 			</if>
-			<if test="teach_mode_ != null">
+			<if test="teachMode != null">
 				teach_mode_ = #{teachMode},
 				teach_mode_ = #{teachMode},
 			</if>
 			</if>
-			<if test="is_pay_to_balance_ != null">
+			<if test="isPayToBalance != null">
 				is_pay_to_balance_ = #{isPayToBalance},
 				is_pay_to_balance_ = #{isPayToBalance},
 			</if>
 			</if>
-			<if test="give_sign_course_time_ != null">
+			<if test="giveSingleCourseTime != null">
 				give_sign_course_time_ = #{giveSingleCourseTime},
 				give_sign_course_time_ = #{giveSingleCourseTime},
 			</if>
 			</if>
-			<if test="single_course_time_ != null">
+			<if test="singleCourseTime != null">
 				single_course_time_ = #{singleCourseTime},
 				single_course_time_ = #{singleCourseTime},
 			</if>
 			</if>
-			<if test="discount_ != null">
+			<if test="discount != null">
 				discount_ = #{discount},
 				discount_ = #{discount},
 			</if>
 			</if>
-			<if test="full_minus_course_times_ != null">
+			<if test="fullMinusCourseTimes != null">
 				full_minus_course_times_ = #{fullMinusCourseTimes},
 				full_minus_course_times_ = #{fullMinusCourseTimes},
 			</if>
 			</if>
-			<if test="give_course_type_ != null">
+			<if test="giveCourseType != null">
 				give_course_type_ = #{giveCourseType},
 				give_course_type_ = #{giveCourseType},
 			</if>
 			</if>
-			<if test="give_category_id_ != null">
+			<if test="giveCategoryId != null">
 				give_category_id_ = #{giveCategoryId},
 				give_category_id_ = #{giveCategoryId},
 			</if>
 			</if>
-			<if test="give_course_num_ != null">
+			<if test="giveCourseNum != null">
 				give_course_num_ = #{giveCourseNum},
 				give_course_num_ = #{giveCourseNum},
 			</if>
 			</if>
-			<if test="activity_type_ != null">
+			<if test="activityType != null">
 				activity_type_ = #{activityType},
 				activity_type_ = #{activityType},
 			</if>
 			</if>
-			<if test="course_type_ != null">
+			<if test="courseType != null">
 				course_type_ = #{courseType},
 				course_type_ = #{courseType},
 			</if>
 			</if>
-			<if test="member_time_ != null">
+			<if test="memberTime != null">
 				member_time_ = #{memberTime},
 				member_time_ = #{memberTime},
 			</if>
 			</if>
-			<if test="member_rank_id_ != null">
+			<if test="memberRankId != null">
 				member_rank_id_ = #{memberRankId},
 				member_rank_id_ = #{memberRankId},
 			</if>
 			</if>
-			<if test="give_member_time_ != null">
+			<if test="giveMemberTime != null">
 				give_member_time_ = #{giveMemberTime},
 				give_member_time_ = #{giveMemberTime},
 			</if>
 			</if>
-			<if test="give_member_rank_id_ != null">
+			<if test="giveMemberRankId != null">
 				give_member_rank_id_ = #{giveMemberRankId},
 				give_member_rank_id_ = #{giveMemberRankId},
 			</if>
 			</if>
 			<if test="salaryReadonlyFlag != null">
 			<if test="salaryReadonlyFlag != null">

+ 2 - 2
mec-web/src/main/java/com/ym/mec/web/controller/VipGroupActivityController.java

@@ -1,5 +1,6 @@
 package com.ym.mec.web.controller;
 package com.ym.mec.web.controller;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
@@ -93,8 +94,7 @@ public class VipGroupActivityController extends BaseController {
         if(sysUser == null){
         if(sysUser == null){
             return failed("用户信息获取失败");
             return failed("用户信息获取失败");
         }
         }
-        vipGroupActivityService.updateVipGroupActivity(vipGroupActivityAddDto, sysUser.getId());
-        return succeed();
+        return succeed(vipGroupActivityService.updateVipGroupActivity(vipGroupActivityAddDto, sysUser.getId()));
     }
     }
 
 
     @ApiOperation(value = "删除活动方案")
     @ApiOperation(value = "删除活动方案")