he2802 преди 3 години
родител
ревизия
0c91355f1e
променени са 1 файла, в които са добавени 12 реда и са изтрити 0 реда
  1. 12 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderBillSheetServiceImpl.java

+ 12 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderBillSheetServiceImpl.java

@@ -7,6 +7,7 @@ import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.modules.course.domain.CourseChapterSection;
 import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.order.bo.*;
+import com.zhongzheng.modules.order.domain.Order;
 import com.zhongzheng.modules.order.domain.OrderBillGoods;
 import com.zhongzheng.modules.order.domain.OrderBillSheet;
 import com.zhongzheng.modules.order.domain.OrderGoods;
@@ -14,6 +15,7 @@ import com.zhongzheng.modules.order.mapper.OrderBillSheetMapper;
 import com.zhongzheng.modules.order.service.IOrderBillGoodsService;
 import com.zhongzheng.modules.order.service.IOrderBillSheetService;
 import com.zhongzheng.modules.order.service.IOrderGoodsService;
+import com.zhongzheng.modules.order.service.IOrderService;
 import com.zhongzheng.modules.order.vo.OrderBillSheetVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -42,6 +44,9 @@ public class OrderBillSheetServiceImpl extends ServiceImpl<OrderBillSheetMapper,
     @Autowired
     private IOrderGoodsService iOrderGoodsService;
 
+    @Autowired
+    private IOrderService iOrderService;
+
     @Override
     public OrderBillSheetVo queryById(Long sheetId){
         OrderBillSheet db = this.baseMapper.selectById(sheetId);
@@ -158,6 +163,10 @@ public class OrderBillSheetServiceImpl extends ServiceImpl<OrderBillSheetMapper,
             if(goods==null){
                 throw new CustomException("订单商品错误");
             }
+            Order order = iOrderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderSn, g.getOrderSn()));
+            if(order==null){
+                throw new CustomException("订单错误");
+            }
             //计费单已收费用累加
             goods.setGoodsReceived(goods.getGoodsReceived().add(orderGoods.getAmount()));
             if(goods.getGoodsRealPrice().compareTo(goods.getGoodsReceived()) == -1){
@@ -171,6 +180,9 @@ public class OrderBillSheetServiceImpl extends ServiceImpl<OrderBillSheetMapper,
                 //部分收费
                 goods.setPayStatus(OrderGoods.PAY_PART);
             }
+            order.setStatus(1);//订单生效
+            order.setUpdateTime(DateUtils.getNowTime());
+            iOrderService.updateById(order);
             goods.setUpdateTime(DateUtils.getNowTime());
             iOrderGoodsService.updateById(goods);
         }