|
@@ -16,6 +16,7 @@ import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
|
import com.zhongzheng.modules.grade.bo.ClassGradeQueryBo;
|
|
|
+import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
|
|
|
import com.zhongzheng.modules.grade.domain.*;
|
|
|
import com.zhongzheng.modules.grade.service.IClassGradeGoodsService;
|
|
|
import com.zhongzheng.modules.grade.service.IClassGradeService;
|
|
@@ -237,18 +238,23 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
//暂不计算优惠券
|
|
|
payPrice = payPrice.add(g.getGoodsPrice());
|
|
|
|
|
|
- this.checkBuyGoods(g.getGoodsId(),bo.getUserId());
|
|
|
+ boolean canRepeatBuy = false;
|
|
|
//视频商品安排班级
|
|
|
if(goods.getGoodsType()==1&&orderGoodsRs){
|
|
|
Long gradeId = null;
|
|
|
if(g.getGoodsInputData()!=null){
|
|
|
gradeId = g.getGoodsInputData().getGradeId();
|
|
|
if(g.getGoodsInputData().getType()!=null&&g.getGoodsInputData().getType().equals("class")){
|
|
|
+ //判断是否购买历史班级都过期
|
|
|
+ canRepeatBuy =this.canBuyRepeatGoods(g.getGoodsId(),bo.getUserId());
|
|
|
arrangeGrade(goods.getGoodsName(),goods.getGoodsId(),orderGoods.getOrderGoodsId(),gradeId,add.getUserId(),out_trade_no);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ if(!canRepeatBuy){
|
|
|
+ this.checkBuyGoods(g.getGoodsId(),bo.getUserId());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
add.setOrderSn(out_trade_no);
|
|
@@ -315,19 +321,24 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
//暂不计算优惠券
|
|
|
payPrice = payPrice.add(goods.getStandPrice());
|
|
|
|
|
|
- this.checkBuyGoods(g.getGoodsId(),bo.getUserId());
|
|
|
|
|
|
+ boolean canRepeatBuy = false;
|
|
|
//视频商品安排班级
|
|
|
if(goods.getGoodsType()==1&&orderGoodsRs){
|
|
|
Long gradeId = null;
|
|
|
if(g.getGoodsInputData()!=null){
|
|
|
gradeId = g.getGoodsInputData().getGradeId();
|
|
|
if(g.getGoodsInputData().getType()!=null&&g.getGoodsInputData().getType().equals("class")){
|
|
|
+ //判断是否购买历史班级都过期
|
|
|
+ canRepeatBuy =this.canBuyRepeatGoods(g.getGoodsId(),bo.getUserId());
|
|
|
arrangeGrade(goods.getGoodsName(),goods.getGoodsId(),orderGoods.getOrderGoodsId(),gradeId,add.getUserId(),out_trade_no);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ if(!canRepeatBuy){
|
|
|
+ this.checkBuyGoods(g.getGoodsId(),bo.getUserId());
|
|
|
+ }
|
|
|
iShoppingCartService.deleteByGoodsId(g.getGoodsId(),bo.getUserId());
|
|
|
}
|
|
|
|
|
@@ -437,6 +448,20 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
return orderListVos;
|
|
|
}
|
|
|
|
|
|
+ //检查是否允许重复购买商品
|
|
|
+ public boolean canBuyRepeatGoods(Long goodsId,Long userId){
|
|
|
+ ClassGradeQueryBo bo = new ClassGradeQueryBo();
|
|
|
+ bo.setUserId(userId);
|
|
|
+ bo.setGoodsId(goodsId);
|
|
|
+ bo.setPastDue(1L);
|
|
|
+ List<ClassGradeVo> list = iClassGradeService.queryList(bo);
|
|
|
+ if(list!=null&&list.size()>0){
|
|
|
+ throw new CustomException("包含购买商品班级尚未过期");
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//检查是否购买过商品
|
|
|
public boolean checkBuyGoods(Long goodsId,Long userId){
|
|
|
OrderGoodsQueryBo bo = new OrderGoodsQueryBo();
|
|
@@ -444,7 +469,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
bo.setGoodsId(goodsId);
|
|
|
Long num = iOrderGoodsService.getBuyGoodsHistory(bo);
|
|
|
if(num.longValue()>0){
|
|
|
- throw new CustomException("无法重复购买此商品");
|
|
|
+ throw new CustomException("无法重复购买商品");
|
|
|
}
|
|
|
return false;
|
|
|
}
|