|
@@ -9,7 +9,9 @@ import com.zhongzheng.common.utils.SecurityUtils;
|
|
|
import com.zhongzheng.modules.bank.mapper.QuestionMapper;
|
|
|
import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
+import com.zhongzheng.modules.grade.domain.ClassGradeGoods;
|
|
|
import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
|
+import com.zhongzheng.modules.grade.service.IClassGradeGoodsService;
|
|
|
import com.zhongzheng.modules.grade.service.IClassGradeService;
|
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
|
import com.zhongzheng.modules.grade.vo.ClassGradeVo;
|
|
@@ -59,6 +61,9 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
|
|
|
@Autowired
|
|
|
private IOrderService iOrderService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IClassGradeGoodsService iClassGradeGoodsService;
|
|
|
+
|
|
|
@Override
|
|
|
public OrderGoodsVo queryById(String orderSn){
|
|
|
OrderGoods db = this.baseMapper.selectById(orderSn);
|
|
@@ -131,7 +136,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
|
|
|
if(goods.getGoodsType()==1){
|
|
|
Order order = iOrderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderSn,bo.getOrderSn()));
|
|
|
//加入新班级
|
|
|
- joinGrade(bo.getOrderGoodsId(),bo.getGradeId(),order.getUserId());
|
|
|
+ joinGrade(bo.getOrderGoodsId(),bo.getGradeId(),order.getUserId(),bo.getGoodsId());
|
|
|
//移除旧班级
|
|
|
ClassGradeUser classGradeUser =iClassGradeUserService.getOne(new LambdaQueryWrapper<ClassGradeUser>()
|
|
|
.eq(ClassGradeUser::getUserId,order.getUserId()).eq(ClassGradeUser::getGradeId,db.getGradeId()
|
|
@@ -142,6 +147,8 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
|
|
|
classGradeUser.setStatus(0);
|
|
|
classGradeUser.setUpdateTime(DateUtils.getNowTime());
|
|
|
iClassGradeUserService.updateById(classGradeUser);
|
|
|
+ }else{
|
|
|
+ throw new CustomException("非视频课程无法修改班级");
|
|
|
}
|
|
|
}
|
|
|
return this.updateById(update);
|
|
@@ -164,11 +171,16 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
|
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
|
|
|
|
- public boolean joinGrade(Long orderGoodsId,Long gradeId,Long userId){
|
|
|
+ public boolean joinGrade(Long orderGoodsId,Long gradeId,Long userId,Long goodsId){
|
|
|
ClassGradeVo classGradeVo = iClassGradeService.queryById(gradeId);
|
|
|
if(classGradeVo==null){
|
|
|
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);
|