Browse Source

活动排课

zouxuan 4 years ago
parent
commit
cf785a955d

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TeacherDefaultPracticeGroupSalaryDao.java

@@ -31,6 +31,7 @@ public interface TeacherDefaultPracticeGroupSalaryDao extends BaseDAO<Long, Teac
      */
     TeacherDefaultPracticeGroupSalary findByTeacherAndCourseMinutes(@Param("userId")Integer userId,
 																	@Param("minutes") Integer minutes);
+
 	List<TeacherDefaultPracticeGroupSalary> findByTeachersAndCourseMinutes(@Param("teacherIds")List<Integer> teacherIds,
 																	@Param("minutes") Integer minutes);
 

+ 112 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/PracticeGroupApplyBaseInfoDto.java

@@ -0,0 +1,112 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.entity.PracticeGroup;
+import com.ym.mec.biz.dal.entity.VipGroup;
+import com.ym.mec.biz.dal.entity.VipGroupStudentCoursePrice;
+import com.ym.mec.biz.dal.enums.ActivityCourseType;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+public class PracticeGroupApplyBaseInfoDto extends PracticeGroup {
+
+    @ApiModelProperty(value = "科目编号列表")
+    private String subjectIdList;
+
+    @ApiModelProperty(value = "课时总数")
+    private Integer allCourseNum;
+
+    @ApiModelProperty(value = "教师ID",required = false)
+    private Long teacherId;
+
+    @ApiModelProperty(value = "课酬",required = false)
+    private BigDecimal salary;
+
+    @ApiModelProperty(value = "预计招生人数",hidden = true)
+    private Integer expectStudentNum;
+
+    @ApiModelProperty(value = "教师线上课课酬")
+    private BigDecimal onlineTeacherSalary;
+
+    @ApiModelProperty(value = "课程组学员缴费设置")
+    private List<VipGroupStudentCoursePrice> vipGroupStudentCoursePrices;
+
+    @ApiModelProperty(value = "第一个选择的学员")
+    private Integer firstStudentId;
+
+    @ApiModelProperty(value = "活动课程类型")
+    private ActivityCourseType activityCourseType;
+
+    public ActivityCourseType getActivityCourseType() {
+        return activityCourseType;
+    }
+
+    public void setActivityCourseType(ActivityCourseType activityCourseType) {
+        this.activityCourseType = activityCourseType;
+    }
+
+    public Integer getFirstStudentId() {
+        return firstStudentId;
+    }
+
+    public void setFirstStudentId(Integer firstStudentId) {
+        this.firstStudentId = firstStudentId;
+    }
+
+    public List<VipGroupStudentCoursePrice> getVipGroupStudentCoursePrices() {
+        return vipGroupStudentCoursePrices;
+    }
+
+    public void setVipGroupStudentCoursePrices(List<VipGroupStudentCoursePrice> vipGroupStudentCoursePrices) {
+        this.vipGroupStudentCoursePrices = vipGroupStudentCoursePrices;
+    }
+
+    public String getSubjectIdList() {
+        return subjectIdList;
+    }
+
+    public void setSubjectIdList(String subjectIdList) {
+        this.subjectIdList = subjectIdList;
+    }
+
+    public BigDecimal getOnlineTeacherSalary() {
+        return onlineTeacherSalary;
+    }
+
+    public void setOnlineTeacherSalary(BigDecimal onlineTeacherSalary) {
+        this.onlineTeacherSalary = onlineTeacherSalary;
+    }
+
+    public Integer getAllCourseNum() {
+        return allCourseNum;
+    }
+
+    public void setAllCourseNum(Integer allCourseNum) {
+        this.allCourseNum = allCourseNum;
+    }
+
+    public Long getTeacherId() {
+        return teacherId;
+    }
+
+    public void setTeacherId(Long teacherId) {
+        this.teacherId = teacherId;
+    }
+
+    public Integer getExpectStudentNum() {
+        return expectStudentNum;
+    }
+
+    public void setExpectStudentNum(Integer expectStudentNum) {
+        this.expectStudentNum = expectStudentNum;
+    }
+
+    public BigDecimal getSalary() {
+        return salary;
+    }
+
+    public void setSalary(BigDecimal salary) {
+        this.salary = salary;
+    }
+}

+ 73 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/PracticeGroupApplyDto.java

