用户开课管理
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
package com.peanut.modules.master.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.peanut.common.utils.DateUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.CourseCatalogueEntity;
|
||||
import com.peanut.modules.common.entity.CourseEntity;
|
||||
import com.peanut.modules.common.entity.MyUserEntity;
|
||||
import com.peanut.modules.common.entity.UserCourseBuyEntity;
|
||||
import com.peanut.modules.master.service.UserCourseBuyService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户开课管理
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController("masterUserCourseBuy")
|
||||
@RequestMapping("master/userCourseBuy")
|
||||
public class UserCourseBuyController {
|
||||
|
||||
@Autowired
|
||||
private UserCourseBuyService userCourseBuyService;
|
||||
|
||||
@RequestMapping("/listByPage")
|
||||
public R listByPage(@RequestBody Map<String, Object> params) {
|
||||
MPJLambdaWrapper<UserCourseBuyEntity> wrapper = new MPJLambdaWrapper();
|
||||
wrapper.leftJoin(MyUserEntity.class, MyUserEntity::getId, UserCourseBuyEntity::getUserId);
|
||||
wrapper.leftJoin(CourseEntity.class, CourseEntity::getId, UserCourseBuyEntity::getCourseId);
|
||||
wrapper.leftJoin(CourseCatalogueEntity.class, CourseCatalogueEntity::getId, UserCourseBuyEntity::getCatalogueId);
|
||||
wrapper.select("t.id,t.user_id userId,t.course_id courseId,t.catalogue_id catalogueId,t.create_time createTime," +
|
||||
"t.come,t.days,t.start_time startTime,t.end_time endTime,t.del_flag expire,t1.tel,t2.title courseName,t3.title catalogueName");
|
||||
if (StringUtils.isNotEmpty(params.get("userInfo").toString())) {
|
||||
wrapper.and(t->t.like(MyUserEntity::getName,params.get("userInfo")).or().like(MyUserEntity::getNickname,params.get("userInfo"))
|
||||
.or().like(MyUserEntity::getTel,params.get("userInfo")).or().like(MyUserEntity::getEmail,params.get("userInfo")));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("courseName").toString())) {
|
||||
wrapper.like(CourseEntity::getTitle,params.get("courseName"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("come").toString())) {
|
||||
wrapper.like(UserCourseBuyEntity::getCome,params.get("come"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(params.get("expire").toString())) {
|
||||
wrapper.eq(UserCourseBuyEntity::getDelFlag,params.get("expire"));
|
||||
}
|
||||
//查询出过期课程
|
||||
wrapper.disableLogicDel();
|
||||
wrapper.orderByDesc(UserCourseBuyEntity::getDelFlag);
|
||||
wrapper.orderByDesc(UserCourseBuyEntity::getCreateTime);
|
||||
Page<Map<String, Object>> page = userCourseBuyService.pageMaps(new Page<>(
|
||||
Long.parseLong(params.get("current").toString()), Long.parseLong(params.get("limit").toString())), wrapper);
|
||||
return R.ok().put("result", page);
|
||||
}
|
||||
|
||||
@RequestMapping("/insertUserCourseBuy")
|
||||
public R insertUserCourseBuy(@RequestBody UserCourseBuyEntity userCourseBuyEntity) {
|
||||
userCourseBuyService.save(userCourseBuyEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/delayUserCourseBuy")
|
||||
public R delayUserCourseBuy(@RequestBody Map<String, Object> params) {
|
||||
UserCourseBuyEntity userCourseBuyEntity = userCourseBuyService.getById(params.get("id").toString());
|
||||
int days = Integer.parseInt(params.get("days").toString());
|
||||
userCourseBuyEntity.setDays(userCourseBuyEntity.getDays()+days);
|
||||
if (userCourseBuyEntity.getEndTime()!=null){
|
||||
userCourseBuyEntity.setEndTime(DateUtils.addDateDays(userCourseBuyEntity.getEndTime(),days));
|
||||
}
|
||||
userCourseBuyEntity.setCome(userCourseBuyEntity.getCome()+";延期(管理员操作:"+days+","+DateUtils.format(new Date(),"yyyyMMdd")+")");
|
||||
userCourseBuyService.updateById(userCourseBuyEntity);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/expireUserCourseBuy")
|
||||
@Transactional
|
||||
public R expireUserCourseBuy(@RequestBody Map<String, Object> params) {
|
||||
UserCourseBuyEntity userCourseBuyEntity = userCourseBuyService.getById(params.get("id").toString());
|
||||
userCourseBuyEntity.setCome(userCourseBuyEntity.getCome()+";终止(管理员操作)");
|
||||
if (userCourseBuyEntity.getStartTime()!=null){
|
||||
userCourseBuyEntity.setStartTime(new Date());
|
||||
}
|
||||
userCourseBuyEntity.setEndTime(new Date());
|
||||
userCourseBuyService.updateById(userCourseBuyEntity);
|
||||
userCourseBuyService.removeById(params.get("id").toString());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user