wangming 2 өдөр өмнө
parent
commit
92648d945f

+ 8 - 2
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/OrderController.java

@@ -25,11 +25,13 @@ import com.yami.shop.common.exception.GlobalException;
 import com.yami.shop.common.util.PageParam;
 import com.yami.shop.common.util.R;
 import com.yami.shop.service.*;
+import com.yami.shop.utils.CullenUtils;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.http.ResponseEntity;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
@@ -80,7 +82,6 @@ public class OrderController {
         return R.SUCCESS(orderService.deliverListStatusNum());
     }
 
-
     /**
      * 根据商家获取支付信息
      */
@@ -131,6 +132,7 @@ public class OrderController {
 
     @ApiOperation("发货")
     @PutMapping("/delivery")
+    @Transactional(rollbackFor = Exception.class)
     public ResponseEntity<Void> delivery(@RequestBody DeliveryOrderParam deliveryOrderParam) {
         Order order = orderService.getOne(new LambdaUpdateWrapper<Order>().eq(Order::getOrderNumber, deliveryOrderParam.getOrderNumber()));
         if (!Objects.equals(order.getHbOrderStatus(), OrderStatus.PADYED.value()) && Objects.equals(order.getDvyType(), DvyType.FETCH.value())){
@@ -139,6 +141,11 @@ public class OrderController {
             throw new GlobalException("订单不处于待发货状态,无法进行发货");
         }
 
+        List<OrderItem> orderItems = orderItemService.getOrderItemsByOrderNumber(deliveryOrderParam.getOrderNumber());
+        if (!orderItems.isEmpty()) {
+            orderItems.forEach(orderItem-> CullenUtils.validateDataThrowException(orderItemService.refundIngCount(orderItem.getOrderItemId())!=0,"该订单存在售后中商品,请处理后发货..."));
+        }
+
         Order orderParam = new Order();
         orderParam.setOrderId(order.getOrderId());
         if (!Objects.equals(order.getDvyType(), DvyType.FETCH.value()) || !Objects.equals(order.getDvyType(), DvyType.NOT_DELIVERY.value())){
@@ -152,7 +159,6 @@ public class OrderController {
 
         orderService.delivery(orderParam);
 
-        List<OrderItem> orderItems = orderItemService.getOrderItemsByOrderNumber(deliveryOrderParam.getOrderNumber());
         for (OrderItem orderItem : orderItems) {
             productService.removeProductCacheByProdId(orderItem.getProdId());
             skuService.removeSkuCacheBySkuId(orderItem.getSkuId(),orderItem.getProdId());