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