From 0256a4da17916bb884f4d62b8765431ec95eaca6 Mon Sep 17 00:00:00 2001 From: sin <2943460818@qq.com> Date: Sat, 30 Mar 2019 21:31:06 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E6=B7=BB=E5=8A=A0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=87=91=E9=A2=9D=20-=20=E6=B7=BB=E5=8A=A0=E5=A4=87=E6=B3=A8?= =?UTF-8?q?=20-=20=E6=B7=BB=E5=8A=A0=E5=8F=96=E6=B6=88=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admins/AdminsOrderController.java | 16 ++++ .../application/vo/OrderPageQueryVO.java | 12 +++ .../mall/order/api/OrderReturnService.java | 21 ++++ .../iocoder/mall/order/api/OrderService.java | 21 +++- .../order/api/constant/ErrorCodeInterval.java | 4 +- .../api/constant/OrderCancelReasonsEnum.java | 54 +++++++++++ .../api/constant/OrderErrorCodeEnum.java | 15 ++- .../api/constant/OrderReturnStatusEnum.java | 41 ++++++++ .../api/constant/OrderReturnTypeEnum.java | 31 ++++++ .../order/api/dto/OrderReturnCreateDTO.java | 93 ++++++++++++++++++ .../mall/order/{ => biz}/OrderCommon.java | 4 +- .../mall/order/{ => biz}/OrderCommonImpl.java | 6 +- .../config/DatabaseConfiguration.java | 4 +- .../config/ServiceExceptionConfiguration.java | 2 +- .../constants/OrderExchangeReasonEnum.java | 2 +- .../constants/OrderReturnReasonEnum.java | 2 +- .../{ => biz}/constants/package-info.java | 2 +- .../order/{ => biz}/convert/OrderConvert.java | 4 +- .../{ => biz}/convert/OrderItemConvert.java | 4 +- .../convert/OrderLogisticsConvert.java | 4 +- .../order/biz/convert/OrderReturnConvert.java | 23 +++++ .../mall/order/biz/dao/OrderCancelMapper.java | 16 ++++ .../order/{ => biz}/dao/OrderItemMapper.java | 10 +- .../{ => biz}/dao/OrderLogisticsMapper.java | 4 +- .../mall/order/{ => biz}/dao/OrderMapper.java | 4 +- .../mall/order/biz/dao/OrderReturnMapper.java | 13 +++ .../order/biz/dataobject/OrderCancelDO.java | 95 +++++++++++++++++++ .../order/{ => biz}/dataobject/OrderDO.java | 20 ++-- .../{ => biz}/dataobject/OrderExchangeDO.java | 6 +- .../{ => biz}/dataobject/OrderItemDO.java | 2 +- .../dataobject/OrderLogisticsDO.java | 3 +- .../dataobject/OrderLogisticsDetailDO.java | 2 +- .../{ => biz}/dataobject/OrderReturnDO.java | 76 ++++++++++----- .../mall/order/{ => biz}/dataobject/README.md | 0 .../{ => biz}/mock/ProductSpuServiceMock.java | 2 +- .../mall/order/{ => biz}/package-info.java | 2 +- .../biz/service/OrderReturnServiceImpl.java | 39 ++++++++ .../{ => biz}/service/OrderServiceImpl.java | 81 +++++++++++++--- .../main/resources/config/application.yaml | 7 +- .../resources/mapper/OrderCancelMapper.xml | 22 +++++ .../main/resources/mapper/OrderItemMapper.xml | 21 ++-- .../resources/mapper/OrderLogisticsMapper.xml | 4 +- .../src/main/resources/mapper/OrderMapper.xml | 28 +++--- .../service/OrderServiceImplTest.java | 6 +- 44 files changed, 715 insertions(+), 113 deletions(-) create mode 100644 order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderReturnService.java create mode 100644 order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderCancelReasonsEnum.java create mode 100644 order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderReturnStatusEnum.java create mode 100644 order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderReturnTypeEnum.java create mode 100644 order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderReturnCreateDTO.java rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/OrderCommon.java (74%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/OrderCommonImpl.java (77%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/config/DatabaseConfiguration.java (79%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/config/ServiceExceptionConfiguration.java (94%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/constants/OrderExchangeReasonEnum.java (94%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/constants/OrderReturnReasonEnum.java (95%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/constants/package-info.java (66%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/convert/OrderConvert.java (81%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/convert/OrderItemConvert.java (88%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/convert/OrderLogisticsConvert.java (88%) create mode 100644 order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/convert/OrderReturnConvert.java create mode 100644 order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderCancelMapper.java rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/dao/OrderItemMapper.java (85%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/dao/OrderLogisticsMapper.java (87%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/dao/OrderMapper.java (91%) create mode 100644 order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderReturnMapper.java create mode 100644 order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderCancelDO.java rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/dataobject/OrderDO.java (94%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/dataobject/OrderExchangeDO.java (96%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/dataobject/OrderItemDO.java (99%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/dataobject/OrderLogisticsDO.java (95%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/dataobject/OrderLogisticsDetailDO.java (97%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/dataobject/OrderReturnDO.java (74%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/dataobject/README.md (100%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/mock/ProductSpuServiceMock.java (96%) rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/package-info.java (59%) create mode 100644 order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderReturnServiceImpl.java rename order/order-service-impl/src/main/java/cn/iocoder/mall/order/{ => biz}/service/OrderServiceImpl.java (79%) create mode 100644 order/order-service-impl/src/main/resources/mapper/OrderCancelMapper.xml rename order/order-service-impl/src/test/java/cn/iocoder/mall/order/{ => biz}/service/OrderServiceImplTest.java (92%) diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminsOrderController.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminsOrderController.java index 7bc20490..340a37ae 100644 --- a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminsOrderController.java +++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminsOrderController.java @@ -36,6 +36,22 @@ public class AdminsOrderController { return orderService.getOrderPage(orderQueryDTO); } + @PutMapping("update_remark") + @ApiOperation("更新-更新订单备注") + public CommonResult updateRemark(@RequestParam("orderId") Integer orderId, + @RequestParam("remark") String remark) { + return orderService.updateOrderRemake(orderId, remark); + } + + @PutMapping("cancel_order") + @ApiOperation("取消订单") + public CommonResult cancelOrder( + @RequestParam("orderId") Integer orderId, + @RequestParam("reasons") Integer reasons, + @RequestParam(value = "otherReasons", required = false) String otherReasons) { + return orderService.cancelOrder(orderId, reasons, otherReasons); + } + @PutMapping("order_item/update_pay_amount") @ApiOperation("更新-订单item实付金额") public CommonResult updateOrderItemPayAmount(@RequestParam("orderId") Integer orderId, diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/vo/OrderPageQueryVO.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/vo/OrderPageQueryVO.java index f6fd3c31..b790b766 100644 --- a/order/order-application/src/main/java/cn/iocoder/mall/order/application/vo/OrderPageQueryVO.java +++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/vo/OrderPageQueryVO.java @@ -59,6 +59,8 @@ public class OrderPageQueryVO implements Serializable { /** * 删除状态 */ + @ApiModelProperty("订单状态") + private Integer status; @ApiModelProperty("删除状态") private Integer deleted; @ApiModelProperty("分页pageNo") @@ -78,6 +80,7 @@ public class OrderPageQueryVO implements Serializable { ", endCreateTime=" + endCreateTime + ", startClosingTime=" + startClosingTime + ", endClosingTime=" + endClosingTime + + ", status=" + status + ", deleted=" + deleted + ", pageNo=" + pageNo + ", pageSize=" + pageSize + @@ -165,6 +168,15 @@ public class OrderPageQueryVO implements Serializable { return this; } + public Integer getStatus() { + return status; + } + + public OrderPageQueryVO setStatus(Integer status) { + this.status = status; + return this; + } + public Integer getDeleted() { return deleted; } diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderReturnService.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderReturnService.java new file mode 100644 index 00000000..e5406d4c --- /dev/null +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/OrderReturnService.java @@ -0,0 +1,21 @@ +package cn.iocoder.mall.order.api; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.order.api.dto.OrderReturnCreateDTO; + +/** + * 订单退货 + * + * @author Sin + * @time 2019-03-30 15:33 + */ +public interface OrderReturnService { + + /** + * 订单退货 - 创建 + * + * @param orderReturnCreate + * @return + */ + CommonResult createOrderReturn(OrderReturnCreateDTO orderReturnCreate); +} 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 601bd313..046d84c7 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 @@ -39,7 +39,7 @@ public interface OrderService { CommonResult updateOrderItem(OrderItemUpdateDTO orderItemUpdateDTO); /** - * 订单item - 更新 payAmount(实付金额) + * 更新订单item - payAmount(实付金额) * * @param orderId * @param orderItemId @@ -49,7 +49,24 @@ public interface OrderService { CommonResult updateOrderItemPayAmount(Integer orderId, Integer orderItemId, Integer payAmount); /** - * 订单item - 删除 + * 订单 - 取消订单 + * + * @param orderId + * @return + */ + CommonResult cancelOrder(Integer orderId, Integer reasons, String otherReasons); + + /** + * 更新订单 - 备注 + * + * @param orderId + * @param remake + * @return + */ + CommonResult updateOrderRemake(Integer orderId, String remake); + + /** + * 删除订单item * * @param orderItemDeletedDTO * @return diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/ErrorCodeInterval.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/ErrorCodeInterval.java index 139ac7a0..3a885e70 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/ErrorCodeInterval.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/ErrorCodeInterval.java @@ -5,13 +5,13 @@ import cn.iocoder.common.framework.constant.ModuleErrorCodeInterval; /** * 错误码区间 * - * 当前模块化区间:[1-000-001-000 ~ 1-000-002-000] + * 当前模块化区间:[1-008-000-000 ~ 1-008-000-000] * * @author Sin * @time 2019-03-23 11:35 */ public class ErrorCodeInterval extends ModuleErrorCodeInterval { - // OrderErrorCodeEnum 错误码区间 [1-000-001-000 ~ 1-000-001-100] + // OrderErrorCodeEnum 错误码区间 [1-008-000-000 ~ 1-008-000-000] } diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderCancelReasonsEnum.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderCancelReasonsEnum.java new file mode 100644 index 00000000..21967208 --- /dev/null +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderCancelReasonsEnum.java @@ -0,0 +1,54 @@ +package cn.iocoder.mall.order.api.constant; + +/** + * 订单取消原因 + * order_cancel_reasons + * @author Sin + * @time 2019-03-30 15:08 + */ +public enum OrderCancelReasonsEnum { + + CANCEL_1(1, "无法联系上买家"), + CANCEL_2(2, "买家误拍或重拍了"), + CANCEL_3(3, "买家无诚意完成交易"), + CANCEL_4(4, "已通过银行线下汇款"), + CANCEL_5(5, "已通过同城见面交易"), + CANCEL_6(6, "已通过货到付款交易"), + CANCEL_7(7, "已通过网上银行直接汇款"), + CANCEL_8(8, "已经缺货无法交易"), + CANCEL_20(20, "其他"), + ; + + // 无法联系上买家 + // 买家误拍或重拍了 + // 买家无诚意完成交易 + // 已通过银行线下汇款 + // 已通过同城见面交易 + // 已通过货到付款交易 + // 已通过网上银行直接汇款 + // 已经缺货无法交易 + + private final int code; + private final String message; + + OrderCancelReasonsEnum(int code, String message) { + this.code = code; + this.message = message; + } + + @Override + public String toString() { + return "OrderCancelEnum{" + + "code=" + code + + ", message='" + message + '\'' + + '}'; + } + + public int getCode() { + return code; + } + + public String getMessage() { + return message; + } +} 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 4d9f13a8..5d90b102 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 @@ -3,17 +3,22 @@ package cn.iocoder.mall.order.api.constant; /** * 订单错误码 * - * 错误码区间 [1-000-001-000 ~ 1-000-002-000] + * 错误码区间 [1-008-000-000 ~ 1-008-000-000] * * @author Sin * @time 2019-03-23 11:23 */ public enum OrderErrorCodeEnum { - ORDER_ITEM_ONLY_ONE(1000001000, "订单Item只有一个!"), - ORDER_GET_SKU_FAIL(1000001001, "获取商品失败!"), - ORDER_GET_SKU_NOT_EXISTENT(1000001002, "获取的商品不存在!"), - ORDER_PAY_AMOUNT_NOT_NEGATIVE(1000001002, "支付金额不能为负数!"), + // order + ORDER_NOT_EXISTENT(1008000000, "获取订单不存在!"), + ORDER_GET_SKU_FAIL(1008000001, "获取商品失败!"), + ORDER_GET_SKU_NOT_EXISTENT(1008000002, "获取的商品不存在!"), + ORDER_PAY_AMOUNT_NOT_NEGATIVE(1008000003, "支付金额不能为负数!"), + ORDER_STATUS_NOT_CANCEL(1008000004, "订单状态不能取消"), + + // order item + ORDER_ITEM_ONLY_ONE(1008000004, "订单Item只有一个!"), ; private final int code; diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderReturnStatusEnum.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderReturnStatusEnum.java new file mode 100644 index 00000000..ef59a92f --- /dev/null +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderReturnStatusEnum.java @@ -0,0 +1,41 @@ +package cn.iocoder.mall.order.api.constant; + +/** + * 订单退货 status + * + * @author Sin + * @time 2019-03-30 15:56 + */ +public enum OrderReturnStatusEnum { + + /** + * 状态 + * + * - 1、退货申请 + * - 2、申请成功 + * - 3、申请失败 + * - 4、退货中 + * - 5、退货成功 + */ + RETURN_APPLICATION(1, "退货申请"), + APPLICATION_SUCCESSFUL(1, "申请成功"), + APPLICATION_FAIL(1, "申请失败"), + ; + private final int value; + + private final String name; + + OrderReturnStatusEnum(int value, String name) { + this.value = value; + this.name = name; + } + + public int getValue() { + return value; + } + + public String getName() { + return name; + } + +} diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderReturnTypeEnum.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderReturnTypeEnum.java new file mode 100644 index 00000000..e4e72a5d --- /dev/null +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderReturnTypeEnum.java @@ -0,0 +1,31 @@ +package cn.iocoder.mall.order.api.constant; + +/** + * 订单退货 类型 + * + * @author Sin + * @time 2019-03-30 15:42 + */ +public enum OrderReturnTypeEnum { + + ORDER(1, "订单"), + ORDER_ITEM(2, "订单item"), + ; + + private final int value; + + private final String name; + + OrderReturnTypeEnum(int value, String name) { + this.value = value; + this.name = name; + } + + public int getValue() { + return value; + } + + public String getName() { + return name; + } +} diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderReturnCreateDTO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderReturnCreateDTO.java new file mode 100644 index 00000000..8c82d921 --- /dev/null +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/dto/OrderReturnCreateDTO.java @@ -0,0 +1,93 @@ +package cn.iocoder.mall.order.api.dto; + +import java.io.Serializable; +import java.util.Date; + +/** + * 订单退货 - 创建 + * + * @author Sin + * @time 2019-03-30 15:34 + */ +public class OrderReturnCreateDTO implements Serializable { + + /** + * 订单编号 + */ + private Integer orderId; + /** + * 订单 item 编号 + */ + private Integer orderItemId; + /** + * 退货原因(字典值) + */ + private Integer orderReason; + /** + * 原因(如果选择其他,原因保存在这) + */ + private String otherReasons; + /** + * 订单类型 + * + * - 0、为 Order 订单 (对整个订单退货) + * - 1、为 OrderItem 订单 (对订单某一个商品退货) + */ + private Integer orderType; + + @Override + public String toString() { + return "OrderReturnCreateDTO{" + + "orderId=" + orderId + + ", orderItemId=" + orderItemId + + ", orderReason=" + orderReason + + ", otherReasons='" + otherReasons + '\'' + + ", orderType=" + orderType + + '}'; + } + + public Integer getOrderId() { + return orderId; + } + + public OrderReturnCreateDTO setOrderId(Integer orderId) { + this.orderId = orderId; + return this; + } + + public Integer getOrderItemId() { + return orderItemId; + } + + public OrderReturnCreateDTO setOrderItemId(Integer orderItemId) { + this.orderItemId = orderItemId; + return this; + } + + public Integer getOrderReason() { + return orderReason; + } + + public OrderReturnCreateDTO setOrderReason(Integer orderReason) { + this.orderReason = orderReason; + return this; + } + + public String getOtherReasons() { + return otherReasons; + } + + public OrderReturnCreateDTO setOtherReasons(String otherReasons) { + this.otherReasons = otherReasons; + return this; + } + + public Integer getOrderType() { + return orderType; + } + + public OrderReturnCreateDTO setOrderType(Integer orderType) { + this.orderType = orderType; + return this; + } +} diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/OrderCommon.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/OrderCommon.java similarity index 74% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/OrderCommon.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/OrderCommon.java index 9a732857..df28d22e 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/OrderCommon.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/OrderCommon.java @@ -1,6 +1,6 @@ -package cn.iocoder.mall.order; +package cn.iocoder.mall.order.biz; -import cn.iocoder.mall.order.dataobject.OrderItemDO; +import cn.iocoder.mall.order.biz.dataobject.OrderItemDO; import java.util.List; diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/OrderCommonImpl.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/OrderCommonImpl.java similarity index 77% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/OrderCommonImpl.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/OrderCommonImpl.java index eeaac3c9..b3e9fdc1 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/OrderCommonImpl.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/OrderCommonImpl.java @@ -1,6 +1,6 @@ -package cn.iocoder.mall.order; +package cn.iocoder.mall.order.biz; -import cn.iocoder.mall.order.dataobject.OrderItemDO; +import cn.iocoder.mall.order.biz.dataobject.OrderItemDO; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -23,7 +23,7 @@ public class OrderCommonImpl implements OrderCommon { } AtomicInteger totalAmount = new AtomicInteger(0); items.forEach(orderItemDO -> { - totalAmount.addAndGet(orderItemDO.getPrice() * orderItemDO.getQuantity()); + totalAmount.addAndGet(orderItemDO.getPayAmount() * orderItemDO.getQuantity()); }); return totalAmount.get(); } 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/biz/config/DatabaseConfiguration.java similarity index 79% 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/biz/config/DatabaseConfiguration.java index 42cc4659..1475b5a4 100644 --- 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/biz/config/DatabaseConfiguration.java @@ -1,11 +1,11 @@ -package cn.iocoder.mall.order.config; +package cn.iocoder.mall.order.biz.config; import org.mybatis.spring.annotation.MapperScan; import org.springframework.context.annotation.Configuration; import org.springframework.transaction.annotation.EnableTransactionManagement; @Configuration -@MapperScan("cn.iocoder.mall.order.dao") // 扫描对应的 Mapper 接口 +@MapperScan("cn.iocoder.mall.order.biz.dao") // 扫描对应的 Mapper 接口 @EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理。为什么使用 proxyTargetClass 参数,参见 https://blog.csdn.net/huang_550/article/details/76492600 public class DatabaseConfiguration { 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/biz/config/ServiceExceptionConfiguration.java similarity index 94% 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/biz/config/ServiceExceptionConfiguration.java index 14e361d0..0a1a466f 100644 --- 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/biz/config/ServiceExceptionConfiguration.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.config; +package cn.iocoder.mall.order.biz.config; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.annotation.Configuration; diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/constants/OrderExchangeReasonEnum.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/constants/OrderExchangeReasonEnum.java similarity index 94% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/constants/OrderExchangeReasonEnum.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/constants/OrderExchangeReasonEnum.java index a8387941..b1444a4c 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/constants/OrderExchangeReasonEnum.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/constants/OrderExchangeReasonEnum.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.constants; +package cn.iocoder.mall.order.biz.constants; /** * 订单换货原因 diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/constants/OrderReturnReasonEnum.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/constants/OrderReturnReasonEnum.java similarity index 95% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/constants/OrderReturnReasonEnum.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/constants/OrderReturnReasonEnum.java index 6e675189..b8335d9d 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/constants/OrderReturnReasonEnum.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/constants/OrderReturnReasonEnum.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.constants; +package cn.iocoder.mall.order.biz.constants; /** * 订单退货原因 diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/constants/package-info.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/constants/package-info.java similarity index 66% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/constants/package-info.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/constants/package-info.java index 5d683d05..ec085dee 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/constants/package-info.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/constants/package-info.java @@ -4,4 +4,4 @@ * @author Sin * @time 2019-03-20 21:16 */ -package cn.iocoder.mall.order.constants; \ No newline at end of file +package cn.iocoder.mall.order.biz.constants; \ No newline at end of file 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/biz/convert/OrderConvert.java similarity index 81% 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/biz/convert/OrderConvert.java index 1d7efb04..cf375c95 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/biz/convert/OrderConvert.java @@ -1,7 +1,7 @@ -package cn.iocoder.mall.order.convert; +package cn.iocoder.mall.order.biz.convert; import cn.iocoder.mall.order.api.bo.OrderBO; -import cn.iocoder.mall.order.dataobject.OrderDO; +import cn.iocoder.mall.order.biz.dataobject.OrderDO; import org.mapstruct.Mapper; import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; 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/biz/convert/OrderItemConvert.java similarity index 88% 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/biz/convert/OrderItemConvert.java index f9036843..9f88cf20 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/biz/convert/OrderItemConvert.java @@ -1,9 +1,9 @@ -package cn.iocoder.mall.order.convert; +package cn.iocoder.mall.order.biz.convert; import cn.iocoder.mall.order.api.dto.OrderCreateItemDTO; import cn.iocoder.mall.order.api.bo.OrderItemBO; import cn.iocoder.mall.order.api.dto.OrderItemUpdateDTO; -import cn.iocoder.mall.order.dataobject.OrderItemDO; +import cn.iocoder.mall.order.biz.dataobject.OrderItemDO; import org.mapstruct.Mapper; import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; 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/biz/convert/OrderLogisticsConvert.java similarity index 88% 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/biz/convert/OrderLogisticsConvert.java index 1eecb7f5..712b540a 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/biz/convert/OrderLogisticsConvert.java @@ -1,9 +1,9 @@ -package cn.iocoder.mall.order.convert; +package cn.iocoder.mall.order.biz.convert; import cn.iocoder.mall.order.api.bo.OrderLogisticsBO; import cn.iocoder.mall.order.api.dto.OrderCreateDTO; import cn.iocoder.mall.order.api.dto.OrderLogisticsUpdateDTO; -import cn.iocoder.mall.order.dataobject.OrderLogisticsDO; +import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDO; import org.mapstruct.Mapper; import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/convert/OrderReturnConvert.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/convert/OrderReturnConvert.java new file mode 100644 index 00000000..87e75562 --- /dev/null +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/convert/OrderReturnConvert.java @@ -0,0 +1,23 @@ +package cn.iocoder.mall.order.biz.convert; + +import cn.iocoder.mall.order.api.dto.OrderCreateDTO; +import cn.iocoder.mall.order.api.dto.OrderReturnCreateDTO; +import cn.iocoder.mall.order.biz.dataobject.OrderReturnDO; +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +/** + * 订单 return + * + * @author Sin + * @time 2019-03-30 15:46 + */ +@Mapper +public interface OrderReturnConvert { + + OrderReturnConvert INSTANCE = Mappers.getMapper(OrderReturnConvert.class); + + @Mappings({}) + OrderReturnDO convert(OrderReturnCreateDTO orderReturnCreate); +} diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderCancelMapper.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderCancelMapper.java new file mode 100644 index 00000000..31a89df9 --- /dev/null +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderCancelMapper.java @@ -0,0 +1,16 @@ +package cn.iocoder.mall.order.biz.dao; + +import cn.iocoder.mall.order.biz.dataobject.OrderCancelDO; +import org.springframework.stereotype.Repository; + +/** + * 订单取消 mapper + * + * @author Sin + * @time 2019-03-30 16:27 + */ +@Repository +public interface OrderCancelMapper { + + int insert(OrderCancelDO orderCancelDO); +} diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderItemMapper.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderItemMapper.java similarity index 85% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderItemMapper.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderItemMapper.java index 6441accd..e60cace4 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderItemMapper.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderItemMapper.java @@ -1,6 +1,6 @@ -package cn.iocoder.mall.order.dao; +package cn.iocoder.mall.order.biz.dao; -import cn.iocoder.mall.order.dataobject.OrderItemDO; +import cn.iocoder.mall.order.biz.dataobject.OrderItemDO; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; @@ -31,6 +31,12 @@ public interface OrderItemMapper { */ void updateById(OrderItemDO orderItemDO); + /** + * 更新 - 根据 orderId + * @param orderItemDO + */ + void updateByOrderId(OrderItemDO orderItemDO); + /** * 更新 - 根据Ids * 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/biz/dao/OrderLogisticsMapper.java similarity index 87% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderLogisticsMapper.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderLogisticsMapper.java index 67cd0cb9..c54d94fd 100644 --- 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/biz/dao/OrderLogisticsMapper.java @@ -1,6 +1,6 @@ -package cn.iocoder.mall.order.dao; +package cn.iocoder.mall.order.biz.dao; -import cn.iocoder.mall.order.dataobject.OrderLogisticsDO; +import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDO; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; 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/biz/dao/OrderMapper.java similarity index 91% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/dao/OrderMapper.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderMapper.java index 6bc8c87a..0488614c 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/biz/dao/OrderMapper.java @@ -1,7 +1,7 @@ -package cn.iocoder.mall.order.dao; +package cn.iocoder.mall.order.biz.dao; import cn.iocoder.mall.order.api.dto.OrderQueryDTO; -import cn.iocoder.mall.order.dataobject.OrderDO; +import cn.iocoder.mall.order.biz.dataobject.OrderDO; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderReturnMapper.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderReturnMapper.java new file mode 100644 index 00000000..cdf6db50 --- /dev/null +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderReturnMapper.java @@ -0,0 +1,13 @@ +package cn.iocoder.mall.order.biz.dao; + +import org.springframework.stereotype.Repository; + +/** + * 订单退货 mapper + * + * @author Sin + * @time 2019-03-30 15:36 + */ +@Repository +public interface OrderReturnMapper { +} diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderCancelDO.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderCancelDO.java new file mode 100644 index 00000000..cf860b35 --- /dev/null +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderCancelDO.java @@ -0,0 +1,95 @@ +package cn.iocoder.mall.order.biz.dataobject; + +import cn.iocoder.common.framework.dataobject.BaseDO; + +import java.io.Serializable; + +/** + * 订单关闭 + * + * - 注意:订单只有在用户为付款前取消。 + * + * - 取消订单,这里是取消整个订单,不能对订单 item 单独做取消 + * + * @author Sin + * @time 2019-03-30 16:20 + */ +public class OrderCancelDO extends BaseDO { + + /** + * id + */ + private Integer id; + /** + * 订单id + */ + private Integer orderId; + /** + * 订单编号 + */ + private String orderNo; + /** + * 关闭订单原因(字典) + */ + private Integer reason; + /** + * 原因(如果选择其他,原因保存在这) + */ + private String otherReason; + + @Override + public String toString() { + return "OrderCancelDO{" + + "id=" + id + + ", orderId=" + orderId + + ", orderNo='" + orderNo + '\'' + + ", reason=" + reason + + ", otherReason='" + otherReason + '\'' + + '}'; + } + + public Integer getId() { + return id; + } + + public OrderCancelDO setId(Integer id) { + this.id = id; + return this; + } + + public Integer getOrderId() { + return orderId; + } + + public OrderCancelDO setOrderId(Integer orderId) { + this.orderId = orderId; + return this; + } + + public String getOrderNo() { + return orderNo; + } + + public OrderCancelDO setOrderNo(String orderNo) { + this.orderNo = orderNo; + return this; + } + + public Integer getReason() { + return reason; + } + + public OrderCancelDO setReason(Integer reason) { + this.reason = reason; + return this; + } + + public String getOtherReason() { + return otherReason; + } + + public OrderCancelDO setOtherReason(String otherReason) { + this.otherReason = otherReason; + return this; + } +} 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/biz/dataobject/OrderDO.java similarity index 94% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderDO.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderDO.java index 6fe64183..59440115 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/biz/dataobject/OrderDO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.dataobject; +package cn.iocoder.mall.order.biz.dataobject; import cn.iocoder.common.framework.dataobject.DeletableDO; @@ -59,20 +59,20 @@ public class OrderDO extends DeletableDO { /** * 是否退货 * - * - 0、没有 - * - 1、换货 - * - 2、退货 - * - 3、换货 + 退货 + * - 1、没有 + * - 2、换货 + * - 3、退货 + * - 4、换货 + 退货 */ private Integer hasReturnExchange; /** * 状态(如果有多个商品分开发货需要全部商品发完才会改变状态) * - * - 0、待付款 - * - 1、待发货 - * - 2、待收获 - * - 3、已完成 - * - 4、已关闭 + * - 1、待付款 + * - 2、待发货 + * - 3、待收获 + * - 4、已完成 + * - 5、已关闭 */ private Integer status; /** 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/biz/dataobject/OrderExchangeDO.java similarity index 96% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderExchangeDO.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderExchangeDO.java index afa1120a..cdee3208 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/biz/dataobject/OrderExchangeDO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.dataobject; +package cn.iocoder.mall.order.biz.dataobject; import cn.iocoder.common.framework.dataobject.DeletableDO; @@ -51,13 +51,13 @@ public class OrderExchangeDO extends DeletableDO { /** * 原因 (关联字典) * - * {@link cn.iocoder.mall.order.constants.OrderExchangeReasonEnum} + * {@link cn.iocoder.mall.order.biz.constants.OrderExchangeReasonEnum} */ private Integer orderReasonId; /** * 原因(如果选择其他,原因保存在这) * - * {@link cn.iocoder.mall.order.constants.OrderExchangeReasonEnum#REASON_000} + * {@link cn.iocoder.mall.order.biz.constants.OrderExchangeReasonEnum#REASON_000} */ private String reason; 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/biz/dataobject/OrderItemDO.java similarity index 99% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderItemDO.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderItemDO.java index 20132cdd..e1a9cd35 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/biz/dataobject/OrderItemDO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.dataobject; +package cn.iocoder.mall.order.biz.dataobject; import cn.iocoder.common.framework.dataobject.DeletableDO; diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderLogisticsDO.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderLogisticsDO.java similarity index 95% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderLogisticsDO.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderLogisticsDO.java index c15c22f8..e5485e65 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderLogisticsDO.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderLogisticsDO.java @@ -1,7 +1,6 @@ -package cn.iocoder.mall.order.dataobject; +package cn.iocoder.mall.order.biz.dataobject; import cn.iocoder.common.framework.dataobject.BaseDO; -import cn.iocoder.common.framework.dataobject.DeletableDO; /** * 订单物流信息 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/biz/dataobject/OrderLogisticsDetailDO.java similarity index 97% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderLogisticsDetailDO.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderLogisticsDetailDO.java index 63da1607..838ab122 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/biz/dataobject/OrderLogisticsDetailDO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.dataobject; +package cn.iocoder.mall.order.biz.dataobject; import cn.iocoder.common.framework.dataobject.DeletableDO; 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/biz/dataobject/OrderReturnDO.java similarity index 74% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/OrderReturnDO.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/OrderReturnDO.java index fad77ce6..20fa6dab 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/biz/dataobject/OrderReturnDO.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.dataobject; +package cn.iocoder.mall.order.biz.dataobject; import cn.iocoder.common.framework.dataobject.DeletableDO; @@ -31,7 +31,15 @@ public class OrderReturnDO extends DeletableDO { /** * 商品编号(保存一个冗余,如果一个订单下存在多个商品,会有很大的作用) */ - private String skuId; + private Integer skuId; + /** + * 商品名称 + */ + private String skuName; + /** + * 商品图片 + */ + private String skuImage; /** * 物流id */ @@ -43,15 +51,15 @@ public class OrderReturnDO extends DeletableDO { /** * 退货原因(字典值) * - * {@link cn.iocoder.mall.order.constants.OrderReturnReasonEnum} + * {@link cn.iocoder.mall.order.biz.constants.OrderReturnReasonEnum} */ - private Integer orderReasonId; + private Integer orderReason; /** * 原因(如果选择其他,原因保存在这) * - * {@link cn.iocoder.mall.order.constants.OrderReturnReasonEnum#REASON_000} + * {@link cn.iocoder.mall.order.biz.constants.OrderReturnReasonEnum#REASON_000} */ - private String reason; + private String otherReasons; /// /// 时间信息 @@ -90,11 +98,11 @@ public class OrderReturnDO extends DeletableDO { /** * 状态 * - * - 0、退货申请 - * - 1、申请成功 - * - 2、申请失败 - * - 3、退货中 - * - 4、退货成功 + * - 1、退货申请 + * - 2、申请成功 + * - 3、申请失败 + * - 4、退货中 + * - 5、退货成功 */ private Integer status; @@ -105,10 +113,12 @@ public class OrderReturnDO extends DeletableDO { ", orderId=" + orderId + ", orderNo='" + orderNo + '\'' + ", orderItemId=" + orderItemId + - ", skuId='" + skuId + '\'' + + ", skuId=" + skuId + + ", skuName='" + skuName + '\'' + + ", skuImage='" + skuImage + '\'' + ", orderLogisticsId=" + orderLogisticsId + - ", orderReasonId=" + orderReasonId + - ", reason='" + reason + '\'' + + ", orderReason=" + orderReason + + ", otherReasons='" + otherReasons + '\'' + ", createTime=" + createTime + ", approvalTime=" + approvalTime + ", logisticsTime=" + logisticsTime + @@ -155,15 +165,33 @@ public class OrderReturnDO extends DeletableDO { return this; } - public String getSkuId() { + public Integer getSkuId() { return skuId; } - public OrderReturnDO setSkuId(String skuId) { + public OrderReturnDO setSkuId(Integer skuId) { this.skuId = skuId; return this; } + public String getSkuName() { + return skuName; + } + + public OrderReturnDO setSkuName(String skuName) { + this.skuName = skuName; + return this; + } + + public String getSkuImage() { + return skuImage; + } + + public OrderReturnDO setSkuImage(String skuImage) { + this.skuImage = skuImage; + return this; + } + public Integer getOrderLogisticsId() { return orderLogisticsId; } @@ -173,21 +201,21 @@ public class OrderReturnDO extends DeletableDO { return this; } - public Integer getOrderReasonId() { - return orderReasonId; + public Integer getOrderReason() { + return orderReason; } - public OrderReturnDO setOrderReasonId(Integer orderReasonId) { - this.orderReasonId = orderReasonId; + public OrderReturnDO setOrderReason(Integer orderReason) { + this.orderReason = orderReason; return this; } - public String getReason() { - return reason; + public String getOtherReasons() { + return otherReasons; } - public OrderReturnDO setReason(String reason) { - this.reason = reason; + public OrderReturnDO setOtherReasons(String otherReasons) { + this.otherReasons = otherReasons; return this; } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/README.md b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/README.md similarity index 100% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/dataobject/README.md rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dataobject/README.md 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/biz/mock/ProductSpuServiceMock.java similarity index 96% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/mock/ProductSpuServiceMock.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/mock/ProductSpuServiceMock.java index cbc3aeaf..fc72c309 100644 --- 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/biz/mock/ProductSpuServiceMock.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.mock; +package cn.iocoder.mall.order.biz.mock; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.product.api.ProductSpuService; 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/biz/package-info.java similarity index 59% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/package-info.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/package-info.java index 3e032413..28901599 100644 --- 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/biz/package-info.java @@ -2,4 +2,4 @@ * @author Sin * @time 2019-03-16 13:49 */ -package cn.iocoder.mall.order; \ No newline at end of file +package cn.iocoder.mall.order.biz; \ No newline at end of file diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderReturnServiceImpl.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderReturnServiceImpl.java new file mode 100644 index 00000000..b57eecbf --- /dev/null +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderReturnServiceImpl.java @@ -0,0 +1,39 @@ +package cn.iocoder.mall.order.biz.service; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.order.api.OrderReturnService; +import cn.iocoder.mall.order.api.constant.OrderReturnStatusEnum; +import cn.iocoder.mall.order.api.dto.OrderReturnCreateDTO; +import cn.iocoder.mall.order.biz.convert.OrderReturnConvert; +import cn.iocoder.mall.order.biz.dao.OrderReturnMapper; +import cn.iocoder.mall.order.biz.dataobject.OrderReturnDO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; + +/** + * 订单退货 service + * + * @author Sin + * @time 2019-03-30 15:35 + */ +@Service +public class OrderReturnServiceImpl implements OrderReturnService { + + @Autowired + private OrderReturnMapper orderReturnMapper; + + @Override + public CommonResult createOrderReturn(OrderReturnCreateDTO orderReturnCreate) { + + + + OrderReturnDO orderReturnDO = OrderReturnConvert.INSTANCE.convert(orderReturnCreate); + orderReturnDO + .setCreateTime(new Date()) + .setStatus(OrderReturnStatusEnum.RETURN_APPLICATION.getValue()); + + 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/biz/service/OrderServiceImpl.java similarity index 79% rename from order/order-service-impl/src/main/java/cn/iocoder/mall/order/service/OrderServiceImpl.java rename to order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderServiceImpl.java index cee0b522..d7e6f3ed 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/biz/service/OrderServiceImpl.java @@ -1,24 +1,26 @@ -package cn.iocoder.mall.order.service; +package cn.iocoder.mall.order.biz.service; import cn.iocoder.common.framework.constant.DeletedStatusEnum; import cn.iocoder.common.framework.util.ServiceExceptionUtil; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.order.OrderCommon; import cn.iocoder.mall.order.api.OrderService; import cn.iocoder.mall.order.api.bo.*; 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.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.order.biz.OrderCommon; +import cn.iocoder.mall.order.biz.convert.OrderConvert; +import cn.iocoder.mall.order.biz.convert.OrderItemConvert; +import cn.iocoder.mall.order.biz.convert.OrderLogisticsConvert; +import cn.iocoder.mall.order.biz.dao.OrderCancelMapper; +import cn.iocoder.mall.order.biz.dao.OrderItemMapper; +import cn.iocoder.mall.order.biz.dao.OrderLogisticsMapper; +import cn.iocoder.mall.order.biz.dao.OrderMapper; +import cn.iocoder.mall.order.biz.dataobject.OrderCancelDO; +import cn.iocoder.mall.order.biz.dataobject.OrderDO; +import cn.iocoder.mall.order.biz.dataobject.OrderItemDO; +import cn.iocoder.mall.order.biz.dataobject.OrderLogisticsDO; import com.google.common.collect.Lists; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -45,6 +47,8 @@ public class OrderServiceImpl implements OrderService { @Autowired private OrderLogisticsMapper orderLogisticsMapper; @Autowired + private OrderCancelMapper orderCancelMapper; + @Autowired private OrderCommon orderCommon; @Override @@ -52,7 +56,7 @@ public class OrderServiceImpl implements OrderService { int totalCount = orderMapper.selectPageCount(orderQueryDTO); if (totalCount == 0) { - return CommonResult.success(new OrderPageBO().setTotal(0)); + return CommonResult.success(new OrderPageBO().setOrders(Collections.EMPTY_LIST).setTotal(0)); } // 获取订单数据 @@ -212,10 +216,18 @@ public class OrderServiceImpl implements OrderService { @Override @Transactional public CommonResult updateOrderItemPayAmount(Integer orderId, Integer orderItemId, Integer payAmount) { + OrderDO orderDO = orderMapper.selectById(orderId); + if (orderDO == null) { + return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode()); + } if (payAmount < 0) { return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_PAY_AMOUNT_NOT_NEGATIVE.getCode()); } + + // 先更新金额 orderItemMapper.updateById(new OrderItemDO().setId(orderItemId).setPayAmount(payAmount)); + + // 再重新计算订单金额 List orderItemDOList = orderItemMapper.selectByOrderIdAndDeleted(orderId, DeletedStatusEnum.DELETED_NO.getValue()); Integer orderPayAmount = orderCommon.calculatedAmount(orderItemDOList); orderMapper.updateById(new OrderDO().setId(orderId).setPayAmount(orderPayAmount)); @@ -223,6 +235,51 @@ public class OrderServiceImpl implements OrderService { } @Override + @Transactional + public CommonResult cancelOrder(Integer orderId, Integer reason, String otherReason) { + // 关闭订单,在用户还未付款的时候可操作 + OrderDO orderDO = orderMapper.selectById(orderId); + if (orderDO == null) { + return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_NOT_EXISTENT.getCode()); + } + + // 检查专题,只有待付款状态才能操作 + if (!orderDO.getStatus().equals(OrderStatusEnum.WAITING_PAYMENT.getValue())) { + return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_STATUS_NOT_CANCEL.getCode()); + } + + OrderCancelDO orderCancelDO + = (OrderCancelDO) new OrderCancelDO() + .setOrderId(orderDO.getId()) + .setOrderNo(orderDO.getOrderNo()) + .setReason(reason) + .setOtherReason(otherReason) + .setCreateTime(new Date()) + .setUpdateTime(null); + + // 关闭订单,修改状态 item + orderItemMapper.updateByOrderId( + new OrderItemDO() + .setOrderId(orderId) + .setStatus(OrderStatusEnum.CLOSED.getValue()) + ); + + // 关闭订单,修改状态 order + orderMapper.updateById(new OrderDO().setId(orderId).setStatus(OrderStatusEnum.CLOSED.getValue())); + // 保存取消订单原因 + orderCancelMapper.insert(orderCancelDO); + return CommonResult.success(null); + } + + @Override + public CommonResult updateOrderRemake(Integer orderId, String remake) { + // 此处不做订单校验,直接设置备注即可 + orderMapper.updateById(new OrderDO().setId(orderId).setRemark(remake)); + return CommonResult.success(null); + } + + @Override + @Transactional public CommonResult deleteOrderItem(OrderItemDeletedDTO orderItemDeletedDTO) { Integer orderId = orderItemDeletedDTO.getOrderId(); List orderItemIds = orderItemDeletedDTO.getOrderItemIds(); diff --git a/order/order-service-impl/src/main/resources/config/application.yaml b/order/order-service-impl/src/main/resources/config/application.yaml index 378b0868..b0648b4e 100644 --- a/order/order-service-impl/src/main/resources/config/application.yaml +++ b/order/order-service-impl/src/main/resources/config/application.yaml @@ -10,7 +10,7 @@ spring: mybatis: config-location: classpath:mybatis-config.xml mapper-locations: classpath:mapper/*.xml - type-aliases-package: cn.iocoder.mall.order.dataobject + type-aliases-package: cn.iocoder.mall.order.biz.dataobject # dubbo dubbo: @@ -22,9 +22,10 @@ dubbo: port: -1 name: dubbo scan: - base-packages: cn.iocoder.mall.order.service + base-packages: cn.iocoder.mall.order.biz.service # logging logging: level: - cn.iocoder.mall.order.dao: debug + # dao 开启 debug 模式 mybatis 输入 sql + cn.iocoder.mall.order.biz.dao: debug diff --git a/order/order-service-impl/src/main/resources/mapper/OrderCancelMapper.xml b/order/order-service-impl/src/main/resources/mapper/OrderCancelMapper.xml new file mode 100644 index 00000000..cb7faca2 --- /dev/null +++ b/order/order-service-impl/src/main/resources/mapper/OrderCancelMapper.xml @@ -0,0 +1,22 @@ + + + + + + id, order_id, order_no, reason, other_reason, + create_time, update_time + + + + + INSERT INTO `order_cancel` ( + order_id, order_no, reason, other_reason, + create_time, update_time + ) VALUES ( + #{orderId}, #{orderNo}, #{reason}, #{otherReason}, + #{createTime}, #{updateTime} + ) + + diff --git a/order/order-service-impl/src/main/resources/mapper/OrderItemMapper.xml b/order/order-service-impl/src/main/resources/mapper/OrderItemMapper.xml index 8d88c3fc..e1c3a0a3 100644 --- a/order/order-service-impl/src/main/resources/mapper/OrderItemMapper.xml +++ b/order/order-service-impl/src/main/resources/mapper/OrderItemMapper.xml @@ -1,6 +1,6 @@ - + id, order_id, order_no, sku_id, sku_name, sku_image, quantity, price, pay_amount, @@ -106,10 +106,19 @@ - - SELECT * FROM `order_item` WHERE 1=1 @@ -123,7 +132,7 @@ - SELECT FROM `order_item` diff --git a/order/order-service-impl/src/main/resources/mapper/OrderLogisticsMapper.xml b/order/order-service-impl/src/main/resources/mapper/OrderLogisticsMapper.xml index a9104007..71c0b78d 100644 --- a/order/order-service-impl/src/main/resources/mapper/OrderLogisticsMapper.xml +++ b/order/order-service-impl/src/main/resources/mapper/OrderLogisticsMapper.xml @@ -1,6 +1,6 @@ - + id, area_no, `name`, mobile, address, logistics_no, create_time, update_time @@ -53,7 +53,7 @@ - SELECT FROM `order_logistics` 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 dcdef4d5..d1b8e51c 100644 --- a/order/order-service-impl/src/main/resources/mapper/OrderMapper.xml +++ b/order/order-service-impl/src/main/resources/mapper/OrderMapper.xml @@ -1,6 +1,6 @@ - + id, user_id, order_logistics_id, order_no, pay_amount, payment_time, @@ -39,7 +39,7 @@ , pay_amount = #{payAmount} --- time + , payment_time = #{paymentTime} @@ -55,7 +55,7 @@ , has_return_exchange = #{hasReturnExchange} --- other + , status = #{status} @@ -86,7 +86,7 @@ - SELECT FROM `order` @@ -94,26 +94,30 @@ - - AND `id` = #{id} + + AND `status` = #{status} AND `user_id` = #{userId} - - AND `order_logistics_id` = #{orderLogisticsId} + + AND `id` = #{id} AND `order_no` = #{orderNo} + + AND `order_logistics_id` = #{orderLogisticsId} + AND `has_return_exchange` = #{hasReturnExchange} - - AND `status` = #{status} + + AND `create_time` >= #{startCreateTime} + AND `create_time` <= #{endCreateTime} @@ -131,7 +135,7 @@ - SELECT FROM `order` diff --git a/order/order-service-impl/src/test/java/cn/iocoder/mall/order/service/OrderServiceImplTest.java b/order/order-service-impl/src/test/java/cn/iocoder/mall/order/biz/service/OrderServiceImplTest.java similarity index 92% rename from order/order-service-impl/src/test/java/cn/iocoder/mall/order/service/OrderServiceImplTest.java rename to order/order-service-impl/src/test/java/cn/iocoder/mall/order/biz/service/OrderServiceImplTest.java index f1bb5a29..784a7ed2 100644 --- a/order/order-service-impl/src/test/java/cn/iocoder/mall/order/service/OrderServiceImplTest.java +++ b/order/order-service-impl/src/test/java/cn/iocoder/mall/order/biz/service/OrderServiceImplTest.java @@ -1,4 +1,4 @@ -package cn.iocoder.mall.order.service; +package cn.iocoder.mall.order.biz.service; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.order.OrderApplicationTest; @@ -6,8 +6,8 @@ import cn.iocoder.mall.order.api.OrderService; import cn.iocoder.mall.order.api.bo.OrderCreateBO; 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 cn.iocoder.mall.order.biz.dao.OrderMapper; +import cn.iocoder.mall.order.biz.dataobject.OrderDO; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith;