|
@@ -3609,6 +3609,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
*/
|
|
|
@Override
|
|
|
public Long sysChangeGrade(Long goodsId, Long orderGoodsId, Long gradeId, Long userId) {
|
|
|
+ String businessFull = iGoodsService.getGoodsBusinessName(goodsId);
|
|
|
+ Goods goods = iGoodsService.getById(goodsId);
|
|
|
+ String tenantId = ServletUtils.getRequest().getHeader("TenantId");
|
|
|
+ SysTenant sysTenant = iSysTenantService.getById(Long.valueOf(tenantId));
|
|
|
//指定班级
|
|
|
if (gradeId != null && gradeId > 0) {
|
|
|
ClassGradeVo classGradeVo = iClassGradeService.queryById(gradeId);
|
|
@@ -3623,31 +3627,94 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
if (gradeGoods == null) {
|
|
|
throw new CustomException("该班级不支持该商品使用");
|
|
|
}
|
|
|
- LambdaQueryWrapper<ClassGradeUser> lqw = new LambdaQueryWrapper<>();
|
|
|
- lqw.eq(ClassGradeUser::getGradeId, gradeId);
|
|
|
- lqw.eq(ClassGradeUser::getStatus, 1);
|
|
|
- int studentNum = iClassGradeUserService.count(lqw);
|
|
|
- //临时锁定的班级学员数量
|
|
|
- LambdaQueryWrapper<ClassGradeUserTemp> lqwLock = new LambdaQueryWrapper<>();
|
|
|
- lqwLock.eq(ClassGradeUserTemp::getGradeId, gradeId);
|
|
|
- lqwLock.eq(ClassGradeUserTemp::getStatus, 1);
|
|
|
- int locakStudentNum = iClassGradeUserTempService.count(lqwLock);
|
|
|
+
|
|
|
+ int locakStudentNum = 0;
|
|
|
+ Boolean sevenFlag = false;
|
|
|
+ if (businessFull.contains("继续教育") && businessFull.contains("施工现场专业人员")){
|
|
|
+ if (ObjectUtils.isNotNull(sysTenant.getSevenClass()) && sysTenant.getSevenClass() == 1){
|
|
|
+ //七大员继教班级共享
|
|
|
+ locakStudentNum = baseMapper.getStudeCountByCodeNoTenant(classGradeVo.getSevenCode());
|
|
|
+ }else {
|
|
|
+ locakStudentNum = baseMapper.getStudeCountByCode(classGradeVo.getSevenCode());
|
|
|
+ }
|
|
|
+ sevenFlag = true;
|
|
|
+ }else {
|
|
|
+ LambdaQueryWrapper<ClassGradeUser> lqw = new LambdaQueryWrapper<>();
|
|
|
+ lqw.eq(ClassGradeUser::getGradeId, gradeId);
|
|
|
+ lqw.eq(ClassGradeUser::getStatus, 1);
|
|
|
+ int studentNum = iClassGradeUserService.count(lqw);
|
|
|
+ //临时锁定的班级学员数量
|
|
|
+ LambdaQueryWrapper<ClassGradeUserTemp> lqwLock = new LambdaQueryWrapper<>();
|
|
|
+ lqwLock.eq(ClassGradeUserTemp::getGradeId, gradeId);
|
|
|
+ lqwLock.eq(ClassGradeUserTemp::getStatus, 1);
|
|
|
+ int count = iClassGradeUserTempService.count(lqwLock);
|
|
|
+ locakStudentNum = studentNum+count;
|
|
|
+
|
|
|
+ }
|
|
|
//预留0空位避免超人数
|
|
|
- if ((classGradeVo.getStudentUpper() - studentNum - locakStudentNum) > 0) {
|
|
|
- //班级还有剩位,直接加入班级
|
|
|
- Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId, goodsId));
|
|
|
- if (iClassGradeService.checkEjjjPeopleNumLimit(goods.getBusinessId(), gradeId)) { //判断全系统平台二建班级人数是否超300
|
|
|
- joinGrade(orderGoodsId, gradeId, userId);
|
|
|
- return gradeId;
|
|
|
- } else {
|
|
|
- throw new CustomException("该二建班级学员已满,请重新选班");
|
|
|
+ if ((classGradeVo.getStudentUpper() - locakStudentNum) > 0) {
|
|
|
+ ClassGradeUser gradeUser = iClassGradeUserService.getOne(new LambdaQueryWrapper<ClassGradeUser>().eq(ClassGradeUser::getGradeId, gradeId)
|
|
|
+ .eq(sevenFlag,ClassGradeUser::getOrderGoodsId,orderGoodsId)
|
|
|
+ .eq(ClassGradeUser::getUserId, userId)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(gradeUser) && gradeUser.getStatus() == 1){
|
|
|
+ throw new CustomException("学员已在此班级报名,请选择其他班级!");
|
|
|
}
|
|
|
+ //不在此班级内
|
|
|
+ if (Validator.isEmpty(gradeUser)) {
|
|
|
+ //班级还有剩位,直接锁定班级
|
|
|
+ if (iClassGradeService.checkEjjjPeopleNumLimit(goods.getBusinessId(), gradeId)) { //判断全系统平台二建班级人数是否超300
|
|
|
+ joinGrade(orderGoodsId, gradeId, userId);
|
|
|
+ return gradeId;
|
|
|
+ }else {
|
|
|
+ throw new CustomException("该二建班级学员已满,请重新选班");
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ }else {
|
|
|
throw new CustomException("该班级学员已满,请重新选班");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //指定班级
|
|
|
+// if (gradeId != null && gradeId > 0) {
|
|
|
+// ClassGradeVo classGradeVo = iClassGradeService.queryById(gradeId);
|
|
|
+// if (classGradeVo == null) {
|
|
|
+// throw new CustomException("班级不存在");
|
|
|
+// }
|
|
|
+// if (classGradeVo.getStatus() != 1) {
|
|
|
+// throw new CustomException("班级已失效");
|
|
|
+// }
|
|
|
+// ClassGradeGoods gradeGoods = iClassGradeGoodsService.getOne(new LambdaQueryWrapper<ClassGradeGoods>().eq(ClassGradeGoods::getGradeId, gradeId)
|
|
|
+// .eq(ClassGradeGoods::getGoodsId, goodsId));
|
|
|
+// if (gradeGoods == null) {
|
|
|
+// throw new CustomException("该班级不支持该商品使用");
|
|
|
+// }
|
|
|
+// LambdaQueryWrapper<ClassGradeUser> lqw = new LambdaQueryWrapper<>();
|
|
|
+// lqw.eq(ClassGradeUser::getGradeId, gradeId);
|
|
|
+// lqw.eq(ClassGradeUser::getStatus, 1);
|
|
|
+// int studentNum = iClassGradeUserService.count(lqw);
|
|
|
+// //临时锁定的班级学员数量
|
|
|
+// LambdaQueryWrapper<ClassGradeUserTemp> lqwLock = new LambdaQueryWrapper<>();
|
|
|
+// lqwLock.eq(ClassGradeUserTemp::getGradeId, gradeId);
|
|
|
+// lqwLock.eq(ClassGradeUserTemp::getStatus, 1);
|
|
|
+// int locakStudentNum = iClassGradeUserTempService.count(lqwLock);
|
|
|
+// //预留0空位避免超人数
|
|
|
+// if ((classGradeVo.getStudentUpper() - studentNum - locakStudentNum) > 0) {
|
|
|
+// //班级还有剩位,直接加入班级
|
|
|
+// Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId, goodsId));
|
|
|
+// if (iClassGradeService.checkEjjjPeopleNumLimit(goods.getBusinessId(), gradeId)) { //判断全系统平台二建班级人数是否超300
|
|
|
+// joinGrade(orderGoodsId, gradeId, userId);
|
|
|
+// return gradeId;
|
|
|
+// } else {
|
|
|
+// throw new CustomException("该二建班级学员已满,请重新选班");
|
|
|
+// }
|
|
|
+//
|
|
|
+// } else {
|
|
|
+// throw new CustomException("该班级学员已满,请重新选班");
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
return null;
|
|
|
}
|
|
|
|