yonge 5 rokov pred
rodič
commit
f2bbed8ac0

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

@@ -1,9 +1,16 @@
 package com.ym.mec.biz.dal.dao;
 
+import java.util.List;
+
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
 import com.ym.mec.common.dal.BaseDAO;
 
 public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicGroupPaymentCalenderDetail> {
 
-	
+	/**
+	 * 批量新增
+	 * @param musicGroupPaymentCalenderDetailList
+	 * @return
+	 */
+	int batchInsert(List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList);
 }

+ 30 - 21
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -1,5 +1,7 @@
 package com.ym.mec.biz.service.impl;
 
+import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.NO;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -7,15 +9,13 @@ import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
-import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
-import com.ym.mec.common.exception.BizException;
-
 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 com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
 import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
@@ -24,17 +24,19 @@ import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
 import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.date.DateUtil;
 
-import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.NO;
-
 @Service
 public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalender> implements MusicGroupPaymentCalenderService {
 
 	@Autowired
 	private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
-	
+
+	@Autowired
+	private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
+
 	@Autowired
 	private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
 
@@ -48,7 +50,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	public boolean create(MusicGroupPaymentCalender musicGroupPaymentCalender) {
 		Date date = new Date();
 		List<MusicGroupStudentFee> list = null;
-		
+
 		musicGroupPaymentCalender.setCreateTime(date);
 		musicGroupPaymentCalender.setUpdateTime(date);
 		musicGroupPaymentCalender.setDeadlinePaymentDate(DateUtil.addDays(musicGroupPaymentCalender.getStartPaymentDate(), 3));
@@ -56,23 +58,24 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			musicGroupPaymentCalender.setPaymentStatus(PaymentStatusEnum.YES);
 		} else if (date.after(musicGroupPaymentCalender.getStartPaymentDate())) {
 			musicGroupPaymentCalender.setPaymentStatus(PaymentStatusEnum.OPEN);
-			//统计缴费人数
+			// 统计缴费人数
 			list = musicGroupStudentFeeDao.queryByMusicGroupId(musicGroupPaymentCalender.getMusicGroupId());
-			if(list == null){
+			if (list == null) {
 				list = new ArrayList<MusicGroupStudentFee>();
 			}
 			musicGroupPaymentCalender.setExpectNum(list.size());
 		} else {
 			musicGroupPaymentCalender.setPaymentStatus(PaymentStatusEnum.NO);
 		}
-		
+
 		this.insert(musicGroupPaymentCalender);
-		
-		if(musicGroupPaymentCalender.getPaymentStatus() == PaymentStatusEnum.OPEN){
-			if(list != null && list.size() > 0){
+
+		List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
+		if (musicGroupPaymentCalender.getPaymentStatus() == PaymentStatusEnum.OPEN) {
+			if (list != null && list.size() > 0) {
 				MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = null;
-				//创建缴费明细
-				for(MusicGroupStudentFee mgsf : list){
+				// 创建缴费明细
+				for (MusicGroupStudentFee mgsf : list) {
 					musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
 					musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
 					musicGroupPaymentCalenderDetail.setCreateTime(date);
@@ -80,10 +83,16 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 					musicGroupPaymentCalenderDetail.setPaymentStatus(PaymentStatus.NON_PAYMENT);
 					musicGroupPaymentCalenderDetail.setUpdateTime(date);
 					musicGroupPaymentCalenderDetail.setUserId(mgsf.getUserId());
+
+					musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
 				}
 			}
 		}
 
+		if (musicGroupPaymentCalenderDetailList.size() > 0) {
+			musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
+		}
+
 		return true;
 	}
 
@@ -146,14 +155,14 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void updateStartTime(Date startTime, Long id) {
-		if(startTime == null || id == null){
+		if (startTime == null || id == null) {
 			throw new BizException("参数校验失败");
 		}
 		MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(id);
-		if(calender == null){
+		if (calender == null) {
 			throw new BizException("缴费信息不存在");
 		}
-		if(calender.getPaymentStatus() == null || calender.getPaymentStatus() != NO){
+		if (calender.getPaymentStatus() == null || calender.getPaymentStatus() != NO) {
 			throw new BizException("修改失败,缴费状态不匹配");
 		}
 		calender.setStartPaymentDate(startTime);
@@ -164,14 +173,14 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void del(Long id) {
-		if(id == null){
+		if (id == null) {
 			throw new BizException("参数校验失败");
 		}
 		MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(id);
-		if(calender == null){
+		if (calender == null) {
 			throw new BizException("缴费信息不存在");
 		}
-		if(calender.getPaymentStatus() == null || calender.getPaymentStatus() != NO){
+		if (calender.getPaymentStatus() == null || calender.getPaymentStatus() != NO) {
 			throw new BizException("删除失败,缴费状态不匹配");
 		}
 		musicGroupPaymentCalenderDao.delete(id);

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

@@ -38,6 +38,15 @@
 		VALUES(#{id},#{musicGroupPaymentCalenderId},#{userId},#{expectAmount},#{actualAmount},#{paymentStatus},#{userStatus},#{payTime},#{updateTime},#{createTime})
 	</insert>
 
+    <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail">
+        INSERT INTO music_group_payment_calender_detail
+		(id_,music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,payment_status_,user_status_,pay_time_,update_time_,create_time_)
+		VALUES
+		<foreach collection="list" item="item" separator=",">
+            (#{item.id},#{item.musicGroupPaymentCalenderId},#{item.userId},#{item.expectAmount},#{item.actualAmount},#{item.paymentStatus},#{item.userStatus},#{item.payTime},#{item.updateTime},#{item.createTime})
+        </foreach>
+    </insert>
+
 	<!-- 根据主键查询一条记录 -->
 	<update id="update"
 		parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail">