소스 검색

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java
#	mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml
周箭河 4 년 전
부모
커밋
7d227b2be8

+ 30 - 8
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java

@@ -1,12 +1,17 @@
 package com.ym.mec.biz.dal.dao;
 
-import java.util.*;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
-import com.ym.mec.biz.dal.dto.CalenderPushDto;
-import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDto;
 import org.apache.ibatis.annotations.Param;
 
+import com.ym.mec.biz.dal.dto.CalenderPushDto;
+import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDto;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType;
 import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
 import com.ym.mec.common.dal.BaseDAO;
 
@@ -83,6 +88,7 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
 
     /**
      * @param musicGroupId:
+     * @param payUserType:
      * @param paymentValidStartDate:
      * @param paymentValidEndDate:
      * @return int
@@ -92,7 +98,7 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
      * @date 2020/9/21
      * @time 10:46
      */
-    int queryIntersectionByValidDate(@Param("musicGroupId") String musicGroupId,
+    int queryIntersectionByValidDate(@Param("musicGroupId") String musicGroupId,@Param("payUserType") PayUserType payUserType,
                                      @Param("paymentValidStartDate") Date paymentValidStartDate,
                                      @Param("paymentValidEndDate") Date paymentValidEndDate,
                                      @Param("calenderId") Long calenderId);
@@ -203,9 +209,25 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
     MusicGroupPaymentCalender findByMusicGroupRegCalender(@Param("musicGroupId") String musicGroupId);
 
     /**
-     * 获取乐团报名缴费日历
-     * @param musicGroupId
-     * @return
+     * @describe 获取收费标准名称
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/11/4
+     * @time 10:11
+     * @param calenderId:
+     * @return java.lang.String
+     */
+    String getCalenderSettingsName(Long calenderId);
+
+    /**
+     * @describe 统计乐团还在审核中或者审核被拒的缴费
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/11/4
+     * @time 10:37
+     * @param musicGroupId:
+     * @param calenderId:
+     * @return int
      */
-    MusicGroupPaymentCalender getMusicGroupRegCalender(@Param("musicGroupId") String musicGroupId);
+    int countAuditReject(@Param("musicGroupId") String musicGroupId, @Param("calenderId") Long calenderId);
 }

+ 47 - 33
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -27,7 +27,6 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
-
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -118,7 +117,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null && musicGroupPaymentCalender.getPayUserType() == PayUserType.STUDENT) {
 			musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
 		}
-		int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPaymentValidStartDate(),
+		int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPayUserType(), musicGroupPaymentCalender.getPaymentValidStartDate(),
 				musicGroupPaymentCalender.getPaymentValidEndDate(), null);
 		if (count > 0) {
 			throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
@@ -182,14 +181,17 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 			// 如果是报名,需要修改乐团状态
 			if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY) {
-				if (musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT) {
-					throw new BizException("创建失败:缴费项目类型不匹配");
+				int countAuditReject = musicGroupPaymentCalenderDao.countAuditReject(musicGroupPaymentCalender.getMusicGroupId(),null);
+				if(countAuditReject == 0){
+					if (musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT) {
+						throw new BizException("创建失败:缴费项目类型不匹配");
+					}
+					musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
+					musicGroup.setUpdateTime(date);
+					// 记录操作日志
+					musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(草稿 -> 审核中)", sysUser.getId(), ""));
+					musicGroupDao.update(musicGroup);
 				}
-				musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
-				musicGroup.setUpdateTime(date);
-				// 记录操作日志
-				musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(草稿 -> 审核中)", sysUser.getId(), ""));
-				musicGroupDao.update(musicGroup);
 			}
 		}
 
@@ -222,8 +224,13 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		calender.setActualNum(actualNumMap.get(id) == null ? 0 : actualNumMap.get(id).intValue());
 		calender.setExpectNum(expectNumMap.get(id) == null ? 0 : expectNumMap.get(id).intValue());
 		BigDecimal sumActualAmount = musicGroupPaymentCalenderDetailDao.sumActualAmount(id);
+		//收费标准名称
+		String name = musicGroupPaymentCalenderDao.getCalenderSettingsName(id);
+		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.queryCalenderCourseSettings(id);
 		Map<String, Object> result = new HashMap<>(2);
+		result.put("musicGroupPaymentCalenderCourseSettings", musicGroupPaymentCalenderCourseSettings);
 		result.put("calender", calender);
+		result.put("calenderSettingsName", name);
 		result.put("sumActualAmount", sumActualAmount);
 		return result;
 	}
@@ -259,7 +266,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		if (musicGroupPaymentCalender.getDeadlinePaymentDate() == null && musicGroupPaymentCalender.getPayUserType() == PayUserType.STUDENT) {
 			musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
 		}
