浏览代码

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

zouxuan 5 年之前
父节点
当前提交
964a172e2f

+ 5 - 0
cms/src/main/java/com/ym/mec/cms/dal/dao/SysNewsInformationDao.java

@@ -1,6 +1,7 @@
 package com.ym.mec.cms.dal.dao;
 
 import java.util.List;
+import java.util.Map;
 
 import com.ym.mec.cms.dal.entity.SysNewsInformation;
 import com.ym.mec.common.dal.BaseDAO;
@@ -20,4 +21,8 @@ public interface SysNewsInformationDao extends BaseDAO<Long, SysNewsInformation>
 	 * @return
 	 */
 	int deleteWithLogical(Long id);
+	
+	List<SysNewsInformation> queryHomePage(Map<String, Object> params);
+	
+	int queryHomeCount(Map<String, Object> params);
 }

+ 28 - 7
cms/src/main/java/com/ym/mec/cms/service/impl/SysNewsInformationServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ym.mec.cms.service.impl;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -7,6 +8,7 @@ import java.util.Map;
 import com.ym.mec.cms.controller.queryinfo.NewsInformationQueryInfo;
 import com.ym.mec.cms.dal.entity.NewsStatusEnum;
 import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.QueryInfo;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -52,28 +54,47 @@ public class SysNewsInformationServiceImpl extends BaseServiceImpl<Long, SysNews
 		MapUtil.populateMap(params, queryInfo);
 
 		queryInfo.setType(3);
-		int count = sysNewsInformationDao.queryCount(params);
+		int count = sysNewsInformationDao.queryHomeCount(params);
 		if(count == 0){
 			queryInfo.setMemo(null);
 		}
-		homeList.put("banner",queryPage(queryInfo));
+		homeList.put("banner",queryHomePage(queryInfo));
 		
 		queryInfo.setMemo(memo);
 		queryInfo.setType(6);
-		count = sysNewsInformationDao.queryCount(params);
+		count = sysNewsInformationDao.queryHomeCount(params);
 		if(count == 0){
 			queryInfo.setMemo(null);
 		}
-		homeList.put("app",queryPage(queryInfo));
+		homeList.put("app",queryHomePage(queryInfo));
 		
 		queryInfo.setMemo(null);
 		queryInfo.setType(1);
-		homeList.put("active",queryPage(queryInfo));
+		homeList.put("active",queryHomePage(queryInfo));
 		queryInfo.setType(2);
-		homeList.put("hot",queryPage(queryInfo));
+		homeList.put("hot",queryHomePage(queryInfo));
 		queryInfo.setType(5);
-		homeList.put("flash",queryPage(queryInfo));
+		homeList.put("flash",queryHomePage(queryInfo));
 		return homeList;
 	}
+	
+	private PageInfo<SysNewsInformation> queryHomePage(QueryInfo queryInfo) {
+		PageInfo<SysNewsInformation> pageInfo = new PageInfo<SysNewsInformation>(queryInfo.getPage(), queryInfo.getRows());
+		Map<String, Object> params = new HashMap<String, Object>();
+		MapUtil.populateMap(params, queryInfo);
+		
+		List<SysNewsInformation> dataList = null;
+		int count = sysNewsInformationDao.queryHomeCount(params);
+		if (count > 0) {
+			pageInfo.setTotal(count);
+			params.put("offset", pageInfo.getOffset());
+			dataList = sysNewsInformationDao.queryHomePage(params);
+		}
+		if (count == 0) {
+			dataList = new ArrayList<SysNewsInformation>();
+		}
+		pageInfo.setRows(dataList);
+		return pageInfo;
+	}
 
 }

+ 56 - 9
cms/src/main/resources/config/mybatis/SysNewsInformationMapper.xml

@@ -37,14 +37,6 @@
 			<if test="search != null">
 				and title_ like '%' #{search} '%'
 			</if>
-			<choose>
-		        <when test="memo != null and memo != ''">
-		            and memo_ = #{memo}
-		        </when>
-		        <otherwise>
-		            and memo_ is null
-		        </otherwise>
-		    </choose>
 		</where>
 	</sql>
 	
@@ -114,7 +106,7 @@
 	<select id="queryPage" resultMap="SysNewsInformation" parameterType="map">
 		SELECT * FROM sys_news_information
 		<include refid="queryCondition" />
-		order by order_ desc,update_time_ desc
+		order by status_ desc,order_ desc,update_time_ desc
 		<include refid="global.limit"/>
 	</select>
 	
@@ -137,4 +129,59 @@
 	<update id="deleteWithLogical">
 		UPDATE sys_news_information SET del_flag_ = 1,update_time_ = NOW() WHERE id_ = #{id}
 	</update>
