- 修改订单 page 返回类,增加 total 条数

pull/1/head
sin 2019-03-28 00:44:52 +08:00
parent e2a19a1d9d
commit 1900ccafe2
8 changed files with 345 additions and 195 deletions

View File

@ -2,14 +2,12 @@ package cn.iocoder.mall.order.application.controller.admins;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.OrderService;
import cn.iocoder.mall.order.api.dto.OrderItemUpdateDTO;
import cn.iocoder.mall.order.api.dto.OrderLogisticsUpdateDTO;
import cn.iocoder.mall.order.api.dto.OrderPageBO;
import cn.iocoder.mall.order.api.dto.OrderQueryDTO;
import cn.iocoder.mall.order.api.dto.*;
import cn.iocoder.mall.order.application.convert.OrderConvertAPP;
import cn.iocoder.mall.order.application.vo.OrderItemUpdateVO;
import cn.iocoder.mall.order.application.vo.OrderLogisticsVO;
import cn.iocoder.mall.order.application.vo.OrderPageQueryVO;
import cn.iocoder.mall.order.application.vo.OrderPageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@ -34,10 +32,9 @@ public class AdminsOrderController {
@GetMapping("page")
@ApiOperation("订单列表")
public CommonResult<List<OrderPageBO>> getOrderPage(@Validated OrderPageQueryVO orderPageQueryVO) {
public CommonResult<OrderPageBO> getOrderPage(@Validated OrderPageQueryVO orderPageQueryVO) {
OrderQueryDTO orderQueryDTO = OrderConvertAPP.INSTANCE.convertPageBO(orderPageQueryVO);
CommonResult<List<OrderPageBO>> result = orderService.getOrderPage(orderQueryDTO);
return result;
return orderService.getOrderPage(orderQueryDTO);
}
@PutMapping("order_item/update")

View File

@ -2,6 +2,7 @@ package cn.iocoder.mall.order.application.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@ -34,16 +35,27 @@ public class OrderPageQueryVO implements Serializable {
*
*/
@ApiModelProperty("start付款时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startPaymentTime;
@ApiModelProperty("end付款时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endPaymentTime;
/**
*
*/
@ApiModelProperty("start订单创建时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startCreateTime;
@ApiModelProperty("end订单创建时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endCreateTime;
/**
*
*/
@ApiModelProperty("start成交时间")
private Date startClosingTime;
@ApiModelProperty("end成交时间")
private Date endClosingTime;
/**
*
*/
@ -64,6 +76,8 @@ public class OrderPageQueryVO implements Serializable {
", endPaymentTime=" + endPaymentTime +
", startCreateTime=" + startCreateTime +
", endCreateTime=" + endCreateTime +
", startClosingTime=" + startClosingTime +
", endClosingTime=" + endClosingTime +
", deleted=" + deleted +
", pageNo=" + pageNo +
", pageSize=" + pageSize +
@ -133,6 +147,24 @@ public class OrderPageQueryVO implements Serializable {
return this;
}
public Date getStartClosingTime() {
return startClosingTime;
}
public OrderPageQueryVO setStartClosingTime(Date startClosingTime) {
this.startClosingTime = startClosingTime;
return this;
}
public Date getEndClosingTime() {
return endClosingTime;
}
public OrderPageQueryVO setEndClosingTime(Date endClosingTime) {
this.endClosingTime = endClosingTime;
return this;
}
public Integer getDeleted() {
return deleted;
}

View File

@ -0,0 +1,70 @@
package cn.iocoder.mall.order.application.vo;
import cn.iocoder.mall.order.api.dto.OrderBO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.List;
/**
* vo
*
* @author Sin
* @time 2019-03-27 21:23
*/
@ApiModel("订单VO")
public class OrderPageVO implements Serializable {
/**
*
*/
@ApiModelProperty("分页下表当前")
private Integer pageNo;
/**
*
*/
@ApiModelProperty("总条数")
private Integer total;
/**
* list
*/
@ApiModelProperty("订单信息")
private List<OrderBO> orders;
@Override
public String toString() {
return "OrderPageVO{" +
"pageNo=" + pageNo +
", total=" + total +
", orders=" + orders +
'}';
}
public Integer getPageNo() {
return pageNo;
}
public OrderPageVO setPageNo(Integer pageNo) {
this.pageNo = pageNo;
return this;
}
public Integer getTotal() {
return total;
}
public OrderPageVO setTotal(Integer total) {
this.total = total;
return this;
}
public List<OrderBO> getOrders() {
return orders;
}
public OrderPageVO setOrders(List<OrderBO> orders) {
this.orders = orders;
return this;
}
}

View File

@ -1,7 +1,6 @@
package cn.iocoder.mall.order.api;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.bo.OrderBO;
import cn.iocoder.mall.order.api.dto.*;
import java.util.List;
@ -20,7 +19,7 @@ public interface OrderService {
* @param orderQueryDTO
* @return
*/
CommonResult<List<OrderPageBO>> getOrderPage(OrderQueryDTO orderQueryDTO);
CommonResult<OrderPageBO> getOrderPage(OrderQueryDTO orderQueryDTO);
/**
* -
@ -29,7 +28,7 @@ public interface OrderService {
* @param orderCreateDTO
* @return
*/
CommonResult<OrderBO> createOrder(Integer userId, OrderCreateDTO orderCreateDTO);
CommonResult<cn.iocoder.mall.order.api.bo.OrderBO> createOrder(Integer userId, OrderCreateDTO orderCreateDTO);
/**
* item -

View File

@ -0,0 +1,207 @@
package cn.iocoder.mall.order.api.dto;
import java.io.Serializable;
import java.util.Date;
/**
* page
*
* @author Sin
* @time 2019-03-23 14:30
*/
public class OrderBO implements Serializable {
/**
* id
*/
private Integer id;
/**
*
*/
private Integer userId;
/**
* id
*/
private Integer orderLogisticsId;
/**
*
*/
private String orderNo;
/**
*
*/
private Integer price;
///
/// 时间信息
/**
*
*/
private Date paymentTime;
/**
*
*/
private Date deliveryTime;
/**
*
*/
private Date receiverTime;
/**
* -> status =
*/
private Date closingTime;
///
/// 其他
/**
* 退
*
* - 0
* - 1
* - 2退
* - 3 + 退
*/
private Integer hasReturnExchange;
/**
* ()
*
* - 0
* - 1
* - 2
* - 3
* - 4
*/
private Integer status;
/**
*
*/
private String remark;
@Override
public String toString() {
return "OrderPageBO{" +
"id=" + id +
", userId=" + userId +
", orderLogisticsId=" + orderLogisticsId +
", orderNo='" + orderNo + '\'' +
", price=" + price +
", paymentTime=" + paymentTime +
", deliveryTime=" + deliveryTime +
", receiverTime=" + receiverTime +
", closingTime=" + closingTime +
", hasReturnExchange=" + hasReturnExchange +
", status=" + status +
", remark='" + remark + '\'' +
'}';
}
public Integer getId() {
return id;
}
public OrderBO setId(Integer id) {
this.id = id;
return this;
}
public Integer getUserId() {
return userId;
}
public OrderBO setUserId(Integer userId) {
this.userId = userId;
return this;
}
public Integer getOrderLogisticsId() {
return orderLogisticsId;
}
public OrderBO setOrderLogisticsId(Integer orderLogisticsId) {
this.orderLogisticsId = orderLogisticsId;
return this;
}
public String getOrderNo() {
return orderNo;
}
public OrderBO setOrderNo(String orderNo) {
this.orderNo = orderNo;
return this;
}
public Integer getPrice() {
return price;
}
public OrderBO setPrice(Integer price) {
this.price = price;
return this;
}
public Date getPaymentTime() {
return paymentTime;
}
public OrderBO setPaymentTime(Date paymentTime) {
this.paymentTime = paymentTime;
return this;
}
public Date getDeliveryTime() {
return deliveryTime;
}
public OrderBO setDeliveryTime(Date deliveryTime) {
this.deliveryTime = deliveryTime;
return this;
}
public Date getReceiverTime() {
return receiverTime;
}
public OrderBO setReceiverTime(Date receiverTime) {
this.receiverTime = receiverTime;
return this;
}
public Date getClosingTime() {
return closingTime;
}
public OrderBO setClosingTime(Date closingTime) {
this.closingTime = closingTime;
return this;
}
public Integer getHasReturnExchange() {
return hasReturnExchange;
}
public OrderBO setHasReturnExchange(Integer hasReturnExchange) {
this.hasReturnExchange = hasReturnExchange;
return this;
}
public Integer getStatus() {
return status;
}
public OrderBO setStatus(Integer status) {
this.status = status;
return this;
}
public String getRemark() {
return remark;
}
public OrderBO setRemark(String remark) {
this.remark = remark;
return this;
}
}

View File

@ -1,207 +1,48 @@
package cn.iocoder.mall.order.api.dto;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* page
*
*
* @author Sin
* @time 2019-03-23 14:30
* @time 2019-03-27 21:27
*/
public class OrderPageBO implements Serializable {
/**
* id
*
*/
private Integer id;
private Integer total;
/**
*
*
*/
private Integer userId;
/**
* id
*/
private Integer orderLogisticsId;
/**
*
*/
private String orderNo;
/**
*
*/
private Integer price;
///
/// 时间信息
/**
*
*/
private Date paymentTime;
/**
*
*/
private Date deliveryTime;
/**
*
*/
private Date receiverTime;
/**
* -> status =
*/
private Date closingTime;
///
/// 其他
/**
* 退
*
* - 0
* - 1
* - 2退
* - 3 + 退
*/
private Integer hasReturnExchange;
/**
* ()
*
* - 0
* - 1
* - 2
* - 3
* - 4
*/
private Integer status;
/**
*
*/
private String remark;
private List<OrderBO> orders;
@Override
public String toString() {
return "OrderPageBO{" +
"id=" + id +
", userId=" + userId +
", orderLogisticsId=" + orderLogisticsId +
", orderNo='" + orderNo + '\'' +
", price=" + price +
", paymentTime=" + paymentTime +
", deliveryTime=" + deliveryTime +
", receiverTime=" + receiverTime +
", closingTime=" + closingTime +
", hasReturnExchange=" + hasReturnExchange +
", status=" + status +
", remark='" + remark + '\'' +
"total=" + total +
", orders=" + orders +
'}';
}
public Integer getId() {
return id;
public Integer getTotal() {
return total;
}
public OrderPageBO setId(Integer id) {
this.id = id;
public OrderPageBO setTotal(Integer total) {
this.total = total;
return this;
}
public Integer getUserId() {
return userId;
public List<OrderBO> getOrders() {
return orders;
}
public OrderPageBO setUserId(Integer userId) {
this.userId = userId;
return this;
}
public Integer getOrderLogisticsId() {
return orderLogisticsId;
}
public OrderPageBO setOrderLogisticsId(Integer orderLogisticsId) {
this.orderLogisticsId = orderLogisticsId;
return this;
}
public String getOrderNo() {
return orderNo;
}
public OrderPageBO setOrderNo(String orderNo) {
this.orderNo = orderNo;
return this;
}
public Integer getPrice() {
return price;
}
public OrderPageBO setPrice(Integer price) {
this.price = price;
return this;
}
public Date getPaymentTime() {
return paymentTime;
}
public OrderPageBO setPaymentTime(Date paymentTime) {
this.paymentTime = paymentTime;
return this;
}
public Date getDeliveryTime() {
return deliveryTime;
}
public OrderPageBO setDeliveryTime(Date deliveryTime) {
this.deliveryTime = deliveryTime;
return this;
}
public Date getReceiverTime() {
return receiverTime;
}
public OrderPageBO setReceiverTime(Date receiverTime) {
this.receiverTime = receiverTime;
return this;
}
public Date getClosingTime() {
return closingTime;
}
public OrderPageBO setClosingTime(Date closingTime) {
this.closingTime = closingTime;
return this;
}
public Integer getHasReturnExchange() {
return hasReturnExchange;
}
public OrderPageBO setHasReturnExchange(Integer hasReturnExchange) {
this.hasReturnExchange = hasReturnExchange;
return this;
}
public Integer getStatus() {
return status;
}
public OrderPageBO setStatus(Integer status) {
this.status = status;
return this;
}
public String getRemark() {
return remark;
}
public OrderPageBO setRemark(String remark) {
this.remark = remark;
public OrderPageBO setOrders(List<OrderBO> orders) {
this.orders = orders;
return this;
}
}

View File

@ -1,6 +1,6 @@
package cn.iocoder.mall.order.application.convert;
import cn.iocoder.mall.order.api.dto.OrderPageBO;
import cn.iocoder.mall.order.api.dto.OrderBO;
import cn.iocoder.mall.order.dataobject.OrderDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
@ -20,5 +20,5 @@ public interface OrderConvert {
OrderConvert INSTANCE = Mappers.getMapper(OrderConvert.class);
@Mappings({})
List<OrderPageBO> convertPageBO(List<OrderDO> orderDOList);
List<OrderBO> convertPageBO(List<OrderDO> orderDOList);
}

View File

@ -5,7 +5,6 @@ import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.OrderCommon;
import cn.iocoder.mall.order.api.OrderService;
import cn.iocoder.mall.order.api.bo.OrderBO;
import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
import cn.iocoder.mall.order.api.constant.OrderHasReturnExchangeEnum;
import cn.iocoder.mall.order.api.constant.OrderStatusEnum;
@ -47,21 +46,26 @@ public class OrderServiceImpl implements OrderService {
private OrderCommon orderCommon;
@Override
public CommonResult<List<OrderPageBO>> getOrderPage(OrderQueryDTO orderQueryDTO) {
public CommonResult<OrderPageBO> getOrderPage(OrderQueryDTO orderQueryDTO) {
int totalCount = orderMapper.selectPageCount(orderQueryDTO);
if (totalCount == 0) {
return CommonResult.success(Collections.EMPTY_LIST);
return CommonResult.success(new OrderPageBO().setTotal(0));
}
List<OrderDO> orderDOList = orderMapper.selectPage(orderQueryDTO);
List<OrderPageBO> orderPageBOList = OrderConvert.INSTANCE.convertPageBO(orderDOList);
return CommonResult.success(orderPageBOList);
List<OrderBO> orderPageBOList = OrderConvert.INSTANCE.convertPageBO(orderDOList);
return CommonResult.success(
new OrderPageBO()
.setTotal(totalCount)
.setOrders(orderPageBOList)
);
}
@Override
@Transactional
public CommonResult<OrderBO> createOrder(Integer userId, OrderCreateDTO orderCreateDTO) {
public CommonResult<cn.iocoder.mall.order.api.bo.OrderBO> createOrder(Integer userId, OrderCreateDTO orderCreateDTO) {
List<OrderCreateItemDTO> orderItemDTOList = orderCreateDTO.getOrderItems();
OrderLogisticsDO orderLogisticsDO = OrderLogisticsConvert.INSTANCE.convert(orderCreateDTO);
List<OrderItemDO> orderItemDOList = OrderItemConvert.INSTANCE.convert(orderItemDTOList);
@ -139,7 +143,7 @@ public class OrderServiceImpl implements OrderService {
// TODO: 2019-03-17 Sin 需要发送 创建成果 MQ 消息
return CommonResult.success(
new OrderBO()
new cn.iocoder.mall.order.api.bo.OrderBO()
.setId(orderDO.getId())
.setOrderNo(orderDO.getOrderNo())
.setMoney(orderDO.getPrice())