Browse Source

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

zouxuan 5 years ago
parent
commit
0ece1b1b65

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

@@ -1008,6 +1008,9 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      */
     List<Map<String, Long>> countTotalCourseScheduleNum(@Param("vipGroupIds") List<String> vipGroupIds, @Param("groupType") String groupType);
 
+    int countTotalCourseScheduleNumWithGroup(@Param("groupId") String groupId,
+                                                        @Param("groupType") String groupType);
+
     /**
      * 获取当前课时(已上)
      *

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/VipGroup.java

@@ -134,6 +134,16 @@ public class VipGroup {
 
 	private BigDecimal courseUnitPrice;
 
+	private int enableDelete;
+
+	public Integer getEnableDelete() {
+		return enableDelete;
+	}
+
+	public void setEnableDelete(Integer enableDelete) {
+		this.enableDelete = enableDelete;
+	}
+
 	public BigDecimal getCourseUnitPrice() {
 		return courseUnitPrice;
 	}

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

@@ -59,6 +59,15 @@ public interface VipGroupService extends BaseService<Long, VipGroup> {
     void checkVipCourseIsInScore(Long vipGroupId);
 
     /**
+     * @describe 删除vip课程组
+     * @author Joburgess
+     * @date 2020.07.08
+     * @param vipGroupId:
+     * @return void
+     */
+    void deleteVipGroup(Long vipGroupId);
+
+    /**
      * @describe 更新vip课程信息
      * @author Joburgess
      * @date 2019/10/30

+ 34 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -135,6 +135,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 	private StudentDao studentDao;
 	@Autowired
 	private OrganizationDao organizationDao;
+	@Autowired
+	private GroupClassService groupClassService;
 
 	private static final Logger LOGGER = LoggerFactory
 			.getLogger(VipGroup.class);
@@ -442,11 +444,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			employeeOrganIds= Arrays.stream(employee.getOrganIdList().split(",")).map(e->Integer.valueOf(e)).collect(Collectors.toList());
 		}
 		List<Integer> teacherOrganIds=new ArrayList<>();
-		if(Objects.nonNull(teacher.getOrganId())){
-			teacherOrganIds.add(teacher.getOrganId());
+		if(Objects.nonNull(teacher.getTeacherOrganId())){
+			teacherOrganIds.add(teacher.getTeacherOrganId());
 		}
-		if(StringUtils.isNotBlank(teacher.getFlowOrganRangeId())){
-			Arrays.stream(teacher.getFlowOrganRangeId().split(","))
+		if(StringUtils.isNotBlank(teacher.getFlowOrganRange())){
+			Arrays.stream(teacher.getFlowOrganRange().split(","))
 					.map(e->Integer.valueOf(e)).collect(Collectors.toSet())
 					.forEach(organId->{
 						teacherOrganIds.add(organId);
@@ -460,6 +462,27 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void deleteVipGroup(Long vipGroupId) {
+		if(Objects.isNull(vipGroupId)){
+			throw new BizException("请指定课程组");
+		}
+		VipGroup vipGroup = vipGroupDao.get(vipGroupId);
+		if(Objects.isNull(vipGroup)){
+			throw new BizException("课程组不存在");
+		}
+		if(!VipGroupStatusEnum.NOT_START.equals(vipGroup.getStatus())
+				&&!VipGroupStatusEnum.APPLYING.equals(vipGroup.getStatus())){
+			throw new BizException("此状态课程组不支持删除");
+		}
+		int totalCourseNum = courseScheduleDao.countTotalCourseScheduleNumWithGroup(vipGroupId.toString(), GroupType.VIP.getCode());
+		if(totalCourseNum>0){
+			throw new BizException("此状态课程组不支持删除");
+		}
+		groupClassService.deleteAllGroupInfo(vipGroupId.toString(), GroupType.VIP);
+	}
+
+	@Override
     @Transactional(rollbackFor = Exception.class)
     public void checkVipCourseIsInScore(Long vipGroupId) {
 	    if(Objects.isNull(vipGroupId)){
@@ -666,6 +689,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 					vipGroup.setTotalClassTimes(aLong==null?0:aLong.intValue());
 					Long aLong1 = currentClassTimeMap.get(vipGroup.getId() + "");
 					vipGroup.setCurrentClassTimes(aLong1==null?0:aLong1.intValue());
+					if(Objects.isNull(aLong)){
+						vipGroup.setEnableDelete(1);
+					}
 
 					vipGroup.setEducationalTeacherName(idNameMap.get(vipGroup.getEducationalTeacherId()));
 
@@ -2394,6 +2420,10 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			ImGroupMember[] newImGroupMemberList = new ImGroupMember[]{new ImGroupMember(oldVipGroupInfo.getEducationalTeacherId().toString())};
 			imFeignService.groupJoin(new ImGroupModel(classGroup.getId().toString(), newImGroupMemberList,classGroup.getName()));
 		}
+		if(Objects.nonNull(vipGroupApplyBaseInfo.getOrganId())&&!vipGroupApplyBaseInfo.getOrganId().equals(oldVipGroupInfo.getOrganId())){
+			isChange=true;
+			oldVipGroupInfo.setOrganId(vipGroupApplyBaseInfo.getOrganId());
+		}
 		//更新vip课
 		if(isChange){
 			oldVipGroupInfo.setUpdateTime(now);

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

@@ -2100,6 +2100,12 @@
         AND cs.group_type_ = #{groupType} AND cs.del_flag_ = 0
         GROUP BY cs.music_group_id_
     </select>
+    <select id="countTotalCourseScheduleNumWithGroup" resultType="int">
+        SELECT COUNT(cs.id_)
+        FROM course_schedule cs
+        WHERE cs.music_group_id_ = #{groupId}
+        AND cs.group_type_ = #{groupType} AND cs.del_flag_ = 0
+    </select>
     <select id="countCourseScheduleNum" resultType="java.util.Map">
         SELECT cs.music_group_id_ 'key',COUNT(cs.id_) 'value' FROM course_schedule cs WHERE cs.music_group_id_ IN
         <foreach collection="vipGroupIds" open="(" close=")" separator="," item="item">

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

@@ -137,7 +137,7 @@
         SELECT * from organization where del_flag_=0 ORDER BY id_ ASC;
     </select>
 
-    <select id="findOrgans" resultType="com.ym.mec.biz.dal.entity.Organization">
+    <select id="findOrgans" resultMap="Organization">
         SELECT * FROM organization WHERE id_ IN
         <foreach collection="organIds" item="organId" separator="," open="(" close=")">
             #{organId}

+ 14 - 5
mec-web/src/main/java/com/ym/mec/web/controller/VipGroupManageController.java

@@ -76,11 +76,13 @@ public class VipGroupManageController extends BaseController {
         if(Objects.isNull(teacher)){
             return failed("请指定指导老师!");
         }
-        Employee employee = employeeDao.get(sysUser.getId());
-        if(StringUtils.isEmpty(employee.getOrganIdList()) || employee.getOrganIdList().contains(",")){
-            vipGroupApplyDto.getVipGroupApplyBaseInfo().setOrganId(teacher.getTeacherOrganId());
-        }else {
-            vipGroupApplyDto.getVipGroupApplyBaseInfo().setOrganId(Integer.parseInt(employee.getOrganIdList()));
+        if(Objects.isNull(vipGroupApplyDto.getVipGroupApplyBaseInfo().getOrganId())){
+            Employee employee = employeeDao.get(sysUser.getId());
+            if(StringUtils.isEmpty(employee.getOrganIdList()) || employee.getOrganIdList().contains(",")){
+                vipGroupApplyDto.getVipGroupApplyBaseInfo().setOrganId(teacher.getTeacherOrganId());
+            }else {
+                vipGroupApplyDto.getVipGroupApplyBaseInfo().setOrganId(Integer.parseInt(employee.getOrganIdList()));
+            }
         }
         return succeed(vipGroupService.createVipGroup(vipGroupApplyDto));
     }
@@ -120,6 +122,13 @@ public class VipGroupManageController extends BaseController {
         return succeed(vipGroupService.findVipGroups(queryInfo));
     }
 
+    @ApiOperation(value = "删除课程组")
+    @PostMapping("/deleteVipGroup")
+    @PreAuthorize("@pcs.hasPermissions('vipGroupManage/deleteVipGroup')")
+    public HttpResponseResult deleteVipGroup(Long vipGroupId){
+        vipGroupService.deleteVipGroup(vipGroupId);
+        return succeed();
+    }
 
     @ApiOperation(value = "获取小课学员")
     @GetMapping(value = "/findVipGroupStudents")