|
@@ -1,18 +1,27 @@
|
|
|
package com.ym.mec.web.controller;
|
|
|
|
|
|
+import com.ym.mec.biz.dal.entity.CourseSchedule;
|
|
|
import com.ym.mec.biz.dal.entity.VipGroupCategory;
|
|
|
+import com.ym.mec.biz.dal.entity.VipGroupDefaultClassesUnitPrice;
|
|
|
import com.ym.mec.biz.service.VipGroupCategoryService;
|
|
|
+import com.ym.mec.biz.service.VipGroupDefaultClassesUnitPriceService;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
+import com.ym.mec.common.tenant.TenantContextHolder;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.joda.time.DateTime;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Api(tags = "vip课类别")
|
|
|
@RequestMapping("vipGroupCategory")
|
|
@@ -21,6 +30,8 @@ public class VipGroupCategoryController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private VipGroupCategoryService vipGroupCategoryService;
|
|
|
+ @Autowired
|
|
|
+ private VipGroupDefaultClassesUnitPriceService vipGroupDefaultClassesUnitPriceService;
|
|
|
|
|
|
@ApiOperation("单查询")
|
|
|
@GetMapping(value = "/query")
|
|
@@ -38,14 +49,29 @@ public class VipGroupCategoryController extends BaseController {
|
|
|
@GetMapping(value = "/queryAll")
|
|
|
@PreAuthorize("@pcs.hasPermissions('vipGroupCategory/queryAll')")
|
|
|
public Object queryAll(String organId, @RequestParam(defaultValue = "VIP") String groupType) {
|
|
|
+
|
|
|
+ // 直播课强制转换为
|
|
|
+ if (CourseSchedule.CourseScheduleType.LIVE.getCode().equals(groupType)) {
|
|
|
+ organId = String.valueOf(TenantContextHolder.getTenantId());
|
|
|
+ }
|
|
|
+
|
|
|
return succeed(vipGroupCategoryService.findAllByOrgan(organId, groupType));
|
|
|
}
|
|
|
|
|
|
@ApiOperation("获取教师课酬")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "userId", value = "教师id", dataType = "Integer", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "groupType", value = "课程类型", dataType = "String", paramType = "query", defaultValue = "VIP"),
|
|
|
+ })
|
|
|
@PostMapping(value = "/findTeacherDefaultSalary")
|
|
|
@PreAuthorize("@pcs.hasPermissions('vipGroupCategory/findTeacherDefaultSalary')")
|
|
|
- public Object findTeacherDefaultSalary(Integer userId) {
|
|
|
- return succeed(vipGroupCategoryService.findTeacherSalary(userId));
|
|
|
+ public Object findTeacherDefaultSalary(Integer userId, @RequestParam(defaultValue = "VIP") String groupType) {
|
|
|
+
|
|
|
+ // 返回LIVE, VIP课薪资设置
|
|
|
+ List<VipGroupCategory> teacherSalary = vipGroupCategoryService.findTeacherSalary(userId).stream()
|
|
|
+ .filter(x -> x.getGroupType().equals(groupType)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ return succeed(teacherSalary);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("新增")
|
|
@@ -62,7 +88,33 @@ public class VipGroupCategoryController extends BaseController {
|
|
|
vipGroupCategory.setCreateTime(date);
|
|
|
vipGroupCategory.setUpdateTime(date);
|
|
|
vipGroupCategory.setDelFlag("0");
|
|
|
+
|
|
|
+ // 强制更新分类名称
|
|
|
+ if (CourseSchedule.CourseScheduleType.LIVE.getCode().equals(vipGroupCategory.getGroupType())) {
|
|
|
+ vipGroupCategory.setStudentNum(0);
|
|
|
+ vipGroupCategory.setName(vipGroupCategory.getSingleClassMinutes());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 课程分类编号
|
|
|
vipGroupCategoryService.insert(vipGroupCategory);
|
|
|
+
|
|
|
+ // 直播流程,主动添加购买价格
|
|
|
+ if (CourseSchedule.CourseScheduleType.LIVE.getCode().equals(vipGroupCategory.getGroupType())) {
|
|
|
+
|
|
|
+ VipGroupDefaultClassesUnitPrice vipGroupDefaultClassesUnitPrice = new VipGroupDefaultClassesUnitPrice();
|
|
|
+ vipGroupDefaultClassesUnitPrice.setOrganId(vipGroupCategory.getTenantId());
|
|
|
+ vipGroupDefaultClassesUnitPrice.setVipGroupCategoryId(vipGroupCategory.getId());
|
|
|
+ vipGroupDefaultClassesUnitPrice.setGroupType(vipGroupCategory.getGroupType());
|
|
|
+ vipGroupDefaultClassesUnitPrice.setCreateTime(DateTime.now().toDate());
|
|
|
+ vipGroupDefaultClassesUnitPrice.setUpdateTime(DateTime.now().toDate());
|
|
|
+ // 售价
|
|
|
+ vipGroupDefaultClassesUnitPrice.setOnlineClassesUnitPrice(Optional.ofNullable(vipGroupCategory.getOnlineClassesUnitPrice()).orElse(BigDecimal.ZERO));
|
|
|
+ // 原价
|
|
|
+ vipGroupDefaultClassesUnitPrice.setOfflineClassesUnitPrice(Optional.ofNullable(vipGroupCategory.getOfflineClassesUnitPrice()).orElse(BigDecimal.ZERO));
|
|
|
+
|
|
|
+ vipGroupDefaultClassesUnitPriceService.insert(vipGroupDefaultClassesUnitPrice);
|
|
|
+ }
|
|
|
+
|
|
|
return succeed();
|
|
|
}
|
|
|
|