Przeglądaj źródła

feat:添加业务异常,改进堆栈信息打印

release_toaliyun_real
xmzhao71 2 lat temu
rodzic
commit
6a167dcecb
7 zmienionych plików z 54 dodań i 29 usunięć
  1. +4
    -4
      mallinkCallback/src/main/java/com/iformall/controller/callback/WxPayBillController.java
  2. +5
    -5
      mallinkCallback/src/main/java/com/iformall/controller/callback/WxPayController.java
  3. +2
    -2
      mallinkCallback/src/main/java/com/iformall/controller/callback/car/pay/WxCarPaidCallBackController.java
  4. +9
    -2
      mallinkService/src/main/java/com/iformall/common/GlobalDefultExceptionHandler.java
  5. +34
    -0
      mallinkService/src/main/java/com/iformall/exception/BizException.java
  6. +0
    -14
      mallinkService/src/main/java/com/iformall/exception/BizMessageException.java
  7. +0
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxMsgModelServiceImpl.java

+ 4
- 4
mallinkCallback/src/main/java/com/iformall/controller/callback/WxPayBillController.java Wyświetl plik

@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.iformall.controller.base.BaseController;
import com.iformall.enums.EnumPayVersion;
import com.iformall.enums.EnumPayWay;
import com.iformall.exception.BizMessageException;
import com.iformall.exception.BizException;
import com.iformall.exception.MallinkException;
import com.iformall.pay.WxPayment;
import com.iformall.service.MailService;
@@ -83,7 +83,7 @@ public class WxPayBillController extends BaseController {
String response = wxPayBillService.notify(getTenantId(attach),paramMap, EnumPayWay.PAY_WAY_WECHAT);
logger.info("微信支付回调, notify success, req : " + resultxml + ", resp: " + response.toString());
return response;
} catch (BizMessageException e) {
} catch (BizException e) {
if (paramMap == null) {
logger.error("微信支付回调, order create error, e: " + e.getMessage());
} else {
@@ -136,7 +136,7 @@ public class WxPayBillController extends BaseController {
response = wxRefundOrderService.notify(paramMap, EnumPayWay.PAY_WAY_WECHAT,EnumPayVersion.WX_PAY_V2);
logger.info("refund wxpay, notify success, req : " + xml + ", resp: " + response.toString());
return response;
} catch (BizMessageException e) {
} catch (BizException e) {
logger.error("refund wxpay, notify error, req: " + xml + ", e:" + e.getLocalizedMessage());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
@@ -185,7 +185,7 @@ public class WxPayBillController extends BaseController {
// response = wxPayBillService.notify(paramMap, EnumPayWay.PAY_WAY_WECHAT);
logger.info("share wxpay, notify success, req : " + xml + ", resp: " + response.toString());
return response;
} catch (BizMessageException e) {
} catch (BizException e) {
logger.error("share wxpay, notify error, req: " + xml + ", e:" + e.getLocalizedMessage());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");


+ 5
- 5
mallinkCallback/src/main/java/com/iformall/controller/callback/WxPayController.java Wyświetl plik

@@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.msg.FmInsideNotifyRefundSuccessMsg;
import com.iformall.enums.*;
import com.iformall.exception.BizMessageException;
import com.iformall.exception.BizException;
import com.iformall.exception.MallinkException;
import com.iformall.mq.MqBaseProducer;
import com.iformall.pay.WxPayment;
@@ -165,7 +165,7 @@ public class WxPayController extends BaseController {

logger.info("refund wxpay, notify success, req : " + xml + ", resp: " + response.toString());
return response;
} catch (BizMessageException e) {
} catch (BizException e) {
logger.error("refund wxpay, notify error, req: " + xml + ", e:" + e.getLocalizedMessage());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
@@ -230,7 +230,7 @@ public class WxPayController extends BaseController {

logger.info("refund wxpay, notify success, req : " + json + ", resp: " + response.toString());
return response;
} catch (BizMessageException e) {
} catch (BizException e) {
logger.error("refund wxpay, notify error, req: " + json + ", e:" + e.getLocalizedMessage());
SortedMap resultMap = new TreeMap();
resultMap.put("code", "FAIL");
@@ -279,7 +279,7 @@ public class WxPayController extends BaseController {
// response = wxPayOrderService.shareNotify(paramMap, EnumPayWay.PAY_WAY_WECHAT,EnumPayVersion.WX_PAY_V2);
logger.info("share wxpay, notify success, req : " + xml + ", resp: " + response.toString());
return response;
} catch (BizMessageException e) {
} catch (BizException e) {
logger.error("share wxpay, notify error, req: " + xml + ", e:" + e.getLocalizedMessage());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");
@@ -319,7 +319,7 @@ public class WxPayController extends BaseController {
response = wxPayOrderService.shareNotify(paramMap, EnumPayWay.PAY_WAY_WECHAT,EnumPayVersion.WX_PAY_V3);
logger.info("share wxpay, notify success, req : " + xml + ", resp: " + response.toString());
return response;
} catch (BizMessageException e) {
} catch (BizException e) {
logger.error("share wxpay, notify error, req: " + xml + ", e:" + e.getLocalizedMessage());
SortedMap resultMap = new TreeMap();
resultMap.put("code", "FAIL");


+ 2
- 2
mallinkCallback/src/main/java/com/iformall/controller/callback/car/pay/WxCarPaidCallBackController.java Wyświetl plik

@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.iformall.controller.callback.car.WxParkCallBackBaseController;
import com.iformall.domain.po.msg.FmInsideNotifyCarPaidSuccessMsg;
import com.iformall.enums.*;
import com.iformall.exception.BizMessageException;
import com.iformall.exception.BizException;
import com.iformall.exception.MallinkException;
import com.iformall.mq.MqBaseProducer;
import com.iformall.pay.WxPayment;
@@ -101,7 +101,7 @@ public class WxCarPaidCallBackController extends WxParkCallBackBaseController {

logger.info("carPaid wxpay, notify success, req : " + xml + ", resp: " + response.toString());
return response;
} catch (BizMessageException e) {
} catch (BizException e) {
logger.error("carPaid wxpay, notify error, req: " + xml + ", e:" + e.getLocalizedMessage());
SortedMap resultMap = new TreeMap();
resultMap.put("return_code", "FAIL");


+ 9
- 2
mallinkService/src/main/java/com/iformall/common/GlobalDefultExceptionHandler.java Wyświetl plik

@@ -1,6 +1,7 @@
package com.iformall.common;


import com.iformall.exception.BizException;
import com.iformall.exception.MallinkException;
import com.iformall.service.MailService;
import org.apache.shiro.authz.AuthorizationException;
@@ -71,17 +72,23 @@ public class GlobalDefultExceptionHandler {
}
}

@ResponseBody
@ExceptionHandler(value = BizException.class)
public ResultData bizExceptionHandler(BizException e, HttpServletRequest request) {
log(e, request);
return new ResultData(e.getCode(), e.getMsg());
}

private void log(Exception ex, HttpServletRequest request) {
logger.error("************************异常开始*******************************");
if(checkExceptionType(ex)) {
// 特殊异常不打印堆栈
logger.error(ex.getMessage());
logger.error("message:"+ ex);
logger.error("************************异常结束*******************************");
return;
}
logger.error("请求地址:" + request.getRequestURL());
logger.error("message:"+ ex.getMessage());
logger.error("message:"+ ex);
Enumeration enumeration = request.getParameterNames();
logger.error("请求参数");
while (enumeration.hasMoreElements()) {


+ 34
- 0
mallinkService/src/main/java/com/iformall/exception/BizException.java Wyświetl plik

@@ -0,0 +1,34 @@
package com.iformall.exception;

import com.iformall.common.ErrorCode;

/**
* 业务异常,该异常不发送邮件
* @author xmzhao71
* @date 2023-09-12
*/
public class BizException extends RuntimeException {

private int code;
private String msg;

public BizException(int code, String msg) {
super(msg);
this.code = code;
this.msg = msg;
}

public BizException(ErrorCode errCode) {
super(errCode.getMessage());
this.code = errCode.getCode();
this.msg = errCode.getMessage();
}

public int getCode() {
return code;
}

public String getMsg() {
return msg;
}
}

+ 0
- 14
mallinkService/src/main/java/com/iformall/exception/BizMessageException.java Wyświetl plik

@@ -1,14 +0,0 @@
package com.iformall.exception;

/**
* Created by Stormeye on 2018/8/10.
*/
public class BizMessageException extends RuntimeException {
public BizMessageException() {
super();
}

public BizMessageException(String bizMessage) {
super(bizMessage);
}
}

+ 0
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxMsgModelServiceImpl.java Wyświetl plik

@@ -13,8 +13,6 @@ import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.GetMessageChannelVO;
import com.iformall.enums.EnumMsgModelStatus;
import com.iformall.enums.EnumVerifyCode;
import com.iformall.exception.BizMessageException;
import com.iformall.exception.MallinkException;
import com.iformall.mapper.WxMsgConfigMapper;
import com.iformall.mapper.WxMsgModelMapper;
import com.iformall.service.WxMsgModelService;


Ładowanie…
Anuluj
Zapisz