瀏覽代碼

售后订单

guomengjiao 2 月之前
父節點
當前提交
bf55d9ed78

+ 3 - 1
ruoyi-api/src/main/java/com/ruoyi/api/controller/info/ApiTeacherOrderRefundController.java

@@ -12,6 +12,7 @@ import com.ruoyi.info.management.domain.vo.TeacherDepartmentRelVo;
 import com.ruoyi.info.management.service.ITeacherDepartmentRelService;
 import com.ruoyi.info.order.domain.bo.OrderRefundBo;
 import com.ruoyi.info.order.domain.vo.OrderRefundVo;
+import com.ruoyi.info.order.enums.OrderOperatorType;
 import com.ruoyi.info.order.service.IOrderRefundService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -34,7 +35,7 @@ import java.util.stream.Collectors;
 @Api(value = "售后订单控制器", tags = {"售后订单管理"})
 @RequiredArgsConstructor
 @RestController
-@RequestMapping("/api/orderRefund")
+@RequestMapping("/api/teacher/orderRefund")
 public class ApiTeacherOrderRefundController extends AbstractApiController {
 
     private final IOrderRefundService iOrderRefundService;
@@ -76,6 +77,7 @@ public class ApiTeacherOrderRefundController extends AbstractApiController {
     @PostMapping("/agreeOrRefuse")
     public R<Void> agreeOrRefuse(@RequestBody OrderRefundBo bo) {
         bo.setOperatorId(getTeacherId());
+        bo.setOperatorType(OrderOperatorType.teacher.getCode());
         return toAjax(iOrderRefundService.agreeOrRefuse(bo) ? 1 : 0);
     }
 

+ 4 - 1
ruoyi-info/ruoyi-info-biz/src/main/java/com/ruoyi/info/order/domain/bo/OrderRefundBo.java

@@ -113,10 +113,13 @@ public class OrderRefundBo extends BaseEntity {
     @ApiModelProperty(value = "操作时间", required = true)
     private Date operationTime;
 
+    /**
+     * 操作人类型 1-平台 2-管理老师
+     */
+    private Integer operatorType;
     /**
      * 操作人
      */
-    @ApiModelProperty(value = "操作人", required = true)
     private Long operatorId;
 
     /**

+ 69 - 0
ruoyi-info/ruoyi-info-biz/src/main/java/com/ruoyi/info/order/enums/OrderOperatorType.java

@@ -0,0 +1,69 @@
+package com.ruoyi.info.order.enums;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.annotation.EnumValue;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+import com.ruoyi.common.enums.IIntegerEnum;
+
+import java.util.Objects;
+
+public enum OrderOperatorType implements IIntegerEnum<Integer> {
+
+    platform(1, "平台"),
+    teacher(2, "管理老师"),
+    ;
+
+    OrderOperatorType(Integer code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+
+    @EnumValue
+    @JsonValue
+    private Integer code;
+
+    private String msg;
+
+    @Override
+    public Integer getCode() {
+        return code;
+    }
+
+    public void setCode(Integer code) {
+        this.code = code;
+    }
+
+    @Override
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
+    @JsonCreator
+    public static OrderOperatorType getByCode(Integer code) {
+        for (OrderOperatorType value : OrderOperatorType.values()) {
+            if (Objects.equals(code, value.getCode())) {
+                return value;
+            }
+        }
+        return null;
+    }
+
+    //转成jsonarray
+    public static JSONArray toJsonArray() {
+        JSONArray jsonArray = new JSONArray();
+        for (OrderOperatorType value : OrderOperatorType.values()) {
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("code", value.getCode());
+            jsonObject.put("value", value.getMsg());
+            jsonArray.add(jsonObject);
+        }
+        return jsonArray;
+    }
+
+}

+ 4 - 1
ruoyi-info/ruoyi-info-biz/src/main/java/com/ruoyi/info/order/exception/OrderRefundExceptionEnum.java

@@ -13,7 +13,10 @@ public enum OrderRefundExceptionEnum implements IIntegerEnum {
     OrderRefund_IS_NOT_EXISTS(180001, "售后订单不存在"),
     Order_STATUS_ERROR(180002, "订单状态无法申请退款"),
     Order_USER_ERROR(180003, "当前订单不是您本人的订单,不可退款!"),
-    OrderRefund_STATUS_ERROR(180004, "售后订单不是待退款,无法取消!");
+    OrderRefund_STATUS_ERROR(180004, "售后订单不是待退款,无法操作!"),
+    OrderRefund_OPERATION_STATUS_ERROR(180005, "售后订单操作状态错误!"),
+    OrderRefund_OPERATION_AMOUNT_ERROR(180006, "售后订单退款金额不能为空!"),
+    OrderRefund_OPERATION_REASON_ERROR(180007, "售后订单退款原因不能为空!");
 
     private Integer code;
 

+ 22 - 1
ruoyi-info/ruoyi-info-biz/src/main/java/com/ruoyi/info/order/service/impl/OrderRefundServiceImpl.java

@@ -211,7 +211,28 @@ public class OrderRefundServiceImpl implements IOrderRefundService {
 
     @Override
     public boolean agreeOrRefuse(OrderRefundBo bo) {
-        return false;
+        OrderRefund orderRefund = loadById(bo.getId(), true);
+        if (!orderRefund.getRefundStatus().equals(RefundStatus.wait)) {
+            throw new ServiceException(OrderRefundExceptionEnum.OrderRefund_STATUS_ERROR);
+        }
+        if (!RefundStatus.complete.equals(bo.getRefundStatus()) && !RefundStatus.fail.equals(bo.getRefundStatus())) {
+            throw new ServiceException(OrderRefundExceptionEnum.OrderRefund_OPERATION_STATUS_ERROR);
+        }
+        orderRefund.setRefundStatus(bo.getRefundStatus());
+        if (RefundStatus.complete.equals(bo.getRefundStatus())) {
+            if (bo.getActualRefundAmount() == null) {
+                throw new ServiceException(OrderRefundExceptionEnum.OrderRefund_OPERATION_AMOUNT_ERROR);
+            }
+            orderRefund.setActualRefundAmount(bo.getActualRefundAmount());
+        }
+        if (StringUtils.isEmpty(bo.getOperationReason())) {
+            throw new ServiceException(OrderRefundExceptionEnum.OrderRefund_OPERATION_REASON_ERROR);
+        }
+        orderRefund.setOperationReason(bo.getOperationReason());
+        orderRefund.setOperationTime(new Date());
+        orderRefund.setOperatorType(bo.getOperatorType());
+        orderRefund.setOperatorId(bo.getOperatorId());
+        return baseMapper.updateById(orderRefund) > 0;
     }
 
 }