-		int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPaymentValidStartDate(),
+		int count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPayUserType(), musicGroupPaymentCalender.getPaymentValidStartDate(),
 				musicGroupPaymentCalender.getPaymentValidEndDate(), null);
 		if (count > 0) {
 			throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
@@ -323,15 +330,19 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			}
 
 			// 如果是报名,需要修改乐团状态
+
 			if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY) {
-				if (musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT) {
-					throw new BizException("创建失败:缴费项目类型不匹配");
+				int countAuditReject = musicGroupPaymentCalenderDao.countAuditReject(musicGroupPaymentCalender.getMusicGroupId(),musicGroupPaymentCalender.getId());
+				if(countAuditReject == 0){
+					if (musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT) {
+						throw new BizException("创建失败:缴费项目类型不匹配");
+					}
+					musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
+					musicGroup.setUpdateTime(date);
+					// 记录操作日志
+					musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(草稿 -> 审核中)", sysUser.getId(), ""));
+					musicGroupDao.update(musicGroup);
 				}
-				musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
-				musicGroup.setUpdateTime(date);
-				// 记录操作日志
-				musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "报名缴费项目创建成功(草稿 -> 审核中)", sysUser.getId(), ""));
-				musicGroupDao.update(musicGroup);
 			}
 		}
 		
@@ -453,23 +464,26 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		} else {
 			musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.NO);
 		}
-		//如果是报名,需要修改乐团状态
-		if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY) {
-			MusicGroup musicGroup = musicGroupDao.get(musicGroupPaymentCalender.getMusicGroupId());
-			musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
-			musicGroup.setUpdateTime(date);
-			musicGroupDao.update(musicGroup);
-			SysUser sysUser = sysUserFeignService.queryUserInfo();
-			if(sysUser == null || sysUser.getId() == null){
-				throw new BizException("请重新登录");
-			}
-			//记录操作日志
-			musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroup.getId(), "报名缴费项目通过(草稿 -> 审核中)", sysUser.getId(), ""));
-
-		}
 		musicGroupPaymentCalender.setAuditMemo(auditMemo);
 		musicGroupPaymentCalender.setUpdateTime(date);
 		musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
+		//如果是报名,并且所有的报名都审核通过,需要修改乐团状态
+
+		if (musicGroupPaymentCalender.getPaymentType() == MUSIC_APPLY) {
+			int count = musicGroupPaymentCalenderDao.countAuditReject(musicGroupPaymentCalender.getMusicGroupId(),calenderId);
+			if(count == 0){
+				MusicGroup musicGroup = musicGroupDao.get(musicGroupPaymentCalender.getMusicGroupId());
+				musicGroup.setStatus(MusicGroupStatusEnum.AUDIT);
+				musicGroup.setUpdateTime(date);
+				musicGroupDao.update(musicGroup);
+				SysUser sysUser = sysUserFeignService.queryUserInfo();
+				if(sysUser == null || sysUser.getId() == null){
+					throw new BizException("请重新登录");
+				}
+				//记录操作日志
+				musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroup.getId(), "报名缴费项目通过(草稿 -> 审核中)", sysUser.getId(), ""));
+			}
+		}
 	}
 
 	@Override
@@ -477,7 +491,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	public void auditRefuse(Long calenderId,String auditMemo) {
 		MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(calenderId);
 		Date date = new Date();
-		musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.AUDITING);
+		musicGroupPaymentCalender.setStatus(PaymentCalenderStatusEnum.REJECT);
 		musicGroupPaymentCalender.setUpdateTime(date);
 		musicGroupPaymentCalender.setAuditMemo(auditMemo);
 		musicGroupPaymentCalenderDao.update(musicGroupPaymentCalender);
@@ -653,7 +667,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		if (count > 0) {
 			throw new BizException("缴费时间存在冲突,请修改缴费开始日期");
 		}
