parent
aae124d888
commit
13c89a34b2
|
@ -2,10 +2,9 @@ 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.OrderCreateDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderItemDeletedDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderLogisticsDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderItemUpdateDTO;
|
||||
import cn.iocoder.mall.order.api.dto.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单 service
|
||||
|
@ -15,13 +14,22 @@ import cn.iocoder.mall.order.api.dto.OrderItemUpdateDTO;
|
|||
*/
|
||||
public interface OrderService {
|
||||
|
||||
/**
|
||||
* 订单 page
|
||||
*
|
||||
* @param orderQueryDTO
|
||||
* @return
|
||||
*/
|
||||
CommonResult<List<OrderPageBO>> getOrderPage(OrderQueryDTO orderQueryDTO);
|
||||
|
||||
/**
|
||||
* 订单 - 创建
|
||||
*
|
||||
* @param userId
|
||||
* @param orderCreateDTO
|
||||
* @return
|
||||
*/
|
||||
CommonResult<OrderBO> createOrder(OrderCreateDTO orderCreateDTO);
|
||||
CommonResult<OrderBO> createOrder(Integer userId, OrderCreateDTO orderCreateDTO);
|
||||
|
||||
/**
|
||||
* 订单item - 更新
|
||||
|
|
|
@ -13,6 +13,10 @@ import java.util.List;
|
|||
*/
|
||||
public class OrderCreateDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 收件区域编号
|
||||
*/
|
||||
|
@ -48,7 +52,8 @@ public class OrderCreateDTO implements Serializable {
|
|||
@Override
|
||||
public String toString() {
|
||||
return "OrderCreateDTO{" +
|
||||
"areaNo='" + areaNo + '\'' +
|
||||
"userId=" + userId +
|
||||
", areaNo='" + areaNo + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", mobile='" + mobile + '\'' +
|
||||
", address='" + address + '\'' +
|
||||
|
@ -57,6 +62,15 @@ public class OrderCreateDTO implements Serializable {
|
|||
'}';
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public OrderCreateDTO setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAreaNo() {
|
||||
return areaNo;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,248 @@
|
|||
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 OrderPageBO implements Serializable {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 物流id
|
||||
*/
|
||||
private Integer orderLogisticsId;
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
private String orderNo;
|
||||
/**
|
||||
* 交易金额
|
||||
*/
|
||||
private Integer money;
|
||||
|
||||
///
|
||||
/// 时间信息
|
||||
|
||||
/**
|
||||
* 付款时间(待发货)
|
||||
*/
|
||||
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 Date createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
private Integer deleted;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrderPageBO{" +
|
||||
"id=" + id +
|
||||
", userId=" + userId +
|
||||
", orderLogisticsId=" + orderLogisticsId +
|
||||
", orderNo='" + orderNo + '\'' +
|
||||
", money=" + money +
|
||||
", paymentTime=" + paymentTime +
|
||||
", deliveryTime=" + deliveryTime +
|
||||
", receiverTime=" + receiverTime +
|
||||
", closingTime=" + closingTime +
|
||||
", hasReturnExchange=" + hasReturnExchange +
|
||||
", status=" + status +
|
||||
", remark='" + remark + '\'' +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
", deleted=" + deleted +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public OrderPageBO setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
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 getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public OrderPageBO setMoney(Integer money) {
|
||||
this.money = money;
|
||||
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;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public OrderPageBO setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public OrderPageBO setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public OrderPageBO setDeleted(Integer deleted) {
|
||||
this.deleted = deleted;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
package cn.iocoder.mall.order.api.dto;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 订单 query
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-03-23 14:15
|
||||
*/
|
||||
public class OrderQueryDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
private String orderNo;
|
||||
/**
|
||||
* 用户 id
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 付款时间(待发货)
|
||||
*/
|
||||
private Date startPaymentTime;
|
||||
private Date endPaymentTime;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date startCreateTime;
|
||||
private Date endCreateTime;
|
||||
/**
|
||||
* 删除状态
|
||||
*/
|
||||
private Integer deleted;
|
||||
|
||||
@NotNull(message = "页码不能为空")
|
||||
private Integer pageNo;
|
||||
@NotNull(message = "每页条数不能为空")
|
||||
private Integer pageSize;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OrderQueryDTO{" +
|
||||
"id=" + id +
|
||||
", orderNo='" + orderNo + '\'' +
|
||||
", userId=" + userId +
|
||||
", startPaymentTime=" + startPaymentTime +
|
||||
", endPaymentTime=" + endPaymentTime +
|
||||
", startCreateTime=" + startCreateTime +
|
||||
", endCreateTime=" + endCreateTime +
|
||||
", deleted=" + deleted +
|
||||
", pageNo=" + pageNo +
|
||||
", pageSize=" + pageSize +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public OrderQueryDTO setId(Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getOrderNo() {
|
||||
return orderNo;
|
||||
}
|
||||
|
||||
public OrderQueryDTO setOrderNo(String orderNo) {
|
||||
this.orderNo = orderNo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public OrderQueryDTO setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getStartPaymentTime() {
|
||||
return startPaymentTime;
|
||||
}
|
||||
|
||||
public OrderQueryDTO setStartPaymentTime(Date startPaymentTime) {
|
||||
this.startPaymentTime = startPaymentTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getEndPaymentTime() {
|
||||
return endPaymentTime;
|
||||
}
|
||||
|
||||
public OrderQueryDTO setEndPaymentTime(Date endPaymentTime) {
|
||||
this.endPaymentTime = endPaymentTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getStartCreateTime() {
|
||||
return startCreateTime;
|
||||
}
|
||||
|
||||
public OrderQueryDTO setStartCreateTime(Date startCreateTime) {
|
||||
this.startCreateTime = startCreateTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getEndCreateTime() {
|
||||
return endCreateTime;
|
||||
}
|
||||
|
||||
public OrderQueryDTO setEndCreateTime(Date endCreateTime) {
|
||||
this.endCreateTime = endCreateTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public OrderQueryDTO setDeleted(Integer deleted) {
|
||||
this.deleted = deleted;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPageNo() {
|
||||
return pageNo;
|
||||
}
|
||||
|
||||
public OrderQueryDTO setPageNo(Integer pageNo) {
|
||||
this.pageNo = pageNo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public OrderQueryDTO setPageSize(Integer pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -84,6 +84,12 @@
|
|||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>user-sdk</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
package cn.iocoder.mall.order.convert;
|
||||
|
||||
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCreateItemDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderItemUpdateDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderLogisticsDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderPageBO;
|
||||
import cn.iocoder.mall.order.dataobject.OrderDO;
|
||||
import cn.iocoder.mall.order.dataobject.OrderItemDO;
|
||||
import cn.iocoder.mall.order.dataobject.OrderLogisticsDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
@ -24,39 +19,6 @@ public interface OrderConvert {
|
|||
|
||||
OrderConvert INSTANCE = Mappers.getMapper(OrderConvert.class);
|
||||
|
||||
/**
|
||||
* 转换 OrderLogisticsDO - OrderCreateDTO
|
||||
*
|
||||
* @param orderCreateDTO
|
||||
* @return
|
||||
*/
|
||||
@Mappings({})
|
||||
OrderLogisticsDO convert(OrderCreateDTO orderCreateDTO);
|
||||
|
||||
/**
|
||||
* 转换 OrderItemDO - orderCreateItemDTOList
|
||||
*
|
||||
* @param orderCreateItemDTOList
|
||||
* @return
|
||||
*/
|
||||
@Mappings({})
|
||||
List<OrderItemDO> convert(List<OrderCreateItemDTO> orderCreateItemDTOList);
|
||||
|
||||
/**
|
||||
* 转换 OrderLogisticsDO - orderReceiverInformationDTO
|
||||
*
|
||||
* @param orderLogisticsDTO
|
||||
* @return
|
||||
*/
|
||||
@Mappings({})
|
||||
OrderLogisticsDO convert(OrderLogisticsDTO orderLogisticsDTO);
|
||||
|
||||
/**
|
||||
* 转换 OrderItemDO - orderReceiverInformationDTO
|
||||
*
|
||||
* @param orderItemUpdateDTO
|
||||
* @return
|
||||
*/
|
||||
@Mappings({})
|
||||
OrderItemDO convert(OrderItemUpdateDTO orderItemUpdateDTO);
|
||||
List<OrderPageBO> convertPageBO(List<OrderDO> orderDOList);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package cn.iocoder.mall.order.convert;
|
||||
|
||||
import cn.iocoder.mall.order.api.dto.OrderCreateItemDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderItemUpdateDTO;
|
||||
import cn.iocoder.mall.order.dataobject.OrderItemDO;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单 item convert
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-03-23 14:34
|
||||
*/
|
||||
public interface OrderItemConvert {
|
||||
|
||||
OrderItemConvert INSTANCE = Mappers.getMapper(OrderItemConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
OrderItemDO convert(OrderItemUpdateDTO orderItemUpdateDTO);
|
||||
|
||||
@Mappings({})
|
||||
List<OrderItemDO> convert(List<OrderCreateItemDTO> orderCreateItemDTOList);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package cn.iocoder.mall.order.convert;
|
||||
|
||||
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderLogisticsDTO;
|
||||
import cn.iocoder.mall.order.dataobject.OrderLogisticsDO;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 订单物流 convert
|
||||
*
|
||||
* @author Sin
|
||||
* @time 2019-03-23 14:39
|
||||
*/
|
||||
public interface OrderLogisticsConvert {
|
||||
|
||||
OrderLogisticsConvert INSTANCE = Mappers.getMapper(OrderLogisticsConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
OrderLogisticsDO convert(OrderCreateDTO orderCreateDTO);
|
||||
|
||||
@Mappings({})
|
||||
OrderLogisticsDO convert(OrderLogisticsDTO orderLogisticsDTO);
|
||||
}
|
|
@ -1,8 +1,12 @@
|
|||
package cn.iocoder.mall.order.dao;
|
||||
|
||||
import cn.iocoder.mall.order.api.dto.OrderQueryDTO;
|
||||
import cn.iocoder.mall.order.dataobject.OrderDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单 mapper
|
||||
*
|
||||
|
@ -26,4 +30,30 @@ public interface OrderMapper {
|
|||
* @return
|
||||
*/
|
||||
int updateById(OrderDO orderDO);
|
||||
|
||||
/**
|
||||
* 查询 - 根据id 查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
OrderDO selectById(
|
||||
@Param("id") Integer id
|
||||
);
|
||||
|
||||
/**
|
||||
* 查询 - 后台分页page
|
||||
*
|
||||
* @param orderQueryDTO
|
||||
* @return
|
||||
*/
|
||||
int selectPageCount(OrderQueryDTO orderQueryDTO);
|
||||
|
||||
/**
|
||||
* 查询 - 后台分页page
|
||||
*
|
||||
* @param orderQueryDTO
|
||||
* @return
|
||||
*/
|
||||
List<OrderDO> selectPage(OrderQueryDTO orderQueryDTO, int offset, int pageSize);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,10 @@ public class OrderDO extends DeletableDO {
|
|||
* id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 物流id
|
||||
*/
|
||||
|
@ -80,9 +84,10 @@ public class OrderDO extends DeletableDO {
|
|||
public String toString() {
|
||||
return "OrderDO{" +
|
||||
"id=" + id +
|
||||
", userId=" + userId +
|
||||
", orderLogisticsId=" + orderLogisticsId +
|
||||
", orderNo='" + orderNo + '\'' +
|
||||
", price=" + money +
|
||||
", money=" + money +
|
||||
", paymentTime=" + paymentTime +
|
||||
", deliveryTime=" + deliveryTime +
|
||||
", receiverTime=" + receiverTime +
|
||||
|
@ -102,6 +107,15 @@ public class OrderDO extends DeletableDO {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public OrderDO setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getOrderLogisticsId() {
|
||||
return orderLogisticsId;
|
||||
}
|
||||
|
|
|
@ -11,21 +11,21 @@ import cn.iocoder.mall.order.api.constant.OrderHasReturnExchangeEnum;
|
|||
import cn.iocoder.mall.order.api.constant.OrderStatusEnum;
|
||||
import cn.iocoder.mall.order.api.dto.*;
|
||||
import cn.iocoder.mall.order.convert.OrderConvert;
|
||||
import cn.iocoder.mall.order.convert.OrderItemConvert;
|
||||
import cn.iocoder.mall.order.convert.OrderLogisticsConvert;
|
||||
import cn.iocoder.mall.order.dao.OrderItemMapper;
|
||||
import cn.iocoder.mall.order.dao.OrderLogisticsMapper;
|
||||
import cn.iocoder.mall.order.dao.OrderMapper;
|
||||
import cn.iocoder.mall.order.dataobject.OrderDO;
|
||||
import cn.iocoder.mall.order.dataobject.OrderItemDO;
|
||||
import cn.iocoder.mall.order.dataobject.OrderLogisticsDO;
|
||||
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -47,12 +47,28 @@ public class OrderServiceImpl implements OrderService {
|
|||
@Autowired
|
||||
private OrderCommon orderCommon;
|
||||
|
||||
@Override
|
||||
public CommonResult<List<OrderPageBO>> getOrderPage(OrderQueryDTO orderQueryDTO) {
|
||||
|
||||
int offset = orderQueryDTO.getPageNo() * orderQueryDTO.getPageSize();
|
||||
int pageSize = orderQueryDTO.getPageSize();
|
||||
|
||||
int totalCount = orderMapper.selectPageCount(orderQueryDTO);
|
||||
if (totalCount == 0) {
|
||||
return CommonResult.success(Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
List<OrderDO> orderDOList = orderMapper.selectPage(orderQueryDTO, offset, pageSize);
|
||||
List<OrderPageBO> orderPageBOList = OrderConvert.INSTANCE.convertPageBO(orderDOList);
|
||||
return CommonResult.success(orderPageBOList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CommonResult<OrderBO> createOrder(OrderCreateDTO orderCreateDTO) {
|
||||
public CommonResult<OrderBO> createOrder(Integer userId, OrderCreateDTO orderCreateDTO) {
|
||||
List<OrderCreateItemDTO> orderItemDTOList = orderCreateDTO.getOrderItems();
|
||||
OrderLogisticsDO orderLogisticsDO = OrderConvert.INSTANCE.convert(orderCreateDTO);
|
||||
List<OrderItemDO> orderItemDOList = OrderConvert.INSTANCE.convert(orderItemDTOList);
|
||||
OrderLogisticsDO orderLogisticsDO = OrderLogisticsConvert.INSTANCE.convert(orderCreateDTO);
|
||||
List<OrderItemDO> orderItemDOList = OrderItemConvert.INSTANCE.convert(orderItemDTOList);
|
||||
|
||||
// 物流信息
|
||||
orderLogisticsDO
|
||||
|
@ -62,21 +78,21 @@ public class OrderServiceImpl implements OrderService {
|
|||
orderLogisticsMapper.insert(orderLogisticsDO);
|
||||
|
||||
// order
|
||||
OrderDO orderDO = new OrderDO();
|
||||
orderDO.setOrderLogisticsId(orderLogisticsDO.getId());
|
||||
orderDO.setOrderNo(UUID.randomUUID().toString().replace("-", ""));
|
||||
orderDO.setMoney(-1); // 先设置一个默认值,金额在下面计算
|
||||
|
||||
orderDO.setClosingTime(null);
|
||||
orderDO.setDeliveryTime(null);
|
||||
orderDO.setPaymentTime(null);
|
||||
orderDO.setStatus(OrderStatusEnum.WAIT_SHIPMENT.getValue());
|
||||
orderDO.setHasReturnExchange(OrderHasReturnExchangeEnum.NO.getValue());
|
||||
orderDO.setRemark(Optional.ofNullable(orderCreateDTO.getRemark()).orElse(""));
|
||||
OrderDO orderDO = new OrderDO()
|
||||
.setUserId(userId)
|
||||
.setOrderLogisticsId(orderLogisticsDO.getId())
|
||||
.setOrderNo(UUID.randomUUID().toString().replace("-", ""))
|
||||
.setMoney(-1) // 先设置一个默认值,金额在下面计算
|
||||
.setClosingTime(null)
|
||||
.setDeliveryTime(null)
|
||||
.setPaymentTime(null)
|
||||
.setStatus(OrderStatusEnum.WAIT_SHIPMENT.getValue())
|
||||
.setHasReturnExchange(OrderHasReturnExchangeEnum.NO.getValue())
|
||||
.setRemark(Optional.ofNullable(orderCreateDTO.getRemark()).orElse(""));
|
||||
|
||||
orderDO.setDeleted(DeletedStatusEnum.DELETED_NO.getValue());
|
||||
orderDO.setCreateTime(new Date());
|
||||
orderDO.setUpdateTime(null);
|
||||
orderDO.setDeleted(DeletedStatusEnum.DELETED_NO.getValue());
|
||||
orderMapper.insert(orderDO);
|
||||
|
||||
// order item
|
||||
|
@ -119,7 +135,7 @@ public class OrderServiceImpl implements OrderService {
|
|||
|
||||
@Override
|
||||
public CommonResult updateOrderItem(OrderItemUpdateDTO orderUpdateDTO) {
|
||||
OrderItemDO orderItemDO = OrderConvert.INSTANCE.convert(orderUpdateDTO);
|
||||
OrderItemDO orderItemDO = OrderItemConvert.INSTANCE.convert(orderUpdateDTO);
|
||||
orderItemMapper.updateById(orderItemDO);
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
|
@ -161,7 +177,7 @@ public class OrderServiceImpl implements OrderService {
|
|||
|
||||
@Override
|
||||
public CommonResult updateLogistics(OrderLogisticsDTO orderLogisticsDTO) {
|
||||
OrderLogisticsDO orderLogisticsDO = OrderConvert.INSTANCE.convert(orderLogisticsDTO);
|
||||
OrderLogisticsDO orderLogisticsDO = OrderLogisticsConvert.INSTANCE.convert(orderLogisticsDTO);
|
||||
orderLogisticsMapper.updateById(orderLogisticsDO);
|
||||
return CommonResult.success(null);
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
<mapper namespace="cn.iocoder.mall.order.dao.OrderMapper">
|
||||
|
||||
<sql id="FIELDS">
|
||||
id, order_logistics_id, order_no, money, payment_time,
|
||||
id, user_id, order_logistics_id, order_no, money, payment_time,
|
||||
delivery_time, receiver_time, closing_time, has_return_exchange,
|
||||
status, remark, create_time, update_time, `delete`
|
||||
status, remark, create_time, update_time, `deleted`
|
||||
</sql>
|
||||
|
||||
<!--
|
||||
|
@ -13,12 +13,12 @@
|
|||
-->
|
||||
<insert id="insert" parameterType="OrderDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
INSERT INTO `order` (
|
||||
order_logistics_id, order_no, money, payment_time,
|
||||
user_id, order_logistics_id, order_no, money, payment_time,
|
||||
delivery_time, receiver_time, closing_time,
|
||||
has_return_exchange, status, remark,
|
||||
create_time, update_time, `deleted`
|
||||
) VALUES (
|
||||
#{orderLogisticsId}, #{orderNo}, #{money}, #{paymentTime},
|
||||
#{orderLogisticsId}, #{userId}, #{orderNo}, #{money}, #{paymentTime},
|
||||
#{deliveryTime}, #{receiverTime}, #{closingTime},
|
||||
#{hasReturnExchange}, #{status}, #{remark},
|
||||
#{createTime}, #{updateTime}, #{deleted}
|
||||
|
@ -82,4 +82,63 @@
|
|||
<include refid="updateFieldSql" />
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!--
|
||||
查询 - 根据id 查询
|
||||
-->
|
||||
<select id="selectById" resultType="cn.iocoder.mall.order.dataobject.OrderDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM `order`
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<!--
|
||||
查询条件
|
||||
-->
|
||||
<sql id="selectWhere">
|
||||
<if test="id">
|
||||
AND `id` = #{id}
|
||||
</if>
|
||||
<if test="userId">
|
||||
AND `user_id` = #{userId}
|
||||
</if>
|
||||
<if test="orderLogisticsId">
|
||||
AND `order_logistics_id` = #{orderLogisticsId}
|
||||
</if>
|
||||
<if test="orderNo">
|
||||
AND `order_no` = #{orderNo}
|
||||
</if>
|
||||
<if test="hasReturnExchange">
|
||||
AND `has_return_exchange` = #{hasReturnExchange}
|
||||
</if>
|
||||
<if test="status">
|
||||
AND `status` = #{status}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<!--
|
||||
查询 - 后台分页page Count
|
||||
-->
|
||||
<select id="selectPageCount" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM `order`
|
||||
WHERE
|
||||
<include refid="selectWhere" />
|
||||
</select>
|
||||
|
||||
<!--
|
||||
查询 - 后台分页page
|
||||
-->
|
||||
<select id="selectPage" resultType="cn.iocoder.mall.order.dataobject.OrderDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM `order`
|
||||
WHERE
|
||||
<include refid="selectWhere" />
|
||||
LIMIT
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
|
@ -1,14 +1,19 @@
|
|||
package cn.iocoder.mall.order.service;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.order.OrderApplicationTest;
|
||||
import cn.iocoder.mall.order.api.OrderService;
|
||||
import cn.iocoder.mall.order.api.bo.OrderBO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCreateItemDTO;
|
||||
import cn.iocoder.mall.order.dao.OrderMapper;
|
||||
import cn.iocoder.mall.order.dataobject.OrderDO;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -22,22 +27,25 @@ import java.util.Arrays;
|
|||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = OrderApplicationTest.class)
|
||||
//@Transactional
|
||||
@Transactional
|
||||
public class OrderServiceImplTest {
|
||||
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
@Test
|
||||
public void createOrderTest() {
|
||||
|
||||
Integer userId = 1;
|
||||
OrderCreateItemDTO orderCreateItemDTO
|
||||
= new OrderCreateItemDTO()
|
||||
.setSkuId(1)
|
||||
.setQuantity(1);
|
||||
|
||||
orderService.createOrder(
|
||||
CommonResult<OrderBO> result = orderService.createOrder(
|
||||
userId,
|
||||
new OrderCreateDTO()
|
||||
.setRemark("")
|
||||
.setName("张三")
|
||||
|
@ -45,5 +53,8 @@ public class OrderServiceImplTest {
|
|||
.setAddress("深圳市福田区")
|
||||
.setAreaNo("1000100")
|
||||
.setOrderItems(Arrays.asList(orderCreateItemDTO)));
|
||||
|
||||
OrderDO orderDO = orderMapper.selectById(result.getData().getId());
|
||||
Assert.assertNotNull("创建的订单不存在!", orderDO);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue