diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/OrderApplication.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/OrderApplication.java similarity index 88% rename from order/order-application/src/main/java/cn/iocoder/mall/order/OrderApplication.java rename to order/order-application/src/main/java/cn/iocoder/mall/order/application/OrderApplication.java index 3b6666d90..4cb758966 100644 --- a/order/order-application/src/main/java/cn/iocoder/mall/order/OrderApplication.java +++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/OrderApplication.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order; +package cn.iocoder.mall.order.application; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/config/MVCConfiguration.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/config/MVCConfiguration.java similarity index 96% rename from order/order-application/src/main/java/cn/iocoder/mall/order/config/MVCConfiguration.java rename to order/order-application/src/main/java/cn/iocoder/mall/order/application/config/MVCConfiguration.java index 343dcc455..f9c72ca17 100644 --- a/order/order-application/src/main/java/cn/iocoder/mall/order/config/MVCConfiguration.java +++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/config/MVCConfiguration.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.config; +package cn.iocoder.mall.order.application.config; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.*; diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/config/SwaggerConfiguration.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/config/SwaggerConfiguration.java similarity index 96% rename from order/order-application/src/main/java/cn/iocoder/mall/order/config/SwaggerConfiguration.java rename to order/order-application/src/main/java/cn/iocoder/mall/order/application/config/SwaggerConfiguration.java index 08f28bd78..a935ffade 100644 --- a/order/order-application/src/main/java/cn/iocoder/mall/order/config/SwaggerConfiguration.java +++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/config/SwaggerConfiguration.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.config; +package cn.iocoder.mall.order.application.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/controller/admins/AdminsOrderController.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminsOrderController.java similarity index 66% rename from order/order-application/src/main/java/cn/iocoder/mall/order/controller/admins/AdminsOrderController.java rename to order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminsOrderController.java index c2b659195..e86b25275 100644 --- a/order/order-application/src/main/java/cn/iocoder/mall/order/controller/admins/AdminsOrderController.java +++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminsOrderController.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.controller.admins; +package cn.iocoder.mall.order.application.controller.admins; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.order.api.OrderService; @@ -6,10 +6,10 @@ 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.convert.OrderConvert; -import cn.iocoder.mall.order.vo.OrderItemUpdateVO; -import cn.iocoder.mall.order.vo.OrderLogisticsVO; -import cn.iocoder.mall.order.vo.OrderPageQueryVO; +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 io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -34,23 +34,23 @@ public class AdminsOrderController { @GetMapping("page") @ApiOperation("订单列表") - public CommonResult> getOrderPage(@RequestBody OrderPageQueryVO orderPageQueryVO) { - OrderQueryDTO orderQueryDTO = OrderConvert.INSTANCE.convertPageBO(orderPageQueryVO); + public CommonResult> getOrderPage(@Validated OrderPageQueryVO orderPageQueryVO) { + OrderQueryDTO orderQueryDTO = OrderConvertAPP.INSTANCE.convertPageBO(orderPageQueryVO); CommonResult> result = orderService.getOrderPage(orderQueryDTO); return result; } - @PutMapping("order/update") + @PutMapping("order_item/update") @ApiOperation("订单item更新") public CommonResult updateOrderItem(@RequestBody @Validated OrderItemUpdateVO orderItemUpdateVO) { - OrderItemUpdateDTO dto = OrderConvert.INSTANCE.convertPageBO(orderItemUpdateVO); + OrderItemUpdateDTO dto = OrderConvertAPP.INSTANCE.convertPageBO(orderItemUpdateVO); return orderService.updateOrderItem(dto); } @PutMapping("logistics/update") @ApiOperation("订单物流更新") public CommonResult updateLogistics(@RequestBody @Validated OrderLogisticsVO orderLogisticsVO) { - OrderLogisticsUpdateDTO dto = OrderConvert.INSTANCE.convertPageBO(orderLogisticsVO); + OrderLogisticsUpdateDTO dto = OrderConvertAPP.INSTANCE.convertPageBO(orderLogisticsVO); return orderService.updateLogistics(dto); } } diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/controller/users/UsersOrderController.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/UsersOrderController.java similarity index 82% rename from order/order-application/src/main/java/cn/iocoder/mall/order/controller/users/UsersOrderController.java rename to order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/UsersOrderController.java index 04e32bfc4..482f2d481 100644 --- a/order/order-application/src/main/java/cn/iocoder/mall/order/controller/users/UsersOrderController.java +++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/UsersOrderController.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.controller.users; +package cn.iocoder.mall.order.application.controller.users; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/convert/OrderConvertAPP.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/convert/OrderConvertAPP.java new file mode 100644 index 000000000..e089fdd1e --- /dev/null +++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/convert/OrderConvertAPP.java @@ -0,0 +1,34 @@ +package cn.iocoder.mall.order.application.convert; + +import cn.iocoder.mall.order.api.dto.OrderItemUpdateDTO; +import cn.iocoder.mall.order.api.dto.OrderLogisticsUpdateDTO; +import cn.iocoder.mall.order.api.dto.OrderQueryDTO; +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 org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +/** + * application 订单 convert + * + * TODO 这种方式 文件名不能一样哈! + * + * @author Sin + * @time 2019-03-24 10:45 + */ +@Mapper +public interface OrderConvertAPP { + + OrderConvertAPP INSTANCE = Mappers.getMapper(OrderConvertAPP.class); + + @Mappings({}) + OrderQueryDTO convertPageBO(OrderPageQueryVO orderPageQueryVO); + + @Mappings({}) + OrderLogisticsUpdateDTO convertPageBO(OrderLogisticsVO orderLogisticsVO); + + @Mappings({}) + OrderItemUpdateDTO convertPageBO(OrderItemUpdateVO orderItemUpdateVO); +} diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/vo/OrderItemUpdateVO.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/vo/OrderItemUpdateVO.java similarity index 97% rename from order/order-application/src/main/java/cn/iocoder/mall/order/vo/OrderItemUpdateVO.java rename to order/order-application/src/main/java/cn/iocoder/mall/order/application/vo/OrderItemUpdateVO.java index 786c55ad4..35e87951b 100644 --- a/order/order-application/src/main/java/cn/iocoder/mall/order/vo/OrderItemUpdateVO.java +++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/vo/OrderItemUpdateVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.vo; +package cn.iocoder.mall.order.application.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/vo/OrderLogisticsVO.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/vo/OrderLogisticsVO.java similarity index 98% rename from order/order-application/src/main/java/cn/iocoder/mall/order/vo/OrderLogisticsVO.java rename to order/order-application/src/main/java/cn/iocoder/mall/order/application/vo/OrderLogisticsVO.java index 0c6993433..e910a9186 100644 --- a/order/order-application/src/main/java/cn/iocoder/mall/order/vo/OrderLogisticsVO.java +++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/vo/OrderLogisticsVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.vo; +package cn.iocoder.mall.order.application.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/vo/OrderPageQueryVO.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/vo/OrderPageQueryVO.java similarity index 98% rename from order/order-application/src/main/java/cn/iocoder/mall/order/vo/OrderPageQueryVO.java rename to order/order-application/src/main/java/cn/iocoder/mall/order/application/vo/OrderPageQueryVO.java index e531125cb..1e40f89d2 100644 --- a/order/order-application/src/main/java/cn/iocoder/mall/order/vo/OrderPageQueryVO.java +++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/vo/OrderPageQueryVO.java @@ -1,6 +1,5 @@ -package cn.iocoder.mall.order.vo; +package cn.iocoder.mall.order.application.vo; -import io.swagger.annotations.Api; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; 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 index 6a6d0d541..9882c6dd6 100644 --- 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 @@ -56,7 +56,7 @@ public interface OrderService { * - 联系人电话 * - 联系人姓名 */ - CommonResult updateLogistics(OrderLogisticsDTO orderLogisticsDTO); + CommonResult updateLogistics(OrderLogisticsUpdateDTO orderLogisticsDTO); /** * 删除订单 diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderErrorCodeEnum.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderErrorCodeEnum.java index 36f60f6f0..af10c9a4a 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderErrorCodeEnum.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderErrorCodeEnum.java @@ -10,7 +10,9 @@ package cn.iocoder.mall.order.api.constant; */ public enum OrderErrorCodeEnum { - ORDER_ITEM_ONLY_ONE(1000001000, "订单Item只有一个"), + ORDER_ITEM_ONLY_ONE(1000001000, "订单Item只有一个!"), + ORDER_GET_SKU_FAIL(1000001001, "获取商品失败!"), + ORDER_GET_SKU_NOT_EXISTENT(1000001002, "获取的商品不存在!"), ; private final int code; diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderHasReturnExchangeEnum.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderHasReturnExchangeEnum.java index b7e03f5a4..084509868 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderHasReturnExchangeEnum.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderHasReturnExchangeEnum.java @@ -10,8 +10,8 @@ public enum OrderHasReturnExchangeEnum { NO(1, "没有"), RETURN_GOODS(2, "退货"), - EXCHANGE_GOODS(2, "换货"), - RETURN_EXCHANGE_GOODS(2, "退换货"); + EXCHANGE_GOODS(3, "换货"), + RETURN_EXCHANGE_GOODS(4, "退换货"); /** * 状态值 diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderLogisticsDTO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderLogisticsUpdateDTO.java similarity index 82% rename from order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderLogisticsDTO.java rename to order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderLogisticsUpdateDTO.java index cdc5b28f5..bf5030bca 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderLogisticsDTO.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderLogisticsUpdateDTO.java @@ -10,7 +10,7 @@ import java.io.Serializable; * @author Sin * @time 2019-03-17 20:22 */ -public class OrderLogisticsDTO implements Serializable { +public class OrderLogisticsUpdateDTO implements Serializable { /** * 订单 id @@ -42,7 +42,6 @@ public class OrderLogisticsDTO implements Serializable { /** * 物流编号 */ - @NotNull private String logisticsNo; @Override @@ -61,7 +60,7 @@ public class OrderLogisticsDTO implements Serializable { return id; } - public OrderLogisticsDTO setId(Integer id) { + public OrderLogisticsUpdateDTO setId(Integer id) { this.id = id; return this; } @@ -70,7 +69,7 @@ public class OrderLogisticsDTO implements Serializable { return areaNo; } - public OrderLogisticsDTO setAreaNo(String areaNo) { + public OrderLogisticsUpdateDTO setAreaNo(String areaNo) { this.areaNo = areaNo; return this; } @@ -79,7 +78,7 @@ public class OrderLogisticsDTO implements Serializable { return name; } - public OrderLogisticsDTO setName(String name) { + public OrderLogisticsUpdateDTO setName(String name) { this.name = name; return this; } @@ -88,7 +87,7 @@ public class OrderLogisticsDTO implements Serializable { return mobile; } - public OrderLogisticsDTO setMobile(String mobile) { + public OrderLogisticsUpdateDTO setMobile(String mobile) { this.mobile = mobile; return this; } @@ -97,7 +96,7 @@ public class OrderLogisticsDTO implements Serializable { return address; } - public OrderLogisticsDTO setAddress(String address) { + public OrderLogisticsUpdateDTO setAddress(String address) { this.address = address; return this; } @@ -106,7 +105,7 @@ public class OrderLogisticsDTO implements Serializable { return logisticsNo; } - public OrderLogisticsDTO setLogisticsNo(String logisticsNo) { + public OrderLogisticsUpdateDTO setLogisticsNo(String logisticsNo) { this.logisticsNo = logisticsNo; return this; } diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderPageBO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderPageBO.java index e28ad4938..d29a87052 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderPageBO.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderPageBO.java @@ -10,6 +10,7 @@ import java.util.Date; * @time 2019-03-23 14:30 */ public class OrderPageBO implements Serializable { + /** * id */ @@ -29,7 +30,7 @@ public class OrderPageBO implements Serializable { /** * 交易金额 */ - private Integer money; + private Integer price; /// /// 时间信息 @@ -77,18 +78,6 @@ public class OrderPageBO implements Serializable { * 备注 */ private String remark; - /** - * 创建时间 - */ - private Date createTime; - /** - * 更新时间 - */ - private Date updateTime; - /** - * 删除 - */ - private Integer deleted; @Override public String toString() { @@ -97,7 +86,7 @@ public class OrderPageBO implements Serializable { ", userId=" + userId + ", orderLogisticsId=" + orderLogisticsId + ", orderNo='" + orderNo + '\'' + - ", money=" + money + + ", price=" + price + ", paymentTime=" + paymentTime + ", deliveryTime=" + deliveryTime + ", receiverTime=" + receiverTime + @@ -105,9 +94,6 @@ public class OrderPageBO implements Serializable { ", hasReturnExchange=" + hasReturnExchange + ", status=" + status + ", remark='" + remark + '\'' + - ", createTime=" + createTime + - ", updateTime=" + updateTime + - ", deleted=" + deleted + '}'; } @@ -147,12 +133,12 @@ public class OrderPageBO implements Serializable { return this; } - public Integer getMoney() { - return money; + public Integer getPrice() { + return price; } - public OrderPageBO setMoney(Integer money) { - this.money = money; + public OrderPageBO setPrice(Integer price) { + this.price = price; return this; } @@ -218,31 +204,4 @@ public class OrderPageBO implements Serializable { 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; - } } diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderQueryDTO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderQueryDTO.java index 79a723545..f911711b9 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderQueryDTO.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderQueryDTO.java @@ -24,6 +24,14 @@ public class OrderQueryDTO implements Serializable { * 用户 id */ private Integer userId; + /** + * 物流id + */ + private Integer orderLogisticsId; + /** + * 是否退换货 + */ + private Integer hasReturnExchange; /** * 付款时间(待发货) */ @@ -38,10 +46,11 @@ public class OrderQueryDTO implements Serializable { * 删除状态 */ private Integer deleted; - - @NotNull(message = "页码不能为空") + /** + * 状态 + */ + private Integer status; private Integer pageNo; - @NotNull(message = "每页条数不能为空") private Integer pageSize; @Override @@ -50,11 +59,14 @@ public class OrderQueryDTO implements Serializable { "id=" + id + ", orderNo='" + orderNo + '\'' + ", userId=" + userId + + ", orderLogisticsId=" + orderLogisticsId + + ", hasReturnExchange=" + hasReturnExchange + ", startPaymentTime=" + startPaymentTime + ", endPaymentTime=" + endPaymentTime + ", startCreateTime=" + startCreateTime + ", endCreateTime=" + endCreateTime + ", deleted=" + deleted + + ", status=" + status + ", pageNo=" + pageNo + ", pageSize=" + pageSize + '}'; @@ -87,6 +99,24 @@ public class OrderQueryDTO implements Serializable { return this; } + public Integer getOrderLogisticsId() { + return orderLogisticsId; + } + + public OrderQueryDTO setOrderLogisticsId(Integer orderLogisticsId) { + this.orderLogisticsId = orderLogisticsId; + return this; + } + + public Integer getHasReturnExchange() { + return hasReturnExchange; + } + + public OrderQueryDTO setHasReturnExchange(Integer hasReturnExchange) { + this.hasReturnExchange = hasReturnExchange; + return this; + } + public Date getStartPaymentTime() { return startPaymentTime; } @@ -132,6 +162,15 @@ public class OrderQueryDTO implements Serializable { return this; } + public Integer getStatus() { + return status; + } + + public OrderQueryDTO setStatus(Integer status) { + this.status = status; + return this; + } + public Integer getPageNo() { return pageNo; } diff --git a/order/order-service-impl/pom.xml b/order/order-service-impl/pom.xml index e7c08a32e..ed05a2a72 100644 --- a/order/order-service-impl/pom.xml +++ b/order/order-service-impl/pom.xml @@ -90,6 +90,12 @@ 1.0-SNAPSHOT compile + + cn.iocoder.mall + product-service-api + 1.0-SNAPSHOT + compile + diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/config/DatabaseConfiguration.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/application/config/DatabaseConfiguration.java similarity index 100% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/config/DatabaseConfiguration.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/application/config/DatabaseConfiguration.java diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/config/ServiceExceptionConfiguration.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/application/config/ServiceExceptionConfiguration.java similarity index 100% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/config/ServiceExceptionConfiguration.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/application/config/ServiceExceptionConfiguration.java diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/convert/OrderConvert.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/application/convert/OrderConvert.java similarity index 90% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/convert/OrderConvert.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/application/convert/OrderConvert.java index de3de2b33..14b63abce 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/convert/OrderConvert.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/application/convert/OrderConvert.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.convert; +package cn.iocoder.mall.order.application.convert; import cn.iocoder.mall.order.api.dto.OrderPageBO; import cn.iocoder.mall.order.dataobject.OrderDO; diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/convert/OrderItemConvert.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/application/convert/OrderItemConvert.java similarity index 92% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/convert/OrderItemConvert.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/application/convert/OrderItemConvert.java index 493873651..e06c50883 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/convert/OrderItemConvert.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/application/convert/OrderItemConvert.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.convert; +package cn.iocoder.mall.order.application.convert; import cn.iocoder.mall.order.api.dto.OrderCreateItemDTO; import cn.iocoder.mall.order.api.dto.OrderItemUpdateDTO; diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/convert/OrderLogisticsConvert.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/application/convert/OrderLogisticsConvert.java similarity index 92% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/convert/OrderLogisticsConvert.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/application/convert/OrderLogisticsConvert.java index 70f1fe76f..3143dc6ae 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/convert/OrderLogisticsConvert.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/application/convert/OrderLogisticsConvert.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.convert; +package cn.iocoder.mall.order.application.convert; import cn.iocoder.mall.order.api.dto.OrderCreateDTO; import cn.iocoder.mall.order.api.dto.OrderLogisticsUpdateDTO; 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 index d98d28875..6bc8c87aa 100644 --- 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 @@ -55,5 +55,5 @@ public interface OrderMapper { * @param orderQueryDTO * @return */ - List selectPage(OrderQueryDTO orderQueryDTO, int offset, int pageSize); + List selectPage(OrderQueryDTO orderQueryDTO); } 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 4b5bf3a6f..41eb4ca87 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 @@ -31,7 +31,7 @@ public class OrderDO extends DeletableDO { /** * 交易金额 */ - private Integer money; + private Integer price; /// /// 时间信息 @@ -87,7 +87,7 @@ public class OrderDO extends DeletableDO { ", userId=" + userId + ", orderLogisticsId=" + orderLogisticsId + ", orderNo='" + orderNo + '\'' + - ", money=" + money + + ", price=" + price + ", paymentTime=" + paymentTime + ", deliveryTime=" + deliveryTime + ", receiverTime=" + receiverTime + @@ -134,12 +134,12 @@ public class OrderDO extends DeletableDO { return this; } - public Integer getMoney() { - return money; + public Integer getPrice() { + return price; } - public OrderDO setMoney(Integer money) { - this.money = money; + public OrderDO setPrice(Integer price) { + this.price = price; return this; } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/mock/ProductSpuServiceMock.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/mock/ProductSpuServiceMock.java new file mode 100644 index 000000000..cbc3aeafb --- /dev/null +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/mock/ProductSpuServiceMock.java @@ -0,0 +1,40 @@ +package cn.iocoder.mall.order.mock; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.product.api.ProductSpuService; +import cn.iocoder.mall.product.api.bo.ProductSpuDetailBO; +import cn.iocoder.mall.product.api.bo.ProductSpuPageBO; +import cn.iocoder.mall.product.api.dto.ProductSpuAddDTO; +import cn.iocoder.mall.product.api.dto.ProductSpuPageDTO; +import cn.iocoder.mall.product.api.dto.ProductSpuUpdateDTO; + +/** + * @author Sin + * @time 2019-03-24 15:24 + */ +public class ProductSpuServiceMock implements ProductSpuService { + @Override + public CommonResult getProductSpu(Integer id) { + return null; + } + + @Override + public CommonResult addProductSpu(Integer adminId, ProductSpuAddDTO productSpuAddDTO) { + return null; + } + + @Override + public CommonResult updateProductSpu(Integer adminId, ProductSpuUpdateDTO productSpuUpdateDTO) { + return null; + } + + @Override + public CommonResult updateProductSpuSort(Integer adminId, Integer spuId, Integer sort) { + return null; + } + + @Override + public CommonResult getProductSpuPage(ProductSpuPageDTO productSpuPageDTO) { + return null; + } +} 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 598eb83ca..bec0a32d5 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 @@ -10,9 +10,9 @@ import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum; 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.application.convert.OrderConvert; +import cn.iocoder.mall.order.application.convert.OrderItemConvert; +import cn.iocoder.mall.order.application.convert.OrderLogisticsConvert; import cn.iocoder.mall.order.dao.OrderItemMapper; import cn.iocoder.mall.order.dao.OrderLogisticsMapper; import cn.iocoder.mall.order.dao.OrderMapper; @@ -49,15 +49,12 @@ public class OrderServiceImpl implements OrderService { @Override public CommonResult> 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 orderDOList = orderMapper.selectPage(orderQueryDTO, offset, pageSize); + List orderDOList = orderMapper.selectPage(orderQueryDTO); List orderPageBOList = OrderConvert.INSTANCE.convertPageBO(orderDOList); return CommonResult.success(orderPageBOList); } @@ -69,6 +66,23 @@ public class OrderServiceImpl implements OrderService { OrderLogisticsDO orderLogisticsDO = OrderLogisticsConvert.INSTANCE.convert(orderCreateDTO); List orderItemDOList = OrderItemConvert.INSTANCE.convert(orderItemDTOList); + // TODO: 2019-03-24 sin 校验商品是否存在 +// for (OrderItemDO orderItemDO : orderItemDOList) { +// CommonResult result = productSpuService.getProductSpu(orderItemDO.getSkuId()); +// +// // 有任何商品获取失败,或者为 null,都直接返回失败。 +// if (result.isError()) { +// return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_GET_SKU_FAIL.getCode()); +// } +// +// if (result.getData() == null) { +// return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_GET_SKU_NOT_EXISTENT.getCode()); +// } +// +// ProductSpuDetailBO spuDetailBO = result.getData(); +// orderItemDO.setPrice(1000); +// } + // 物流信息 orderLogisticsDO .setLogisticsNo("") @@ -81,7 +95,7 @@ public class OrderServiceImpl implements OrderService { .setUserId(userId) .setOrderLogisticsId(orderLogisticsDO.getId()) .setOrderNo(UUID.randomUUID().toString().replace("-", "")) - .setMoney(-1) // 先设置一个默认值,金额在下面计算 + .setPrice(-1) // 先设置一个默认值,金额在下面计算 .setClosingTime(null) .setDeliveryTime(null) .setPaymentTime(null) @@ -119,7 +133,7 @@ public class OrderServiceImpl implements OrderService { orderMapper.updateById( new OrderDO() .setId(orderDO.getId()) - .setMoney(totalAmount) + .setPrice(totalAmount) ); // TODO: 2019-03-17 Sin 需要发送 创建成果 MQ 消息 @@ -128,7 +142,7 @@ public class OrderServiceImpl implements OrderService { new OrderBO() .setId(orderDO.getId()) .setOrderNo(orderDO.getOrderNo()) - .setMoney(orderDO.getMoney()) + .setMoney(orderDO.getPrice()) ); } @@ -136,6 +150,9 @@ public class OrderServiceImpl implements OrderService { public CommonResult updateOrderItem(OrderItemUpdateDTO orderUpdateDTO) { OrderItemDO orderItemDO = OrderItemConvert.INSTANCE.convert(orderUpdateDTO); orderItemMapper.updateById(orderItemDO); + + // TODO: 2019-03-24 sin 需要重新计算金额 + // TODO: 2019-03-24 sin 需要记录日志 return CommonResult.success(null); } @@ -169,7 +186,7 @@ public class OrderServiceImpl implements OrderService { orderMapper.updateById( new OrderDO() .setId(orderId) - .setMoney(totalAmount) + .setPrice(totalAmount) ); return CommonResult.success(null); } 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 2f6655162..1ba0d39c7 100644 --- a/order/order-service-impl/src/main/resources/mapper/OrderMapper.xml +++ b/order/order-service-impl/src/main/resources/mapper/OrderMapper.xml @@ -3,7 +3,7 @@ - id, user_id, order_logistics_id, order_no, money, payment_time, + id, user_id, order_logistics_id, order_no, price, payment_time, delivery_time, receiver_time, closing_time, has_return_exchange, status, remark, create_time, update_time, `deleted` @@ -13,12 +13,12 @@ --> INSERT INTO `order` ( - user_id, order_logistics_id, order_no, money, payment_time, + user_id, order_logistics_id, order_no, price, payment_time, delivery_time, receiver_time, closing_time, has_return_exchange, status, remark, create_time, update_time, `deleted` ) VALUES ( - #{orderLogisticsId}, #{userId}, #{orderNo}, #{money}, #{paymentTime}, + #{orderLogisticsId}, #{userId}, #{orderNo}, #{price}, #{paymentTime}, #{deliveryTime}, #{receiverTime}, #{closingTime}, #{hasReturnExchange}, #{status}, #{remark}, #{createTime}, #{updateTime}, #{deleted} @@ -36,8 +36,8 @@ , order_no = #{orderNo} - - , money = #{money} + + , price = #{price} -- time @@ -97,22 +97,22 @@ 查询条件 --> - + AND `id` = #{id} - + AND `user_id` = #{userId} - + AND `order_logistics_id` = #{orderLogisticsId} - + AND `order_no` = #{orderNo} - + AND `has_return_exchange` = #{hasReturnExchange} - + AND `status` = #{status} @@ -124,7 +124,7 @@ SELECT COUNT(*) FROM `order` - WHERE + WHERE 1 = 1 @@ -135,9 +135,9 @@ SELECT FROM `order` - WHERE + WHERE 1 = 1 - LIMIT + LIMIT ${pageNo * pageSize}, ${pageSize}