diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminOrderReturnController.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminOrderReturnController.java index 625b341f..080beb3d 100644 --- a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminOrderReturnController.java +++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminOrderReturnController.java @@ -35,7 +35,11 @@ public class AdminOrderReturnController { @PostMapping("agree") public CommonResult agree(@RequestParam("id") Integer id) { - CommonResult commonResult = orderReturnService.agree(id); - return commonResult; + return orderReturnService.orderReturnAgree(id); + } + + @PostMapping("refuse") + public CommonResult refuse(@RequestParam("id") Integer id) { + return orderReturnService.orderReturnRefuse(id); } } 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 index be847f25..c598d8fb 100644 --- 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 @@ -50,4 +50,20 @@ public interface OrderReturnService { * @return */ CommonResult orderReturnList(OrderReturnQueryDTO queryDTO); + + /** + * 订单退货 - 接受 + * + * @param id + * @return + */ + CommonResult orderReturnAgree(Integer id); + + /** + * 订单退货 - 拒绝 + * + * @param id + * @return + */ + CommonResult orderReturnRefuse(Integer id); } 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 15b616bd..382e851f 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 @@ -34,6 +34,7 @@ public enum OrderErrorCodeEnum { // 订单退货 ORDER_RETURN_NO_RETURN_APPLY(1008000400, "未退货申请"), + ORDER_RETURN_NOT_EXISTENT(1008000401, "退货订单不存在"), // ========== 购物车 ========== CARD_ITEM_NOT_FOUND(1008003000, "购物车项不存在"), diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderReturnReturnTypeEnum.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderReturnServiceTypeEnum.java similarity index 84% rename from order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderReturnReturnTypeEnum.java rename to order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderReturnServiceTypeEnum.java index 08e595db..0be9ebbb 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderReturnReturnTypeEnum.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/constant/OrderReturnServiceTypeEnum.java @@ -6,7 +6,7 @@ package cn.iocoder.mall.order.api.constant; * @author Sin * @time 2019-04-27 11:53 */ -public enum OrderReturnReturnTypeEnum { +public enum OrderReturnServiceTypeEnum { /** * 状态 @@ -21,7 +21,7 @@ public enum OrderReturnReturnTypeEnum { private final String name; - OrderReturnReturnTypeEnum(int value, String name) { + OrderReturnServiceTypeEnum(int value, String name) { this.value = value; this.name = name; } 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 index ef59a92f..8b37f22f 100644 --- 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 @@ -18,8 +18,10 @@ public enum OrderReturnStatusEnum { * - 5、退货成功 */ RETURN_APPLICATION(1, "退货申请"), - APPLICATION_SUCCESSFUL(1, "申请成功"), - APPLICATION_FAIL(1, "申请失败"), + APPLICATION_SUCCESSFUL(2, "申请成功"), + APPLICATION_FAIL(3, "申请失败"), + RETURN(4, "退货中"), + RETURN_SUCCESS(5, "退货成功"), ; private final int value; 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 index 4e354e14..7dd3e1ba 100644 --- 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 @@ -9,6 +9,7 @@ import cn.iocoder.mall.order.api.bo.OrderLastLogisticsInfoBO; import cn.iocoder.mall.order.api.bo.OrderReturnInfoBO; import cn.iocoder.mall.order.api.bo.OrderReturnListBO; import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum; +import cn.iocoder.mall.order.api.constant.OrderReturnServiceTypeEnum; import cn.iocoder.mall.order.api.constant.OrderReturnStatusEnum; import cn.iocoder.mall.order.api.dto.OrderReturnApplyDTO; import cn.iocoder.mall.order.api.dto.OrderReturnQueryDTO; @@ -142,11 +143,37 @@ public class OrderReturnServiceImpl implements OrderReturnService { } @Override - public CommonResult agree(Integer id) { + public CommonResult orderReturnAgree(Integer id) { OrderReturnDO orderReturnDO = orderReturnMapper.selectById(id); if (orderReturnDO == null) { - + return ServiceExceptionUtil + .error(OrderErrorCodeEnum.ORDER_RETURN_NOT_EXISTENT.getCode()); } - return null; + + // TODO: 2019/5/8 sin, 发送 MQ 消息,申请退货成功! + // TODO: 2019/5/8 sin 退款:支付系统退款 + // TODO: 2019/5/8 sin 退货+退款:退回商品签收后,支付系统退款 + + orderReturnMapper.updateByOrderId( + new OrderReturnDO() + .setId(id) + .setStatus(OrderReturnStatusEnum.APPLICATION_SUCCESSFUL.getValue()) + ); + return CommonResult.success(null); + } + + @Override + public CommonResult orderReturnRefuse(Integer id) { + OrderReturnDO orderReturnDO = orderReturnMapper.selectById(id); + if (orderReturnDO == null) { + return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_RETURN_NOT_EXISTENT.getCode()); + } + + orderReturnMapper.updateByOrderId( + new OrderReturnDO() + .setId(id) + .setStatus(OrderReturnStatusEnum.APPLICATION_FAIL.getValue()) + ); + return CommonResult.success(null); } }