Commit 3c8b195b by hanghang.wang

Merge branch 'feature/20201231_ID1020975C端购物车日志优化_wanghanghang'

parents ef21f671 9e66fbad
package cn.freemud.aop;
import com.alibaba.fastjson.JSON;
import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare;
import com.freemud.application.sdk.api.exception.IgnoreErrorAnnotation;
import com.freemud.application.sdk.api.log.*;
import com.freemud.application.sdk.api.service.EmailAlertService;
import com.google.common.collect.Lists;
import org.apache.commons.beanutils.BeanUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
/**
* @author freemud_whh
*/
@Aspect
@Component
public class ControllerLogAop implements Ordered {
@Autowired
private EmailAlertService emailAlertService;
/**
* 是否打印响应报文日志,默认是false,若为true会覆盖注解里面的{@link LogIgnore}配置,输出响应报文里面所有的信息
*/
@Value("${print-response-body-log-shop-cart:false}")
private volatile boolean printResponseBodyLogForShopCart = false;
/**
* 即使printResponseBodyLog设置为true, 该参数中包含的url也会被过滤且不打印日志
*/
@Value("${exclude-print-body-log-methods:findNearPickUpStores,getMenuCategory}")
private volatile List<String> excludePrintBodyLogMethods = Lists.newArrayList();
@Pointcut("@annotation(cn.freemud.aop.LogIgnore)")
public void pointcut() {
}
@Around("pointcut()")
public Object doAroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
long startTime = System.currentTimeMillis();
StringBuilder logMethod = new StringBuilder(joinPoint.getSignature().getDeclaringTypeName());
logMethod.append(".");
logMethod.append(joinPoint.getSignature().getName());
Signature sig = joinPoint.getSignature();
MethodSignature msig = null;
if (!(sig instanceof MethodSignature)) {
throw new IllegalArgumentException("非法参数使用 ");
} else {
msig = (MethodSignature) sig;
Object target = joinPoint.getTarget();
Method currentMethod = target.getClass().getMethod(msig.getName(), msig.getParameterTypes());
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
if (ApiLog.isDebugEnabled()) {
ApiLog.debug("获取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"));
List logArgs = this.getLogArgs(currentMethod, joinPoint);
String requestData = JSON.toJSONString(logArgs);
LogIgnore logIgnore = currentMethod.getAnnotation(LogIgnore.class);
Object object = joinPoint.proceed();
Object logObj = object;
if (logIgnore != null && logIgnore.printLog()) {
if (!this.printResponseBodyLogForShopCart || excludePrintBodyLogMethods.contains(logIgnore.logMessage())) {
String statusCodeValue = BeanUtils.getProperty(object, logIgnore.statusCodeFieldName());
String messageValue = BeanUtils.getProperty(object, logIgnore.messageFieldName());
String[] excludeStatusCodes = logIgnore.excludeStatusCodes();
//todo 当排除了这个状态码不打印响应的具体内容只会打印状态码和状态描述信息
//当返回code在不打印的范围,则将打印信息变更为只打印code和message
if (this.containStatusCode(excludeStatusCodes, statusCodeValue)) {
logObj = object.getClass().newInstance();
BeanUtils.setProperty(logObj, logIgnore.statusCodeFieldName(), statusCodeValue);
BeanUtils.setProperty(logObj, logIgnore.messageFieldName(), messageValue);
}
}
}
ApiLog.infoConvertJson(logMethod.toString(), logIgnore.logMessage(), request, startTime, System.currentTimeMillis(), requestData, logObj);
LogThreadLocal.removeTrackingNo();
return object;
}
}
/**
* 过滤返参code是否在excludeStatusCodes存在
*
* @param excludeStatusCodes
* @param statusCodeValue
* @return
*/
private boolean containStatusCode(String[] excludeStatusCodes, String statusCodeValue) {
if (excludeStatusCodes == null || excludeStatusCodes.length == 0) {
return false;
}
for (int i = 0; i < excludeStatusCodes.length; i++) {
if (excludeStatusCodes[i].equals(statusCodeValue)) {
return true;
}
}
return false;
}
/**
* 系统异常时,AfterThrowing在ApiAnnotation注解中已经处理。
* 此处先注释,暂不删除,代码保留
*
* @param joinPoint
* @return
*/
@AfterThrowing(
pointcut = "pointcut()",
throwing = "e"
)
public void doAfterThrowing(JoinPoint joinPoint, Exception e) {
long startTime = System.currentTimeMillis();
Signature sig = joinPoint.getSignature();
Method currentMethod = null;
MethodSignature msig = null;
if (!(sig instanceof MethodSignature)) {
throw new IllegalArgumentException("非法参数使用");
} else {
msig = (MethodSignature) sig;
Object target = joinPoint.getTarget();
try {
currentMethod = target.getClass().getMethod(msig.getName(), msig.getParameterTypes());
} catch (NoSuchMethodException var19) {
var19.printStackTrace();
}
StringBuilder logMethod = new StringBuilder(joinPoint.getSignature().getDeclaringTypeName());
logMethod.append(".");
logMethod.append(joinPoint.getSignature().getName());
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
try {
Class<?> clz = e.getClass();
boolean clzHasAnno = clz.isAnnotationPresent(IgnoreErrorAnnotation.class);
if (!clzHasAnno) {
this.emailAlertService.sendEmailAlert("系统全局异常", e);
}
} catch (Exception var17) {
ErrorLog.errorConvertJson(SDKCommonBaseContextWare.getAppName(), logMethod.toString(), "出错:" + e.getMessage(), request, startTime, System.currentTimeMillis(), this.getLogArgs(currentMethod, joinPoint), var17);
} finally {
ErrorLog.errorConvertJson(SDKCommonBaseContextWare.getAppName(), logMethod.toString(), "出错:" + e.getMessage(), request, startTime, System.currentTimeMillis(), this.getLogArgs(currentMethod, joinPoint), e);
LogThreadLocal.removeTrackingNo();
}
}
}
private List getLogArgs(Method method, JoinPoint joinPoint) {
if (method == null) {
return null;
} else {
Object[] args = joinPoint.getArgs();
if (args != null && args.length != 0) {
List logArgs = new ArrayList();
Parameter[] parameters = method.getParameters();
for (int j = 0; j < parameters.length; ++j) {
Parameter parameter = parameters[j];
LogParams logParams = (LogParams) parameter.getAnnotation(LogParams.class);
if (logParams != null) {
logArgs.add(args[j]);
}
}
return logArgs;
} else {
return null;
}
}
}
@Override
public int getOrder() {
return 0;
}
}
package cn.freemud.aop;
import java.lang.annotation.*;
/**
* @author freemud
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {ElementType.METHOD})
@Documented
@Inherited
public @interface IgnoreFeignLogAnnotation {
/**
* 是否打印日志,true打印,false不打印,注意设置成false状态码和状态码信息都不会打印
* @return
*/
boolean printLog() default true;
/**
* printLog 设置成true的时候,可以排除哪些状态码的响应不用打印响应报文,只会打印状态码
*
* @return
*/
String[] excludeStatusCodes() default "100";
String statusCodeFieldName() default "code";
String messageFieldName() default "message";
}
package cn.freemud.aop;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* @author
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface LogIgnore {
/**
* 是否打印日志,true打印,false不打印,注意设置成false状态码和状态码信息都不会打印
*
* @return
*/
boolean printLog() default true;
/**
* printLog 设置成true的时候,可以排除哪些状态码的响应不用打印响应报文,只会打印状态码
* 默认成功100
* @return
*/
String[] excludeStatusCodes() default "100";
/**
* statusCodeFieldName 默认返回状态码字段为code
*
* @return
*/
String statusCodeFieldName() default "code";
/**
* statusCodeFieldName 默认返回状态码字段为message
*
* @return
*/
String messageFieldName() default "message";
/**
* logMessage 日志打印
* @return
*/
String logMessage() default "";
}
......@@ -15,12 +15,16 @@ import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare;
import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.freemud.application.sdk.api.log.ThirdPartyLog;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.context.request.RequestAttributes;
......@@ -74,6 +78,12 @@ public class WebAspect {
private static final String APP_CHANNEL = "3";
/**
* 是否打印响应报文日志,默认是false,若为true会覆盖注解里面的{@link IgnoreFeignLogAnnotation}配置,输出响应报文里面所有的信息
*/
@Value("${print-feign-response-body-log-shop-cart:false}")
private volatile boolean printFeignResponseBodyLogForShopCart = false;
@Pointcut("execution(* cn.freemud.controller..*.*(..))")
public void webAspect() {
}
......@@ -84,18 +94,18 @@ public class WebAspect {
ServletRequestAttributes sra = (ServletRequestAttributes) ra;
HttpServletRequest request = sra.getRequest();
String sessionId = request.getHeader(SESSION_ID_STR);
if(!StringUtils.isEmpty(sessionId)) {
if (!StringUtils.isEmpty(sessionId)) {
String requestUrl = request.getRequestURI();
List<String> notFilterUrls = Arrays.asList(getNotFilterUrl(CommonRedisKeyConstant.SAAS_NOT_FILTER_URL, KEY).split(","));
// 是否授权验证
AssortmentCustomerInfoVo userInfo = assortmentCustomerInfoManager.getCustomerInfoByObject(sessionId);
if (!notFilterUrls.contains(requestUrl)) {
if(userInfo == null) {
if (userInfo == null) {
throw new CommonServiceException(CommonResponseResult.USER_UNAUTHORIZED);
}
// app 没有unionId得概念, 并且app上是thirdMemberId概念。 不需要做校验
if(!Objects.equals(userInfo.getChannel(), APP_CHANNEL)) {
if(StringUtils.isEmpty(userInfo.getMemberId())) {
if (!Objects.equals(userInfo.getChannel(), APP_CHANNEL)) {
if (StringUtils.isEmpty(userInfo.getMemberId())) {
throw new CommonServiceException(CommonResponseResult.USER_UNAUTHORIZED);
}
List<String> unauthorizedUrls = Arrays.asList(getNotFilterUrl(CommonRedisKeyConstant.SAAS_NOT_AUTHORIZED_URL, NOT_AUTHORIZED_KEY).split(","));
......@@ -132,6 +142,11 @@ public class WebAspect {
return result;
}
/**
* 20201231改造feign日志打印判断
* 根据printFeignResponseBodyLog判断是否开启打印
*/
@Pointcut("execution(* cn.freemud.service.thirdparty..*.*(..))")
public void clientLog() {
}
......@@ -147,13 +162,91 @@ public class WebAspect {
LogUtil.thirdPartError(start, System.currentTimeMillis(), thirdPartLogVo, null);
throw ex;
}
ThirdPartLogVo thirdPartLogVo = LogUtil.createThirdPartLogVo(joinPoint);
// 打印第三方出参日志
ThirdPartyLog.infoConvertJson(LogThreadLocal.getTrackingNo(), SDKCommonBaseContextWare.getAppName(),start,System.currentTimeMillis(),
thirdPartLogVo.getUri(),thirdPartLogVo.getRequestBody(),result);
try {
Signature sig = joinPoint.getSignature();
MethodSignature msig = null;
if (sig instanceof MethodSignature) {
msig = (MethodSignature) sig;
Method currentMethod = sig.getDeclaringType().getDeclaredMethod(msig.getName(), msig.getParameterTypes());
Object logReult = result;
ThirdPartLogVo thirdPartLogVo = LogUtil.createThirdPartLogVo(joinPoint);
// 打印第三方出参日志
if (!this.printFeignResponseBodyLogForShopCart) {
IgnoreFeignLogAnnotation logIgnore = currentMethod.getAnnotation(IgnoreFeignLogAnnotation.class);
if (logIgnore != null && logIgnore.printLog()) {
String statusCodeValue = org.apache.commons.beanutils.BeanUtils.getProperty(result, logIgnore.statusCodeFieldName());
String messageValue = org.apache.commons.beanutils.BeanUtils.getProperty(result, logIgnore.messageFieldName());
String[] excludeStatusCodes = logIgnore.excludeStatusCodes();
//当排除了这个状态码不打印响应的具体内容只会打印状态码和状态描述信息
if (!StringUtils.isEmpty(statusCodeValue) && this.containStatusCode(excludeStatusCodes, statusCodeValue)) {
logReult = result.getClass().newInstance();
org.apache.commons.beanutils.BeanUtils.setProperty(logReult, logIgnore.statusCodeFieldName(), statusCodeValue);
org.apache.commons.beanutils.BeanUtils.setProperty(logReult, logIgnore.messageFieldName(), messageValue);
}
}
}
ThirdPartyLog.infoConvertJson(LogThreadLocal.getTrackingNo(), SDKCommonBaseContextWare.getAppName(), start, System.currentTimeMillis(),
thirdPartLogVo.getUri(), thirdPartLogVo.getRequestBody(), logReult);
}
} catch (Exception e) {
log.error("WebAspect Feign Log Ignore error {}", ExceptionUtils.getMessage(e));
}
return result;
}
/**
* 20201231改造SDK日志打印判断
* 根据printFeignResponseBodyLog判断是否开启打印
* 后续将模块内SDK整合为feign请求,此次暂时不用
*/
/**
* @Pointcut("@annotation(com.freemud.application.sdk.api.log.ThirdPartyLog)") public void restTemplateLog() {
* }
* @Around("restTemplateLog()") public Object doAroundRestTemplate(ProceedingJoinPoint joinPoint) throws Throwable {
* long start = System.currentTimeMillis();
* Object result = null;
* try {
* result = joinPoint.proceed();
* } catch (Exception ex) {
* ThirdPartLogVo thirdPartLogVo = LogUtil.createThirdPartLogVo(joinPoint);
* LogUtil.thirdPartError(start, System.currentTimeMillis(), thirdPartLogVo, null);
* throw ex;
* }
* try {
* Signature sig = joinPoint.getSignature();
* MethodSignature msig = null;
* if (sig instanceof MethodSignature) {
* msig = (MethodSignature) sig;
* Method currentMethod = sig.getDeclaringType().getDeclaredMethod(msig.getName(), msig.getParameterTypes());
* <p>
* Object logReult = result;
* ThirdPartLogVo thirdPartLogVo = LogUtil.createThirdPartLogVo(joinPoint);
* // 打印第三方出参日志
* if (!this.printFeignResponseBodyLog) {
* IgnoreFeignLogAnnotation logIgnore = currentMethod.getAnnotation(IgnoreFeignLogAnnotation.class);
* if (logIgnore != null && logIgnore.printLog()) {
* String statusCodeValue = org.apache.commons.beanutils.BeanUtils.getProperty(result, logIgnore.statusCodeFieldName());
* String messageValue = org.apache.commons.beanutils.BeanUtils.getProperty(result, logIgnore.messageFieldName());
* String[] excludeStatusCodes = logIgnore.excludeStatusCodes();
* //todo 当排除了这个状态码不打印响应的具体内容只会打印状态码和状态描述信息
* if (!StringUtils.isEmpty(statusCodeValue) && this.containStatusCode(excludeStatusCodes, statusCodeValue)) {
* logReult = result.getClass().newInstance();
* org.apache.commons.beanutils.BeanUtils.setProperty(logReult, logIgnore.statusCodeFieldName(), statusCodeValue);
* org.apache.commons.beanutils.BeanUtils.setProperty(logReult, logIgnore.messageFieldName(), messageValue);
* }
* }
* }
* ThirdPartyLog.infoConvertJson(LogThreadLocal.getTrackingNo(), SDKCommonBaseContextWare.getAppName(), start, System.currentTimeMillis(),
* thirdPartLogVo.getUri(), thirdPartLogVo.getRequestBody(), logReult);
* <p>
* }
* } catch (Exception e) {
* log.error("WebAspect Feign Log Ignore error {}", ExceptionUtils.getMessage(e));
* }
* return result;
* }
*/
public String getNotFilterUrl(String redisKey, String configKey) {
String notFilterUrl;
try {
......@@ -171,4 +264,17 @@ public class WebAspect {
return notFilterUrl;
}
private boolean containStatusCode(String[] excludeStatusCodes,
String statusCodeValue) {
if (excludeStatusCodes == null || excludeStatusCodes.length == 0) {
return false;
}
for (int i = 0; i < excludeStatusCodes.length; i++) {
if (excludeStatusCodes[i].equals(statusCodeValue)) {
return true;
}
}
return false;
}
}
......@@ -21,10 +21,22 @@ import java.util.Set;
public class ResponseCodeKeyConstant {
public final static String CODE = "code";
public final static String ERR_CODE = "errcode";
public final static String MESSAGE = "message";
public final static String STATUS_CODE = "statusCode";
public static final String MEG = "meg";
public static final String MSG = "msg";
//code名称来源根据 ProductInfosDto
public final static String ERR_CODE = "errcode";
//errmsg名称来源根据 ProductInfosDto
public static final String ERR_MSG = "errmsg";
private final static Set<String> responseCodeKeySet = new HashSet<>();
......@@ -43,4 +55,6 @@ public class ResponseCodeKeyConstant {
}
return o;
}
}
......@@ -12,6 +12,7 @@
*/
package cn.freemud.controller;
import cn.freemud.aop.LogIgnore;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.entities.vo.*;
import cn.freemud.enums.ResponseResult;
......@@ -39,8 +40,8 @@ public class ShoppingCartCollageController {
/**
* 向拼单购物车中添加商品
*/
@ApiAnnotation(logMessage = "addGoods")
@PostMapping(value = "/addGoods")
@LogIgnore(logMessage = "addGoods")
public BaseResponse addGoods(@Validated @LogParams @RequestBody AddShoppingCartGoodsRequestVo request) {
return SDKCommonBaseContextWare.getBean(ShoppingCartCollageServiceImpl.class).addGoods(request);
}
......@@ -48,7 +49,7 @@ public class ShoppingCartCollageController {
/**
* 修改拼单购物车中商品数量
*/
@ApiAnnotation(logMessage = "updateGoodsQty")
@LogIgnore(logMessage = "updateGoodsQty")
@PostMapping(value = "/updateGoodsQty")
public BaseResponse updateGoodsQty(@Validated @LogParams @RequestBody UpdateShoppingCartGoodsQtyRequestVo request) {
return SDKCommonBaseContextWare.getBean(ShoppingCartCollageServiceImpl.class).updateGoodsQty(request);
......@@ -57,7 +58,7 @@ public class ShoppingCartCollageController {
/**
* 查询购物车信息
*/
@ApiAnnotation(logMessage = "listCartGoods")
@LogIgnore(logMessage = "listCartGoods")
@PostMapping(value = "/listCartGoods")
public BaseResponse listCartGoods(@Validated @LogParams @RequestBody ShoppingCartInfoRequestVo request) {
return SDKCommonBaseContextWare.getBean(ShoppingCartCollageServiceImpl.class).getGoodsList(request);
......@@ -66,7 +67,7 @@ public class ShoppingCartCollageController {
/**
* 清空自己的购物车
*/
@ApiAnnotation(logMessage = "clearPartCartGoods")
@LogIgnore(logMessage = "clearPartCartGoods")
@PostMapping(value = "/clearPartCartGoods")
public BaseResponse clearPartCartGoods(@Validated @LogParams @RequestBody ShoppingCartCollageClearRequestVo request) {
return SDKCommonBaseContextWare.getBean(ShoppingCartCollageServiceImpl.class).clearPartCarGoods(request);
......@@ -75,7 +76,7 @@ public class ShoppingCartCollageController {
/**
* 清空购物车
*/
@ApiAnnotation(logMessage = "clearCartGoods")
@LogIgnore(logMessage = "clearCartGoods")
@PostMapping(value = "/clearCartGoods")
public BaseResponse clearCartGoods(@Validated @LogParams @RequestBody ShoppingCartClearRequestVo request) {
return SDKCommonBaseContextWare.getBean(ShoppingCartCollageServiceImpl.class).clear(request);
......@@ -87,7 +88,7 @@ public class ShoppingCartCollageController {
* @param getShoppingCartGoodsApportionRequestVo
* @return
*/
@ApiAnnotation(logMessage = "getShoppingCartGoodsApportion")
@LogIgnore(logMessage = "getShoppingCartGoodsApportion")
@PostMapping(value = "/getShoppingCartGoodsApportion")
public BaseResponse getShoppingCartGoodsApportion(@Validated @LogParams @RequestBody GetShoppingCartGoodsApportionRequestVo getShoppingCartGoodsApportionRequestVo) {
if (getShoppingCartGoodsApportionRequestVo == null || getShoppingCartGoodsApportionRequestVo.getShoppingCartInfoRequestVo() == null) {
......@@ -111,7 +112,7 @@ public class ShoppingCartCollageController {
* 查询购车信息无配送费
* SVC卡支付check,check购物车金额加配送费小于储值卡金额
*/
@ApiAnnotation(logMessage = "listCartGoodsCheck")
@LogIgnore(logMessage = "listCartGoodsCheck")
@PostMapping(value = "/listCartGoodsCheck")
public BaseResponse listCartGoodsCheck(@Validated @LogParams @RequestBody ShoppingCartInfoRequestVo request) {
return SDKCommonBaseContextWare.getBean(ShoppingCartCollageServiceImpl.class).getGoodsListCheck(request);
......
......@@ -12,7 +12,9 @@
*/
package cn.freemud.controller;
import cn.freemud.aop.LogIgnore;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.entities.dto.GetMemberInfoRequestDto;
import cn.freemud.entities.vo.*;
import cn.freemud.enums.OrderChannelType;
......@@ -52,8 +54,8 @@ public class ShoppingCartController {
/**
* 从微信卡券向购物车中添加商品
*/
@ApiAnnotation(logMessage = "addGoodsByCard")
@PostMapping(value = "/addGoodsByCard")
@LogIgnore(logMessage = "addGoodsByCard")
public BaseResponse addGoodsByCard(@Validated @LogParams @RequestBody AddGoodsByWeixinCardRequestVo request) {
return getInstanceByRequest(request).addGoodsByCard(request);
}
......@@ -61,8 +63,8 @@ public class ShoppingCartController {
/**
* 向购物车中添加商品
*/
@ApiAnnotation(logMessage = "addGoods")
@PostMapping(value = "/addGoods")
@LogIgnore(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},logMessage = "addGoods")
public BaseResponse addGoods(@Validated @LogParams @RequestBody AddShoppingCartGoodsRequestVo request) {
return getInstanceByRequest(request).addGoods(request);
}
......@@ -70,8 +72,8 @@ public class ShoppingCartController {
/**
* 修改购物车中商品数量
*/
@ApiAnnotation(logMessage = "updateGoodsQty")
@PostMapping(value = "/updateGoodsQty")
@LogIgnore(logMessage = "updateGoodsQty")
public BaseResponse updateGoodsQty(@Validated @LogParams @RequestBody UpdateShoppingCartGoodsQtyRequestVo request) {
return getInstanceByRequest(request).updateGoodsQty(request);
}
......@@ -79,8 +81,8 @@ public class ShoppingCartController {
/**
* 查询购物车信息
*/
@ApiAnnotation(logMessage = "listCartGoods")
@PostMapping(value = "/listCartGoods")
@LogIgnore(logMessage = "listCartGoods")
public BaseResponse listCartGoods(@Validated @LogParams @RequestBody ShoppingCartInfoRequestVo request) {
return getInstanceByRequest(request).getGoodsList(request);
}
......@@ -89,8 +91,8 @@ public class ShoppingCartController {
* 查询购车信息无配送费
* SVC卡支付check,check购物车金额加配送费小于储值卡金额
*/
@ApiAnnotation(logMessage = "listCartGoodsCheck")
@PostMapping(value = "/listCartGoodsCheck")
@LogIgnore(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},logMessage = "listCartGoodsCheck")
public BaseResponse listCartGoodsCheck(@Validated @LogParams @RequestBody ShoppingCartInfoRequestVo request) {
return getInstanceByRequest(request).getGoodsListCheck(request);
}
......@@ -106,14 +108,14 @@ public class ShoppingCartController {
/**
* 清空购物车
*/
@ApiAnnotation(logMessage = "clearCartGoods")
@PostMapping(value = "/clearCartGoods")
@LogIgnore(logMessage = "clearCartGoods")
public BaseResponse clearCartGoods(@Validated @LogParams @RequestBody ShoppingCartClearRequestVo request) {
String sessionId = request.getSessionId();
if(StringUtils.isEmpty(sessionId)){
if (StringUtils.isEmpty(sessionId)) {
String tableNumber = request.getTableNumber();
if(StringUtils.isEmpty(tableNumber)){
return ResponseUtil.error(ResponseResult.PARAMETER_MISSING,"sessionId和tableNumber不能同时为空");
if (StringUtils.isEmpty(tableNumber)) {
return ResponseUtil.error(ResponseResult.PARAMETER_MISSING, "sessionId和tableNumber不能同时为空");
}
return getInstanceByIAppId(IappIdType.WC_XCX.getCode()).clear(request);
}
......@@ -127,8 +129,8 @@ public class ShoppingCartController {
* @param getShoppingCartGoodsApportionRequestVo
* @return
*/
@ApiAnnotation(logMessage = "getShoppingCartGoodsApportion")
@PostMapping(value = "/getShoppingCartGoodsApportion")
@LogIgnore(logMessage = "getShoppingCartGoodsApportion")
public BaseResponse getShoppingCartGoodsApportion(@Validated @LogParams @RequestBody GetShoppingCartGoodsApportionRequestVo getShoppingCartGoodsApportionRequestVo) {
if (getShoppingCartGoodsApportionRequestVo == null || getShoppingCartGoodsApportionRequestVo.getShoppingCartInfoRequestVo() == null) {
return ResponseUtil.error(ResponseResult.NOT_LOGIN);
......@@ -141,7 +143,7 @@ public class ShoppingCartController {
private ShoppingCartNewService getInstanceByRequest(BaseRequestVo requestVo) {
if(requestVo.getChannelType() != null && OrderChannelType.SAASMALL.getCode().equals(requestVo.getChannelType())) {
if (requestVo.getChannelType() != null && OrderChannelType.SAASMALL.getCode().equals(requestVo.getChannelType())) {
return SDKCommonBaseContextWare.getBean(ShoppingCartMallServiceImpl.class);
} else {
return getInstanceBySessionId(requestVo.getSessionId());
......@@ -179,8 +181,8 @@ public class ShoppingCartController {
/**
* 线下订单查询接口
*/
@ApiAnnotation(logMessage = "/getMemberInfo")
@PostMapping(value = "/getMemberInfo")
@LogIgnore(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},logMessage = "/getMemberInfo")
public BaseResponse getMemberInfo(@LogParams @RequestBody GetMemberInfoRequestDto request) {
return SDKCommonBaseContextWare.getBean(ShoppingCartNewServiceImpl.class).getMemberInfo(request);
}
......
......@@ -323,7 +323,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
Integer checkQty = this.checkSkuQty(allCartGoodsList, cartGoods);
//购物车添加数量限制
Integer productsCount = limitGoodsQty(allCartGoodsList,cartGoods,appId);
//查询多个商品库存信息
//查询多个商品库存信息 TODO
queryManyGoodsStocks(addShoppingCartGoodsRequestVo, productIds, productBeanListSpuClass, skuId, checkQty);
String productName = null;
// 当添加的商品不是商品券时
......
......@@ -12,6 +12,9 @@
*/
package cn.freemud.service.thirdparty;
import cn.freemud.aop.IgnoreFeignLogAnnotation;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.constant.ResponseCodeKeyConstant;
import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.activity.ActivityQueryResponseDto;
import com.freemud.application.sdk.api.base.BaseResponse;
......@@ -29,12 +32,14 @@ public interface ActivityClient {
* 统一活动查询接口
*/
@PostMapping("/activity/query")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.STATUS_CODE,messageFieldName=ResponseCodeKeyConstant.MSG)
ActivityQueryResponseDto query(ActivityQueryRequestDto activityQueryRequestDto);
/**
* 优惠金额计算
*/
@PostMapping("/calculation/discount")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.STATUS_CODE,messageFieldName=ResponseCodeKeyConstant.MSG)
ActivityCalculationDiscountResponseDto calculationDiscount(ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto);
/**
......@@ -57,5 +62,6 @@ public interface ActivityClient {
* @return
*/
@PostMapping("/calculation/discount/sharing")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.STATUS_CODE,messageFieldName=ResponseCodeKeyConstant.MSG)
ActivityCalculationDiscountResponseDto calculationDiscountSharing(ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto);
}
package cn.freemud.service.thirdparty;
import cn.freemud.aop.IgnoreFeignLogAnnotation;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.constant.ResponseCodeKeyConstant;
import cn.freemud.entities.dto.BuryingPointBigDto;
import cn.freemud.entities.dto.BuryingPointResDto;
import org.springframework.cloud.netflix.feign.FeignClient;
......
package cn.freemud.service.thirdparty;
import cn.freemud.aop.IgnoreFeignLogAnnotation;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.constant.ResponseCodeKeyConstant;
import cn.freemud.entities.dto.calculate.CalculationSharingDiscountRequestDto;
import cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto;
import org.springframework.cloud.netflix.feign.FeignClient;
......@@ -13,5 +16,6 @@ public interface CalculationClient {
* 促销新的算价对接
*/
@PostMapping("/promotioncenter/calculateservice/discount/sharing")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.STATUS_CODE,messageFieldName=ResponseCodeKeyConstant.MEG)
CalculationSharingDiscountResponseDto calculationSharingDiscount(CalculationSharingDiscountRequestDto shareDiscountRequestDto);
}
package cn.freemud.service.thirdparty;
import cn.freemud.aop.IgnoreFeignLogAnnotation;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.constant.ResponseCodeKeyConstant;
import cn.freemud.entities.dto.BatchQueryActivityInfoRequestDto;
import cn.freemud.entities.dto.BatchQueryActivityInfoResponseDto;
import cn.freemud.entities.dto.GetAppKeyRequestDto;
......@@ -18,6 +21,7 @@ public interface CardBinClient {
* @return
*/
@PostMapping("/getAppKey")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.STATUS_CODE,messageFieldName=ResponseCodeKeyConstant.MEG)
GetAppKeyResponseDto getAppKey(GetAppKeyRequestDto requestDto);
/**
......@@ -26,6 +30,7 @@ public interface CardBinClient {
* @return
*/
@PostMapping(value = "/batchQueryActivityInfo")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.STATUS_CODE,messageFieldName=ResponseCodeKeyConstant.MEG)
BatchQueryActivityInfoResponseDto batchQueryActivityInfo(BatchQueryActivityInfoRequestDto requestDto);
......
package cn.freemud.service.thirdparty;
import cn.freemud.aop.IgnoreFeignLogAnnotation;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.constant.ResponseCodeKeyConstant;
import cn.freemud.entities.dto.user.GetUserScoreUseDetailRequest;
import cn.freemud.entities.dto.user.GetUserScoreUserDetailResponse;
import org.springframework.cloud.netflix.feign.FeignClient;
......@@ -26,5 +29,6 @@ public interface CustomScoreClient {
* 用户可用积分
*/
@PostMapping(value = "/user/scoreUseDetail")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.CODE,messageFieldName=ResponseCodeKeyConstant.MESSAGE)
GetUserScoreUserDetailResponse getUserScoreUseDetail(@RequestBody GetUserScoreUseDetailRequest getUserScoreUseDetailRequest);
}
package cn.freemud.service.thirdparty;
import cn.freemud.aop.IgnoreFeignLogAnnotation;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.entities.dto.GetPaidRuleRequestDto;
import cn.freemud.entities.dto.GetPaidRuleResponseDto;
import cn.freemud.entities.dto.user.GetSessionUserInfoDto;
......@@ -28,5 +30,6 @@ public interface CustomerApplicationClient {
BaseResponse<GetPaidRuleResponseDto> getPaidRule(GetPaidRuleRequestDto getPaidRuleRequestDto);
@PostMapping(value = "/user/getSessionUserInfo")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR})
BaseResponse<CustomerInfoVo>getSessionUserInfo(GetSessionUserInfoDto getSessionUserInfoDto);
}
......@@ -12,7 +12,10 @@
*/
package cn.freemud.service.thirdparty;
import cn.freemud.aop.IgnoreFeignLogAnnotation;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.constant.ResponseCodeKeyConstant;
import cn.freemud.entities.dto.GetProductStockRequestDto;
import cn.freemud.entities.dto.GetProductStockResponseDto;
import cn.freemud.entities.dto.UpdateProductStockRequestDto;
......@@ -29,6 +32,7 @@ public interface StockClient {
* 前端查询多个商品库存信息
*/
@PostMapping("/getAvailableStocks")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.CODE,messageFieldName=ResponseCodeKeyConstant.MESSAGE)
GetProductStockResponseDto getAvailableStocks(@RequestBody GetProductStockRequestDto requestDto);
/**
......
......@@ -12,6 +12,9 @@
*/
package cn.freemud.service.thirdparty;
import cn.freemud.aop.IgnoreFeignLogAnnotation;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.constant.ResponseCodeKeyConstant;
import cn.freemud.entities.dto.*;
import com.freemud.application.sdk.api.productcenter.request.product.valid.ValidateShopProductRequest;
import com.freemud.application.sdk.api.productcenter.response.ProductResponseDTO;
......@@ -42,6 +45,9 @@ public interface StoreItemClient {
* 获取商品的详细信息
*/
@PostMapping("/Shop/ListProductInfoByIdList")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.ERR_CODE,messageFieldName=ResponseCodeKeyConstant.MEG)
ProductInfosDto listProductInfos(@RequestBody GetProductInfoDto getProductInfoDto);
......
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