|
|
@@ -12,30 +12,30 @@ package com.yami.shop.platform.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.yami.shop.bean.enums.DvyType;
|
|
|
+import com.yami.shop.bean.enums.OrderStatus;
|
|
|
import com.yami.shop.bean.model.Order;
|
|
|
import com.yami.shop.bean.model.OrderItem;
|
|
|
import com.yami.shop.bean.model.UserAddrOrder;
|
|
|
+import com.yami.shop.bean.param.DeliveryOrderParam;
|
|
|
import com.yami.shop.bean.param.OrderParam;
|
|
|
import com.yami.shop.bean.param.OrderPayParam;
|
|
|
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.OrderItemService;
|
|
|
-import com.yami.shop.service.OrderService;
|
|
|
-import com.yami.shop.service.UserAddrOrderService;
|
|
|
+import com.yami.shop.service.*;
|
|
|
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.stereotype.Controller;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* 订单信息管理实现
|
|
|
@@ -52,6 +52,9 @@ public class OrderController {
|
|
|
private final OrderService orderService;
|
|
|
private final OrderItemService orderItemService;
|
|
|
private final UserAddrOrderService userAddrOrderService;
|
|
|
+ private final ProductService productService;
|
|
|
+ private final SkuService skuService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 分页获取
|
|
|
@@ -104,4 +107,36 @@ public class OrderController {
|
|
|
orderService.soldExcel(orderParam,response);
|
|
|
//
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation("发货")
|
|
|
+ @PutMapping("/delivery")
|
|
|
+ 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())){
|
|
|
+ throw new GlobalException("订单不处于待入库状态,无法进行入库");
|
|
|
+ }else if (!Objects.equals(order.getHbOrderStatus(), OrderStatus.PADYED.value())){
|
|
|
+ throw new GlobalException("订单不处于待发货状态,无法进行发货");
|
|
|
+ }
|
|
|
+
|
|
|
+ Order orderParam = new Order();
|
|
|
+ orderParam.setOrderId(order.getOrderId());
|
|
|
+ if (!Objects.equals(order.getDvyType(), DvyType.FETCH.value()) || !Objects.equals(order.getDvyType(), DvyType.NOT_DELIVERY.value())){
|
|
|
+ orderParam.setDvyId(deliveryOrderParam.getDvyId());
|
|
|
+ orderParam.setDvyFlowId(deliveryOrderParam.getDvyFlowId());
|
|
|
+ }
|
|
|
+ orderParam.setDvyTime(new Date());
|
|
|
+ orderParam.setUpdateTime(new Date());
|
|
|
+ orderParam.setHbOrderStatus(OrderStatus.CONSIGNMENT.value());
|
|
|
+ orderParam.setUserId(order.getUserId());
|
|
|
+
|
|
|
+ orderService.delivery(orderParam);
|
|
|
+
|
|
|
+ List<OrderItem> orderItems = orderItemService.getOrderItemsByOrderNumber(deliveryOrderParam.getOrderNumber());
|
|
|
+ for (OrderItem orderItem : orderItems) {
|
|
|
+ productService.removeProductCacheByProdId(orderItem.getProdId());
|
|
|
+ skuService.removeSkuCacheBySkuId(orderItem.getSkuId(),orderItem.getProdId());
|
|
|
+ }
|
|
|
+ return ResponseEntity.ok().build();
|
|
|
+ }
|
|
|
+
|
|
|
}
|