From f4c7f65cb8aa9764a6e47f18535929cd37605fa5 Mon Sep 17 00:00:00 2001 From: sin <2943460818@qq.com> Date: Fri, 22 Mar 2019 21:51:55 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=A2=9E=E5=8A=A0=20OrderLogisticsMapper?= =?UTF-8?q?=20-=20=E4=BF=AE=E6=94=B9=20OrderServiceImpl=20=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=88=9B=E5=BB=BA=E5=92=8C=E5=88=A0=E9=99=A4=20-=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E8=AE=A2=E5=8D=95=E7=9A=84=E8=A1=A8?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/order/dao/OrderLogisticsMapper.java | 22 ++++ .../mall/order/dataobject/OrderDO.java | 26 +--- .../order/dataobject/OrderExchangeDO.java | 46 +++++-- .../mall/order/dataobject/OrderItemDO.java | 61 +++------ .../dataobject/OrderLogisticsDetailDO.java | 14 -- .../mall/order/dataobject/OrderReturnDO.java | 14 ++ .../mall/order/service/OrderServiceImpl.java | 59 +++++++-- .../resources/mapper/OrderLogisticsMapper.xml | 21 +++ .../src/main/resources/mapper/OrderMapper.xml | 62 ++++----- .../src/main/resources/sql/mall_order.sql | 121 ++++++++++++++++++ 10 files changed, 307 insertions(+), 139 deletions(-) create mode 100644 order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderLogisticsMapper.java create mode 100644 order/order-service-impl/src/main/resources/mapper/OrderLogisticsMapper.xml create mode 100644 order/order-service-impl/src/main/resources/sql/mall_order.sql diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderLogisticsMapper.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderLogisticsMapper.java new file mode 100644 index 000000000..b72e6dc88 --- /dev/null +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderLogisticsMapper.java @@ -0,0 +1,22 @@ +package cn.iocoder.mall.order.dao; + +import cn.iocoder.mall.order.dataobject.OrderDO; +import cn.iocoder.mall.order.dataobject.OrderLogisticsDO; +import org.springframework.stereotype.Repository; + +/** + * 订单 item mapper + * + * @author Sin + * @time 2019-03-16 15:09 + */ +@Repository +public interface OrderLogisticsMapper { + + /** + * 插入数据 + * + * @param orderLogisticsDO + */ + void insert(OrderLogisticsDO orderLogisticsDO); +} diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderDO.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderDO.java index ba3a9014e..a318766dd 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderDO.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderDO.java @@ -2,7 +2,6 @@ package cn.iocoder.mall.order.dataobject; import cn.iocoder.common.framework.dataobject.BaseDO; -import java.io.Serializable; import java.util.Date; /** @@ -34,19 +33,19 @@ public class OrderDO extends BaseDO { /// 时间信息 /** - * 付款时间 + * 付款时间(待发货) */ private Date paymentTime; /** - * 发货时间 + * 发货时间(待收货) */ private Date deliveryTime; /** - * 收货时间 + * 收货时间(已签收) */ private Date receiverTime; /** - * 成交时间 + * 成交时间(用户确认收货 -> status = 已完成) */ private Date closingTime; @@ -72,13 +71,6 @@ public class OrderDO extends BaseDO { * - 4、已关闭 */ private Integer status; - /** - * 删除状态 - * - * - 0 未删除 - * - 1 已删除 - */ - private Integer deleteStatus; /** * 备注 */ @@ -97,7 +89,6 @@ public class OrderDO extends BaseDO { ", closingTime=" + closingTime + ", hasReturnExchange=" + hasReturnExchange + ", status=" + status + - ", deleteStatus=" + deleteStatus + ", remark='" + remark + '\'' + '}'; } @@ -192,15 +183,6 @@ public class OrderDO extends BaseDO { return this; } - public Integer getDeleteStatus() { - return deleteStatus; - } - - public OrderDO setDeleteStatus(Integer deleteStatus) { - this.deleteStatus = deleteStatus; - return this; - } - public String getRemark() { return remark; } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderExchangeDO.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderExchangeDO.java index f01e392e6..bc22e0ff2 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderExchangeDO.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderExchangeDO.java @@ -24,6 +24,10 @@ public class OrderExchangeDO extends BaseDO { * 订单编号 */ private String orderNo; + /** + * 订单 item 编号 + */ + private Integer orderItemId; /** * 商品id(保存一个冗余,如果一个订单下存在多个商品,会有很大的作用) */ @@ -62,8 +66,9 @@ public class OrderExchangeDO extends BaseDO { /** * 创建时间 + * supper baseDO */ - private Date createTime; +// private Date createTime; /** * 付款时间 */ @@ -84,6 +89,13 @@ public class OrderExchangeDO extends BaseDO { /// /// 其他 + /** + * 订单类型 + * + * - 0、为 Order 订单 (对整个订单退货) + * - 1、为 OrderItem 订单 (对订单某一个商品退货) + */ + private Integer orderType; /** * 状态 * @@ -101,17 +113,18 @@ public class OrderExchangeDO extends BaseDO { "id=" + id + ", orderId=" + orderId + ", orderNo='" + orderNo + '\'' + + ", orderItemId=" + orderItemId + ", skuId='" + skuId + '\'' + ", exchangeSkuId='" + exchangeSkuId + '\'' + ", exchangeOrderLogisticsId=" + exchangeOrderLogisticsId + ", receiverOrderLogisticsId=" + receiverOrderLogisticsId + ", orderReasonId=" + orderReasonId + ", reason='" + reason + '\'' + - ", createTime=" + createTime + ", paymentTime=" + paymentTime + ", deliveryTime=" + deliveryTime + ", receiverTime=" + receiverTime + ", closingTime=" + closingTime + + ", orderType=" + orderType + ", status=" + status + '}'; } @@ -143,6 +156,15 @@ public class OrderExchangeDO extends BaseDO { return this; } + public Integer getOrderItemId() { + return orderItemId; + } + + public OrderExchangeDO setOrderItemId(Integer orderItemId) { + this.orderItemId = orderItemId; + return this; + } + public String getSkuId() { return skuId; } @@ -197,17 +219,6 @@ public class OrderExchangeDO extends BaseDO { return this; } - @Override - public Date getCreateTime() { - return createTime; - } - - @Override - public OrderExchangeDO setCreateTime(Date createTime) { - this.createTime = createTime; - return this; - } - public Date getPaymentTime() { return paymentTime; } @@ -244,6 +255,15 @@ public class OrderExchangeDO extends BaseDO { return this; } + public Integer getOrderType() { + return orderType; + } + + public OrderExchangeDO setOrderType(Integer orderType) { + this.orderType = orderType; + return this; + } + public Integer getStatus() { return status; } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderItemDO.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderItemDO.java index 7c463e7f5..70dae0cdb 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderItemDO.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderItemDO.java @@ -40,10 +40,6 @@ public class OrderItemDO extends BaseDO { /// /// 时间信息 - /** - * 创建时间 - */ - private Date createTime; /** * 付款时间 */ @@ -67,25 +63,20 @@ public class OrderItemDO extends BaseDO { /** * 是否退货 * - * - 0、no - * - 1、yes + * - 1、没有 + * - 2、换货 + * - 3、退货 + * - 4、换货 + 退货 */ - private Integer hasReturn; - /** - * 是否换货 - * - * - 0、no - * - 1、yes - */ - private Integer hasExchange; + private Integer hasReturnExchange; /** * 状态 * - * - 0、待付款 - * - 1、待发货 - * - 2、待收获 - * - 3、已完成 - * - 4、已关闭 + * - 1、待付款 + * - 2、待发货 + * - 3、已发货 + * - 4、已完成 + * - 5、已关闭 */ private Integer status; @@ -98,13 +89,11 @@ public class OrderItemDO extends BaseDO { ", skuId='" + skuId + '\'' + ", quantity=" + quantity + ", price=" + price + - ", createTime=" + createTime + ", paymentTime=" + paymentTime + ", deliveryTime=" + deliveryTime + ", receiverTime=" + receiverTime + ", closingTime=" + closingTime + - ", hasReturn=" + hasReturn + - ", hasExchange=" + hasExchange + + ", hasReturnExchange=" + hasReturnExchange + ", status=" + status + '}'; } @@ -163,17 +152,6 @@ public class OrderItemDO extends BaseDO { return this; } - @Override - public Date getCreateTime() { - return createTime; - } - - @Override - public OrderItemDO setCreateTime(Date createTime) { - this.createTime = createTime; - return this; - } - public Date getPaymentTime() { return paymentTime; } @@ -210,21 +188,12 @@ public class OrderItemDO extends BaseDO { return this; } - public Integer getHasReturn() { - return hasReturn; + public Integer getHasReturnExchange() { + return hasReturnExchange; } - public OrderItemDO setHasReturn(Integer hasReturn) { - this.hasReturn = hasReturn; - return this; - } - - public Integer getHasExchange() { - return hasExchange; - } - - public OrderItemDO setHasExchange(Integer hasExchange) { - this.hasExchange = hasExchange; + public OrderItemDO setHasReturnExchange(Integer hasReturnExchange) { + this.hasReturnExchange = hasReturnExchange; return this; } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderLogisticsDetailDO.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderLogisticsDetailDO.java index 6e461b455..0e3bf4795 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderLogisticsDetailDO.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderLogisticsDetailDO.java @@ -30,10 +30,6 @@ public class OrderLogisticsDetailDO extends BaseDO { * 物流信息 */ private String logisticsInformation; - /** - * 创建时间(同步时间) - */ - private Date createTime; @Override public String toString() { @@ -42,7 +38,6 @@ public class OrderLogisticsDetailDO extends BaseDO { ", orderLogisticsId=" + orderLogisticsId + ", logisticsTime=" + logisticsTime + ", logisticsInformation='" + logisticsInformation + '\'' + - ", createTime=" + createTime + '}'; } @@ -81,13 +76,4 @@ public class OrderLogisticsDetailDO extends BaseDO { this.logisticsInformation = logisticsInformation; return this; } - - public Date getCreateTime() { - return createTime; - } - - public OrderLogisticsDetailDO setCreateTime(Date createTime) { - this.createTime = createTime; - return this; - } } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderReturnDO.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderReturnDO.java index 3e6714d87..7a0088f75 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderReturnDO.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderReturnDO.java @@ -32,6 +32,10 @@ public class OrderReturnDO extends BaseDO { * 商品编号(保存一个冗余,如果一个订单下存在多个商品,会有很大的作用) */ private String skuId; + /** + * 物流id + */ + private Integer orderLogisticsId; /// /// 退货原因 @@ -102,6 +106,7 @@ public class OrderReturnDO extends BaseDO { ", orderNo='" + orderNo + '\'' + ", orderItemId=" + orderItemId + ", skuId='" + skuId + '\'' + + ", orderLogisticsId=" + orderLogisticsId + ", orderReasonId=" + orderReasonId + ", reason='" + reason + '\'' + ", createTime=" + createTime + @@ -159,6 +164,15 @@ public class OrderReturnDO extends BaseDO { return this; } + public Integer getOrderLogisticsId() { + return orderLogisticsId; + } + + public OrderReturnDO setOrderLogisticsId(Integer orderLogisticsId) { + this.orderLogisticsId = orderLogisticsId; + return this; + } + public Integer getOrderReasonId() { return orderReasonId; } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/service/OrderServiceImpl.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/service/OrderServiceImpl.java index 974657db0..5a8d66266 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/service/OrderServiceImpl.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/service/OrderServiceImpl.java @@ -1,27 +1,30 @@ package cn.iocoder.mall.order.service; +import cn.iocoder.common.framework.constant.DeleteStatusEnum; import cn.iocoder.mall.order.api.OrderService; import cn.iocoder.mall.order.api.bo.OrderBO; -import cn.iocoder.mall.order.api.constants.OrderDeleteStatusEnum; -import cn.iocoder.mall.order.api.constants.OrderPayStatusEnum; -import cn.iocoder.mall.order.api.constants.OrderStatusEnum; +import cn.iocoder.mall.order.api.constant.OrderHasReturnExchangeEnum; +import cn.iocoder.mall.order.api.constant.OrderStatusEnum; import cn.iocoder.mall.order.api.dto.OrderCreateDTO; import cn.iocoder.mall.order.api.dto.OrderCreateItemDTO; import cn.iocoder.mall.order.api.dto.OrderReceiverInformationDTO; import cn.iocoder.mall.order.api.dto.OrderUpdateDTO; import cn.iocoder.mall.order.convert.OrderConvert; 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 org.checkerframework.checker.units.qual.A; +import cn.iocoder.mall.order.dataobject.OrderLogisticsDO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Date; import java.util.List; +import java.util.Optional; import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; /** * 订单 service impl @@ -37,39 +40,67 @@ public class OrderServiceImpl implements OrderService { private OrderMapper orderMapper; @Autowired private OrderItemMapper orderItemMapper; + @Autowired + private OrderLogisticsMapper orderLogisticsMapper; @Override @Transactional public OrderBO createOrder(OrderCreateDTO orderCreateDTO) { List orderItemDTOList = orderCreateDTO.getOrderItems(); - OrderDO orderDO = OrderConvert.INSTANCE.convert(orderCreateDTO); + OrderLogisticsDO orderLogisticsDO = OrderConvert.INSTANCE.convert(orderCreateDTO); List orderItemDOList = OrderConvert.INSTANCE.convert(orderItemDTOList); + // 物流信息 + orderLogisticsDO.setLogisticsNo(""); + orderLogisticsMapper.insert(orderLogisticsDO); + // order + OrderDO orderDO = new OrderDO(); + orderDO.setOrderLogisticsId(orderLogisticsDO.getId()); orderDO.setOrderNo(UUID.randomUUID().toString().replace("-", "")); - orderDO.setPrice(1000); + orderDO.setPrice(-1); // 先设置一个默认值,金额在下面计算 orderDO.setCreateTime(new Date()); + orderDO.setUpdateTime(null); + orderDO.setDeleted(DeleteStatusEnum.DELETE_NO.getValue()); + orderDO.setClosingTime(null); orderDO.setDeliveryTime(null); orderDO.setPaymentTime(null); orderDO.setStatus(OrderStatusEnum.WAIT_SHIPMENT.getValue()); - orderDO.setPayStatus(OrderPayStatusEnum.WAITING_PAYMENT.getValue()); - orderDO.setDeleteStatus(OrderDeleteStatusEnum.DELETE_NO.getValue()); + orderDO.setHasReturnExchange(OrderHasReturnExchangeEnum.NO.getValue()); + orderDO.setRemark(Optional.ofNullable(orderCreateDTO.getRemark()).orElse("")); orderMapper.insert(orderDO); // order item - int goodsPrice = 1000; + AtomicInteger totalPrice = new AtomicInteger(); orderItemDOList.forEach(orderItemDO -> { + int goodsPrice = 1000; // 商品单价 int price = orderItemDO.getQuantity() * goodsPrice; + totalPrice.addAndGet(price); orderItemDO - .setStatus(OrderStatusEnum.WAIT_SHIPMENT.getValue()) .setOrderId(orderDO.getId()) - .setPrice(price) - .setDeliveryTime(null); + .setOrderNo(orderDO.getOrderNo()) + .setPrice(goodsPrice) + .setPaymentTime(null) + .setDeliveryTime(null) + .setReceiverTime(null) + .setClosingTime(null) + .setHasReturnExchange(OrderStatusEnum.WAITING_PAYMENT.getValue()) + .setStatus(OrderStatusEnum.WAITING_PAYMENT.getValue()) + .setCreateTime(new Date()) + .setUpdateTime(new Date()) + .setDeleted(DeleteStatusEnum.DELETE_NO.getValue()); orderItemMapper.insert(orderItemDO); }); + // 更新订单金额 + orderMapper.updateById( + new OrderDO() + .setId(orderDO.getId()) + .setPrice(totalPrice.get()) + ); + // TODO: 2019-03-17 Sin 需要发送 创建成果 MQ 消息 return new OrderBO() @@ -93,9 +124,9 @@ public class OrderServiceImpl implements OrderService { @Override public void deleteOrder(Integer id) { // 删除订单操作,一般用于 用户端删除,是否存在检查可以过掉 - orderMapper.updateById(new OrderDO() + orderMapper.updateById((OrderDO) new OrderDO() .setId(id) - .setDeleteStatus(OrderDeleteStatusEnum.DELETE_YES.getValue()) + .setDeleted(DeleteStatusEnum.DELETE_YES.getValue()) ); } diff --git a/order/order-service-impl/src/main/resources/mapper/OrderLogisticsMapper.xml b/order/order-service-impl/src/main/resources/mapper/OrderLogisticsMapper.xml new file mode 100644 index 000000000..ad3bedb80 --- /dev/null +++ b/order/order-service-impl/src/main/resources/mapper/OrderLogisticsMapper.xml @@ -0,0 +1,21 @@ + + + + + + id, area_no, `name`, mobile, address, logistics_no + + + + + INSERT INTO `order_logistics` ( + area_no, `name`, mobile, address, logistics_no + ) VALUES ( + #{areaNo}, #{name}, #{mobile}, #{address}, + #{logisticsNo} + ) + + + \ No newline at end of file diff --git a/order/order-service-impl/src/main/resources/mapper/OrderMapper.xml b/order/order-service-impl/src/main/resources/mapper/OrderMapper.xml index a1ac6d962..254e7ec40 100644 --- a/order/order-service-impl/src/main/resources/mapper/OrderMapper.xml +++ b/order/order-service-impl/src/main/resources/mapper/OrderMapper.xml @@ -3,9 +3,9 @@ - order_no, price, receiver_area_no, receiver_mobile, - receiver_address, `status`, pay_status, create_time, - payment_time, delivery_time, closing_time, remark + id, order_logistics_id, order_no, price, payment_time, + delivery_time, receiver_time, closing_time, has_return_exchange, + status, remark INSERT INTO `order` ( - order_no, price, receiver_area_no, receiver_mobile, - receiver_address, `status`, pay_status, create_time, - payment_time, delivery_time, closing_time, remark + order_logistics_id, order_no, price, payment_time, + delivery_time, receiver_time, closing_time, + has_return_exchange, status, remark ) VALUES ( - #{orderNo}, ${price}, #{receiverAreaNo}, #{receiverMobile}, - #{receiverAddress}, #{status}, #{payStatus}, #{createTime}, - #{paymentTime}, #{deliveryTime}, #{closingTime}, #{remark} + #{orderLogisticsId}, ${orderNo}, #{price}, #{paymentTime}, + #{deliveryTime}, #{receiverTime}, #{closingTime}, + #{hasReturnExchange}, #{status}, #{remark} ) @@ -28,42 +28,44 @@ --> + + , order_logistics_id = #{orderLogisticsId} + , order_no = #{orderNo} , price = #{price} - - , receiver_area_no = #{receiverAreaNo} - - - , receiver_mobile = #{receiverMobile} - - - , receiver_address = #{receiverAddress} - - - , status = #{status} - - - , pay_status = #{payStatus} - - - , delete_status = #{deleteStatus} - - - , create_time = #{createTime} - +-- time , payment_time = #{paymentTime} , delivery_time = #{deliveryTime} + + , receiver_time = #{receiverTime} + , closing_time = #{closingTime} + + , has_return_exchange = #{hasReturnExchange} + +-- other + + , status = #{status} + + + , `delete` = #{delete} + + + , create_time = #{createTime} + + + , update_time = #{updateTime} + , remark = #{remark} diff --git a/order/order-service-impl/src/main/resources/sql/mall_order.sql b/order/order-service-impl/src/main/resources/sql/mall_order.sql new file mode 100644 index 000000000..4683263a8 --- /dev/null +++ b/order/order-service-impl/src/main/resources/sql/mall_order.sql @@ -0,0 +1,121 @@ +DROP TABLE `order`; +DROP TABLE `order_item`; +DROP TABLE `order_exchange`; +DROP TABLE `order_return`; +DROP TABLE `order_logistics`; +DROP TABLE `order_logistics_detail`; + +CREATE TABLE `order` ( +`id` int NOT NULL AUTO_INCREMENT COMMENT 'Id,自增长', +`order_logistics_id` int NOT NULL COMMENT '物流id', +`order_no` varchar(50) NOT NULL COMMENT '订单单号', +`price` int(10) NULL COMMENT '金额(分)', +`payment_time` datetime NULL COMMENT '付款时间', +`delivery_time` datetime NULL COMMENT '发货时间', +`receiver_time` datetime NULL COMMENT '收货时间', +`closing_time` datetime NULL COMMENT '成交时间', +`has_return_exchange` smallint NULL COMMENT '是否退换货', +`remark` varchar(255) NULL COMMENT '备注', +`status` smallint(2) NULL COMMENT '状态(如果有多个商品分开发货需要全部商品发完才会改变状态) 0、待付款 1、待发货 2、待收货 3、已完成 4、已关闭', +`create_time` datetime NULL COMMENT '订单创建时间', +`update_time` datetime NULL COMMENT '更新时间', +`deleted` smallint NULL COMMENT '删除状态', +PRIMARY KEY (`id`) +); +CREATE TABLE `order_item` ( +`id` int NOT NULL AUTO_INCREMENT COMMENT 'id自增长', +`order_id` int NOT NULL COMMENT '订单编号', +`order_no` varchar(50) NOT NULL COMMENT '订单号', +`sku_id` int NOT NULL COMMENT '商品编号', +`quantity` int(3) NOT NULL COMMENT '商品数量', +`price` int(255) NOT NULL COMMENT '金额', +`payment_time` datetime NULL COMMENT '付款时间', +`delivery_time` datetime NULL COMMENT '发货时间', +`receiver_time` datetime NULL COMMENT '收货时间', +`closing_time` datetime NULL, +`has_return_exchange` int NULL COMMENT '是否退换货', +`create_time` datetime NULL COMMENT '创建时间', +`update_time` datetime NULL COMMENT '更新时间', +`status` smallint(2) NOT NULL COMMENT '状态:0、代发货 1、已发货 2、已收货 20、换货中 21、换货成功 40、退货中 41、已退货', +`delete` smallint(2) NOT NULL COMMENT '删除状态', +PRIMARY KEY (`id`) +); + +CREATE TABLE `order_exchange` ( +`id` int(11) NOT NULL AUTO_INCREMENT, +`order_id` int(11) NOT NULL, +`order_no` varchar(50) NOT NULL, +`sku_id` int(11) NOT NULL, +`exchange_sku_id` int(11) NOT NULL COMMENT '换货商品id', +`exchange_order_logistics_id` int(11) NOT NULL COMMENT '换货物流id', +`receiver_order_logistics_id` int(11) NOT NULL COMMENT '收件地址', +`order_reason_id` int(11) NULL COMMENT '换货原因', +`reason` varchar(255) NULL COMMENT '换货原因 (其他的时候)', +`payment_time` datetime NULL COMMENT '付款时间', +`delivery_time` datetime NULL COMMENT '发货时间', +`receiver_time` datetime NULL COMMENT '收货时间', +`closing_time` datetime NULL COMMENT '成交时间', +`create_time` datetime NULL COMMENT '创建时间', +`update_time` datetime NULL COMMENT '更新时间', +`delete` smallint(2) NULL COMMENT '删除状态', +`order_type` int(2) NULL COMMENT '订单类型 0、为 Order 订单 1、为 OrderItem 订单', +`status` int(2) NULL COMMENT '状态 申请换货、申请成功、申请失败、换货中、换货成功', +PRIMARY KEY (`id`) +); + + +CREATE TABLE `order_return` ( +`id` int NOT NULL AUTO_INCREMENT COMMENT 'id自增长', +`order_id` int NOT NULL COMMENT '订单编号', +`order_no` varchar(50) NOT NULL COMMENT '订单号', +`sku_id` int NOT NULL COMMENT '商品编号', +`order_item_id` int(11) NOT NULL COMMENT '订单item id', +`order_logistics_id` int(11) NOT NULL COMMENT '物流 id', + +`order_reason_id` int(11) NULL COMMENT '退货原因', +`reason` varchar(255) NULL COMMENT '换货原因 (其他的时候)', +`create_time` datetime NULL COMMENT '创建时间', +`approval_time` datetime NULL COMMENT '同意时间', +`logistics_time` datetime NULL COMMENT '物流时间(填写物流单号时间)', +`receiver_time` datetime NULL COMMENT '收货时间', +`closing_time` datetime NULL COMMENT '成交时间', +`order_type` int(2) NULL COMMENT '订单类型 0、为 Order 订单 1、为 OrderItem 订单', + +`update_time` datetime NULL COMMENT '更新时间', +`delete` smallint(2) NULL COMMENT '删除状态', +`status` int(2) NULL COMMENT '状态 申请换货、申请成功、申请失败、退货中、退货成功', +PRIMARY KEY (`id`) +); + + +CREATE TABLE `order_logistics` ( +`id` int NOT NULL AUTO_INCREMENT COMMENT 'id自增长', +`area_no` int NOT NULL COMMENT '订单编号', +`name` VARCHAR(20) NOT NULL COMMENT '名称', +`mobile` VARCHAR(20) NOT NULL COMMENT '手机号', +`address` VARCHAR(255) NOT NULL COMMENT '详细地址', +`logistics_no` VARCHAR(20) NOT NULL COMMENT '物流单号', +PRIMARY KEY (`id`) +); + + +CREATE TABLE `order_logistics_detail` ( +`id` int NOT NULL AUTO_INCREMENT COMMENT 'id自增长', +`order_logistics_id` int NOT NULL COMMENT '物流编号', +`logistics_time` datetime NOT NULL COMMENT '物流时间', +`logistics_information` VARCHAR(20) NOT NULL COMMENT '物流信息', +PRIMARY KEY (`id`) +); + + + + + + + + + + + + +