|
@@ -16,13 +16,11 @@ import com.zhongzheng.modules.goods.domain.Goods;
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
import com.zhongzheng.modules.grade.bo.ClassGradeQueryBo;
|
|
import com.zhongzheng.modules.grade.bo.ClassGradeQueryBo;
|
|
-import com.zhongzheng.modules.grade.domain.ClassGrade;
|
|
|
|
-import com.zhongzheng.modules.grade.domain.ClassGradeGoods;
|
|
|
|
-import com.zhongzheng.modules.grade.domain.ClassGradeSys;
|
|
|
|
-import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
|
|
|
|
+import com.zhongzheng.modules.grade.domain.*;
|
|
import com.zhongzheng.modules.grade.service.IClassGradeGoodsService;
|
|
import com.zhongzheng.modules.grade.service.IClassGradeGoodsService;
|
|
import com.zhongzheng.modules.grade.service.IClassGradeService;
|
|
import com.zhongzheng.modules.grade.service.IClassGradeService;
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
|
|
+import com.zhongzheng.modules.grade.service.IClassGradeUserTempService;
|
|
import com.zhongzheng.modules.grade.vo.ClassGradeVo;
|
|
import com.zhongzheng.modules.grade.vo.ClassGradeVo;
|
|
import com.zhongzheng.modules.inform.bo.InformUserAddBo;
|
|
import com.zhongzheng.modules.inform.bo.InformUserAddBo;
|
|
import com.zhongzheng.modules.inform.service.IInformRemindService;
|
|
import com.zhongzheng.modules.inform.service.IInformRemindService;
|
|
@@ -74,6 +72,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
@Autowired
|
|
@Autowired
|
|
private IClassGradeService iClassGradeService;
|
|
private IClassGradeService iClassGradeService;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private IClassGradeUserTempService iClassGradeUserTempService;
|
|
|
|
+ @Autowired
|
|
private IClassGradeUserService iClassGradeUserService;
|
|
private IClassGradeUserService iClassGradeUserService;
|
|
@Autowired
|
|
@Autowired
|
|
private IClassGradeGoodsService iClassGradeGoodsService;
|
|
private IClassGradeGoodsService iClassGradeGoodsService;
|
|
@@ -236,13 +236,17 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
totalPrice = totalPrice.add(g.getGoodsPrice());
|
|
totalPrice = totalPrice.add(g.getGoodsPrice());
|
|
//暂不计算优惠券
|
|
//暂不计算优惠券
|
|
payPrice = payPrice.add(g.getGoodsPrice());
|
|
payPrice = payPrice.add(g.getGoodsPrice());
|
|
|
|
+
|
|
|
|
+ this.checkBuyGoods(g.getGoodsId(),bo.getUserId());
|
|
//视频商品安排班级
|
|
//视频商品安排班级
|
|
if(goods.getGoodsType()==1&&orderGoodsRs){
|
|
if(goods.getGoodsType()==1&&orderGoodsRs){
|
|
Long gradeId = null;
|
|
Long gradeId = null;
|
|
if(g.getGoodsInputData()!=null){
|
|
if(g.getGoodsInputData()!=null){
|
|
gradeId = g.getGoodsInputData().getGradeId();
|
|
gradeId = g.getGoodsInputData().getGradeId();
|
|
}
|
|
}
|
|
- arrangeGrade(goods.getGoodsName(),goods.getGoodsId(),orderGoods.getOrderGoodsId(),gradeId,add.getUserId());
|
|
|
|
|
|
+ if(g.getGoodsInputData().getType().equals("class")){
|
|
|
|
+ arrangeGrade(goods.getGoodsName(),goods.getGoodsId(),orderGoods.getOrderGoodsId(),gradeId,add.getUserId(),out_trade_no);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -309,13 +313,18 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
totalPrice = totalPrice.add(goods.getStandPrice());
|
|
totalPrice = totalPrice.add(goods.getStandPrice());
|
|
//暂不计算优惠券
|
|
//暂不计算优惠券
|
|
payPrice = payPrice.add(goods.getStandPrice());
|
|
payPrice = payPrice.add(goods.getStandPrice());
|
|
|
|
+
|
|
|
|
+ this.checkBuyGoods(g.getGoodsId(),bo.getUserId());
|
|
|
|
+
|
|
//视频商品安排班级
|
|
//视频商品安排班级
|
|
if(goods.getGoodsType()==1&&orderGoodsRs){
|
|
if(goods.getGoodsType()==1&&orderGoodsRs){
|
|
Long gradeId = null;
|
|
Long gradeId = null;
|
|
if(g.getGoodsInputData()!=null){
|
|
if(g.getGoodsInputData()!=null){
|
|
gradeId = g.getGoodsInputData().getGradeId();
|
|
gradeId = g.getGoodsInputData().getGradeId();
|
|
}
|
|
}
|
|
- arrangeGrade(goods.getGoodsName(),goods.getGoodsId(),orderGoods.getOrderGoodsId(),gradeId,add.getUserId());
|
|
|
|
|
|
+ if(g.getGoodsInputData().getType().equals("class")){
|
|
|
|
+ arrangeGrade(goods.getGoodsName(),goods.getGoodsId(),orderGoods.getOrderGoodsId(),gradeId,add.getUserId(),out_trade_no);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
iShoppingCartService.deleteByGoodsId(g.getGoodsId(),bo.getUserId());
|
|
iShoppingCartService.deleteByGoodsId(g.getGoodsId(),bo.getUserId());
|
|
}
|
|
}
|
|
@@ -409,6 +418,17 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
return orderListVos;
|
|
return orderListVos;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //检查是否购买过商品
|
|
|
|
+ public boolean checkBuyGoods(Long goodsId,Long userId){
|
|
|
|
+ OrderGoodsQueryBo bo = new OrderGoodsQueryBo();
|
|
|
|
+ bo.setUserId(userId);
|
|
|
|
+ bo.setGoodsId(goodsId);
|
|
|
|
+ Long num = iOrderGoodsService.getBuyGoodsHistory(bo);
|
|
|
|
+ if(num.longValue()>0){
|
|
|
|
+ throw new CustomException("无法重复购买此商品");
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 加入班级
|
|
* 加入班级
|
|
@@ -416,7 +436,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
* @param gradeId
|
|
* @param gradeId
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public boolean arrangeGrade(String goodsName,Long goodsId,Long orderGoodsId,Long gradeId,Long userId){
|
|
|
|
|
|
+ public boolean arrangeGrade(String goodsName,Long goodsId,Long orderGoodsId,Long gradeId,Long userId,String orderSn){
|
|
//查询该学员有没有有效期内同商品班级 有就不允许添加
|
|
//查询该学员有没有有效期内同商品班级 有就不允许添加
|
|
Integer classNum = baseMapper.selectUserClass(goodsId,userId);
|
|
Integer classNum = baseMapper.selectUserClass(goodsId,userId);
|
|
if (classNum > 0){
|
|
if (classNum > 0){
|
|
@@ -475,13 +495,41 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
classGradeGoods.setCreateTime(DateUtils.getNowTime());
|
|
classGradeGoods.setCreateTime(DateUtils.getNowTime());
|
|
classGradeGoods.setUpdateTime(DateUtils.getNowTime());
|
|
classGradeGoods.setUpdateTime(DateUtils.getNowTime());
|
|
iClassGradeGoodsService.save(classGradeGoods);
|
|
iClassGradeGoodsService.save(classGradeGoods);
|
|
- //加入班级
|
|
|
|
- joinGrade(orderGoodsId,classGrade.getGradeId(),userId);
|
|
|
|
|
|
+ //锁定班级
|
|
|
|
+ lockGrade(orderGoodsId,classGrade.getGradeId(),userId,goodsId,orderSn);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 锁定班级
|
|
|
|
+ * @param orderGoodsId
|
|
|
|
+ * @param gradeId
|
|
|
|
+ * @param userId
|
|
|
|
+ * @param goodsId
|
|
|
|
+ * @param orderSn
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public boolean lockGrade(Long orderGoodsId,Long gradeId,Long userId,Long goodsId,String orderSn){
|
|
|
|
+ //锁定班级
|
|
|
|
+ ClassGradeUserTemp classGradeUserTemp = new ClassGradeUserTemp();
|
|
|
|
+ classGradeUserTemp.setUserId(userId);
|
|
|
|
+ classGradeUserTemp.setGradeId(gradeId);
|
|
|
|
+ classGradeUserTemp.setStatus(1);
|
|
|
|
+ classGradeUserTemp.setFromType(1);
|
|
|
|
+ classGradeUserTemp.setGoodsId(goodsId);
|
|
|
|
+ classGradeUserTemp.setOrderSn(orderSn);
|
|
|
|
+ classGradeUserTemp.setCreateTime(DateUtils.getNowTime());
|
|
|
|
+ classGradeUserTemp.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
+ iClassGradeUserTempService.save(classGradeUserTemp);
|
|
|
|
+ //更新订单绑定班级ID
|
|
|
|
+ OrderGoods orderGoods = new OrderGoods();
|
|
|
|
+ orderGoods.setOrderGoodsId(orderGoodsId);
|
|
|
|
+ orderGoods.setGradeId(gradeId);
|
|
|
|
+ orderGoods.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
+ iOrderGoodsService.updateById(orderGoods);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
public boolean joinGrade(Long orderGoodsId,Long gradeId,Long userId){
|
|
public boolean joinGrade(Long orderGoodsId,Long gradeId,Long userId){
|
|
- // System.out.println("加入班级"+gradeId);
|
|
|
|
//进入班级
|
|
//进入班级
|
|
ClassGradeUser classGradeUser = new ClassGradeUser();
|
|
ClassGradeUser classGradeUser = new ClassGradeUser();
|
|
classGradeUser.setUserId(userId);
|
|
classGradeUser.setUserId(userId);
|