+	
+	<!-- 分页查询 -->
+	<select id="queryHomePage" resultMap="SysNewsInformation"
+		parameterType="map">
+		SELECT * FROM sys_news_information where del_flag_=0
+		<if test="type != null">
+			and type_ = #{type}
+		</if>
+		<if test="status != null">
+			and status_ = #{status,
+			typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+		</if>
+		<if test="title != null">
+			and title_ like '%' #{title} '%'
+		</if>
+		<if test="search != null">
+			and title_ like '%' #{search} '%'
+		</if>
+		<choose>
+			<when test="memo != null and memo != ''">
+				and memo_ = #{memo}
+			</when>
+			<otherwise>
+				and (memo_ is null or memo_ = '')
+			</otherwise>
+		</choose>
+		order by status_ desc,order_ desc,update_time_ desc
+		<include refid="global.limit" />
+	</select>
+
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryHomeCount" resultType="int">
+		SELECT COUNT(*) FROM sys_news_information where del_flag_=0
+		<if test="type != null">
+			and type_ = #{type}
+		</if>
+		<if test="status != null">
+			and status_ = #{status,
+			typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+		</if>
+		<if test="title != null">
+			and title_ like '%' #{title} '%'
+		</if>
+		<if test="search != null">
+			and title_ like '%' #{search} '%'
+		</if>
+		<choose>
+			<when test="memo != null and memo != ''">
+				and memo_ = #{memo}
+			</when>
+			<otherwise>
+				and (memo_ is null or memo_ = '')
+			</otherwise>
+		</choose>
+	</select>
 </mapper>

+ 3 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupTeacherMapperDao.java

@@ -5,11 +5,9 @@ import com.ym.mec.biz.dal.entity.ClassGroupTeacherMapper;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.TeachTypeEnum;
 import com.ym.mec.common.dal.BaseDAO;
