Przeglądaj źródła

Merge remote-tracking branch 'origin/master'

Joe 5 lat temu
rodzic
commit
ec82b7ffb2

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

@@ -36,4 +36,10 @@ public interface MusicGroupPaymentCalenderDetailService extends BaseService<Long
      */
     void refreshUserMusicGroupPaymentStatusTask();
 
+    /**
+     * 乐团缴费记录新增学员
+     * @param musicGroupPaymentCalenderId
+     * @param userId
+     */
+    void add(Long musicGroupPaymentCalenderId, Integer userId);
 }

+ 38 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java

@@ -6,7 +6,9 @@ import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
 import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
 import com.ym.mec.biz.dal.dto.SimpleUserDto;
 import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
+import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderDetailService;
 import com.ym.mec.biz.service.MusicGroupStudentFeeService;
@@ -131,4 +133,40 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 	public void refreshUserMusicGroupPaymentStatusTask() {
 		musicGroupPaymentCalenderDetailDao.refreshUserMusicGroupPaymentStatusTask();
 	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void add(Long musicGroupPaymentCalenderId, Integer userId) {
+		if(musicGroupPaymentCalenderId == null || userId == null){
+			throw new BizException("参数校验异常");
+		}
+		MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(musicGroupPaymentCalenderId);
+		if(calender == null){
+			throw new BizException("缴费信息不存在");
+		}
+		MusicGroupPaymentCalenderDetail userLastCalenderDetail = musicGroupPaymentCalenderDetailDao.getUserLastCalenderDetail(calender.getMusicGroupId(), userId);
+		if(userLastCalenderDetail != null){
+			throw new BizException("数据已存在");
+		}
+		Date date = new Date();
+		MusicGroupStudentFee studentFee = musicGroupStudentFeeDao.findByUser(userId, calender.getMusicGroupId());
+		//修改预计人数
+		calender.setExpectNum(calender.getExpectNum());
+		calender.setUpdateTime(date);
+
+		//生成详情
+		MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
+		musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(calender.getId());
+		musicGroupPaymentCalenderDetail.setCreateTime(date);
+		musicGroupPaymentCalenderDetail.setExpectAmount(studentFee.getCourseFee());
+		if (studentFee.getCourseFee().doubleValue() == 0) {
+			musicGroupPaymentCalenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED);
+		} else {
+			musicGroupPaymentCalenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.NON_PAYMENT);
+		}
+		musicGroupPaymentCalenderDetail.setUpdateTime(date);
+		musicGroupPaymentCalenderDetail.setUserId(userId);
+		musicGroupPaymentCalenderDetailDao.insert(musicGroupPaymentCalenderDetail);
+		musicGroupPaymentCalenderDao.update(calender);
+	}
 }

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

@@ -73,7 +73,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			// 统计缴费人数
 			musicGroupStudentFeeList = musicGroupStudentFeeDao.queryByMusicGroupId(musicGroupPaymentCalender.getMusicGroupId());
 			if (musicGroupStudentFeeList == null) {
-				musicGroupStudentFeeList = new ArrayList<MusicGroupStudentFee>();
+				musicGroupStudentFeeList = new ArrayList<>();
 			}
 			musicGroupPaymentCalender.setExpectNum(musicGroupStudentFeeList.size());
 		} else {

+ 8 - 0
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderDetailController.java

@@ -37,6 +37,14 @@ public class MusicGroupPaymentCalenderDetailController extends BaseController {
         return succeed();
     }
 
+    @ApiOperation(value = "乐团缴费记录新增学员")
+    @PostMapping("/add")
+    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalenderDetail/add')")
+    public Object add(Long musicGroupPaymentCalenderId,Integer userId) {
+        musicGroupPaymentCalenderDetailService.add(musicGroupPaymentCalenderId,userId);
+        return succeed();
+    }
+
     @ApiOperation(value = "开启缴费")
     @PostMapping("/openPayment")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalenderDetail/openPayment')")