Commit bef298c7 by ping.wu

日志修改

parent c45aeed3
package cn.freemud.annotations; //package cn.freemud.annotations;
//
import java.lang.annotation.Retention; //import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; //import java.lang.annotation.RetentionPolicy;
//
/** ///**
* @author wanghanghang // * @author wanghanghang
*/ // */
//
@Retention(RetentionPolicy.RUNTIME) //@Retention(RetentionPolicy.RUNTIME)
public @interface LogIgnore { //public @interface LogIgnore {
/** // /**
* 是否打印日志,true打印,false不打印,注意设置成false状态码和状态码信息都不会打印 // * 是否打印日志,true打印,false不打印,注意设置成false状态码和状态码信息都不会打印
* // *
* @return // * @return
*/ // */
boolean printLog() default true; // boolean printLog() default true;
//
/** // /**
* printLog 设置成true的时候,可以排除哪些状态码的响应不用打印响应报文,只会打印状态码 // * printLog 设置成true的时候,可以排除哪些状态码的响应不用打印响应报文,只会打印状态码
* 默认成功100 // * 默认成功100
* @return // * @return
*/ // */
String[] excludeSuccessCodes() default "100"; // String[] excludeSuccessCodes() default "100";
//
/** // /**
* statusCodeFieldName 默认返回状态码字段为code // * statusCodeFieldName 默认返回状态码字段为code
* // *
* @return // * @return
*/ // */
String codeFieldName() default "code"; // String codeFieldName() default "code";
//
/** // /**
* statusCodeFieldName 默认返回状态码字段为message // * statusCodeFieldName 默认返回状态码字段为message
* // *
* @return // * @return
*/ // */
String messageFieldName() default "message"; // String messageFieldName() default "message";
//
/** // /**
* logMessage 日志打印 // * logMessage 日志打印
* @return // * @return
*/ // */
String logMessage() default ""; // String logMessage() default "";
} //}
package cn.freemud.aop; //package cn.freemud.aop;
//
import cn.freemud.annotations.LogIgnore; //import cn.freemud.annotations.LogIgnore;
import cn.freemud.utils.AppLogUtil; //import cn.freemud.utils.AppLogUtil;
import com.alibaba.fastjson.JSON; //import com.alibaba.fastjson.JSON;
import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare; //import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare;
import com.freemud.application.sdk.api.exception.IgnoreErrorAnnotation; //import com.freemud.application.sdk.api.exception.IgnoreErrorAnnotation;
import com.freemud.application.sdk.api.log.ApiLog; //import com.freemud.application.sdk.api.log.ApiLog;
import com.freemud.application.sdk.api.log.ErrorLog; //import com.freemud.application.sdk.api.log.ErrorLog;
import com.freemud.application.sdk.api.log.LogParams; //import com.freemud.application.sdk.api.log.LogParams;
import com.freemud.application.sdk.api.log.LogThreadLocal; //import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.freemud.application.sdk.api.service.EmailAlertService; //import com.freemud.application.sdk.api.service.EmailAlertService;
import com.google.common.collect.Lists; //import com.google.common.collect.Lists;
import org.apache.commons.beanutils.BeanUtils; //import org.apache.commons.beanutils.BeanUtils;
import org.aspectj.lang.JoinPoint; //import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint; //import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature; //import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.AfterThrowing; //import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around; //import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect; //import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut; //import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature; //import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; //import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.Ordered; //import org.springframework.core.Ordered;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils; //import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder; //import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; //import org.springframework.web.context.request.ServletRequestAttributes;
//
import javax.servlet.http.HttpServletRequest; //import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method; //import java.lang.reflect.Method;
import java.lang.reflect.Parameter; //import java.lang.reflect.Parameter;
import java.util.ArrayList; //import java.util.ArrayList;
import java.util.List; //import java.util.List;
import java.util.UUID; //import java.util.UUID;
//
/** ///**
* @author freemud_whh // * @author freemud_whh
*/ // */
@Aspect //@Aspect
@Component //@Component
public class LogIgnoreAspect implements Ordered { //public class LogIgnoreAspect implements Ordered {
//
@Autowired // @Autowired
private EmailAlertService emailAlertService; // private EmailAlertService emailAlertService;
//
/** // /**
* 是否打印响应报文日志,默认是false,若为true会覆盖注解里面的{@link LogIgnore}配置,输出响应报文里面所有的信息 // * 是否打印响应报文日志,默认是false,若为true会覆盖注解里面的{@link LogIgnore}配置,输出响应报文里面所有的信息
*/ // */
@Value("${print-response-body-log-order-application-service:false}") // @Value("${print-response-body-log-order-application-service:false}")
private volatile boolean printResponseBodyLog = false; // private volatile boolean printResponseBodyLog = false;
//
/** // /**
* 即使printResponseBodyLog设置为true, 该参数中包含的url也会被过滤且不打印日志 // * 即使printResponseBodyLog设置为true, 该参数中包含的url也会被过滤且不打印日志
*/ // */
@Value("${exclude-print-body-log-methods:findNearPickUpStores,getMenuCategory}") // @Value("${exclude-print-body-log-methods:findNearPickUpStores,getMenuCategory}")
private volatile List<String> excludePrintBodyLogMethods = Lists.newArrayList(); // private volatile List<String> excludePrintBodyLogMethods = Lists.newArrayList();
//
@Pointcut("@annotation(cn.freemud.annotations.LogIgnore)") // @Pointcut("@annotation(cn.freemud.annotations.LogIgnore)")
public void pointcut() { // public void pointcut() {
} // }
//
@Around("pointcut()") // @Around("pointcut()")
public Object doAroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable { // public Object doAroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
long startTime = System.currentTimeMillis(); // long startTime = System.currentTimeMillis();
StringBuilder logMethod = new StringBuilder(joinPoint.getSignature().getDeclaringTypeName()); // StringBuilder logMethod = new StringBuilder(joinPoint.getSignature().getDeclaringTypeName());
logMethod.append("."); // logMethod.append(".");
logMethod.append(joinPoint.getSignature().getName()); // logMethod.append(joinPoint.getSignature().getName());
Signature sig = joinPoint.getSignature(); // Signature sig = joinPoint.getSignature();
MethodSignature msig = null; // MethodSignature msig = null;
if (!(sig instanceof MethodSignature)) { // if (!(sig instanceof MethodSignature)) {
throw new IllegalArgumentException("非法参数使用 "); // throw new IllegalArgumentException("非法参数使用 ");
} else { // } else {
msig = (MethodSignature) sig; // msig = (MethodSignature) sig;
Object target = joinPoint.getTarget(); // Object target = joinPoint.getTarget();
Method currentMethod = target.getClass().getMethod(msig.getName(), msig.getParameterTypes()); // Method currentMethod = target.getClass().getMethod(msig.getName(), msig.getParameterTypes());
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); // HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
AppLogUtil.debugLotsParams("获取tracking的值====>{}", new Object[]{request.getHeader("x-transaction-id")}); // AppLogUtil.debugLotsParams("获取tracking的值====>{}", new Object[]{request.getHeader("x-transaction-id")});
LogThreadLocal.setTrackingNo(StringUtils.isEmpty(request.getHeader("x-transaction-id")) ? UUID.randomUUID().toString().replaceAll("-", "") : request.getHeader("x-transaction-id")); // LogThreadLocal.setTrackingNo(StringUtils.isEmpty(request.getHeader("x-transaction-id")) ? UUID.randomUUID().toString().replaceAll("-", "") : request.getHeader("x-transaction-id"));
List logArgs = this.getLogArgs(currentMethod, joinPoint); // List logArgs = this.getLogArgs(currentMethod, joinPoint);
String requestData = JSON.toJSONString(logArgs); // String requestData = JSON.toJSONString(logArgs);
LogIgnore logIgnore = currentMethod.getAnnotation(LogIgnore.class); // LogIgnore logIgnore = currentMethod.getAnnotation(LogIgnore.class);
Object object = joinPoint.proceed(); // Object object = joinPoint.proceed();
Object logObj = object; // Object logObj = object;
if (logIgnore != null && logIgnore.printLog()) { // if (logIgnore != null && logIgnore.printLog()) {
if (!this.printResponseBodyLog || excludePrintBodyLogMethods.contains(logIgnore.logMessage())) { // if (!this.printResponseBodyLog || excludePrintBodyLogMethods.contains(logIgnore.logMessage())) {
String statusCodeValue = BeanUtils.getProperty(object, logIgnore.codeFieldName()); // String statusCodeValue = BeanUtils.getProperty(object, logIgnore.codeFieldName());
String messageValue = BeanUtils.getProperty(object, logIgnore.messageFieldName()); // String messageValue = BeanUtils.getProperty(object, logIgnore.messageFieldName());
String[] excludeStatusCodes = logIgnore.excludeSuccessCodes(); // String[] excludeStatusCodes = logIgnore.excludeSuccessCodes();
//当排除了这个状态码不打印响应的具体内容只会打印状态码和状态描述信息 // //当排除了这个状态码不打印响应的具体内容只会打印状态码和状态描述信息
//当返回code在不打印的范围,则将打印信息变更为只打印code和message // //当返回code在不打印的范围,则将打印信息变更为只打印code和message
if (this.containStatusCode(excludeStatusCodes, statusCodeValue)) { // if (this.containStatusCode(excludeStatusCodes, statusCodeValue)) {
logObj = object.getClass().newInstance(); // logObj = object.getClass().newInstance();
BeanUtils.setProperty(logObj, logIgnore.codeFieldName(), statusCodeValue); // BeanUtils.setProperty(logObj, logIgnore.codeFieldName(), statusCodeValue);
BeanUtils.setProperty(logObj, logIgnore.messageFieldName(), messageValue); // BeanUtils.setProperty(logObj, logIgnore.messageFieldName(), messageValue);
} // }
} // }
} // }
ApiLog.infoConvertJson(logMethod.toString(), logIgnore.logMessage(), request, startTime, System.currentTimeMillis(), requestData, logObj,null,null); // ApiLog.infoConvertJson(logMethod.toString(), logIgnore.logMessage(), request, startTime, System.currentTimeMillis(), requestData, logObj,null,null);
LogThreadLocal.removeTrackingNo(); // LogThreadLocal.removeTrackingNo();
return object; // return object;
} // }
} // }
//
/** // /**
* 过滤返参code是否在excludeStatusCodes存在 // * 过滤返参code是否在excludeStatusCodes存在
* // *
* @param excludeStatusCodes // * @param excludeStatusCodes
* @param statusCodeValue // * @param statusCodeValue
* @return // * @return
*/ // */
private boolean containStatusCode(String[] excludeStatusCodes, String statusCodeValue) { // private boolean containStatusCode(String[] excludeStatusCodes, String statusCodeValue) {
if (excludeStatusCodes == null || excludeStatusCodes.length == 0) { // if (excludeStatusCodes == null || excludeStatusCodes.length == 0) {
return false; // return false;
} // }
for (int i = 0; i < excludeStatusCodes.length; i++) { // for (int i = 0; i < excludeStatusCodes.length; i++) {
if (excludeStatusCodes[i].equals(statusCodeValue)) { // if (excludeStatusCodes[i].equals(statusCodeValue)) {
return true; // return true;
} // }
} // }
return false; // return false;
} // }
//
/** // /**
* 系统异常时,AfterThrowing在ApiAnnotation注解中已经处理。 // * 系统异常时,AfterThrowing在ApiAnnotation注解中已经处理。
* 此处先注释,暂不删除,代码保留 // * 此处先注释,暂不删除,代码保留
* // *
* @param joinPoint // * @param joinPoint
* @return // * @return
*/ // */
@AfterThrowing( // @AfterThrowing(
pointcut = "pointcut()", // pointcut = "pointcut()",
throwing = "e" // throwing = "e"
) // )
public void doAfterThrowing(JoinPoint joinPoint, Exception e) { // public void doAfterThrowing(JoinPoint joinPoint, Exception e) {
long startTime = System.currentTimeMillis(); // long startTime = System.currentTimeMillis();
Signature sig = joinPoint.getSignature(); // Signature sig = joinPoint.getSignature();
Method currentMethod = null; // Method currentMethod = null;
MethodSignature msig = null; // MethodSignature msig = null;
if (!(sig instanceof MethodSignature)) { // if (!(sig instanceof MethodSignature)) {
throw new IllegalArgumentException("非法参数使用"); // throw new IllegalArgumentException("非法参数使用");
} else { // } else {
msig = (MethodSignature) sig; // msig = (MethodSignature) sig;
Object target = joinPoint.getTarget(); // Object target = joinPoint.getTarget();
try { // try {
currentMethod = target.getClass().getMethod(msig.getName(), msig.getParameterTypes()); // currentMethod = target.getClass().getMethod(msig.getName(), msig.getParameterTypes());
} catch (NoSuchMethodException var19) { // } catch (NoSuchMethodException var19) {
var19.printStackTrace(); // var19.printStackTrace();
} // }
StringBuilder logMethod = new StringBuilder(joinPoint.getSignature().getDeclaringTypeName()); // StringBuilder logMethod = new StringBuilder(joinPoint.getSignature().getDeclaringTypeName());
logMethod.append("."); // logMethod.append(".");
logMethod.append(joinPoint.getSignature().getName()); // logMethod.append(joinPoint.getSignature().getName());
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); // HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
try { // try {
Class<?> clz = e.getClass(); // Class<?> clz = e.getClass();
boolean clzHasAnno = clz.isAnnotationPresent(IgnoreErrorAnnotation.class); // boolean clzHasAnno = clz.isAnnotationPresent(IgnoreErrorAnnotation.class);
if (!clzHasAnno) { // if (!clzHasAnno) {
this.emailAlertService.sendEmailAlert("系统全局异常", e); // this.emailAlertService.sendEmailAlert("系统全局异常", e);
} // }
} catch (Exception var17) { // } catch (Exception var17) {
ErrorLog.errorConvertJson(SDKCommonBaseContextWare.getAppName(), logMethod.toString(), "出错:" + e.getMessage(), request, startTime, System.currentTimeMillis(), this.getLogArgs(currentMethod, joinPoint), var17); // ErrorLog.errorConvertJson(SDKCommonBaseContextWare.getAppName(), logMethod.toString(), "出错:" + e.getMessage(), request, startTime, System.currentTimeMillis(), this.getLogArgs(currentMethod, joinPoint), var17);
} finally { // } finally {
ErrorLog.errorConvertJson(SDKCommonBaseContextWare.getAppName(), logMethod.toString(), "出错:" + e.getMessage(), request, startTime, System.currentTimeMillis(), this.getLogArgs(currentMethod, joinPoint), e); // ErrorLog.errorConvertJson(SDKCommonBaseContextWare.getAppName(), logMethod.toString(), "出错:" + e.getMessage(), request, startTime, System.currentTimeMillis(), this.getLogArgs(currentMethod, joinPoint), e);
LogThreadLocal.removeTrackingNo(); // LogThreadLocal.removeTrackingNo();
} // }
} // }
} // }
//
private List getLogArgs(Method method, JoinPoint joinPoint) { // private List getLogArgs(Method method, JoinPoint joinPoint) {
if (method == null) { // if (method == null) {
return null; // return null;
} else { // } else {
Object[] args = joinPoint.getArgs(); // Object[] args = joinPoint.getArgs();
if (args != null && args.length != 0) { // if (args != null && args.length != 0) {
List logArgs = new ArrayList(); // List logArgs = new ArrayList();
Parameter[] parameters = method.getParameters(); // Parameter[] parameters = method.getParameters();
for (int j = 0; j < parameters.length; ++j) { // for (int j = 0; j < parameters.length; ++j) {
Parameter parameter = parameters[j]; // Parameter parameter = parameters[j];
LogParams logParams = (LogParams) parameter.getAnnotation(LogParams.class); // LogParams logParams = (LogParams) parameter.getAnnotation(LogParams.class);
if (logParams != null) { // if (logParams != null) {
logArgs.add(args[j]); // logArgs.add(args[j]);
} // }
} // }
return logArgs; // return logArgs;
} else { // } else {
return null; // return null;
} // }
} // }
} // }
//
@Override // @Override
public int getOrder() { // public int getOrder() {
return 0; // return 0;
} // }
} //}
package cn.freemud.aop; package cn.freemud.aop;
import cn.freemud.annotations.LogIgnore;
import cn.freemud.annotations.LogIgnoreFeign; import cn.freemud.annotations.LogIgnoreFeign;
import cn.freemud.entities.vo.ThirdPartLogVo; import cn.freemud.entities.vo.ThirdPartLogVo;
import cn.freemud.utils.AppLogUtil; import cn.freemud.utils.AppLogUtil;
......
...@@ -507,16 +507,16 @@ public class CheckMCCafeOrder { ...@@ -507,16 +507,16 @@ public class CheckMCCafeOrder {
McdNetBatchQueryResponse mcdNetBatchQueryResponse = couponClientService.batchQuery(mcCafeCouponRequest); McdNetBatchQueryResponse mcdNetBatchQueryResponse = couponClientService.batchQuery(mcCafeCouponRequest);
if (mcdNetBatchQueryResponse == null || !ResponseCodeConstant.RESPONSE_SUCCESS.equals(mcdNetBatchQueryResponse.getStatusCode()) if (mcdNetBatchQueryResponse == null || !ResponseCodeConstant.RESPONSE_SUCCESS.equals(mcdNetBatchQueryResponse.getStatusCode())
|| CollectionUtils.isEmpty(mcdNetBatchQueryResponse.getCouponlist())) { || CollectionUtils.isEmpty(mcdNetBatchQueryResponse.getCouponlist())) {
AppLogUtil.errorLog("部分优惠券当前不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse); AppLogUtil.infoLog("部分优惠券当前不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse);
throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, "部分优惠券当前不可用"); throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, "部分优惠券当前不可用");
} else if(!ResponseCodeConstant.RESPONSE_SUCCESS.equals(mcdNetBatchQueryResponse.getCouponlist().get(0).getStatusCode())) { } else if(!ResponseCodeConstant.RESPONSE_SUCCESS.equals(mcdNetBatchQueryResponse.getCouponlist().get(0).getStatusCode())) {
mcdNetBatchQueryResponse.getCouponlist().forEach(o -> { mcdNetBatchQueryResponse.getCouponlist().forEach(o -> {
if(!ResponseCodeConstant.RESPONSE_SUCCESS.equals(o.getStatusCode())) { if(!ResponseCodeConstant.RESPONSE_SUCCESS.equals(o.getStatusCode())) {
if(o.getCodeInfo() != null) { if(o.getCodeInfo() != null) {
AppLogUtil.errorLog(o.getCodeInfo().getAct_name()+"当前不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse); AppLogUtil.infoLog(o.getCodeInfo().getAct_name()+"当前不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse);
throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, o.getCodeInfo().getAct_name()+"当前不可用"); throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, o.getCodeInfo().getAct_name()+"当前不可用");
} else { } else {
AppLogUtil.errorLog("部分优惠券暂时不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse); AppLogUtil.infoLog("部分优惠券暂时不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse);
throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, "部分优惠券暂时不可用"); throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, "部分优惠券暂时不可用");
} }
} }
...@@ -604,16 +604,16 @@ public class CheckMCCafeOrder { ...@@ -604,16 +604,16 @@ public class CheckMCCafeOrder {
McdNetBatchQueryResponse mcdNetBatchQueryResponse = couponClientService.batchQuery(mcCafeCouponRequest); McdNetBatchQueryResponse mcdNetBatchQueryResponse = couponClientService.batchQuery(mcCafeCouponRequest);
if (mcdNetBatchQueryResponse == null || !ResponseCodeConstant.RESPONSE_SUCCESS.equals(mcdNetBatchQueryResponse.getStatusCode()) if (mcdNetBatchQueryResponse == null || !ResponseCodeConstant.RESPONSE_SUCCESS.equals(mcdNetBatchQueryResponse.getStatusCode())
|| CollectionUtils.isEmpty(mcdNetBatchQueryResponse.getCouponlist())) { || CollectionUtils.isEmpty(mcdNetBatchQueryResponse.getCouponlist())) {
AppLogUtil.errorLog("部分优惠券当前不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse); AppLogUtil.infoLog("部分优惠券当前不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse);
throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, "部分优惠券当前不可用"); throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, "部分优惠券当前不可用");
} else { } else {
mcdNetBatchQueryResponse.getCouponlist().forEach(o -> { mcdNetBatchQueryResponse.getCouponlist().forEach(o -> {
if(!ResponseCodeConstant.RESPONSE_SUCCESS.equals(o.getStatusCode())) { if(!ResponseCodeConstant.RESPONSE_SUCCESS.equals(o.getStatusCode())) {
if(o.getCodeInfo() != null) { if(o.getCodeInfo() != null) {
AppLogUtil.errorLog(o.getCodeInfo().getAct_name()+"当前不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse); AppLogUtil.infoLog(o.getCodeInfo().getAct_name()+"当前不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse);
throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, o.getCodeInfo().getAct_name()+"当前不可用"); throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, o.getCodeInfo().getAct_name()+"当前不可用");
} else { } else {
AppLogUtil.errorLog("部分优惠券暂时不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse); AppLogUtil.infoLog("部分优惠券暂时不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse);
throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, "部分优惠券暂时不可用"); throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, "部分优惠券暂时不可用");
} }
} }
......
...@@ -564,7 +564,7 @@ public class MallOrderServiceImpl implements MallOrderService { ...@@ -564,7 +564,7 @@ public class MallOrderServiceImpl implements MallOrderService {
try { try {
com.freemud.application.sdk.api.ordercenter.response.BaseResponse baseResponse = orderSdkService.acceptOrder(acceptOrderReq, LogThreadLocal.getTrackingNo()); com.freemud.application.sdk.api.ordercenter.response.BaseResponse baseResponse = orderSdkService.acceptOrder(acceptOrderReq, LogThreadLocal.getTrackingNo());
if(baseResponse == null || !ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(baseResponse.getCode())) { if(baseResponse == null || !ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(baseResponse.getCode())) {
AppLogUtil.errorLog("paySuccessCallback_acceptOrder_faild", gson.toJson(confirmOrderDto), gson.toJson(payAccessResponse)); AppLogUtil.infoLog("paySuccessCallback_acceptOrder_faild", gson.toJson(confirmOrderDto), gson.toJson(payAccessResponse));
} }
}catch (Exception e){ }catch (Exception e){
AppLogUtil.errorLog("paySuccessCallback_acceptOrder_error",orderId,e); AppLogUtil.errorLog("paySuccessCallback_acceptOrder_error",orderId,e);
......
...@@ -69,12 +69,13 @@ public class AppLogUtil implements BeanFactoryAware { ...@@ -69,12 +69,13 @@ public class AppLogUtil implements BeanFactoryAware {
public void info(String message, Object... params) { public void info(String message, Object... params) {
logUtil.info(message,params); logUtil.info(message,params);
} }
public void error(String message, Exception e, String... params) { public void error(String message, Exception e, String... params) {
logUtil.error(message, e, params); logUtil.errorDev("",message, e, params);
}
public void error(String message, Object... params) {
ErrorLog.errorDev(message, params);
} }
// public void error(String message, Object... params) {
// ErrorLog.errorDev(message, params);
// }
public void errorSe(String message, Exception e, String... params) { public void errorSe(String message, Exception e, String... params) {
......
...@@ -221,16 +221,16 @@ public class CouponActivityServiceTest { ...@@ -221,16 +221,16 @@ public class CouponActivityServiceTest {
System.out.println(JSON.toJSONString(mcdNetBatchQueryResponse)); System.out.println(JSON.toJSONString(mcdNetBatchQueryResponse));
if (mcdNetBatchQueryResponse == null || !ResponseCodeConstant.RESPONSE_SUCCESS.equals(mcdNetBatchQueryResponse.getStatusCode()) if (mcdNetBatchQueryResponse == null || !ResponseCodeConstant.RESPONSE_SUCCESS.equals(mcdNetBatchQueryResponse.getStatusCode())
|| CollectionUtils.isEmpty(mcdNetBatchQueryResponse.getCouponlist())) { || CollectionUtils.isEmpty(mcdNetBatchQueryResponse.getCouponlist())) {
AppLogUtil.errorLog("部分优惠券当前不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse); AppLogUtil.infoLog("部分优惠券当前不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse);
throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, "部分优惠券当前不可用"); throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, "部分优惠券当前不可用");
} else { } else {
mcdNetBatchQueryResponse.getCouponlist().forEach(o -> { mcdNetBatchQueryResponse.getCouponlist().forEach(o -> {
if(!ResponseCodeConstant.RESPONSE_SUCCESS.equals(o.getStatusCode())) { if(!ResponseCodeConstant.RESPONSE_SUCCESS.equals(o.getStatusCode())) {
if(o.getCodeInfo() != null) { if(o.getCodeInfo() != null) {
AppLogUtil.errorLog(o.getCodeInfo().getAct_name()+"当前不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse); AppLogUtil.infoLog(o.getCodeInfo().getAct_name()+"当前不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse);
throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, o.getCodeInfo().getAct_name()+"当前不可用"); throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, o.getCodeInfo().getAct_name()+"当前不可用");
} else { } else {
AppLogUtil.errorLog("部分优惠券暂时不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse); AppLogUtil.infoLog("部分优惠券暂时不可用", mcCafeCouponRequest, mcdNetBatchQueryResponse);
throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, "部分优惠券暂时不可用"); throw new ServiceException(ResponseResult.COUPON_SHOP_NOTSUPPORT, "部分优惠券暂时不可用");
} }
} }
......
...@@ -62,6 +62,10 @@ public class LogUtil { ...@@ -62,6 +62,10 @@ public class LogUtil {
ErrorLog.errorDev(message, e, params); ErrorLog.errorDev(message, e, params);
} }
public void errorDev(String statusCode, String message,Exception e, Object... params) {
ErrorLog.errorDev(statusCode,message, e, params);
}
public void errorSe(String message, Exception e, Object... params) { public void errorSe(String message, Exception e, Object... params) {
ErrorLog.errorSe(message, e, params); ErrorLog.errorSe(message, e, params);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment