添加空值过滤
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.peanut.modules.mq.Consumer;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.peanut.common.utils.DateUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
@@ -9,6 +10,7 @@ import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.service.ClassEntityService;
|
||||
import com.peanut.modules.common.service.ClassExamService;
|
||||
import com.peanut.modules.common.service.CouponHistoryService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -19,6 +21,7 @@ import java.util.Map;
|
||||
|
||||
//通用延迟队列
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CommonConsumer {
|
||||
|
||||
@Autowired
|
||||
@@ -42,60 +45,66 @@ public class CommonConsumer {
|
||||
|
||||
@RabbitListener(queues = DelayQueueConfig.COMMON_QUEUE)
|
||||
public void commonConsumer(String typeAndParam) {
|
||||
//参数为 业务模块 + , + 参数
|
||||
String[] typeAndParams = typeAndParam.split(",");
|
||||
//考试周天数,根据设置的天数将班级状态从进行中设置成考试中
|
||||
if ("examDays".equals(typeAndParams[0])){
|
||||
ClassEntity classEntity = classEntityDao.selectById(typeAndParams[1]);
|
||||
if (classEntity!=null&&!"3".equals(classEntity.getState())){
|
||||
classEntity.setState("3");
|
||||
classEntityDao.updateById(classEntity);
|
||||
try {
|
||||
//参数为 业务模块 + , + 参数
|
||||
String[] typeAndParams = typeAndParam.split(",");
|
||||
//考试周天数,根据设置的天数将班级状态从进行中设置成考试中
|
||||
if ("examDays".equals(typeAndParams[0])){
|
||||
ClassEntity classEntity = classEntityDao.selectById(typeAndParams[1]);
|
||||
if (classEntity!=null&&!"3".equals(classEntity.getState())){
|
||||
classEntity.setState("3");
|
||||
classEntityDao.updateById(classEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
//在考试结束时检查是否提交,未完成者自动提交
|
||||
if ("examSubmit".equals(typeAndParams[0])){
|
||||
ClassExamUser classExamUser = classExamUserDao.selectById(typeAndParams[1]);
|
||||
if (classExamUser!=null&&classExamUser.getScoreSuccess()==0){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("id",classExamUser.getId());
|
||||
classexamService.submitExamPaper(map);
|
||||
//在考试结束时检查是否提交,未完成者自动提交
|
||||
if ("examSubmit".equals(typeAndParams[0])){
|
||||
ClassExamUser classExamUser = classExamUserDao.selectById(typeAndParams[1]);
|
||||
if (classExamUser!=null&&classExamUser.getScoreSuccess()==0){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("id",classExamUser.getId());
|
||||
classexamService.submitExamPaper(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
//加班后24小时未买课踢出去
|
||||
if ("joinClass".equals(typeAndParams[0])){
|
||||
ClassEntity classEntity = classEntityDao.selectById(typeAndParams[1]);
|
||||
MyUserEntity user = myUserDao.selectById(typeAndParams[2]);
|
||||
if ("0".equals(user.getVip())||"3".equals(user.getVip())){
|
||||
//不是vip查询每门课是否购买
|
||||
List<ClassCourse> courses = classCourseDao.selectList(new LambdaQueryWrapper<ClassCourse>()
|
||||
.eq(ClassCourse::getModelId,classEntity.getModelId()));
|
||||
for (ClassCourse classCourse:courses){
|
||||
List<CourseCatalogueEntity> catalogues = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>()
|
||||
.eq(CourseCatalogueEntity::getCourseId,classCourse.getCourseId()));
|
||||
for (CourseCatalogueEntity catalog:catalogues){
|
||||
int ucbCount = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>()
|
||||
.eq(UserCourseBuyEntity::getUserId,user.getId())
|
||||
.eq(UserCourseBuyEntity::getCatalogueId,catalog.getId()));
|
||||
if (ucbCount == 0){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("classId",classEntity.getId());
|
||||
map.put("userId",user.getId());
|
||||
classEntityService.quitClass(map);
|
||||
//加班后24小时未买课踢出去
|
||||
if ("joinClass".equals(typeAndParams[0])){
|
||||
ClassEntity classEntity = classEntityDao.selectById(typeAndParams[1]);
|
||||
if (classEntity!=null&&"0".equals(classEntity.getState())){
|
||||
MyUserEntity user = myUserDao.selectById(typeAndParams[2]);
|
||||
if (user!=null){
|
||||
if ("0".equals(user.getVip())||"3".equals(user.getVip())){
|
||||
//不是vip查询每门课是否购买
|
||||
List<ClassCourse> courses = classCourseDao.selectList(new LambdaQueryWrapper<ClassCourse>()
|
||||
.eq(ClassCourse::getModelId,classEntity.getModelId()));
|
||||
for (ClassCourse classCourse:courses){
|
||||
List<CourseCatalogueEntity> catalogues = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>()
|
||||
.eq(CourseCatalogueEntity::getCourseId,classCourse.getCourseId()));
|
||||
for (CourseCatalogueEntity catalog:catalogues){
|
||||
int ucbCount = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>()
|
||||
.eq(UserCourseBuyEntity::getUserId,user.getId())
|
||||
.eq(UserCourseBuyEntity::getCatalogueId,catalog.getId()));
|
||||
if (ucbCount == 0){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("classId",classEntity.getId());
|
||||
map.put("userId",user.getId());
|
||||
classEntityService.quitClass(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//优惠卷过期
|
||||
if ("couponExpire".equals(typeAndParams[0])){
|
||||
CouponHistory couponHistory = couponHistoryService.getById(typeAndParams[1]);
|
||||
if (couponHistory != null&&couponHistory.getStatus()==0) {
|
||||
couponHistory.setStatus(2);
|
||||
couponHistoryService.updateById(couponHistory);
|
||||
//优惠卷过期
|
||||
if ("couponExpire".equals(typeAndParams[0])){
|
||||
CouponHistory couponHistory = couponHistoryService.getById(typeAndParams[1]);
|
||||
if (couponHistory != null&&couponHistory.getStatus()==0) {
|
||||
couponHistory.setStatus(2);
|
||||
couponHistoryService.updateById(couponHistory);
|
||||
}
|
||||
}
|
||||
}catch (Exception e) {
|
||||
log.error("mq通用队列消费异常",e.getMessage()+"-"+typeAndParam);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user