|
@@ -1,6 +1,7 @@
|
|
|
package com.zhongzheng.modules.goods.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
@@ -27,6 +28,8 @@ import com.zhongzheng.modules.goods.service.IGoodsCourseService;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.goods.vo.*;
|
|
|
import com.zhongzheng.modules.grade.vo.ClassGradeVo;
|
|
|
+import com.zhongzheng.modules.order.domain.OrderGoods;
|
|
|
+import com.zhongzheng.modules.order.service.IOrderGoodsService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -62,6 +65,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
@Autowired
|
|
|
private CourseMapper courseMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IOrderGoodsService iOrderGoodsService;
|
|
|
+
|
|
|
@Override
|
|
|
public GoodsVo queryById(Long goodsId){
|
|
|
Goods db = this.baseMapper.selectById(goodsId);
|
|
@@ -303,6 +309,17 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
throw new CustomException("过期商品不允许上架");
|
|
|
}
|
|
|
}
|
|
|
+ if ((entity.getStatus() ==-1||entity.getStatus() ==0)&&entity.getGoodsId().longValue()>0) {
|
|
|
+ List<Long> payStatus = new ArrayList<>();
|
|
|
+ payStatus.add(2L);
|
|
|
+ payStatus.add(3L);
|
|
|
+ //查看是否有出售过
|
|
|
+ OrderGoods orderGoods = iOrderGoodsService.getOne(new LambdaQueryWrapper< OrderGoods >().eq(OrderGoods::getGoodsId,entity.getGoodsId())
|
|
|
+ .in(OrderGoods::getPayStatus,payStatus).last("limit 1"));
|
|
|
+ if(Validator.isNotEmpty(orderGoods)){
|
|
|
+ throw new CustomException("该商品已被购买过,无法改变状态");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|