|
@@ -10,6 +10,7 @@ import com.zhongzheng.common.utils.ServletUtils;
|
|
|
import com.zhongzheng.modules.bank.domain.QuestionBusiness;
|
|
|
import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
+import com.zhongzheng.modules.grade.bo.ClassGradeQueryBo;
|
|
|
import com.zhongzheng.modules.grade.domain.ClassGrade;
|
|
|
import com.zhongzheng.modules.grade.domain.ClassGradeSys;
|
|
|
import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
@@ -167,7 +168,6 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
BigDecimal totalPrice = new BigDecimal(0);
|
|
|
BigDecimal payPrice = new BigDecimal(0);
|
|
|
//生成订单
|
|
|
- Collection<OrderGoods> coll = new HashSet<>();
|
|
|
for (OrderGoodsAddBo g : goodsList) {
|
|
|
//订单商品
|
|
|
Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId,g.getGoodsId()));
|
|
@@ -191,19 +191,16 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
|
|
|
orderGoods.setCreateTime(DateUtils.getNowTime());
|
|
|
orderGoods.setUpdateTime(DateUtils.getNowTime());
|
|
|
- coll.add(orderGoods);
|
|
|
+ boolean orderGoodsRs = iOrderGoodsService.save(orderGoods);
|
|
|
//订单价格不计算优惠
|
|
|
totalPrice = totalPrice.add(g.getGoodsPrice());
|
|
|
//暂不计算优惠券
|
|
|
payPrice = payPrice.add(g.getGoodsPrice());
|
|
|
//视频商品安排班级
|
|
|
- if(goods.getGoodsType()==1){
|
|
|
- if(g.getGoodsInputData().getGradeId()!=null){
|
|
|
-
|
|
|
- }
|
|
|
+ if(goods.getGoodsType()==1&&orderGoodsRs){
|
|
|
+ arrangeGrade(goods.getGoodsName(),goods.getGoodsId(),orderGoods.getOrderGoodsId(),g.getGoodsInputData().getGradeId(),add.getUserId());
|
|
|
}
|
|
|
}
|
|
|
- iOrderGoodsService.saveBatch(coll);
|
|
|
|
|
|
add.setOrderSn(out_trade_no);
|
|
|
add.setOrderFrom(1);
|
|
@@ -249,7 +246,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
* @param gradeId
|
|
|
* @return
|
|
|
*/
|
|
|
- public boolean checkGrade(String goodsName,Long orderGoodsId,Long gradeId,Long userId){
|
|
|
+ public boolean arrangeGrade(String goodsName,Long goodsId,Long orderGoodsId,Long gradeId,Long userId){
|
|
|
//指定班级
|
|
|
if(gradeId!=null){
|
|
|
ClassGradeVo classGradeVo = iClassGradeService.queryById(gradeId);
|
|
@@ -266,7 +263,18 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
}
|
|
|
}else {
|
|
|
//无指定班级
|
|
|
-
|
|
|
+ ClassGradeQueryBo bo = new ClassGradeQueryBo();
|
|
|
+ bo.setGoodsId(goodsId);
|
|
|
+ List<ClassGradeVo> classGradeVoList = iClassGradeService.queryList(bo);
|
|
|
+ for(int i = 0; i < classGradeVoList.size(); i++){
|
|
|
+ ClassGradeVo classGradeVo = classGradeVoList.get(i);
|
|
|
+ if(classGradeVo.getStudentUpper()>classGradeVo.getStudentNum()){
|
|
|
+ //有空位则进入班级
|
|
|
+ gradeId = classGradeVo.getGradeId();
|
|
|
+ //班级还有剩位,直接加入班级
|
|
|
+ return joinGrade(orderGoodsId,gradeId,userId);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
//创建新班级
|
|
|
ClassGrade classGrade = new ClassGrade();
|
|
@@ -279,7 +287,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
boolean save = iClassGradeService.save(classGrade);
|
|
|
//加入班级
|
|
|
joinGrade(orderGoodsId,classGrade.getGradeId(),userId);
|
|
|
- return false;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
public boolean joinGrade(Long orderGoodsId,Long gradeId,Long userId){
|