|
@@ -2,11 +2,21 @@ package com.zhongzheng.modules.grade.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
import cn.hutool.core.convert.Convert;
|
|
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
-import com.zhongzheng.modules.grade.bo.UserPeriodQueryBo;
|
|
|
|
|
|
|
+import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
|
|
+import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
|
|
|
+import com.zhongzheng.modules.grade.bo.*;
|
|
|
|
|
+import com.zhongzheng.modules.grade.service.IClassGradeService;
|
|
|
import com.zhongzheng.modules.grade.service.IUserPeriodStatusService;
|
|
import com.zhongzheng.modules.grade.service.IUserPeriodStatusService;
|
|
|
import com.zhongzheng.modules.grade.vo.*;
|
|
import com.zhongzheng.modules.grade.vo.*;
|
|
|
|
|
+import com.zhongzheng.modules.order.bo.OrderGoodsQueryBo;
|
|
|
|
|
+import com.zhongzheng.modules.order.domain.OrderGoods;
|
|
|
|
|
+import com.zhongzheng.modules.order.service.IOrderGoodsService;
|
|
|
|
|
+import com.zhongzheng.modules.order.service.IOrderService;
|
|
|
|
|
+import com.zhongzheng.modules.order.vo.OrderGoodsVo;
|
|
|
import com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo;
|
|
import com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo;
|
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
|
import com.zhongzheng.modules.user.domain.UserPlan;
|
|
import com.zhongzheng.modules.user.domain.UserPlan;
|
|
@@ -22,18 +32,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.Page;
|
|
|
-import com.zhongzheng.modules.grade.bo.ClassGradeUserAddBo;
|
|
|
|
|
-import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
|
|
|
|
|
-import com.zhongzheng.modules.grade.bo.ClassGradeUserEditBo;
|
|
|
|
|
import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
|
import com.zhongzheng.modules.grade.mapper.ClassGradeUserMapper;
|
|
import com.zhongzheng.modules.grade.mapper.ClassGradeUserMapper;
|
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.Collection;
|
|
|
|
|
-import java.util.Collections;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -54,6 +60,18 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IUserStudyRecordPhotoService userStudyRecordPhotoService;
|
|
private IUserStudyRecordPhotoService userStudyRecordPhotoService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IOrderService iOrderService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IOrderGoodsService iOrderGoodsService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IClassGradeService iClassGradeService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IGoodsService iGoodsService;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private UserMapper userMapper;
|
|
private UserMapper userMapper;
|
|
|
|
|
|
|
@@ -97,6 +115,42 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
|
|
|
return this.save(add);
|
|
return this.save(add);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public Boolean changeGrade(ClassGradeUserChangeBo bo) {
|
|
|
|
|
+ ClassGradeQueryBo classGradeQueryBo = new ClassGradeQueryBo();
|
|
|
|
|
+ classGradeQueryBo.setUserId(bo.getUserId());
|
|
|
|
|
+ classGradeQueryBo.setGoodsId(bo.getGoodsId());
|
|
|
|
|
+ classGradeQueryBo.setPastDue(1L);
|
|
|
|
|
+ List<ClassGradeVo> list = iClassGradeService.queryList(classGradeQueryBo);
|
|
|
|
|
+ if(list!=null&&list.size()>0){
|
|
|
|
|
+ throw new CustomException("包含购买商品班级尚未过期");
|
|
|
|
|
+ }
|
|
|
|
|
+ OrderGoodsVo orderGoodsVo = iOrderGoodsService.queryById(bo.getOrderGoodsId());
|
|
|
|
|
+ if(Validator.isEmpty(orderGoodsVo)||Validator.isEmpty(orderGoodsVo.getStudyCount())||orderGoodsVo.getStudyCount()<1){
|
|
|
|
|
+ throw new CustomException("学习次数不够");
|
|
|
|
|
+ }
|
|
|
|
|
+ GoodsVo goodsVo = iGoodsService.selectDetail(bo.getGoodsId());
|
|
|
|
|
+ //分新班
|
|
|
|
|
+ if(iOrderService.changeGrade(goodsVo.getGoodsName(),bo.getGoodsId(),bo.getOrderGoodsId(),bo.getGradeId(),bo.getUserId())){
|
|
|
|
|
+ //老班修改换班状态
|
|
|
|
|
+ ClassGradeUser classGradeUser = getOne(new LambdaQueryWrapper< ClassGradeUser>().eq(ClassGradeUser::getUserId,bo.getUserId())
|
|
|
|
|
+ .eq(ClassGradeUser::getStatus,1)
|
|
|
|
|
+ .eq(ClassGradeUser::getGradeId,bo.getOldGradeId())
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ classGradeUser.setChangeGrade(1);
|
|
|
|
|
+ classGradeUser.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
|
+ updateById(classGradeUser);
|
|
|
|
|
+ //消耗学习次数
|
|
|
|
|
+ OrderGoods orderGoods = new OrderGoods();
|
|
|
|
|
+ orderGoods.setOrderGoodsId(bo.getOrderGoodsId());
|
|
|
|
|
+ orderGoods.setStudyCount(orderGoodsVo.getStudyCount()-1);
|
|
|
|
|
+ orderGoods.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
|
+ iOrderGoodsService.updateById(orderGoods);
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean updateByEditBo(ClassGradeUserEditBo bo) {
|
|
public Boolean updateByEditBo(ClassGradeUserEditBo bo) {
|
|
|
for (Long aLong : bo.getId()) {
|
|
for (Long aLong : bo.getId()) {
|