yonge 5 anni fa
parent
commit
9c2b70f023

+ 34 - 19
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java

@@ -1,31 +1,46 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
 import com.ym.mec.common.dal.BaseDAO;
+
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
 public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPaymentCalender> {
 
+	/**
+	 * 根据乐团编号删除乐团缴费周期
+	 * @param musicGroupId
+	 */
+	void delByGroupId(String musicGroupId);
+
+	/**
+	 * 根据乐团编号获取乐团缴费日历
+	 * @param musicGroupId
+	 * @return
+	 */
+	List<MusicGroupPaymentCalender> findByMusicGroupId(String musicGroupId);
+
+	/**
+	 * 批量新增乐团缴费周期
+	 * @param calender
+	 * @param musicGroupId
+	 */
+	void batchAdd(@Param("calender") List<Integer> calender, @Param("musicGroupId") String musicGroupId);
+	
+	/**
+	 * 批量修改
+	 * @param musicGroupPaymentCalenderList
+	 * @return
+	 */
+	int batchUpdate(List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList);
 
-    /**
-     * 根据乐团编号删除乐团缴费周期
-     * @param musicGroupId
-     */
-    void delByGroupId(String musicGroupId);
-
-    /**
-     * 根据乐团编号获取乐团缴费日历
-     * @param musicGroupId
-     * @return
-     */
-    List<MusicGroupPaymentCalender> findByMusicGroupId(String musicGroupId);
-
-    /**
-     * 批量新增乐团缴费周期
-     * @param calender
-     * @param musicGroupId
-     */
-    void batchAdd(@Param("calender") List<Integer> calender,@Param("musicGroupId") String musicGroupId);
+	/**
+	 * 查询指定状态的记录
+	 * @param status
+	 * @return
+	 */
+	List<MusicGroupPaymentCalender> queryByPaymentStatus(List<PaymentStatusEnum> status);
 }

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

@@ -13,4 +13,11 @@ public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicG
 	 * @return
 	 */
 	int batchInsert(List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList);
+	
+	/**
+	 * 根据指定的日历编号查询
+	 * @param musicGroupPaymentCalenderId
+	 * @return
+	 */
+	List<MusicGroupPaymentCalenderDetail> queryByCalenderId(Long musicGroupPaymentCalenderId);
 }

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java

@@ -15,6 +15,12 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
 	 * @return
 	 */
 	boolean create(MusicGroupPaymentCalender musicGroupPaymentCalender);
+	
+	/**
+	 * 自动更新付款日历记录状态
+	 * @return
+	 */
+	boolean autoUpdateMusicGroupPaymentCalenderStatus();
 
 	/**
 	 * 批量新增、修改乐团缴费周期

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

@@ -98,6 +98,65 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
+	public boolean autoUpdateMusicGroupPaymentCalenderStatus() {
+		Date date = new Date();
+		List<PaymentStatusEnum> statusList = new ArrayList<PaymentStatusEnum>();
+		statusList.add(PaymentStatusEnum.NO);
+		statusList.add(PaymentStatusEnum.OPEN);
+		List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.queryByPaymentStatus(statusList);
+		
+		List<MusicGroupPaymentCalender> updateMusicGroupPaymentCalenderList = new ArrayList<MusicGroupPaymentCalender>();
+
+		MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
+		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
+		
+		for(MusicGroupPaymentCalender mgpc : musicGroupPaymentCalenderList){
+			
+			if(date.after(mgpc.getDeadlinePaymentDate())){
+				//“进行中”更新至“已结束”
+				mgpc.setUpdateTime(date);
+				mgpc.setPaymentStatus(PaymentStatusEnum.YES);
+				updateMusicGroupPaymentCalenderList.add(mgpc);
+				
+				//学生状态更新已结束
+				
+			} else if (date.after(mgpc.getStartPaymentDate())) {
+				//“未开始”更新至“进行中”
+				mgpc.setUpdateTime(date);
+				mgpc.setPaymentStatus(PaymentStatusEnum.OPEN);
+				updateMusicGroupPaymentCalenderList.add(mgpc);
+				
+				//学生状态更新进行中
+				List<MusicGroupStudentFee> list = musicGroupStudentFeeDao.queryByMusicGroupId(mgpc.getMusicGroupId());
+				
+				// 创建缴费明细
+				for (MusicGroupStudentFee mgsf : list) {
+					musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
+					musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(mgpc.getId());
+					musicGroupPaymentCalenderDetail.setCreateTime(date);
+					musicGroupPaymentCalenderDetail.setExpectAmount(mgsf.getCourseFee());
+					musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
+					musicGroupPaymentCalenderDetail.setUpdateTime(date);
+					musicGroupPaymentCalenderDetail.setUserId(mgsf.getUserId());
+
+					musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
+				}
+			}
+		}
+		
+		if(updateMusicGroupPaymentCalenderList.size() > 0){
+			
+		}
+
+		if (musicGroupPaymentCalenderDetailList.size() > 0) {
+			musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
+		}
+		
+		return true;
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public void batchInsert(List<MusicGroupPaymentCalender> musicGroupPaymentCalenders) {
 		if (musicGroupPaymentCalenders != null && musicGroupPaymentCalenders.size() > 0) {
 			musicGroupPaymentCalenderDao.delByGroupId(musicGroupPaymentCalenders.get(0).getMusicGroupId());

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml

@@ -119,4 +119,8 @@
 			</if>
 		</where>
 	</select>
+	
+	<select id="queryByCalenderId" resultMap="MusicGroupPaymentCalenderDetail">
+		SELECT * FROM music_group_payment_calender_detail where music_group_payment_calender_id_ = #{calenderId}
+	</select>
 </mapper>

+ 13 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml

@@ -108,9 +108,22 @@
 		SELECT COUNT(mgpc.id_) FROM music_group_payment_calender mgpc
         WHERE mgpc.music_group_id_ = #{musicGroupId}
 	</select>
+	
     <select id="findByMusicGroupId" resultMap="MusicGroupPaymentCalender">
         SELECT * FROM music_group_payment_calender mgpc
         WHERE music_group_id_ = #{musicGroupId}
         ORDER BY payment_month_
     </select>
+	
+    <select id="queryByPaymentStatus" resultMap="MusicGroupPaymentCalender">
+        SELECT * FROM music_group_payment_calender mgpc
+        <where>
+        	<if test="status != null">
+        		payment_status_ in
+        		<foreach collection=list item="item" separator=",">
+		            #{item}
+		        </foreach>
+        	</if>
+        </where>
+    </select>
 </mapper>

+ 13 - 8
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

@@ -1,19 +1,24 @@
 package com.ym.mec.web.controller;
 
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
-import com.ym.mec.biz.dal.page.MusicCalenderQueryInfo;
-import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
-import com.ym.mec.common.controller.BaseController;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.*;
 
 import java.util.Date;
 import java.util.List;
 
+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.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.page.MusicCalenderQueryInfo;
+import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
+import com.ym.mec.common.controller.BaseController;
+
 @RequestMapping("musicGroupPaymentCalender")
 @Api(tags = "乐团缴费日历服务")
 @RestController

+ 4 - 0
mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

@@ -222,4 +222,8 @@ public class TaskController extends BaseController {
 	public void updateStudentOperatingTag(){
 		studentService.updateOperatingTempTag();
 	}
+	
+	public void updateMusicGroupPaymentCalenderStatus(){
+		
+	}
 }