自定义订单异常
This commit is contained in:
@@ -113,6 +113,14 @@ public class CzgControllerAdvice {
|
||||
return CzgResult.failure(ex.getCode(), ex.getMsg());
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(OrderValidateException.class)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public CzgResult<Object> handleOrderValidateException(OrderValidateException ex) {
|
||||
log.error("订单校验异常:{}", ex.getMessage());
|
||||
return CzgResult.failure(ex.getCode(), ex.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付成功
|
||||
* 支付金额为零的统一处理
|
||||
@@ -127,7 +135,7 @@ public class CzgControllerAdvice {
|
||||
*/
|
||||
@ExceptionHandler(OrderCancelException.class)
|
||||
public CzgResult<Object> handleOrderCancelException() {
|
||||
return CzgResult.failure(701,"订单已过期,请重新下单");
|
||||
return CzgResult.failure(701, "订单已过期,请重新下单");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,6 +163,6 @@ public class CzgControllerAdvice {
|
||||
|
||||
private void setErrorLog(Exception ex) {
|
||||
log.error(ex.getMessage());
|
||||
log.error("错误",ex);
|
||||
log.error("错误", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class SmsPushEvent implements Serializable {
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 0待发送 1 发送中 2发送成功 -1失败
|
||||
* 0待发送 1 发送中 2发送完成 -1失败
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.czg.exception;
|
||||
|
||||
import com.czg.resp.CzgRespCode;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
public class OrderValidateException extends RuntimeException{
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
|
||||
public OrderValidateException(String msg) {
|
||||
super(msg);
|
||||
this.code = CzgRespCode.FAILURE.getCode();
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user