-
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
-import java.util.Set;
 
 public interface ClassGroupTeacherMapperDao extends BaseDAO<Long, ClassGroupTeacherMapper> {
 
@@ -60,6 +58,9 @@ public interface ClassGroupTeacherMapperDao extends BaseDAO<Long, ClassGroupTeac
 
     List<ClassGroupTeacherMapper> findByClassGroup(Integer classGroupId);
 
+    ClassGroupTeacherMapper findByClassGroupAndTeacher(@Param("classGroupId") Integer classGroupId,
+                                                       @Param("userId") Integer userId);
+
     /**
      * 批量查询班级的老师关联关系
      *

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/BatchInsertCoursesDto.java

@@ -25,6 +25,8 @@ public class BatchInsertCoursesDto {
 	private Integer schoolId;
 
 	private boolean isJumpHoliday;
+	
+    private List<Long> courseScheduleIdList;
 
 	public String getMusicGroupId() {
 		return musicGroupId;
@@ -97,4 +99,12 @@ public class BatchInsertCoursesDto {
 	public void setIsJumpHoliday(boolean isJumpHoliday) {
 		this.isJumpHoliday = isJumpHoliday;
 	}
+
+	public List<Long> getCourseScheduleIdList() {
+		return courseScheduleIdList;
+	}
+
+	public void setCourseScheduleIdList(List<Long> courseScheduleIdList) {
+		this.courseScheduleIdList = courseScheduleIdList;
+	}
 }

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

@@ -36,7 +36,7 @@ public interface CourseScheduleService extends BaseService<Long, CourseSchedule>
 	 * @param courseScheduleIds: 课程计划编号列表
 	 * @return int
 	 */
-	void deleteCourseSchedules(List<Long> courseScheduleIds);
+	void batchDeleteCourseSchedules(List<Long> courseScheduleIds);
 
 	/**
 	 * @describe 删除乐团下所有未上的课时
@@ -85,6 +85,13 @@ public interface CourseScheduleService extends BaseService<Long, CourseSchedule>
 	 */
 	boolean batchAddCourseSchedule(Integer classGroupId, int coursesTimes, Date startDate, List<CourseTimeDto> teachingArrangementList,
 			TeachModeEnum teachMode, CourseScheduleType type, Integer schoolId, boolean isJumpHoliday);
+	
+	/**
+	 * 批量调整
+	 * @param batchInsertCoursesDto
+	 * @return
+	 */
+	boolean batchUpdateCourseSchedule(BatchInsertCoursesDto batchInsertCoursesDto);
 
 	/**
 	 * @Author: Joburgess

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

@@ -47,7 +47,7 @@ public interface SysUserCashAccountService extends BaseService<Integer, SysUserC
 	 * @param userId
 	 * @return
 	 */
-	boolean transferCourseBalanceToBalance(Integer userId);
+	boolean transferCourseBalanceToBalance(Integer userId,BigDecimal money);
 
 	/**
 	 * 获取行级锁

+ 34 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -168,7 +168,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-	public void deleteCourseSchedules(List<Long> courseScheduleIds) {
+	public void batchDeleteCourseSchedules(List<Long> courseScheduleIds) {
 
 		List<CourseSchedule> courseScheduleList = courseScheduleDao.findByCourseScheduleIds(courseScheduleIds);
 
@@ -211,7 +211,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
         List<Long> courseScheduleIds = musicGroupCourseSchedules.stream()
                 .map(CourseSchedule::getId)
                 .collect(Collectors.toList());
-        deleteCourseSchedules(courseScheduleIds);
+        batchDeleteCourseSchedules(courseScheduleIds);
     }
 
     @Override
@@ -280,6 +280,9 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 			}
 			subSidy = school.getSubsidy();
 		}
+		
+		//查询声部
+		String subjectName = subjectDao.findNames(classGroup.getSubjectIdList());
 
 		// 查询班级老师信息
 		List<ClassGroupTeacherMapper> classGroupTeacherMapperList = classGroupTeacherMapperService.getClassGroupTeachers(classGroupId);
@@ -341,6 +344,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
 		// 查询班级学生信息
 		List<ClassGroupStudentMapper> classGroupStudentMapperList = classGroupStudentMapperDao.findByClassGroup(classGroupId);
+		String usernameList = classGroupStudentMapperList.stream().map(ClassGroupStudentMapper::getUserName).collect(Collectors.joining("、"));
 
 		Map<Integer, CourseTimeDto> dayOfWeekMap = teachingArrangementList.stream().collect(Collectors.toMap(CourseTimeDto::getDayOfWeek, ct -> ct));
 
@@ -409,6 +413,11 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 					courseSchedule.setName(classGroup.getName());
 					courseSchedule.setSchoolId(schoolId);
 					courseSchedule.setSubsidy(subSidy);
+					if (type == CourseScheduleType.PRACTICE || type == CourseScheduleType.VIP) {
+						courseSchedule.setName(subjectName + "•" + usernameList);
+					} else {
+						courseSchedule.setName(type.getMsg());
+					}
 					courseScheduleList.add(courseSchedule);
 
 					// 课程与老师薪水表
@@ -508,7 +517,6 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		
 		//检查冲突
 		checkNewCourseSchedules(courseScheduleList, false);
-        createCourseScheduleName(courseScheduleList);
 
 		if (courseScheduleList.size() > 0) {
 			courseScheduleDao.batchAddCourseSchedules(courseScheduleList);
@@ -557,6 +565,29 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
     @Override
     @Transactional(rollbackFor = Exception.class)
+	public boolean batchUpdateCourseSchedule(BatchInsertCoursesDto batchInsertCoursesDto) {
+
+		List<CourseSchedule> courseScheduleList = courseScheduleDao.findByCourseScheduleIds(batchInsertCoursesDto.getCourseScheduleIdList());
+		List<Integer> classGroupList = courseScheduleList.stream().map(CourseSchedule::getClassGroupId).distinct().collect(Collectors.toList());
+
+		if (classGroupList == null || classGroupList.size() != 1) {
+			throw new BizException("修改失败,只支持同一个班级的课程批量调整");
+		}
+
+		Integer classGroupId = classGroupList.get(0);
+
+		// 批量上课
+		batchDeleteCourseSchedules(batchInsertCoursesDto.getCourseScheduleIdList());
+
+		// 批量加课
+		batchAddCourseSchedule(classGroupId, batchInsertCoursesDto.getCourseScheduleIdList().size(), batchInsertCoursesDto.getStartDate(),
+				batchInsertCoursesDto.getTeachingArrangementList(), batchInsertCoursesDto.getTeachMode(), batchInsertCoursesDto.getType(),
+				batchInsertCoursesDto.getSchoolId(), batchInsertCoursesDto.getIsJumpHoliday());
+		return true;
+	}
+
+	@Override
+    @Transactional(rollbackFor = Exception.class)
     public void batchAddCourseSchedule(List<CourseSchedule> courseSchedules) {
         if (Objects.isNull(courseSchedules) && courseSchedules.size() <= 0) {
             throw new BizException("参数错误!");

+ 208 - 200
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysUserCashAccountServiceImpl.java

@@ -32,205 +32,213 @@ import java.util.Map;
 @Service
 public class SysUserCashAccountServiceImpl extends BaseServiceImpl<Integer, SysUserCashAccount> implements SysUserCashAccountService {
 
-	@Autowired
-	private SysUserCashAccountDao sysUserCashAccountDao;
-	@Autowired
-	private SysUserFeignService sysUserFeignService;
-	@Autowired
-	private SysMessageService sysMessageService;
-
-	@Autowired
-	private SysUserCashAccountDetailDao sysUserCashAccountDetailDao;
-	@Autowired
-	private SysUserCoursesAccountDetailDao sysUserCoursesAccountDetailDao;
-
-	@Override
-	public BaseDAO<Integer, SysUserCashAccount> getDAO() {
-		return sysUserCashAccountDao;
-	}
-
-	@Override
-	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-	public boolean updateBalance(Integer userId, BigDecimal decimal) {
-
-		SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId);
-		if (cashAccount == null) {
-			throw new BizException("用户[{}]现金账户不存在", userId);
-		}
-
-		if (cashAccount.getStatus() != PlatformCashAccountStatusEnum.NORMAL) {
-			throw new BizException("账户不可用");
-		}
-		BigDecimal balance = cashAccount.getBalance().add(decimal);
-		if (balance.doubleValue() < 0) {
-			throw new BizException("现金账户[{}]余额不足,可用余额剩{}元", userId, cashAccount.getBalance().doubleValue());
-		}
-
-		cashAccount.setBalance(balance);
-		cashAccount.setUpdateTime(new Date());
-
-		sysUserCashAccountDao.update(cashAccount);
-
-		return true;
-	}
-
-	@Override
-	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-	public boolean updateBalance(Integer userId, BigDecimal decimal, PlatformCashAccountDetailTypeEnum type, String memo) {
-		SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId);
-		if (cashAccount == null) {
-			throw new BizException("用户[{}]现金账户不存在", userId);
-		}
-
-		if (cashAccount.getStatus() != PlatformCashAccountStatusEnum.NORMAL) {
-			throw new BizException("账户不可用");
-		}
-		BigDecimal balance = cashAccount.getBalance().add(decimal);
-		if (balance.doubleValue() < 0) {
-			throw new BizException("现金账户[{}]余额不足,可用余额剩{}元", userId, cashAccount.getBalance().doubleValue());
-		}
-
-		Date date = new Date();
-
-		SysUserCashAccountDetail detail = new SysUserCashAccountDetail();
-		detail.setAmount(decimal);
-		detail.setBalance(cashAccount.getBalance().add(decimal));
-		detail.setComment(memo);
-		detail.setCreateTime(date);
-		detail.setStatus(DealStatusEnum.SUCCESS);
-		detail.setType(type);
-		detail.setUpdateTime(date);
-		detail.setUserId(userId);
-
-		sysUserCashAccountDetailDao.insert(detail);
-
-		cashAccount.setBalance(balance);
-		cashAccount.setUpdateTime(date);
-
-		sysUserCashAccountDao.update(cashAccount);
-		if(!decimal.equals(BigDecimal.ZERO)){
-			//推送余额消费信息
-			Map<Integer,String> phoneMap = new HashMap<>(1);
-			SysUser sysUser = sysUserFeignService.queryUserById(userId);
-			phoneMap.put(userId,sysUser.getPhone());
-			sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.YIMEI, MessageTypeEnum.STUDENT_SMS_BALANCE_CONSUME,
-					phoneMap,null,0,null,"",decimal,balance);
-			Map<Integer,String> idMap = new HashMap<>(1);
-			idMap.put(userId,userId.toString());
-			sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_SMS_BALANCE_CONSUME,
-					idMap,null,0,null,"",decimal,balance);
-		}
-		return true;
-	}
-
-	@Override
-	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-	public boolean updateCourseBalance(Integer userId, BigDecimal decimal, BigDecimal amount, String description) {
-		SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId);
-		if (cashAccount == null) {
-			throw new BizException("用户[{}]现金账户不存在", userId);
-		}
-
-		cashAccount.setCourseBalance(decimal);
-		cashAccount.setUpdateTime(new Date());
-
-		sysUserCashAccountDao.update(cashAccount);
-
-		if(amount.compareTo(BigDecimal.ZERO)!=0){
-			SysUser sysUser = sysUserFeignService.queryUserById(userId);
-			SysUserCoursesAccountDetail sysUserCoursesAccountDetail=new SysUserCoursesAccountDetail();
-			sysUserCoursesAccountDetail.setUserId(userId);
-			sysUserCoursesAccountDetail.setAmount(amount);
-			sysUserCoursesAccountDetail.setBalance(decimal);
-			sysUserCoursesAccountDetail.setDescription(description+"-"+sysUser.getId());
-			sysUserCoursesAccountDetail.setStatus(DealStatusEnum.SUCCESS);
-			sysUserCoursesAccountDetailDao.insert(sysUserCoursesAccountDetail);
-		}
-
-		return true;
-	}
-
-	@Override
-	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-	public boolean appendCourseBalance(Integer userId, BigDecimal decimal, String description) {
-		SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId);
-		if (cashAccount == null) {
-			throw new BizException("用户[{}]现金账户不存在", userId);
-		}
-
-		BigDecimal balance = cashAccount.getCourseBalance().add(decimal);
-		if (balance.doubleValue() < 0) {
-			throw new BizException("现金账户[{}]课程余额不足,可用余额剩{}元", userId, cashAccount.getBalance().doubleValue());
-		}
-
-		Date date = new Date();
-		cashAccount.setCourseBalance(balance);
-		cashAccount.setUpdateTime(date);
-
-		sysUserCashAccountDao.update(cashAccount);
-
-		if(decimal.compareTo(BigDecimal.ZERO)!=0){
-			SysUser sysUser = sysUserFeignService.queryUserById(userId);
-			SysUserCoursesAccountDetail sysUserCoursesAccountDetail=new SysUserCoursesAccountDetail();
-			sysUserCoursesAccountDetail.setUserId(userId);
-			sysUserCoursesAccountDetail.setAmount(decimal);
-			sysUserCoursesAccountDetail.setBalance(balance);
-			sysUserCoursesAccountDetail.setDescription(description+"-"+sysUser.getId());
-			sysUserCoursesAccountDetail.setStatus(DealStatusEnum.SUCCESS);
-			sysUserCoursesAccountDetailDao.insert(sysUserCoursesAccountDetail);
-		}
-
-		return true;
-	}
-
-	@Override
-	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-	public boolean transferCourseBalanceToBalance(Integer userId) {
-		SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId);
-		if (cashAccount == null) {
-			throw new BizException("用户[{}]现金账户不存在", userId);
-		}
-
-		if (cashAccount.getStatus() != PlatformCashAccountStatusEnum.NORMAL) {
-			throw new BizException("账户不可用");
-		}
-
-		Date date = new Date();
-
-		SysUserCashAccountDetail detail = new SysUserCashAccountDetail();
-		detail.setAmount(cashAccount.getCourseBalance());
-		detail.setBalance(cashAccount.getBalance().add(cashAccount.getCourseBalance()));
-		detail.setComment("课程余额转账");
-		detail.setCreateTime(date);
-		detail.setStatus(DealStatusEnum.SUCCESS);
-		detail.setType(PlatformCashAccountDetailTypeEnum.FILL_ACCOUNT);
-		detail.setUpdateTime(date);
-		detail.setUserId(userId);
-
-		sysUserCashAccountDetailDao.insert(detail);
-
-		cashAccount.setBalance(cashAccount.getBalance().add(cashAccount.getCourseBalance()));
-		cashAccount.setCourseBalance(new BigDecimal(0));
-		cashAccount.setUpdateTime(date);
-
-		sysUserCashAccountDao.update(cashAccount);
-
-		if(cashAccount.getCourseBalance().compareTo(BigDecimal.ZERO)!=0){
-			SysUserCoursesAccountDetail sysUserCoursesAccountDetail=new SysUserCoursesAccountDetail();
-			sysUserCoursesAccountDetail.setUserId(userId);
-			sysUserCoursesAccountDetail.setAmount(cashAccount.getCourseBalance());
-			sysUserCoursesAccountDetail.setBalance(new BigDecimal(0));
-			sysUserCoursesAccountDetail.setDescription("课程余额转账");
-			sysUserCoursesAccountDetail.setStatus(DealStatusEnum.SUCCESS);
-			sysUserCoursesAccountDetailDao.insert(sysUserCoursesAccountDetail);
-		}
-
-		return true;
-	}
-
-	@Override
-	public SysUserCashAccount getLocked(Integer userId) {
-		return sysUserCashAccountDao.getLocked(userId);
-	}
+    @Autowired
+    private SysUserCashAccountDao sysUserCashAccountDao;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private SysMessageService sysMessageService;
+
+    @Autowired
+    private SysUserCashAccountDetailDao sysUserCashAccountDetailDao;
+    @Autowired
+    private SysUserCoursesAccountDetailDao sysUserCoursesAccountDetailDao;
+
+    @Override
+    public BaseDAO<Integer, SysUserCashAccount> getDAO() {
+        return sysUserCashAccountDao;
+    }
+
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public boolean updateBalance(Integer userId, BigDecimal decimal) {
+
+        SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId);
+        if (cashAccount == null) {
+            throw new BizException("用户[{}]现金账户不存在", userId);
+        }
+
+        if (cashAccount.getStatus() != PlatformCashAccountStatusEnum.NORMAL) {
+            throw new BizException("账户不可用");
+        }
+        BigDecimal balance = cashAccount.getBalance().add(decimal);
+        if (balance.doubleValue() < 0) {
+            throw new BizException("现金账户[{}]余额不足,可用余额剩{}元", userId, cashAccount.getBalance().doubleValue());
+        }
+
+        cashAccount.setBalance(balance);
+        cashAccount.setUpdateTime(new Date());
+
+        sysUserCashAccountDao.update(cashAccount);
+
+        return true;
+    }
+
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public boolean updateBalance(Integer userId, BigDecimal decimal, PlatformCashAccountDetailTypeEnum type, String memo) {
+        SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId);
+        if (cashAccount == null) {
+            throw new BizException("用户[{}]现金账户不存在", userId);
+        }
+
+        if (cashAccount.getStatus() != PlatformCashAccountStatusEnum.NORMAL) {
+            throw new BizException("账户不可用");
+        }
+        BigDecimal balance = cashAccount.getBalance().add(decimal);
+        if (balance.doubleValue() < 0) {
+            throw new BizException("现金账户[{}]余额不足,可用余额剩{}元", userId, cashAccount.getBalance().doubleValue());
+        }
+
+        Date date = new Date();
+
+        SysUserCashAccountDetail detail = new SysUserCashAccountDetail();
+        detail.setAmount(decimal);
+        detail.setBalance(cashAccount.getBalance().add(decimal));
+        detail.setComment(memo);
+        detail.setCreateTime(date);
+        detail.setStatus(DealStatusEnum.SUCCESS);
+        detail.setType(type);
+        detail.setUpdateTime(date);
+        detail.setUserId(userId);
+
+        sysUserCashAccountDetailDao.insert(detail);
+
+        cashAccount.setBalance(balance);
+        cashAccount.setUpdateTime(date);
+
+        sysUserCashAccountDao.update(cashAccount);
+        if (!decimal.equals(BigDecimal.ZERO)) {
+            //推送余额消费信息
+            Map<Integer, String> phoneMap = new HashMap<>(1);
+            SysUser sysUser = sysUserFeignService.queryUserById(userId);
+            phoneMap.put(userId, sysUser.getPhone());
+            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.YIMEI, MessageTypeEnum.STUDENT_SMS_BALANCE_CONSUME,
+                    phoneMap, null, 0, null, "", decimal, balance);
+            Map<Integer, String> idMap = new HashMap<>(1);
+            idMap.put(userId, userId.toString());
+            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_SMS_BALANCE_CONSUME,
+                    idMap, null, 0, null, "", decimal, balance);
+        }
+        return true;
+    }
+
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
+    public boolean updateCourseBalance(Integer userId, BigDecimal decimal, BigDecimal amount, String description) {
+        SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId);
+        if (cashAccount == null) {
+            throw new BizException("用户[{}]现金账户不存在", userId);
+        }
+
+        cashAccount.setCourseBalance(decimal);
+        cashAccount.setUpdateTime(new Date());
+
+        sysUserCashAccountDao.update(cashAccount);
+
+        if (amount.compareTo(BigDecimal.ZERO) != 0) {
+            SysUser sysUser = sysUserFeignService.queryUserById(userId);
+            SysUserCoursesAccountDetail sysUserCoursesAccountDetail = new SysUserCoursesAccountDetail();
+            sysUserCoursesAccountDetail.setUserId(userId);
+            sysUserCoursesAccountDetail.setAmount(amount);
+            sysUserCoursesAccountDetail.setBalance(decimal);
+            sysUserCoursesAccountDetail.setDescription(description + "-" + sysUser.getId());
+            sysUserCoursesAccountDetail.setStatus(DealStatusEnum.SUCCESS);
+            sysUserCoursesAccountDetailDao.insert(sysUserCoursesAccountDetail);
+        }
+
+        return true;
+    }
+
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
+    public boolean appendCourseBalance(Integer userId, BigDecimal decimal, String description) {
+        SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId);
+        if (cashAccount == null) {
+            throw new BizException("用户[{}]现金账户不存在", userId);
+        }
+
+        BigDecimal balance = cashAccount.getCourseBalance().add(decimal);
+        if (balance.doubleValue() < 0) {
+            throw new BizException("现金账户[{}]课程余额不足,可用余额剩{}元", userId, cashAccount.getBalance().doubleValue());
+        }
+
+        Date date = new Date();
+        cashAccount.setCourseBalance(balance);
+        cashAccount.setUpdateTime(date);
+
+        sysUserCashAccountDao.update(cashAccount);
+
+        if (decimal.compareTo(BigDecimal.ZERO) != 0) {
+            SysUser sysUser = sysUserFeignService.queryUserById(userId);
+            SysUserCoursesAccountDetail sysUserCoursesAccountDetail = new SysUserCoursesAccountDetail();
+            sysUserCoursesAccountDetail.setUserId(userId);
+            sysUserCoursesAccountDetail.setAmount(decimal);
+            sysUserCoursesAccountDetail.setBalance(balance);
+            sysUserCoursesAccountDetail.setDescription(description + "-" + sysUser.getId());
+            sysUserCoursesAccountDetail.setStatus(DealStatusEnum.SUCCESS);
+            sysUserCoursesAccountDetailDao.insert(sysUserCoursesAccountDetail);
+        }
+
+        return true;
+    }
+
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public boolean transferCourseBalanceToBalance(Integer userId, BigDecimal money) {
+        SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId);
+        if (money == null || money.compareTo(BigDecimal.ZERO) <= 0) {
+            throw new BizException("充值金额必须大于0");
+        }
+        if (cashAccount == null) {
+            throw new BizException("用户[{}]现金账户不存在", userId);
+        }
+
+        if (cashAccount.getStatus() != PlatformCashAccountStatusEnum.NORMAL) {
+            throw new BizException("账户不可用");
+        }
+
+        if (money.compareTo(cashAccount.getCourseBalance()) > 0) {
+            throw new BizException("充值金额不能大于课程余额");
+        }
+
+        Date date = new Date();
+
+        SysUserCashAccountDetail detail = new SysUserCashAccountDetail();
+        detail.setAmount(money);
+        detail.setBalance(cashAccount.getBalance().add(money));
+        detail.setComment("课程余额转账");
+        detail.setCreateTime(date);
+        detail.setStatus(DealStatusEnum.SUCCESS);
+        detail.setType(PlatformCashAccountDetailTypeEnum.FILL_ACCOUNT);
+        detail.setUpdateTime(date);
+        detail.setUserId(userId);
+
+        sysUserCashAccountDetailDao.insert(detail);
+
+        cashAccount.setBalance(cashAccount.getBalance().add(money));
+        cashAccount.setCourseBalance(cashAccount.getCourseBalance().subtract(money));
+        cashAccount.setUpdateTime(date);
+
+        sysUserCashAccountDao.update(cashAccount);
+
+        SysUserCoursesAccountDetail sysUserCoursesAccountDetail = new SysUserCoursesAccountDetail();
+        sysUserCoursesAccountDetail.setUserId(userId);
+        sysUserCoursesAccountDetail.setType(PlatformCashAccountDetailTypeEnum.FILL_ACCOUNT);
+        sysUserCoursesAccountDetail.setAmount(money.negate());
+        sysUserCoursesAccountDetail.setBalance(cashAccount.getCourseBalance().subtract(money));
+        sysUserCoursesAccountDetail.setDescription("课程余额转账");
+        sysUserCoursesAccountDetail.setStatus(DealStatusEnum.SUCCESS);
+        sysUserCoursesAccountDetail.setUpdateTime(date);
+        sysUserCoursesAccountDetail.setCreateTime(date);
+        sysUserCoursesAccountDetailDao.insert(sysUserCoursesAccountDetail);
+
+        return true;
+    }
+
+    @Override
+    public SysUserCashAccount getLocked(Integer userId) {
+        return sysUserCashAccountDao.getLocked(userId);
+    }
 
 }

+ 53 - 33
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -27,6 +27,7 @@ import com.ym.mec.util.date.DateUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
@@ -470,7 +471,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 					.map(CourseSchedule::getId)
 					.collect(Collectors.toList());
 			//删除对应的课程及相关信息
-			courseScheduleService.deleteCourseSchedules(deleteCourseScheduleIds);
+			courseScheduleService.batchDeleteCourseSchedules(deleteCourseScheduleIds);
 
 		}
 
@@ -1301,35 +1302,37 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 		//插入缴费明细
 		//收入
-		SysUserCashAccountDetail sysUserIncomeCashAccountDetail = new SysUserCashAccountDetail();
-		sysUserIncomeCashAccountDetail.setUserId(userId);
-		sysUserIncomeCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
-		sysUserIncomeCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
-		sysUserIncomeCashAccountDetail.setAmount(order.getActualAmount());
-		sysUserIncomeCashAccountDetail.setBalance(sysUserCashAccount.getBalance().add(order.getActualAmount()));
-		sysUserIncomeCashAccountDetail.setAttribute(order.getTransNo());
-		sysUserIncomeCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
-		sysUserIncomeCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount());
-		sysUserIncomeCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount());
-
-		//支出
-		SysUserCashAccountDetail sysUserExpendCashAccountDetail = new SysUserCashAccountDetail();
-		sysUserExpendCashAccountDetail.setUserId(userId);
-		sysUserExpendCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.PAY_FEE);
-		sysUserExpendCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
-		sysUserExpendCashAccountDetail.setAmount(order.getActualAmount().negate());
-		sysUserExpendCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
-		sysUserExpendCashAccountDetail.setAttribute(order.getTransNo());
-		sysUserExpendCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
-		if(studentPaymentOrder.getComAmount() != null){
-			sysUserExpendCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
-		}
-		if(studentPaymentOrder.getPerAmount() != null){
-			sysUserExpendCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
-		}
-
-		sysUserCashAccountDetailService.insert(sysUserIncomeCashAccountDetail);
-		sysUserCashAccountDetailService.insert(sysUserExpendCashAccountDetail);
+		if(Objects.nonNull(order.getActualAmount())&&order.getActualAmount().compareTo(BigDecimal.ZERO)!=0){
+			SysUserCashAccountDetail sysUserIncomeCashAccountDetail = new SysUserCashAccountDetail();
+			sysUserIncomeCashAccountDetail.setUserId(userId);
+			sysUserIncomeCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
+			sysUserIncomeCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
+			sysUserIncomeCashAccountDetail.setAmount(order.getActualAmount());
+			sysUserIncomeCashAccountDetail.setBalance(sysUserCashAccount.getBalance().add(order.getActualAmount()));
+			sysUserIncomeCashAccountDetail.setAttribute(order.getTransNo());
+			sysUserIncomeCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+			sysUserIncomeCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount());
+			sysUserIncomeCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount());
+
+			//支出
+			SysUserCashAccountDetail sysUserExpendCashAccountDetail = new SysUserCashAccountDetail();
+			sysUserExpendCashAccountDetail.setUserId(userId);
+			sysUserExpendCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.PAY_FEE);
+			sysUserExpendCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
+			sysUserExpendCashAccountDetail.setAmount(order.getActualAmount().negate());
+			sysUserExpendCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
+			sysUserExpendCashAccountDetail.setAttribute(order.getTransNo());
+			sysUserExpendCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+			if(studentPaymentOrder.getComAmount() != null){
+				sysUserExpendCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
+			}
+			if(studentPaymentOrder.getPerAmount() != null){
+				sysUserExpendCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
+			}
+
+			sysUserCashAccountDetailService.insert(sysUserIncomeCashAccountDetail);
+			sysUserCashAccountDetailService.insert(sysUserExpendCashAccountDetail);
+		}
 		Map<Integer,String> map = new HashMap<>(1);
 		map.put(userId,userId.toString());
 		sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_VIP_BUY, map, null, 0, "2","STUDENT",
@@ -1613,12 +1616,18 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			throw new BizException("此学生存在退课申请,请到系统日志中查看");
 		}
 
+		ClassGroup classGroup = classGroupDao.findByVipGroup(studentRecoverInfo.getVipGroupId().longValue(), null);
+
 		Integer oldTeacherId=vipGroup.getUserId();
 		if(Objects.nonNull(studentRecoverInfo.getTeacherId())&&!studentRecoverInfo.getTeacherId().equals(vipGroup.getUserId())){
-			vipGroup.setUserId(studentRecoverInfo.getUserId());
-		}
+			vipGroup.setUserId(studentRecoverInfo.getTeacherId());
 
-		ClassGroup classGroup = classGroupDao.findByVipGroup(studentRecoverInfo.getVipGroupId().longValue(), null);
+			ImGroupMember[] imGroupMembers = new ImGroupMember[]{new ImGroupMember(oldTeacherId.toString())};
+			imFeignService.groupQuit(new ImGroupModel(classGroup.getId().toString(), imGroupMembers, classGroup.getName()));
+
+			ImGroupMember[] newImGroupMemberList = new ImGroupMember[]{new ImGroupMember(vipGroup.getUserId().toString())};
+			imFeignService.groupJoin(new ImGroupModel(classGroup.getId().toString(), newImGroupMemberList,classGroup.getName()));
+		}
 
 		ClassGroupStudentMapper classStudentMapperByUserIdAndClassGroupId = classGroupStudentMapperDao.query(classGroup.getId(),
 				studentRecoverInfo.getUserId());
@@ -1677,6 +1686,17 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 				throw new BizException("请设置默认课酬");
 			}
 
+			ClassGroupTeacherMapper oldClassGroupTeacherMapper = classGroupTeacherMapperDao.findByClassGroupAndTeacher(classGroup.getId(),oldTeacherId);
+			if(Objects.nonNull(oldClassGroupTeacherMapper)){
+				ClassGroupTeacherMapper classGroupTeacherMapper=new ClassGroupTeacherMapper();
+				BeanUtils.copyProperties(oldClassGroupTeacherMapper,classGroupTeacherMapper);
+				classGroupTeacherMapper.setUserId(vipGroup.getUserId());
+				classGroupTeacherMapper.setCreateTime(now);
+				classGroupTeacherMapper.setUpdateTime(now);
+				classGroupTeacherMapperDao.delete(oldClassGroupTeacherMapper.getId());
+				classGroupTeacherMapperDao.insert(classGroupTeacherMapper);
+			}
+
 			//创建老师单节课课酬信息
 			courseScheduleTeacherSalaryService.createCourseScheduleTeacherVipSalary(vipGroup,
 					newCourseSchedules,

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

@@ -162,6 +162,9 @@
     <select id="findByClassGroup" resultMap="ClassGroupTeacherMapper">
         SELECT * FROM class_group_teacher_mapper WHERE class_group_id_=#{classGroupId}
     </select>
+    <select id="findByClassGroupAndTeacher" resultMap="ClassGroupTeacherMapper">
+        SELECT * FROM class_group_teacher_mapper WHERE class_group_id_=#{classGroupId} AND user_id_=#{userId}
+    </select>
     <select id="findByClassGroupIds" resultMap="ClassGroupTeacherMapDto">
         SELECT
             cgtm.*,

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

@@ -137,7 +137,7 @@ public class CourseScheduleController extends BaseController {
         }
         long[] ints = Arrays.asList(courseScheduleIds.split(",")).stream().mapToLong(Long::parseLong).toArray();
         Long[] longs = ArrayUtils.toObject(ints);
-        scheduleService.deleteCourseSchedules(Arrays.asList(longs));
+        scheduleService.batchDeleteCourseSchedules(Arrays.asList(longs));
         return succeed();
     }
 
@@ -282,6 +282,14 @@ public class CourseScheduleController extends BaseController {
         return succeed();
     }
 
+    @ApiOperation(value = "课程批量调整")
+    @PostMapping("/batchUpdateCourseSchedule")
+    @PreAuthorize("@pcs.hasPermissions('courseSchedule/batchUpdateCourseSchedule')")
+    public Object batchUpdateCourseSchedule(@RequestBody BatchInsertCoursesDto batchInsertCoursesDto){
+        scheduleService.batchUpdateCourseSchedule(batchInsertCoursesDto);
+        return succeed();
+    }
+
     @ApiOperation(value = "vip课批量新增")
     @PostMapping("/batchAppendVipGroupCourses")
     @PreAuthorize("@pcs.hasPermissions('courseSchedule/batchAppendVipGroupCourses')")

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

@@ -47,8 +47,8 @@ public class SysUserCashAccountController extends BaseController {
 	@ApiOperation(value = "将课程余额转入到可用余额")
 	@PostMapping("/transferCourseBalanceToBalance")
 	@PreAuthorize("@pcs.hasPermissions('userCashAccount/transferCourseBalanceToBalance')")
-	public Object transferCourseBalanceToBalance(Integer userId) {
-		sysUserCashAccountService.transferCourseBalanceToBalance(userId);
+	public Object transferCourseBalanceToBalance(Integer userId,BigDecimal money) {
+		sysUserCashAccountService.transferCourseBalanceToBalance(userId,money);
 		return succeed();
 	}