Browse Source

系统收费

zouxuan 3 years ago
parent
commit
9dcdd25735

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MemberRankPrivilegesDao.java

@@ -14,4 +14,11 @@ public interface MemberRankPrivilegesDao extends BaseDAO<Integer, MemberRankPriv
     List<MemberRankPrivileges> findByRankSettingId(Integer memberRankSettingId);
 
     void deleteByRankSettingId(Integer memberRankSettingId);
+
+    /**
+     * 当前功能是否被会员使用
+     * @param parentId
+     * @return
+     */
+    boolean hasPrivileges(Integer parentId);
 }

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentRegistrationDao.java

@@ -608,4 +608,12 @@ public interface StudentRegistrationDao extends BaseDAO<Long, StudentRegistratio
      * @return
      */
     boolean checkHasNotClass(@Param("musicGroupId") String musicGroupId);
+
+    /**
+     * 是否有其他会员收费团
+     * @param musicGroupId
+     * @param userId
+     * @return
+     */
+    boolean checkHasMemberGroup(@Param("musicGroupId") String musicGroupId, @Param("userId") Integer userId);
 }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MemberPrivilegesItemService.java

@@ -14,4 +14,6 @@ public interface MemberPrivilegesItemService extends BaseService<Integer, Member
     PageInfo<MemberPrivilegesItem> queryItemPage(MemberPrivilegesItemQueryInfo queryInfo);
 
     List<MemberPrivilegesItem> findAllItem(MemberPrivilegesItemQueryInfo queryInfo);
+
+    void updateItem(MemberPrivilegesItem memberPrivilegesItem);
 }

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

@@ -1,10 +1,12 @@
 package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.biz.dal.dao.MemberPrivilegesItemDao;
+import com.ym.mec.biz.dal.dao.MemberRankPrivilegesDao;
 import com.ym.mec.biz.dal.entity.MemberPrivilegesItem;
 import com.ym.mec.biz.dal.page.MemberPrivilegesItemQueryInfo;
 import com.ym.mec.biz.service.MemberPrivilegesItemService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -19,6 +21,8 @@ public class MemberPrivilegesItemServiceImpl extends BaseServiceImpl<Integer, Me
 	
 	@Autowired
 	private MemberPrivilegesItemDao memberPrivilegesItemDao;
+	@Autowired
+	private MemberRankPrivilegesDao memberRankPrivilegesDao;
 
 	@Override
 	public BaseDAO<Integer, MemberPrivilegesItem> getDAO() {
@@ -38,17 +42,26 @@ public class MemberPrivilegesItemServiceImpl extends BaseServiceImpl<Integer, Me
 
     @Override
 	@Transactional(rollbackFor = Exception.class)
-    public void recursiveDel(Integer parentId) {
-		List<MemberPrivilegesItem> memberPrivilegesItems = memberPrivilegesItemDao.findList(parentId);
+    public void recursiveDel(Integer memberPrivilegesItemId) {
+//		MemberPrivilegesItem privilegesItem = memberPrivilegesItemDao.get(memberPrivilegesItemId);
+//		Integer parentId = privilegesItem.getParentId();
+		//当前功能原有父级是否被会员使用
+//		if(memberRankPrivilegesDao.hasPrivileges(parentId)){
+//			throw new BizException("修改失败:该功能已被使用");
+//		}
+		if(memberRankPrivilegesDao.hasPrivileges(memberPrivilegesItemId)){
+			throw new BizException("删除失败:该功能已被使用");
+		}
+		List<MemberPrivilegesItem> memberPrivilegesItems = memberPrivilegesItemDao.findList(memberPrivilegesItemId);
 		for (MemberPrivilegesItem item : memberPrivilegesItems) {
 			item = getTree(item);
 		}
 		List<Integer> collect = memberPrivilegesItems.stream().map(e -> e.getId()).collect(Collectors.toList());
 		if(collect == null || collect.size() <= 0){
-			memberPrivilegesItemDao.delete(parentId);
+			memberPrivilegesItemDao.delete(memberPrivilegesItemId);
 			return;
 		}
-		collect.add(parentId);
+		collect.add(memberPrivilegesItemId);
 		memberPrivilegesItemDao.batchDel(collect);
     }
 
@@ -76,4 +89,21 @@ public class MemberPrivilegesItemServiceImpl extends BaseServiceImpl<Integer, Me
 		}
 		return rows;
 	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateItem(MemberPrivilegesItem memberPrivilegesItem) {
+//		MemberPrivilegesItem privilegesItem = memberPrivilegesItemDao.get(memberPrivilegesItem.getId());
+//		Integer parentId = memberPrivilegesItem.getParentId();
+//		if(privilegesItem.getParentId() != parentId){
+			//当前功能原有父级是否被会员使用
+//			if(memberRankPrivilegesDao.hasPrivileges(parentId)){
+//				throw new BizException("修改失败:该功能已被使用");
+//			}
+//		}
+		if(memberRankPrivilegesDao.hasPrivileges(memberPrivilegesItem.getId())){
+			throw new BizException("修改失败:该功能已被使用");
+		}
+		memberPrivilegesItemDao.update(memberPrivilegesItem);
+	}
 }

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

@@ -167,6 +167,11 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		if (paymentType == PaymentType.ADD_STUDENT) {
 			//获取缴费状态在审核中或者已拒绝的缴费项目的学员
 			Integer userId = Integer.parseInt(musicGroupPaymentCalenderDto.getStudentIds());
+			//该学员是否在其他的会员团
+			boolean hasMemberGroup = studentRegistrationDao.checkHasMemberGroup(musicGroupId,userId);
+			if(hasMemberGroup){
+				throw new BizException("操作失败:该学员已在其他系统收费团");
+			}
 			String studentIds = musicGroupPaymentCalenderDao.queryCalenderStudentIds(musicGroupId,null);
 			if(StringUtils.isNotEmpty(studentIds)){
 				if(studentIds.contains(userId.toString())){

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

@@ -60,4 +60,7 @@
 	<select id="findByRankSettingId" resultMap="MemberRankPrivileges">
 		SELECT * FROM member_rank_privileges WHERE member_rank_id_ = #{memberRankSettingId}
 	</select>
+    <select id="hasPrivileges" resultType="java.lang.Boolean">
+		SELECT COUNT(member_privileges_id_) > 0 FROM member_rank_privileges WHERE member_privileges_id_ = #{parentId}
+	</select>
 </mapper>

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

@@ -1504,4 +1504,7 @@
         WHERE sr.music_group_id_ = #{musicGroupId} AND sr.music_group_status_ = 'NORMAL'
         GROUP BY sr.music_group_id_
     </select>
+    <select id="checkHasMemberGroup" resultType="java.lang.Boolean">
+        SELECT COUNT(id_) > 0 FROM student_registration WHERE music_group_id_ != #{musicGroupId} AND music_group_status_ != 'QUIT' AND user_id_ = #{userId}
+    </select>
 </mapper>

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

@@ -40,7 +40,7 @@ public class MemberPrivilegesItemController extends BaseController {
     @PostMapping("/update")
     @PreAuthorize("@pcs.hasPermissions('memberPrivilegesItem/update')")
     public Object update(@RequestBody MemberPrivilegesItem memberPrivilegesItem) {
-        memberPrivilegesItemService.update(memberPrivilegesItem);
+        memberPrivilegesItemService.updateItem(memberPrivilegesItem);
         return succeed();
     }