@@ -0,0 +1,73 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.entity.CourseSchedule;
+import io.swagger.annotations.ApiModelProperty;
+import java.math.BigDecimal;
+import java.util.List;
+
+public class PracticeGroupApplyDto {
+
+    @ApiModelProperty(value = "vip课基本信息",required = false)
+    private PracticeGroupApplyBaseInfoDto practiceGroupApplyBaseInfoDto;
+
+    @ApiModelProperty(value = "课程计划列表",required = false)
+    private List<CourseSchedule> courseSchedules;
+
+    @ApiModelProperty(value = "课程组只能是正常状态")
+    private boolean onlyProgress;
+
+    private BigDecimal singleClassPrice;
+
+    @ApiModelProperty(value = "是否允许超出活动允许的学生使用次数")
+    private Boolean allowOverstepActivityStudentNum = false;
+
+    public Boolean getAllowOverstepActivityStudentNum() {
+        return allowOverstepActivityStudentNum;
+    }
+
+    public void setAllowOverstepActivityStudentNum(Boolean allowOverstepActivityStudentNum) {
+        this.allowOverstepActivityStudentNum = allowOverstepActivityStudentNum;
+    }
+
+    public BigDecimal getSingleClassPrice() {
+        return singleClassPrice;
+    }
+
+    public void setSingleClassPrice(BigDecimal singleClassPrice) {
+        this.singleClassPrice = singleClassPrice;
+    }
+
+    private String studentIds;
+
+    public String getStudentIds() {
+        return studentIds;
+    }
+
+    public void setStudentIds(String studentIds) {
+        this.studentIds = studentIds;
+    }
+
+    public PracticeGroupApplyBaseInfoDto getPracticeGroupApplyBaseInfoDto() {
+        return practiceGroupApplyBaseInfoDto;
+    }
+
+    public void setPracticeGroupApplyBaseInfoDto(PracticeGroupApplyBaseInfoDto practiceGroupApplyBaseInfoDto) {
+        this.practiceGroupApplyBaseInfoDto = practiceGroupApplyBaseInfoDto;
+    }
+
+    public List<CourseSchedule> getCourseSchedules() {
+        return courseSchedules;
+    }
+
+    public void setCourseSchedules(List<CourseSchedule> courseSchedules) {
+        this.courseSchedules = courseSchedules;
+    }
+
+    public boolean getOnlyProgress() {
+        return onlyProgress;
+    }
+
+    public void setOnlyProgress(boolean onlyProgress) {
+        this.onlyProgress = onlyProgress;
+    }
+}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/PracticeGroup.java

@@ -66,6 +66,16 @@ public class PracticeGroup {
 
 	private Integer educationalTeacherId;
 
+	private Integer vipGroupActivityId;
+
+	public Integer getVipGroupActivityId() {
+		return vipGroupActivityId;
+	}
+
+	public void setVipGroupActivityId(Integer vipGroupActivityId) {
+		this.vipGroupActivityId = vipGroupActivityId;
+	}
+
 	public String getCoursesStartDates() {
 		return coursesStartDates;
 	}

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/PracticeGroupService.java

@@ -323,4 +323,15 @@ public interface PracticeGroupService extends BaseService<Long, PracticeGroup> {
      * @return void
      */
     void practiceGroupRenewRemind();
+
+    Map countPracticeGroupPredictFee(PracticeGroupApplyBaseInfoDto practice, Integer userId, Long courseId);
+
+    /**
+    * @description: 网管课申请
+     * @param practiceGroupApplyDto
+    * @return java.lang.Object
+    * @author zx
+    * @date 2021/10/8 12:22
+    */
+    Object createPracticeGroup(PracticeGroupApplyDto practiceGroupApplyDto);
 }

+ 41 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

@@ -138,6 +138,8 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
     private StudentGoodsSellDao studentGoodsSellDao;
     @Autowired
     private SysCouponCodeService sysCouponCodeService;
+    @Autowired
+    private VipGroupActivityDao vipGroupActivityDao;
 
     private static Map<Integer, Map<Integer, List<Integer>>> schoolSubjectTeachersMap;
 
@@ -4277,4 +4279,43 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             practiceGroupDao.batchUpdatePracticeRemindStatus(practiceIds, YesOrNoEnum.YES.getCode());
         }
     }
+
+    @Override
+    public Map countPracticeGroupPredictFee(PracticeGroupApplyBaseInfoDto practice, Integer teacherId, Long courseId) {
+        if(Objects.isNull(teacherId)){
+            throw new BizException("请指定教师");
+        }
+        SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
+        Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
+        TeacherDefaultPracticeGroupSalary teacherDefaultPracticeGroupSalary = teacherDefaultPracticeGroupSalaryDao.findByTeacherAndCourseMinutes(teacherId,practiceCourseMinutes);
+
+        BigDecimal teacherDefaultSalary=null;
+        if(Objects.nonNull(teacherDefaultPracticeGroupSalary)){
+            teacherDefaultSalary = teacherDefaultPracticeGroupSalary.getMainTeacherSalary();
+        }
+        if(teacherDefaultSalary == null){
+            throw new BizException("请设置老师课酬");
+        }
+
+        VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(practice.getVipGroupActivityId());
+
+        Map<String,BigDecimal> results=new HashMap<>(1);
+        VipGroupSalarySettlementDto vipGroupSalarySettlementDto = JSON.parseObject(vipGroupActivity.getSalarySettlementJson(), VipGroupSalarySettlementDto.class);
+        if(Objects.isNull(vipGroupSalarySettlementDto)){
+            throw new BizException("课酬结算方案错误");
+        }
+        BigDecimal onlineClassNum = new BigDecimal(practice.getAllCourseNum());
+        BigDecimal onlineVipGroupCharge = teacherDefaultSalary.multiply(onlineClassNum);
+        //课程购买费用计算
+        BigDecimal totalPrice = onlineVipGroupCharge.add(onlineVipGroupCharge);
+        totalPrice = totalPrice.multiply(vipGroupActivity.getDiscount()).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
+        results.put("totalPrice",totalPrice.setScale(0,BigDecimal.ROUND_CEILING));
+        return results;
+    }
+
+    @Override
+    public Object createPracticeGroup(PracticeGroupApplyDto practiceGroupApplyDto) {
+
+        return null;
+    }
 }

