浏览代码

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

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDetailDao.java
#	mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java
yonge 5 年之前
父节点
当前提交
2adefa0bcb

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

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
 
 public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicGroupPaymentCalenderDetail> {
 
@@ -13,11 +14,25 @@ public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicG
 	 * @return
 	 */
 	int batchInsert(List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList);
-	
+
+	/**
+	 * 获取列表
+	 * @param ids
+	 * @return
+	 */
+    List<MusicGroupPaymentCalenderDetail> queryListByIds(@Param("ids") String ids);
+
+	/**
+	 * 批量修改
+	 * @param calenderDetails
+	 */
+	void batchUpdate(@Param("calenderDetails") List<MusicGroupPaymentCalenderDetail> calenderDetails);
+
 	/**
 	 * 根据指定的日历编号查询
 	 * @param musicGroupPaymentCalenderId
 	 * @return
 	 */
 	List<MusicGroupPaymentCalenderDetail> queryByCalenderId(Long musicGroupPaymentCalenderId);
+
 }

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

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.entity;
 
+import com.ym.mec.auth.api.entity.SysUser;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
@@ -38,7 +39,27 @@ public class MusicGroupPaymentCalenderDetail {
 	
 	/**  */
 	private java.util.Date createTime;
-	
+
+	private SysUser sysUser;
+
+	private Student student;
+
+	public Student getStudent() {
+		return student;
+	}
+
+	public void setStudent(Student student) {
+		this.student = student;
+	}
+
+	public SysUser getSysUser() {
+		return sysUser;
+	}
+
+	public void setSysUser(SysUser sysUser) {
+		this.sysUser = sysUser;
+	}
+
 	public void setId(Long id){
 		this.id = id;
 	}

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Student.java

@@ -13,6 +13,9 @@ public class Student {
 	/**  */
 	private String subjectIdList;
 
+	/**  */
+	private String subjectNames;
+
 	private Integer serviceTag;
 
 	private Integer operatingTag;
@@ -32,6 +35,14 @@ public class Student {
 		this.subjectIdList = subjectIdList;
 	}
 
+	public String getSubjectNames() {
+		return subjectNames;
+	}
+
+	public void setSubjectNames(String subjectNames) {
+		this.subjectNames = subjectNames;
+	}
+
 	public Student(Integer userId) {
 		this.userId = userId;
 	}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicCalenderDetailQueryInfo.java

@@ -9,8 +9,18 @@ public class MusicCalenderDetailQueryInfo extends QueryInfo {
 
 	private PaymentStatusEnum paymentStatus;
 
+	private Integer subjectId;
+
 	private Long id;
 
+	public Integer getSubjectId() {
+		return subjectId;
+	}
+
+	public void setSubjectId(Integer subjectId) {
+		this.subjectId = subjectId;
+	}
+
 	public Integer getUserId() {
 		return userId;
 	}

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

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

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderDetailService.java

@@ -3,6 +3,21 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
 import com.ym.mec.common.service.BaseService;
 
+import java.math.BigDecimal;
+
 public interface MusicGroupPaymentCalenderDetailService extends BaseService<Long, MusicGroupPaymentCalenderDetail> {
 
+    /**
+     * 修改学员预计缴费金额
+     * @param actualAmount
+     * @param ids
+     * @return
+     */
+    void updateActualAmount(BigDecimal actualAmount,String ids);
+
+    /**
+     * 开启缴费
+     * @param ids
+     */
+    void openPayment(String ids);
 }

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

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

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

@@ -1,13 +1,24 @@
 package com.ym.mec.biz.service.impl;
 
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderDetailService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.NON_PAYMENT;
+import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.PROCESSING;
 
 @Service
 public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalenderDetail>  implements MusicGroupPaymentCalenderDetailService {
@@ -19,5 +30,51 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 	public BaseDAO<Long, MusicGroupPaymentCalenderDetail> getDAO() {
 		return musicGroupPaymentCalenderDetailDao;
 	}
-	
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateActualAmount(BigDecimal actualAmount,String ids) {
+		if(actualAmount == null || StringUtils.isEmpty(ids)){
+			throw new BizException("参数校验失败");
+		}
+		String[] split = ids.split(",");
+		//获取缴费列表
+		List<MusicGroupPaymentCalenderDetail> calenderDetails = musicGroupPaymentCalenderDetailDao.queryListByIds(ids);
+		if(calenderDetails.size() == 0){
+			throw new BizException("缴费记录不存在");
+		}
+		Date date = new Date();
+		calenderDetails.forEach(e->{
+			if(e.getPaymentStatus() == null || e.getPaymentStatus() != NON_PAYMENT){
+				throw new BizException("修改失败,缴费状态不匹配");
+			}
+			e.setUpdateTime(date);
+			e.setActualAmount(actualAmount);
+		});
+		musicGroupPaymentCalenderDetailDao.batchUpdate(calenderDetails);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void openPayment(String ids) {
+		if(StringUtils.isEmpty(ids)){
+			throw new BizException("参数校验失败");
+		}
+		//获取缴费列表
+		List<MusicGroupPaymentCalenderDetail> calenderDetails = musicGroupPaymentCalenderDetailDao.queryListByIds(ids);
+		if(calenderDetails.size() == 0){
+			throw new BizException("缴费记录不存在");
+		}
+		Date date = new Date();
+		calenderDetails.forEach(e->{
+			if(e.getPaymentStatus() == null || e.getPaymentStatus() != NON_PAYMENT){
+				throw new BizException("修改失败,缴费状态不匹配");
+			}
+			e.setUpdateTime(date);
+			e.setPaymentStatus(PROCESSING);
+		});
+		musicGroupPaymentCalenderDetailDao.batchUpdate(calenderDetails);
+		Set<Integer> studentIds = calenderDetails.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
+		//推送消息
+	}
 }

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

@@ -225,6 +225,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			throw new BizException("修改失败,缴费状态不匹配");
 		}
 		calender.setStartPaymentDate(startTime);
+		calender.setDeadlinePaymentDate(DateUtil.addDays(startTime,3));
 		calender.setUpdateTime(new Date());
 		musicGroupPaymentCalenderDao.update(calender);
 	}

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

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

+ 60 - 5
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml

@@ -15,6 +15,12 @@
 		<result column="pay_time_" property="payTime" />
 		<result column="update_time_" property="updateTime" />
 		<result column="create_time_" property="createTime" />
+		<association property="sysUser" javaType="com.ym.mec.auth.api.entity.SysUser">
+			<result column="username_" property="username" />
+		</association>
+		<association property="student" javaType="com.ym.mec.biz.dal.entity.Student">
+			<result column="subject_names_" property="subjectNames" />
+		</association>
 	</resultMap>
 
 	<!-- 根据主键查询一条记录 -->
@@ -85,6 +91,38 @@
 		</set>
 		WHERE id_ = #{id}
 	</update>
+	<update id="batchUpdate">
+		<foreach collection="calenderDetails" item="item" index="index" open="" close="" separator=";">
+			UPDATE music_group_payment_calender_detail
+			<set>
+				<if test="item.userId != null">
+					user_id_ = #{item.userId},
+				</if>
+				<if test="item.userStatus != null">
+					user_status_ = #{item.userStatus},
+				</if>
+				<if test="item.paymentStatus != null">
+					payment_status_ = #{item.paymentStatus},
+				</if>
+				<if test="item.expectAmount != null">
+					expect_amount_ = #{item.expectAmount},
+				</if>
+				<if test="item.updateTime != null">
+					update_time_ = #{item.updateTime},
+				</if>
+				<if test="item.musicGroupPaymentCalenderId != null">
+					music_group_payment_calender_id_ = #{item.musicGroupPaymentCalenderId},
+				</if>
+				<if test="item.actualAmount != null">
+					actual_amount_ = #{item.actualAmount},
+				</if>
+				<if test="item.payTime != null">
+					pay_time_ = #{item.payTime}
+				</if>
+			</set>
+			WHERE id_ = #{item.id}
+		</foreach>
+	</update>
 
 	<!-- 根据主键删除一条记录 -->
 	<delete id="delete">
@@ -94,30 +132,47 @@
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="MusicGroupPaymentCalenderDetail"
 		parameterType="map">
-		SELECT * FROM music_group_payment_calender_detail
+		SELECT mgpc.*,su.username_,GROUP_CONCAT(DISTINCT st.name_) subject_names_
+		FROM music_group_payment_calender_detail mgpc
+		LEFT JOIN sys_user su ON su.id_ = mgpc.user_id_
+		LEFT JOIN student s ON s.user_id_ = mgpc.user_id_
+		LEFT JOIN `subject` st ON FIND_IN_SET(st.id_,s.subject_id_list_)
 		<where>
 			<if test="userId != null">
-				user_id_ = #{userId}
+				mgpc.user_id_ = #{userId}
 			</if>
 			<if test="paymentStatus != null">
-				payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+				mgpc.payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+			</if>
+			<if test="subjectId != null">
+				FIND_IN_SET(#{subjectId},s.subject_id_list_)
 			</if>
 		</where>
-		ORDER BY create_time_
+		GROUP BY mgpc.id_
+		ORDER BY mgpc.create_time_
 		<include refid="global.limit" />
 	</select>
 
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM music_group_payment_calender_detail
+		SELECT COUNT(mgpc.id_) FROM music_group_payment_calender_detail mgpc
+		LEFT JOIN student s ON s.user_id_ = mgpc.user_id_
+		LEFT JOIN `subject` st ON FIND_IN_SET(st.id_,s.subject_id_list_)
 		<where>
 			<if test="userId != null">
 				user_id_ = #{userId}
 			</if>
+			<if test="subjectId != null">
+				FIND_IN_SET(#{subjectId},s.subject_id_list_)
+			</if>
 			<if test="paymentStatus != null">
 				payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 			</if>
 		</where>
+		GROUP BY mgpc.id_
+	</select>
+	<select id="queryListByIds" resultMap="MusicGroupPaymentCalenderDetail">
+		SELECT * FROM music_group_payment_calender_detail WHERE FIND_IN_SET(id_,#{ids})
 	</select>
 	
 	<select id="queryByCalenderId" resultMap="MusicGroupPaymentCalenderDetail">

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

@@ -2,7 +2,6 @@ package com.ym.mec.web.controller;
 
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-
 import java.util.Date;
 import java.util.List;
 

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

@@ -3,15 +3,17 @@ package com.ym.mec.web.controller;
 import com.ym.mec.biz.dal.page.MusicCalenderDetailQueryInfo;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderDetailService;
 import com.ym.mec.common.controller.BaseController;
-import com.ym.mec.common.page.QueryInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
+
 @RequestMapping("musicGroupPaymentCalenderDetail")
 @Api(tags = "乐团缴费明细")
 @RestController
@@ -20,10 +22,26 @@ public class MusicGroupPaymentCalenderDetailController extends BaseController {
     @Autowired
     private MusicGroupPaymentCalenderDetailService musicGroupPaymentCalenderDetailService;
 
-    @ApiOperation(value = "分页查询乐团缴费日历列表")
+    @ApiOperation(value = "分页查询乐团缴费明细列表")
     @GetMapping("/queryPage")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalenderDetail/queryPage')")
     public Object queryPage(MusicCalenderDetailQueryInfo queryInfo) {
         return succeed(musicGroupPaymentCalenderDetailService.queryPage(queryInfo));
     }
+
+    @ApiOperation(value = "修改学员预计缴费金额")
+    @PostMapping("/updateActualAmount")
+    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalenderDetail/updateActualAmount')")
+    public Object updateActualAmount(BigDecimal actualAmount,String ids) {
+        musicGroupPaymentCalenderDetailService.updateActualAmount(actualAmount,ids);
+        return succeed();
+    }
+
+    @ApiOperation(value = "开启缴费")
+    @PostMapping("/openPayment")
+    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalenderDetail/openPayment')")
+    public Object openPayment(String ids) {
+        musicGroupPaymentCalenderDetailService.openPayment(ids);
+        return succeed();
+    }
 }