|
|
|
|
@ -10,6 +10,7 @@
|
|
|
|
|
|
|
|
|
|
package com.yami.shop.api.controller;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.yami.shop.bean.app.dto.*;
|
|
|
|
|
import com.yami.shop.bean.enums.OrderStatus;
|
|
|
|
|
@ -18,20 +19,19 @@ import com.yami.shop.bean.model.OrderItem;
|
|
|
|
|
import com.yami.shop.bean.model.ShopDetail;
|
|
|
|
|
import com.yami.shop.bean.model.UserAddrOrder;
|
|
|
|
|
import com.yami.shop.common.exception.YamiShopBindException;
|
|
|
|
|
import com.yami.shop.common.response.ServerResponseEntity;
|
|
|
|
|
import com.yami.shop.common.util.Arith;
|
|
|
|
|
import com.yami.shop.common.util.PageParam;
|
|
|
|
|
import com.yami.shop.security.api.util.SecurityUtils;
|
|
|
|
|
import com.yami.shop.service.*;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Parameters;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import com.yami.shop.common.response.ServerResponseEntity;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
@ -47,7 +47,6 @@ public class MyOrderController {
|
|
|
|
|
private final OrderService orderService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final UserAddrOrderService userAddrOrderService;
|
|
|
|
|
|
|
|
|
|
private final ProductService productService;
|
|
|
|
|
@ -67,7 +66,7 @@ public class MyOrderController {
|
|
|
|
|
@GetMapping("/orderDetail")
|
|
|
|
|
@Operation(summary = "订单详情信息", description = "根据订单号获取订单详情信息")
|
|
|
|
|
@Parameter(name = "orderNumber", description = "订单号", required = true)
|
|
|
|
|
public ServerResponseEntity<OrderShopDto> orderDetail(@RequestParam(value = "orderNumber", required = true) String orderNumber) {
|
|
|
|
|
public ServerResponseEntity<OrderShopDto> orderDetail(@RequestParam(value = "orderNumber") String orderNumber) {
|
|
|
|
|
|
|
|
|
|
String userId = SecurityUtils.getUser().getUserId();
|
|
|
|
|
OrderShopDto orderShopDto = new OrderShopDto();
|
|
|
|
|
@ -85,13 +84,13 @@ public class MyOrderController {
|
|
|
|
|
UserAddrOrder userAddrOrder = userAddrOrderService.getById(order.getAddrOrderId());
|
|
|
|
|
UserAddrDto userAddrDto = BeanUtil.copyProperties(userAddrOrder, UserAddrDto.class);
|
|
|
|
|
List<OrderItem> orderItems = orderItemService.getOrderItemsByOrderNumber(orderNumber);
|
|
|
|
|
List<OrderItemDto> orderItemDtos = BeanUtil.copyToList(orderItems, OrderItemDto.class);
|
|
|
|
|
List<OrderItemDto> orderItemList = BeanUtil.copyToList(orderItems, OrderItemDto.class);
|
|
|
|
|
|
|
|
|
|
orderShopDto.setShopId(shopDetail.getShopId());
|
|
|
|
|
orderShopDto.setShopName(shopDetail.getShopName());
|
|
|
|
|
orderShopDto.setActualTotal(order.getActualTotal());
|
|
|
|
|
orderShopDto.setUserAddrDto(userAddrDto);
|
|
|
|
|
orderShopDto.setOrderItemDtos(orderItemDtos);
|
|
|
|
|
orderShopDto.setOrderItemDtos(orderItemList);
|
|
|
|
|
orderShopDto.setTransfee(order.getFreightAmount());
|
|
|
|
|
orderShopDto.setReduceAmount(order.getReduceAmount());
|
|
|
|
|
orderShopDto.setCreateTime(order.getCreateTime());
|
|
|
|
|
@ -120,7 +119,6 @@ public class MyOrderController {
|
|
|
|
|
@Parameter(name = "status", description = "订单状态 1:待付款 2:待发货 3:待收货 4:待评价 5:成功 6:失败")
|
|
|
|
|
})
|
|
|
|
|
public ServerResponseEntity<IPage<MyOrderDto>> myOrder(@RequestParam(value = "status") Integer status, PageParam<MyOrderDto> page) {
|
|
|
|
|
|
|
|
|
|
String userId = SecurityUtils.getUser().getUserId();
|
|
|
|
|
IPage<MyOrderDto> myOrderDtoIpage = myOrderService.pageMyOrderByUserIdAndStatus(page, userId, status);
|
|
|
|
|
return ServerResponseEntity.success(myOrderDtoIpage);
|
|
|
|
|
@ -144,7 +142,7 @@ public class MyOrderController {
|
|
|
|
|
List<OrderItem> orderItems = orderItemService.getOrderItemsByOrderNumber(orderNumber);
|
|
|
|
|
order.setOrderItems(orderItems);
|
|
|
|
|
// 取消订单
|
|
|
|
|
orderService.cancelOrders(Arrays.asList(order));
|
|
|
|
|
orderService.cancelOrders(Collections.singletonList(order));
|
|
|
|
|
|
|
|
|
|
// 清除缓存
|
|
|
|
|
for (OrderItem orderItem : orderItems) {
|
|
|
|
|
@ -172,7 +170,7 @@ public class MyOrderController {
|
|
|
|
|
List<OrderItem> orderItems = orderItemService.getOrderItemsByOrderNumber(orderNumber);
|
|
|
|
|
order.setOrderItems(orderItems);
|
|
|
|
|
// 确认收货
|
|
|
|
|
orderService.confirmOrder(Arrays.asList(order));
|
|
|
|
|
orderService.confirmOrder(Collections.singletonList(order));
|
|
|
|
|
|
|
|
|
|
for (OrderItem orderItem : orderItems) {
|
|
|
|
|
productService.removeProductCacheByProdId(orderItem.getProdId());
|
|
|
|
|
@ -202,7 +200,7 @@ public class MyOrderController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 删除订单
|
|
|
|
|
orderService.deleteOrders(Arrays.asList(order));
|
|
|
|
|
orderService.deleteOrders(Collections.singletonList(order));
|
|
|
|
|
|
|
|
|
|
return ServerResponseEntity.success("删除成功");
|
|
|
|
|
}
|
|
|
|
|
|