-		count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(calender.getMusicGroupId(), paymentCalender.getPaymentValidStartDate(),
+		count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(calender.getMusicGroupId(), paymentCalender.getPayUserType(), paymentCalender.getPaymentValidStartDate(),
 				paymentCalender.getPaymentValidEndDate(), paymentCalender.getId());
 		if (count > 0) {
 			throw new BizException("缴费有效期存在冲突,请修改缴费有效期");

+ 23 - 17
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml

@@ -32,7 +32,7 @@
 
     <!-- 根据主键查询一条记录 -->
     <select id="get" resultMap="MusicGroupPaymentCalender">
-		SELECT * FROM music_group_payment_calender WHERE id_ = #{id}
+		SELECT * FROM music_group_payment_calender WHERE id_ = #{id} 
 	</select>
 
     <!-- 全查询 -->
@@ -129,7 +129,7 @@
         </set>
         WHERE id_ = #{id}
     </update>
-
+    
     <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender">
 	    <foreach collection="list" item="item" index="index" open="" close="" separator=";">
 	        UPDATE music_group_payment_calender
@@ -189,7 +189,7 @@
 
     <!-- 根据主键删除一条记录 -->
     <delete id="delete">
-		DELETE FROM music_group_payment_calender WHERE id_ = #{id}
+		DELETE FROM music_group_payment_calender WHERE id_ = #{id} 
 	</delete>
 
     <delete id="delByGroupId">
@@ -229,13 +229,13 @@
         	</if>
         </where>
 	</select>
-
+	
     <select id="findByMusicGroupId" resultMap="MusicGroupPaymentCalender">
         SELECT * FROM music_group_payment_calender mgpc
         WHERE music_group_id_ = #{musicGroupId}
         ORDER BY id_
     </select>
-
+	
     <select id="queryByPaymentStatus" resultMap="MusicGroupPaymentCalender">
         SELECT * FROM music_group_payment_calender mgpc
         <where>
@@ -251,17 +251,17 @@
     <select id="getForLock" resultMap="MusicGroupPaymentCalender">
         SELECT * FROM music_group_payment_calender WHERE id_ = #{id} FOR UPDATE
     </select>
-
+	
     <select id="queryIntersectionByPaymentDate" resultType="int" parameterType="map">
         SELECT count(*) FROM music_group_payment_calender mgpc
-        WHERE music_group_id_ = #{musicGroupId}
+        WHERE music_group_id_ = #{musicGroupId} 
         and (start_payment_date_ between #{startPaymentDate} and #{deadlinePaymentDate}
         or deadline_payment_date_ between #{startPaymentDate} and #{deadlinePaymentDate})
         <if test="calenderId != null">
             AND mgpc.id_ != #{calenderId}
         </if>
     </select>
-
+    
     <select id="getLastStartOne" resultMap="MusicGroupPaymentCalender">
         SELECT * FROM music_group_payment_calender WHERE music_group_id_ = #{musicGroupId} ORDER BY start_payment_date_ DESC LIMIT 1
     </select>
@@ -277,6 +277,9 @@
         WHERE music_group_id_ = #{musicGroupId}
         AND (payment_valid_end_date_ IS NULL OR payment_valid_start_date_ BETWEEN #{paymentValidStartDate} AND #{paymentValidEndDate}
         OR payment_valid_end_date_ BETWEEN #{paymentValidStartDate} AND #{paymentValidEndDate}) AND payment_valid_start_date_ IS NOT NULL
+        <if test="payUserType != null">
+        	and pay_user_type_ = #{payUserType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        </if>
         <if test="calenderId != null">
             AND mgpc.id_ != #{calenderId}
         </if>
@@ -385,8 +388,8 @@
             <if test="paymentType != null">
                 AND mgpc.payment_type_ = #{paymentType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
             </if>
-            <if test="paymentCalenderStatus != null">
-                AND mgpc.status_ = #{paymentCalenderStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            <if test="status != null">
+                AND mgpc.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
             </if>
             <if test="organId != null and organId != ''">
                 AND FIND_IN_SET(mg.organ_id_,#{organId})
@@ -440,12 +443,15 @@
     <select id="findByMusicGroupRegCalender" resultMap="MusicGroupPaymentCalender">
         SELECT * FROM music_group_payment_calender WHERE music_group_id_=#{musicGroupId} AND payment_type_='MUSIC_APPLY'
     </select>
-
-    <select id="getMusicGroupRegCalender" resultMap="MusicGroupPaymentCalender">
-        SELECT * FROM music_group_payment_calender
-        WHERE music_group_id_ = #{musicGroupId}
-        AND payment_type_ = 'MUSIC_APPLY'
-        AND pay_user_type_='STUDENT'
-        AND status_='OPEN'
+    <select id="getCalenderSettingsName" resultType="java.lang.String">
+        SELECT name_ FROM music_group_payment_calender_course_settings
+        WHERE music_group_payment_calender_id_ = #{calenderId} LIMIT 1
+    </select>
+    <select id="countAuditReject" resultType="java.lang.Integer">
+        SELECT COUNT(0) FROM music_group_payment_calender
+        WHERE music_group_id_ = #{musicGroupId} AND payment_type_='MUSIC_APPLY' AND status_ IN ('REJECT','AUDITING')
+        <if test="calenderId != null">
+            AND id_ != #{calenderId}
+        </if>
     </select>
 </mapper>