yonge před 5 roky
rodič
revize
ac718739ce

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

@@ -3,6 +3,7 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.common.service.BaseService;
 
+import java.util.Date;
 import java.util.List;
 
 public interface MusicGroupPaymentCalenderService extends BaseService<Long, MusicGroupPaymentCalender> {
@@ -12,4 +13,11 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
      * @param musicGroupPaymentCalenders
      */
     void batchInsert(List<MusicGroupPaymentCalender> musicGroupPaymentCalenders);
+
+	/**
+	 * 获取下次缴费时间
+	 * @param musicGroupId
+	 * @return
+	 */
+	Date getNextPaymentDate(String musicGroupId);
 }

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

@@ -10,11 +10,14 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 
 @Service
 public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalender> implements MusicGroupPaymentCalenderService {
-	
+
 	@Autowired
 	private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
 
@@ -26,11 +29,30 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void batchInsert(List<MusicGroupPaymentCalender> musicGroupPaymentCalenders) {
-		if(musicGroupPaymentCalenders != null && musicGroupPaymentCalenders.size() > 0){
+		if (musicGroupPaymentCalenders != null && musicGroupPaymentCalenders.size() > 0) {
 			musicGroupPaymentCalenderDao.delByGroupId(musicGroupPaymentCalenders.get(0).getMusicGroupId());
 			musicGroupPaymentCalenders.forEach(e -> {
 				musicGroupPaymentCalenderDao.insert(e);
 			});
 		}
 	}
+
+	@Override
+	public Date getNextPaymentDate(String musicGroupId) {
+		List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
+		if (musicGroupPaymentCalenderList != null && musicGroupPaymentCalenderList.size() > 0) {
+
+			Collections.sort(musicGroupPaymentCalenderList);
+
+			Calendar cale = Calendar.getInstance();
+			int month = cale.get(Calendar.MONTH) + 1;
+
+			for (MusicGroupPaymentCalender cal : musicGroupPaymentCalenderList) {
+				if (cal.getPaymentMonth() >= month) {
+					return cal.getStartPaymentDate();
+				}
+			}
+		}
+		return null;
+	}
 }

+ 27 - 22
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -45,6 +45,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 	@Autowired
 	private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
 	@Autowired
+	private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
+	@Autowired
 	private MusicGroupPaymentEntitiesDao musicGroupPaymentEntitiesDao;
 	@Autowired
 	private MusicGroupSubjectGoodsGroupDao musicGroupSubjectGoodsGroupDao;
@@ -240,27 +242,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 		musicGroup.setUpdateTime(new Date());
 		musicGroupDao.update(musicGroup);
 
-		// 查询下次缴费时间
-		List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
-		if (musicGroupPaymentCalenderList != null && musicGroupPaymentCalenderList.size() > 0) {
-
-			Collections.sort(musicGroupPaymentCalenderList);
-
-			Calendar cale = Calendar.getInstance();
-			int month = cale.get(Calendar.MONTH) + 1;
-
-			MusicGroupPaymentCalender calender = null;
-
-			for (MusicGroupPaymentCalender cal : musicGroupPaymentCalenderList) {
-				if (cal.getPaymentMonth() >= month) {
-					calender = cal;
-					break;
-				}
-			}
-
-			// 重新设置下次缴费时间
-			musicGroupStudentFeeDao.updateNextPaymentDate(musicGroupId, calender.getStartPaymentDate());
-		}
+		// 重新设置下次缴费时间
+		musicGroupStudentFeeDao.updateNextPaymentDate(musicGroupId, musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId));
 
 		return true;
 	}
@@ -411,7 +394,29 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 	public boolean renewForCallback(StudentPaymentOrder studentPaymentOrder) {
 		
-		return false;
+		studentPaymentOrderDao.update(studentPaymentOrder);
+		
+		Integer userId = studentPaymentOrder.getUserId();
+		String musicGroupId = studentPaymentOrder.getMusicGroupId();
+		
+		//更新下次续费时间
+		MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(userId, musicGroupId);
+		
+		if(musicGroupStudentFee == null){
+			throw new BizException("系统数据异常,找不到学员预缴费信息");
+		}
+		
+		Date date = new Date();
+		
+		musicGroupStudentFee.setUpdateTime(date);
+		musicGroupStudentFee.setLatestPaidTime(date);
+		musicGroupStudentFee.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
+		musicGroupStudentFee.setTemporaryCourseFee(new BigDecimal(0));
+		musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId));
+		
+		musicGroupStudentFeeDao.update(musicGroupStudentFee);
+		
+		return true;
 	}
 
 	@Override

+ 8 - 0
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -4,11 +4,14 @@ import com.ym.mec.biz.dal.dao.SysAccountDao;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.service.MusicGroupService;
 import com.ym.mec.biz.service.StudentPaymentOrderService;
 import com.ym.mec.biz.service.StudentRegistrationService;
 import com.ym.mec.biz.service.VipGroupService;
 import com.ym.mec.thirdparty.union.NotifyMsg;
+
 import io.swagger.annotations.Api;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,6 +33,9 @@ public class StudentOrderController {
     private StudentRegistrationService studentRegistrationService;
     @Autowired
     private VipGroupService vipGroupService;
+    
+    @Autowired
+    private MusicGroupService musicGroupService;
 
 
     @PostMapping("/notify")
@@ -66,6 +72,8 @@ public class StudentOrderController {
             studentRegistrationService.updateApplyOrder(order);
         }else if (order.getType().equals(OrderTypeEnum.SMALL_CLASS_TO_BUY)){
             vipGroupService.orderCallback(order);
+        }else if(order.getType().equals(OrderTypeEnum.RENEW)){
+        	musicGroupService.renewForCallback(order);
         }
 
         return "SUCCESS";