+ 54 - 14
mec-web/src/main/java/com/ym/mec/web/controller/PracticeGroupManageController.java

@@ -3,7 +3,13 @@ package com.ym.mec.web.controller;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
+import com.ym.mec.biz.dal.dao.TeacherDao;
+import com.ym.mec.biz.dal.dto.PracticeGroupApplyBaseInfoDto;
+import com.ym.mec.biz.dal.dto.PracticeGroupApplyDto;
+import com.ym.mec.biz.dal.dto.VipGroupApplyBaseInfoDto;
+import com.ym.mec.biz.dal.dto.VipGroupApplyDto;
 import com.ym.mec.biz.dal.entity.Employee;
+import com.ym.mec.biz.dal.entity.Teacher;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.page.PracticeGroupQueryInfo;
 import com.ym.mec.biz.dal.page.StudentBuyPracticeQueryInfo;
@@ -17,14 +23,13 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 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.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 /**
  * @Author Joburgess
@@ -45,6 +50,8 @@ public class PracticeGroupManageController extends BaseController {
     private GroupClassService groupService;
     @Autowired
     private CourseScheduleEvaluateService courseScheduleEvaluateService;
+    @Autowired
+    private TeacherDao teacherDao;
 
     @ApiOperation(value = "全查询")
     @GetMapping("/queryAll")
@@ -54,17 +61,17 @@ public class PracticeGroupManageController extends BaseController {
         if (sysUser == null) {
             return failed("用户信息获取失败");
         }
-            Employee employee = employeeDao.get(sysUser.getId());
-            if (StringUtils.isEmpty(queryInfo.getOrganId())) {
-                queryInfo.setOrganId(employee.getOrganIdList());
-            } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
-                return failed("用户所在分部异常");
-            } else {
-                List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
-                if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
-                    return failed("非法请求");
-                }
+        Employee employee = employeeDao.get(sysUser.getId());
+        if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+            queryInfo.setOrganId(employee.getOrganIdList());
+        } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
+            return failed("用户所在分部异常");
+        } else {
+            List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+            if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
+                return failed("非法请求");
             }
+        }
         return succeed(practiceGroupService.findPracticeGroups(queryInfo));
     }
 
@@ -155,4 +162,37 @@ public class PracticeGroupManageController extends BaseController {
         }
         return succeed(practiceGroupService.studentBuys(queryInfo));
     }
+
+    @ApiOperation("课酬总费用")
+    @PostMapping("/getPracticeGroupCostCount")
+    @PreAuthorize("@pcs.hasPermissions('practiceGroupManage/getPracticeGroupCostCount')")
+    public Object getPracticeGroupCostCount(@RequestBody PracticeGroupApplyBaseInfoDto practice){
+        Map results = practiceGroupService.countPracticeGroupPredictFee(practice,practice.getUserId(), null);
+        return succeed(results);
+    }
+
+    @ApiOperation(value = "网管课申请")
+    @PostMapping("/practiceGroupApply")
+    @PreAuthorize("@pcs.hasPermissions('practiceGroupManage/practiceGroupApply')")
+    public Object vipGroupApply(@RequestBody PracticeGroupApplyDto practiceGroupApplyDto){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        PracticeGroupApplyBaseInfoDto applyBaseInfoDto = practiceGroupApplyDto.getPracticeGroupApplyBaseInfoDto();
+        Integer userId = applyBaseInfoDto.getUserId();
+        Teacher teacher = teacherDao.get(userId);
+        if(Objects.isNull(teacher)){
+            return failed("请指定指导老师!");
+        }
+        if(Objects.isNull(applyBaseInfoDto.getOrganId())){
+            Integer firstStudentId = applyBaseInfoDto.getFirstStudentId();
+            SysUser student = teacherDao.getUser(firstStudentId);
+            if(Objects.isNull(student)||Objects.isNull(student.getOrganId())){
+                return failed("学员信息异常");
+            }
+            applyBaseInfoDto.setOrganId(student.getOrganId());
+        }
+        return practiceGroupService.createPracticeGroup(practiceGroupApplyDto);
+    }
 }

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/VipGroupActivityController.java

@@ -57,7 +57,7 @@ public class VipGroupActivityController extends BaseController {
     }
 
     @ApiOperation(value = "获取活动方案")
-    @PostMapping("/get")
+    @GetMapping("/get")
     @PreAuthorize("@pcs.hasPermissions('vipGroupActivity/get')")
     public Object get(Integer id){
         return succeed(vipGroupActivityService.get(id));