管理端:
订单数量统计 查看订单详情
This commit is contained in:
@@ -4,15 +4,15 @@ import com.sky.dto.OrdersPageQueryDTO;
|
|||||||
import com.sky.result.PageResult;
|
import com.sky.result.PageResult;
|
||||||
import com.sky.result.Result;
|
import com.sky.result.Result;
|
||||||
import com.sky.service.OrderService;
|
import com.sky.service.OrderService;
|
||||||
|
import com.sky.vo.OrderOverViewVO;
|
||||||
|
import com.sky.vo.OrderStatisticsVO;
|
||||||
|
import com.sky.vo.OrderVO;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
@RestController("adminOrderController")
|
||||||
@RequestMapping("/admin/order")
|
@RequestMapping("/admin/order")
|
||||||
@Api(tags = "Order-Controller")
|
@Api(tags = "Order-Controller")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -25,4 +25,18 @@ public class OrderController {
|
|||||||
PageResult pageResult = orderService.pageQuery(ordersPageQueryDTO);
|
PageResult pageResult = orderService.pageQuery(ordersPageQueryDTO);
|
||||||
return Result.success(pageResult);
|
return Result.success(pageResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/statistics")
|
||||||
|
public Result<OrderStatisticsVO> statistics() {
|
||||||
|
log.info("order overview");
|
||||||
|
OrderStatisticsVO orderStatisticsVO = orderService.statistics();
|
||||||
|
return Result.success(orderStatisticsVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/details/{id}")
|
||||||
|
public Result<OrderVO> details(@PathVariable Long id) {
|
||||||
|
log.info("check order details: {}",id);
|
||||||
|
OrderVO orderVO = orderService.details(id);
|
||||||
|
return Result.success(orderVO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,4 +37,7 @@ public interface OrderMapper {
|
|||||||
|
|
||||||
@Select("select * from orders where id = #{id}")
|
@Select("select * from orders where id = #{id}")
|
||||||
Orders getById(Long id);
|
Orders getById(Long id);
|
||||||
|
|
||||||
|
@Select("select count(*) from orders where status = #{status}")
|
||||||
|
int countStatus(Integer status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
package com.sky.service;
|
package com.sky.service;
|
||||||
|
|
||||||
import com.sky.dto.OrdersDTO;
|
|
||||||
import com.sky.dto.OrdersPageQueryDTO;
|
import com.sky.dto.OrdersPageQueryDTO;
|
||||||
import com.sky.dto.OrdersPaymentDTO;
|
import com.sky.dto.OrdersPaymentDTO;
|
||||||
import com.sky.dto.OrdersSubmitDTO;
|
import com.sky.dto.OrdersSubmitDTO;
|
||||||
import com.sky.result.PageResult;
|
import com.sky.result.PageResult;
|
||||||
import com.sky.vo.OrderPaymentVO;
|
import com.sky.vo.*;
|
||||||
import com.sky.vo.OrderSubmitVO;
|
|
||||||
import com.sky.vo.OrderVO;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -68,4 +65,18 @@ public interface OrderService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
PageResult pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);
|
PageResult pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* order overview
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
OrderStatisticsVO statistics();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check order details
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
OrderVO details(Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,7 @@ import com.sky.mapper.*;
|
|||||||
import com.sky.result.PageResult;
|
import com.sky.result.PageResult;
|
||||||
import com.sky.service.OrderService;
|
import com.sky.service.OrderService;
|
||||||
import com.sky.utils.WeChatPayUtil;
|
import com.sky.utils.WeChatPayUtil;
|
||||||
import com.sky.vo.OrderPaymentVO;
|
import com.sky.vo.*;
|
||||||
import com.sky.vo.OrderSubmitVO;
|
|
||||||
import com.sky.vo.OrderVO;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -240,12 +238,41 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
OrderVO orderVO = new OrderVO();
|
OrderVO orderVO = new OrderVO();
|
||||||
BeanUtils.copyProperties(orders, orderVO);
|
BeanUtils.copyProperties(orders, orderVO);
|
||||||
List<OrderDetail> orderDetailList = orderDetailMapper.getByOrderId(orders.getId());
|
List<OrderDetail> orderDetailList = orderDetailMapper.getByOrderId(orders.getId());
|
||||||
String orderDishes = Arrays.toString(orderDetailList.toArray());
|
StringBuilder orderDishes = new StringBuilder();
|
||||||
orderDishes = orderDishes.substring(1, orderDishes.length() - 1);
|
for (OrderDetail orderDetail : orderDetailList) {
|
||||||
orderVO.setOrderDishes(orderDishes);
|
orderDishes.append(orderDetail.getName()).append(",");
|
||||||
|
}
|
||||||
|
orderVO.setOrderDishes(orderDishes.substring(0, orderDishes.length() - 1));
|
||||||
list.add(orderVO);
|
list.add(orderVO);
|
||||||
}
|
}
|
||||||
return new PageResult(list.size(), list);
|
return new PageResult(list.size(), list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderStatisticsVO statistics() {
|
||||||
|
int confirmed = orderMapper.countStatus(Orders.CONFIRMED);
|
||||||
|
int deliveryInProgress = orderMapper.countStatus(Orders.DELIVERY_IN_PROGRESS);
|
||||||
|
int toBeConfirmed = orderMapper.countStatus(Orders.TO_BE_CONFIRMED);
|
||||||
|
OrderStatisticsVO orderStatisticsVO = new OrderStatisticsVO();
|
||||||
|
orderStatisticsVO.setConfirmed(confirmed);
|
||||||
|
orderStatisticsVO.setDeliveryInProgress(deliveryInProgress);
|
||||||
|
orderStatisticsVO.setToBeConfirmed(toBeConfirmed);
|
||||||
|
return orderStatisticsVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderVO details(Long id) {
|
||||||
|
Orders orders = orderMapper.getById(id);
|
||||||
|
List<OrderDetail> orderDetailList = orderDetailMapper.getByOrderId(orders.getId());
|
||||||
|
StringBuilder orderDishes = new StringBuilder();
|
||||||
|
for (OrderDetail orderDetail : orderDetailList) {
|
||||||
|
orderDishes.append(orderDetail.getName()).append(",");
|
||||||
|
}
|
||||||
|
OrderVO orderVO = new OrderVO();
|
||||||
|
BeanUtils.copyProperties(orders, orderVO);
|
||||||
|
orderVO.setOrderDetailList(orderDetailList);
|
||||||
|
orderVO.setOrderDishes(orderDishes.substring(0, orderDishes.length() - 1));
|
||||||
|
return orderVO;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user