From d70d1dcc7a30b8e7368a5efd3af86b5550a8965a Mon Sep 17 00:00:00 2001 From: sin <2943460818@qq.com> Date: Sat, 16 Mar 2019 15:22:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20order=20=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=EF=BC=8C=E5=86=99=E5=AE=8C=20api=20dataObjec?= =?UTF-8?q?t=20=E5=92=8C=E4=B8=80=E4=BA=9B=E5=AE=9A=E4=B9=89=EF=BC=8C?= =?UTF-8?q?=E4=B8=BA=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iocoder/mall/order/api/OrderService.java | 57 +++++ .../cn/iocoder/mall/order/api/bo/OrderBO.java | 12 ++ .../mall/order/api/constants/MQConstants.java | 15 ++ .../api/constants/OrderPayStatusEnum.java | 26 +++ .../order/api/constants/OrderStatusEnum.java | 36 ++++ .../mall/order/api/dto/OrderCreateDTO.java | 12 ++ .../mall/order/api/dto/OrderUpdateDTO.java | 12 ++ .../iocoder/mall/order/api/package-info.java | 7 + order/order-service-impl/pom.xml | 47 ++++ .../iocoder/mall/order/dao/OrderMapper.java | 21 ++ .../mall/order/dataobject/OrderDO.java | 201 ++++++++++++++++++ .../mall/order/dataobject/OrderItemDO.java | 105 +++++++++ .../cn/iocoder/mall/order/package-info.java | 5 + .../mall/order/service/ServiceImpl.java | 16 ++ .../main/resources/config/application.yaml | 25 +++ .../src/main/resources/mapper/OrderMapper.xml | 23 ++ .../src/main/resources/mybatis-config.xml | 19 ++ order/pom.xml | 1 + 18 files changed, 640 insertions(+) create mode 100644 order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderService.java create mode 100644 order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderBO.java create mode 100644 order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/MQConstants.java create mode 100644 order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderPayStatusEnum.java create mode 100644 order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderStatusEnum.java create mode 100644 order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderCreateDTO.java create mode 100644 order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderUpdateDTO.java create mode 100644 order/order-service-api/src/main/java/cn/iocoder/mall/order/api/package-info.java create mode 100644 order/order-service-impl/pom.xml create mode 100644 order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderMapper.java create mode 100644 order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderDO.java create mode 100644 order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderItemDO.java create mode 100644 order/order-service-impl/src/main/java/cn/iocoder/mall/order/package-info.java create mode 100644 order/order-service-impl/src/main/java/cn/iocoder/mall/order/service/ServiceImpl.java create mode 100644 order/order-service-impl/src/main/resources/config/application.yaml create mode 100644 order/order-service-impl/src/main/resources/mapper/OrderMapper.xml create mode 100644 order/order-service-impl/src/main/resources/mybatis-config.xml diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderService.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderService.java new file mode 100644 index 000000000..972614316 --- /dev/null +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderService.java @@ -0,0 +1,57 @@ +package cn.iocoder.mall.order.api; + +import cn.iocoder.mall.order.api.bo.OrderBO; +import cn.iocoder.mall.order.api.dto.OrderCreateDTO; +import cn.iocoder.mall.order.api.dto.OrderUpdateDTO; + +/** + * 订单 service + * + * @author Sin + * @time 2019-03-16 13:15 + */ +public interface OrderService { + + /** + * 订单创建 + * + * @param orderCreateDTO + * @return + */ + OrderBO createOrder(OrderCreateDTO orderCreateDTO); + + /** + * 订单更新 + * + * @param orderUpdateDTO + */ + void updateOrder(OrderUpdateDTO orderUpdateDTO); + + /** + * 删除订单 + * + * @param orderId + */ + void deleteOrder(String orderId); + + /** + * 监听支付动作 + * + * mq 更新 payStatus + */ + void listenerPayment(); + + /** + * 监听确认收货 + * + * mq 更新 status + */ + void listenerConfirmGoods(); + + /** + * 监听换货 + * + * mq 更新 status + */ + void listenerExchangeGoods(); +} diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderBO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderBO.java new file mode 100644 index 000000000..41a67260c --- /dev/null +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/OrderBO.java @@ -0,0 +1,12 @@ +package cn.iocoder.mall.order.api.bo; + +import java.io.Serializable; + +/** + * 订单创建 BO + * + * @author Sin + * @time 2019-03-16 14:38 + */ +public class OrderBO implements Serializable { +} diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/MQConstants.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/MQConstants.java new file mode 100644 index 000000000..b19bc9dd4 --- /dev/null +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/MQConstants.java @@ -0,0 +1,15 @@ +package cn.iocoder.mall.order.api.constants; + +/** + * MQ 订阅消息 + * + * @author Sin + * @time 2019-03-16 15:04 + */ +public class MQConstants { + + /** + * 订单 - 创建成功 消息 + */ + public static final String ORDER_CREATE_SUCCESS = "order.orderCreateSuccess"; +} diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderPayStatusEnum.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderPayStatusEnum.java new file mode 100644 index 000000000..b9e9c507b --- /dev/null +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderPayStatusEnum.java @@ -0,0 +1,26 @@ +package cn.iocoder.mall.order.api.constants; + +/** + * 订单状态 status + * + * @author Sin + * @time 2019-03-16 14:32 + */ +public enum OrderPayStatusEnum { + + WAITING_PAYMENT(0, "等待支付"), + SUCCESSFUL_PAYMENT(1, "支付成功"), + REFUND_PAYMENT(2, "退款成功"), + + ; + + + private final int value; + + private final String text; + + OrderPayStatusEnum(int value, String text) { + this.value = value; + this.text = text; + } +} diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderStatusEnum.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderStatusEnum.java new file mode 100644 index 000000000..dd4b315b2 --- /dev/null +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constants/OrderStatusEnum.java @@ -0,0 +1,36 @@ +package cn.iocoder.mall.order.api.constants; + +/** + * 订单 - status + * + * @author Sin + * @time 2019-03-16 14:06 + */ +public enum OrderStatusEnum { + + // 基本状态 + WAIT_SHIPMENT(0, "等待发货"), + ALREADY_SHIPMENT(1, "已发货"), + RECEIVED_GOODS(2, "已收货"), + CONFIRM_RECEIPT_GOODS(3, "确认收货"), // 确认收货,也就是交易成功! + + // 换货 + APPLY_EXCHANGE_GOODS(20, "申请换货"), + EXCHANGE_GOODS(21, "换货中"), + EXCHANGE_GOODS_SUCCESSFUL(22, "换货成功"), + + // 退货 + APPLY_RETURN_GOODS(40, "申请退货"), + RETURN_GOODS(41, "退货中"), + RETURN_GOODS_SUCCESSFUL(42, "退货成功"), + + ; + + private final int value; + + private final String text; + + OrderStatusEnum(int value, String text) { + this.value = value; + this.text = text; + }} diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderCreateDTO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderCreateDTO.java new file mode 100644 index 000000000..ffc105548 --- /dev/null +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderCreateDTO.java @@ -0,0 +1,12 @@ +package cn.iocoder.mall.order.api.dto; + +import java.io.Serializable; + +/** + * 订单创建 + * + * @author Sin + * @time 2019-03-16 14:42 + */ +public class OrderCreateDTO implements Serializable { +} diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderUpdateDTO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderUpdateDTO.java new file mode 100644 index 000000000..93ef4be1a --- /dev/null +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderUpdateDTO.java @@ -0,0 +1,12 @@ +package cn.iocoder.mall.order.api.dto; + +import java.io.Serializable; + +/** + * 订单更新 + * + * @author Sin + * @time 2019-03-16 14:46 + */ +public class OrderUpdateDTO implements Serializable { +} diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/package-info.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/package-info.java new file mode 100644 index 000000000..80054d29d --- /dev/null +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/package-info.java @@ -0,0 +1,7 @@ +/** + * 订单 api + * + * @author Sin + * @time 2019-03-16 13:15 + */ +package cn.iocoder.mall.order.api; \ No newline at end of file diff --git a/order/order-service-impl/pom.xml b/order/order-service-impl/pom.xml new file mode 100644 index 000000000..84772f74b --- /dev/null +++ b/order/order-service-impl/pom.xml @@ -0,0 +1,47 @@ + + + + order + cn.iocoder.mall + 1.0-SNAPSHOT + + 4.0.0 + + order-service-impl + + + + cn.iocoder.mall + order-service-api + 1.0-SNAPSHOT + + + + com.alibaba + dubbo + compile + + + mysql + mysql-connector-java + + + org.springframework.boot + spring-boot-starter-jdbc + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 2.0.0 + + + + com.google.guava + guava + 27.0.1-jre + + + \ No newline at end of file diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderMapper.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderMapper.java new file mode 100644 index 000000000..45ad68977 --- /dev/null +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderMapper.java @@ -0,0 +1,21 @@ +package cn.iocoder.mall.order.dao; + +import cn.iocoder.mall.order.dataobject.OrderDO; +import org.springframework.stereotype.Repository; + +/** + * 订单 mapper + * + * @author Sin + * @time 2019-03-16 15:09 + */ +@Repository +public interface OrderMapper { + + /** + * 插入数据 + * + * @param orderDO + */ + void insert(OrderDO orderDO); +} 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 new file mode 100644 index 000000000..7ea7d5519 --- /dev/null +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderDO.java @@ -0,0 +1,201 @@ +package cn.iocoder.mall.order.dataobject; + +import java.io.Serializable; +import java.util.Date; + +/** + * 订单 + * + * @author Sin + * @time 2019-03-16 13:49 + */ +public class OrderDO implements Serializable { + + /** + * 编号 + */ + private String id; + /** + * 订单编号 + */ + private String orderNo; + /** + * 交易金额 + */ + private Integer price; + /** + * 收件区域编号 + */ + private String receiverAreaNo; + /** + * 收件手机号 + */ + private String receiverMobile; + /** + * 收件详细地址 + */ + private String receiverAddress; + /** + * 状态(如果有多个商品分开发货需要全部商品发完才会改变状态) + * + * - 0、代发货 + * - 1、已发货 + * - 2、已收货 + * - 20、换货中 + * - 21、换货成功 + * - 40、退货中 + * - 41、已退货 + */ + private Integer status; + /** + * 支付状态 + * + * - 0、待支付 + * - 1、支付完成 + * - 2、已退款 + */ + private Integer payStatus; + /** + * 订单创建时间 + */ + private Date createTime; + /** + * 付款时间 + */ + private Date paymentTime; + /** + * 发货时间 + */ + private Date deliveryTime; + /** + * 成交时间 + */ + private Date closingTime; + /** + * 备注 + */ + private String remark; + + @Override + public String toString() { + return "Order{" + + "id='" + id + '\'' + + ", orderNo='" + orderNo + '\'' + + ", price=" + price + + ", receiverAreaNo='" + receiverAreaNo + '\'' + + ", receiverMobile='" + receiverMobile + '\'' + + ", receiverAddress='" + receiverAddress + '\'' + + ", status=" + status + + ", payStatus=" + payStatus + + ", createTime=" + createTime + + ", paymentTime=" + paymentTime + + ", deliveryTime=" + deliveryTime + + ", closingTime=" + closingTime + + ", remark='" + remark + '\'' + + '}'; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getOrderNo() { + return orderNo; + } + + public void setOrderNo(String orderNo) { + this.orderNo = orderNo; + } + + public Integer getPrice() { + return price; + } + + public void setPrice(Integer price) { + this.price = price; + } + + public String getReceiverAreaNo() { + return receiverAreaNo; + } + + public void setReceiverAreaNo(String receiverAreaNo) { + this.receiverAreaNo = receiverAreaNo; + } + + public String getReceiverMobile() { + return receiverMobile; + } + + public void setReceiverMobile(String receiverMobile) { + this.receiverMobile = receiverMobile; + } + + public String getReceiverAddress() { + return receiverAddress; + } + + public void setReceiverAddress(String receiverAddress) { + this.receiverAddress = receiverAddress; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public Integer getPayStatus() { + return payStatus; + } + + public void setPayStatus(Integer payStatus) { + this.payStatus = payStatus; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getPaymentTime() { + return paymentTime; + } + + public void setPaymentTime(Date paymentTime) { + this.paymentTime = paymentTime; + } + + public Date getDeliveryTime() { + return deliveryTime; + } + + public void setDeliveryTime(Date deliveryTime) { + this.deliveryTime = deliveryTime; + } + + public Date getClosingTime() { + return closingTime; + } + + public void setClosingTime(Date closingTime) { + this.closingTime = closingTime; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } +} 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 new file mode 100644 index 000000000..474d94b46 --- /dev/null +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderItemDO.java @@ -0,0 +1,105 @@ +package cn.iocoder.mall.order.dataobject; + +import java.io.Serializable; + +/** + * 订单 item + * + * @author Sin + * @time 2019-03-16 14:03 + */ +public class OrderItemDO implements Serializable { + + /** + * 编号 + */ + private String id; + /** + * 订单编号 + */ + private String orderId; + /** + * 商品编号 + */ + private String commodityId; + /** + * 数量 + */ + private Integer quantity; + /** + * 金额(分) + */ + private Integer price; + /** + * 状态 + * + * - 0、代发货 + * - 1、已发货 + * - 2、已收货 + * - 20、换货中 + * - 21、换货成功 + * - 40、退货中 + * - 41、已退货 + */ + private Integer status; + + @Override + public String toString() { + return "OrderItem{" + + "id='" + id + '\'' + + ", orderId='" + orderId + '\'' + + ", commodityId='" + commodityId + '\'' + + ", quantity=" + quantity + + ", price=" + price + + ", status=" + status + + '}'; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public String getCommodityId() { + return commodityId; + } + + public void setCommodityId(String commodityId) { + this.commodityId = commodityId; + } + + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public Integer getPrice() { + return price; + } + + public void setPrice(Integer price) { + this.price = price; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } +} diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/package-info.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/package-info.java new file mode 100644 index 000000000..3e032413e --- /dev/null +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/package-info.java @@ -0,0 +1,5 @@ +/** + * @author Sin + * @time 2019-03-16 13:49 + */ +package cn.iocoder.mall.order; \ No newline at end of file diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/service/ServiceImpl.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/service/ServiceImpl.java new file mode 100644 index 000000000..69c69fba2 --- /dev/null +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/service/ServiceImpl.java @@ -0,0 +1,16 @@ +package cn.iocoder.mall.order.service; + +import org.springframework.stereotype.Service; + +/** + * 订单 service impl + * + * @author Sin + * @time 2019-03-16 15:08 + */ +@Service +@com.alibaba.dubbo.config.annotation.Service(validation = "true") +public class ServiceImpl { + + +} diff --git a/order/order-service-impl/src/main/resources/config/application.yaml b/order/order-service-impl/src/main/resources/config/application.yaml new file mode 100644 index 000000000..598257e83 --- /dev/null +++ b/order/order-service-impl/src/main/resources/config/application.yaml @@ -0,0 +1,25 @@ +spring: + # datasource + datasource: + url: jdbc:mysql://180.167.213.26:13306/mall_order?useSSL=false&useUnicode=true&characterEncoding=UTF-8 + driver-class-name: com.mysql.jdbc.Driver + username: root + password: ${MALL_MYSQL_PASSWORD} + +# mybatis +mybatis: + config-location: classpath:mybatis-config.xml + mapper-locations: classpath:mapper/*.xml + type-aliases-package: cn.iocoder.mall.order.dataobject + +# dubbo +dubbo: + application: + name: order-service + registry: + address: zookeeper://127.0.0.1:2181 + protocol: + port: -1 + name: dubbo + scan: + base-packages: cn.iocoder.mall.order.service \ 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 new file mode 100644 index 000000000..04cab6fd0 --- /dev/null +++ b/order/order-service-impl/src/main/resources/mapper/OrderMapper.xml @@ -0,0 +1,23 @@ + + + + + + id, order_no, price, receiver_area_no, receiver_mobile, + receiver_address, status, pay_status, create_time, + payment_time, delivery_time, closing_time, remark + + + + INSERT INTO order ( + id, order_no, price, receiver_area_no, receiver_mobile, + receiver_address, status, pay_status, create_time, + payment_time, delivery_time, closing_time, remark + ) VALUES ( + ${orderNo}, ${price}, ${receiverAreaNo}, ${receiverMobile}, + ${receiverAddress}, ${status}, ${payStatus}, ${createTime}, + ${paymentTime}, ${deliveryTime}, ${closingTime}, ${remark} + ) + + + \ No newline at end of file diff --git a/order/order-service-impl/src/main/resources/mybatis-config.xml b/order/order-service-impl/src/main/resources/mybatis-config.xml new file mode 100644 index 000000000..7f604cc7e --- /dev/null +++ b/order/order-service-impl/src/main/resources/mybatis-config.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/order/pom.xml b/order/pom.xml index 6facf3d6e..f1dd38c85 100644 --- a/order/pom.xml +++ b/order/pom.xml @@ -14,6 +14,7 @@ order-application order-service-api + order-service-impl