|
@@ -5,9 +5,14 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.common.utils.SecurityUtils;
|
|
|
+import com.zhongzheng.common.utils.ServletUtils;
|
|
|
import com.zhongzheng.modules.bank.domain.QuestionBusiness;
|
|
|
import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
+import com.zhongzheng.modules.grade.domain.ClassGrade;
|
|
|
+import com.zhongzheng.modules.grade.domain.ClassGradeSys;
|
|
|
+import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
|
import com.zhongzheng.modules.grade.service.IClassGradeService;
|
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
|
import com.zhongzheng.modules.grade.vo.ClassGradeVo;
|
|
@@ -240,20 +245,49 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
|
|
|
/**
|
|
|
* 加入班级
|
|
|
- * @param goodsId
|
|
|
- * @param classId
|
|
|
+ * @param orderGoodsId
|
|
|
+ * @param gradeId
|
|
|
* @return
|
|
|
*/
|
|
|
- public boolean joinClass(Long goodsId,Long gradeId,Long userId){
|
|
|
+ public boolean checkGrade(String goodsName,Long orderGoodsId,Long gradeId,Long userId){
|
|
|
if(gradeId!=null){
|
|
|
ClassGradeVo classGradeVo = iClassGradeService.queryById(gradeId);
|
|
|
if(classGradeVo==null){
|
|
|
throw new CustomException("班级不存在");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ LambdaQueryWrapper<ClassGradeUser> lqw = new LambdaQueryWrapper<>();
|
|
|
+ lqw.eq(ClassGradeUser::getGradeId,gradeId);
|
|
|
+ lqw.eq(ClassGradeUser::getStatus,1);
|
|
|
+ int studentNum = iClassGradeUserService.count(lqw);
|
|
|
+ if(classGradeVo.getStudentUpper()>studentNum){
|
|
|
+ //加入班级
|
|
|
+ joinGrade(orderGoodsId,gradeId,userId);
|
|
|
+ }
|
|
|
}
|
|
|
+ //创建新班级
|
|
|
+ ClassGrade classGrade = new ClassGrade();
|
|
|
+ classGrade.setStudentUpper(ClassGrade.INIT_UPPER); //上限300
|
|
|
+ classGrade.setCreateTime(DateUtils.getNowTime());
|
|
|
+ classGrade.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ String gradeCode = ServletUtils.getEncoded("BJ");
|
|
|
+ classGrade.setGradeCode(gradeCode);
|
|
|
+ classGrade.setClassName(goodsName+gradeCode);
|
|
|
+ boolean save = iClassGradeService.save(classGrade);
|
|
|
+ //加入班级
|
|
|
+ joinGrade(orderGoodsId,classGrade.getGradeId(),userId);
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+ public boolean joinGrade(Long orderGoodsId,Long gradeId,Long userId){
|
|
|
+ //班级还有剩位,进入班级
|
|
|
+ ClassGradeUser classGradeUser = new ClassGradeUser();
|
|
|
+ classGradeUser.setUserId(userId);
|
|
|
+ classGradeUser.setGradeId(gradeId);
|
|
|
+ classGradeUser.setStatus(1);
|
|
|
+ classGradeUser.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ classGradeUser.setFromType(1);
|
|
|
+ classGradeUser.setOrderGoodsId(orderGoodsId);
|
|
|
+ iClassGradeUserService.save(classGradeUser);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|