Browse Source

feat:乐团费用改造

Joburgess 4 years ago
parent
commit
daeb993759

+ 13 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderCourseSettingsService.java

@@ -3,6 +3,18 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.common.service.BaseService;
 
+import java.util.List;
+
 public interface MusicGroupPaymentCalenderCourseSettingsService extends BaseService<Integer, MusicGroupPaymentCalenderCourseSettings> {
 
-}
+    /**
+     * @describe 获取指定学员在指定乐团下本次课排课时长
+     * @author Joburgess
+     * @date 2020.11.02
+     * @param musicGroupId:
+     * @param studentIds:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings>
+     */
+    List<MusicGroupPaymentCalenderCourseSettings> getMusicCourseSettingsWithStudents(String musicGroupId, List<Integer> studentIds);
+
+}

+ 36 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderCourseSettingsServiceImpl.java

@@ -1,5 +1,10 @@
 package com.ym.mec.biz.service.impl;
 
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
+import com.ym.mec.common.exception.BizException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -8,16 +13,45 @@ import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderCourseSettingsService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
 
 @Service
 public class MusicGroupPaymentCalenderCourseSettingsServiceImpl extends BaseServiceImpl<Integer, MusicGroupPaymentCalenderCourseSettings>  implements MusicGroupPaymentCalenderCourseSettingsService {
 	
 	@Autowired
 	private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
+	@Autowired
+	private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
+	@Autowired
+	private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
 
 	@Override
 	public BaseDAO<Integer, MusicGroupPaymentCalenderCourseSettings> getDAO() {
 		return musicGroupPaymentCalenderCourseSettingsDao;
 	}
-	
-}
+
+	@Override
+	public List<MusicGroupPaymentCalenderCourseSettings> getMusicCourseSettingsWithStudents(String musicGroupId, List<Integer> studentIds) {
+		MusicGroupPaymentCalender musicGroupUnusedFirstPaymentCalender = musicGroupPaymentCalenderDao.getMusicGroupUnusedFirstPaymentCalender(musicGroupId, studentIds);
+		if(Objects.isNull(musicGroupUnusedFirstPaymentCalender)){
+			throw new BizException("当前乐团暂无新缴费设置");
+		}
+
+		List<MusicGroupPaymentCalenderDetail> unusedPaymentCalenderDetail = musicGroupPaymentCalenderDetailDao.getCalenderDetailWithCalender(musicGroupUnusedFirstPaymentCalender.getId());
+		if(CollectionUtils.isEmpty(unusedPaymentCalenderDetail)){
+			throw new BizException("当前乐团无学员缴费信息");
+		}
+		Map<Integer, List<MusicGroupPaymentCalenderDetail>> studentPaymentCalenderMap = unusedPaymentCalenderDetail.stream().collect(Collectors.groupingBy(MusicGroupPaymentCalenderDetail::getUserId));
+
+		List<MusicGroupPaymentCalenderCourseSettings> calenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupUnusedFirstPaymentCalender.getId());
+		if(CollectionUtils.isEmpty(calenderCourseSettings)){
+			throw new BizException("课程收费标准设置异常");
+		}
+		return calenderCourseSettings;
+	}
+}

+ 20 - 0
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java

@@ -1,16 +1,24 @@
 package com.ym.mec.web.controller;
 
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 import com.ym.mec.biz.dal.page.MusicGroupPaymentCalenderQueryInfo;
+import com.ym.mec.biz.service.MusicGroupPaymentCalenderCourseSettingsService;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
 @RequestMapping("musicGroupPaymentCalender")
 @Api(tags = "乐团缴费日历服务")
 @RestController
@@ -18,6 +26,8 @@ public class MusicGroupPaymentCalenderController extends BaseController {
 
     @Autowired
     private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
+    @Autowired
+    private MusicGroupPaymentCalenderCourseSettingsService musicGroupPaymentCalenderCourseSettingsService;
 
     @ApiOperation(value = "分页查询乐团缴费日历列表")
     @GetMapping(value = "/queryPage", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@@ -87,4 +97,14 @@ public class MusicGroupPaymentCalenderController extends BaseController {
         musicGroupPaymentCalenderService.auditRefuse(calenderId,auditMemo);
         return succeed();
     }
+
+    @ApiOperation(value = "获取指定学员在指定乐团下本次课排课时长")
+    @PostMapping("/getMusicCourseSettingsWithStudents")
+    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/getMusicCourseSettingsWithStudents')")
+    public HttpResponseResult<List<MusicGroupPaymentCalenderCourseSettings>> getMusicCourseSettingsWithStudents(String musicGroupId, String studentIds){
+        if(StringUtils.isBlank(studentIds)){
+            return failed("请指定学员编号");
+        }
+        return succeed(musicGroupPaymentCalenderCourseSettingsService.getMusicCourseSettingsWithStudents(musicGroupId,Arrays.stream(studentIds.split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toList())));
+    }
 }