|
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.Page;
|
|
@@ -14,6 +15,8 @@ import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.SecurityUtils;
|
|
|
import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
|
|
|
+import com.zhongzheng.modules.base.domain.ShoppingCart;
|
|
|
+import com.zhongzheng.modules.base.service.IShoppingCartService;
|
|
|
import com.zhongzheng.modules.course.mapper.CourseMapper;
|
|
|
import com.zhongzheng.modules.course.service.ICourseChapterSectionService;
|
|
|
import com.zhongzheng.modules.course.service.ICourseMenuService;
|
|
@@ -26,8 +29,10 @@ import com.zhongzheng.modules.exam.service.IExamApplyGoodsService;
|
|
|
import com.zhongzheng.modules.exam.service.IExamApplyUserService;
|
|
|
import com.zhongzheng.modules.exam.service.IExamBeforeService;
|
|
|
import com.zhongzheng.modules.exam.vo.ExamApplyGoodsVo;
|
|
|
+import com.zhongzheng.modules.goods.bo.CheckGoodsStatusBo;
|
|
|
import com.zhongzheng.modules.goods.bo.GoodsCourseQueryBo;
|
|
|
import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
|
|
|
+import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsCourseService;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
@@ -138,6 +143,9 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
|
|
|
@Autowired
|
|
|
private IExamApplyUserService iExamApplyUserService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IShoppingCartService iShoppingCartService;
|
|
|
+
|
|
|
@Override
|
|
|
public OrderGoodsVo queryById(Long orderGoodsId) {
|
|
|
OrderGoods db = this.baseMapper.selectById(orderGoodsId);
|
|
@@ -604,6 +612,43 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean checkGoodsStatus(CheckGoodsStatusBo bo) {
|
|
|
+ if (CollectionUtils.isEmpty(bo.getGoodsIds())){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ bo.getGoodsIds().forEach(item ->{
|
|
|
+ Goods goods = iGoodsService.getById(item);
|
|
|
+ if (ObjectUtils.isNull(goods)){
|
|
|
+ throw new CustomException("商品信息获取失败!");
|
|
|
+ }
|
|
|
+ if (goods.getGoodsStatus() == 0){
|
|
|
+ throw new CustomException("存在未上架商品,请检查!");
|
|
|
+ }
|
|
|
+ Long nowTime = DateUtils.getNowTime();
|
|
|
+ if (nowTime < goods.getValidityStartTime() || nowTime > goods.getValidityEndTime()){
|
|
|
+ throw new CustomException("存在过期商品,请检查!");
|
|
|
+ }
|
|
|
+ if (bo.getIsCart() == 1){
|
|
|
+ //购物车校验
|
|
|
+ if(checkUnique(item,bo.getUserId())){
|
|
|
+ throw new CustomException("存在购物车已有商品,请检查!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean checkUnique(Long GoodsId,Long UserId) {
|
|
|
+ ShoppingCart info = iShoppingCartService.getOne(new LambdaQueryWrapper<ShoppingCart>()
|
|
|
+ .eq(ShoppingCart::getUserId,UserId).eq(ShoppingCart::getGoodsId,GoodsId).last("limit 1"));
|
|
|
+ if (Validator.isNotNull(info)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<CourseLiveVo> getLiveList(Long userId) {
|
|
|
List<CourseLiveVo> liveVos = orderGoodsMapper.getLiveList(userId);
|