Commit 4c405242 by hanghang.wang

Merge branch 'feature/20210608_【技术线】【订单】服务打印日志删减——购物车聚合服务_wanghanghang' into qa

# Conflicts:
#	order-application-service/src/main/java/cn/freemud/controller/OrderController.java
#	shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CalculationServiceImpl.java
parents 9727e987 51550825
......@@ -3179,7 +3179,7 @@ public class OrderAdapter {
orderPayDto.setPayCode(PayChannelType.TIKTOKPAY.getEbcode());
}
orderPayDto.setFoodOrderType(getFoodOrderType(orderBean.getOrderType()));
orderPayDto.setMerchantDiscount(orderBean.getOriginalAmount().longValue()-orderBean.getAmount());
// orderPayDto.setMerchantDiscount(orderBean.getOriginalAmount().longValue()-orderBean.getAmount());
return orderPayDto;
}
......
package cn.freemud.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* @author wanghanghang
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface LogIgnore {
/**
* 是否打印日志,true打印,false不打印,注意设置成false状态码和状态码信息都不会打印
*
* @return
*/
boolean printLog() default true;
/**
* printLog 设置成true的时候,可以排除哪些状态码的响应不用打印响应报文,只会打印状态码
* 默认成功100
* @return
*/
String[] excludeSuccessCodes() default "100";
/**
* statusCodeFieldName 默认返回状态码字段为code
*
* @return
*/
String codeFieldName() default "code";
/**
* statusCodeFieldName 默认返回状态码字段为message
*
* @return
*/
String messageFieldName() default "message";
/**
* logMessage 日志打印
* @return
*/
String logMessage() default "";
}
package cn.freemud.annotations;
import java.lang.annotation.*;
/**
* @author freemud
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(value = {ElementType.METHOD})
@Documented
@Inherited
public @interface LogIgnoreFeign {
/**
* 是否打印日志,true打印,false不打印,注意设置成false状态码和状态码信息都不会打印
* @return
*/
boolean printLog() default true;
/**
* printLog 设置成true的时候,可以排除哪些状态码的响应不用打印响应报文,只会打印状态码
*
* @return
*/
String[] excludeStatusCodes() default "100";
String statusCodeFieldName() default "code";
String messageFieldName() default "message";
}
......@@ -61,34 +61,11 @@ public class IsConvertEnAspect implements Ordered {
return baseResponse;
}
private HttpServletRequest currentRequest() {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
return Optional.ofNullable(servletRequestAttributes).map(ServletRequestAttributes::getRequest).orElse(null);
}
/**
* 备用方法,避免code或者message信息不统一
* 过滤返参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;
}
@Override
public int getOrder() {
return 0;
......
package cn.freemud.aop;
import cn.freemud.annotations.LogIgnore;
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.ApiLog;
import com.freemud.application.sdk.api.log.ErrorLog;
import com.freemud.application.sdk.api.log.LogParams;
import com.freemud.application.sdk.api.log.LogThreadLocal;
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.List;
import java.util.UUID;
/**
* @author freemud_whh
*/
@Aspect
@Component
public class LogIgnoreAspect implements Ordered {
@Autowired
private EmailAlertService emailAlertService;
/**
* 是否打印响应报文日志,默认是false,若为true会覆盖注解里面的{@link LogIgnore}配置,输出响应报文里面所有的信息
*/
@Value("${print-response-body-log-order-application-service:false}")
private volatile boolean printResponseBodyLog = false;
/**
* 即使printResponseBodyLog设置为true, 该参数中包含的url也会被过滤且不打印日志
*/
@Value("${exclude-print-body-log-methods:findNearPickUpStores,getMenuCategory}")
private volatile List<String> excludePrintBodyLogMethods = Lists.newArrayList();
@Pointcut("@annotation(cn.freemud.annotations.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.printResponseBodyLog || excludePrintBodyLogMethods.contains(logIgnore.logMessage())) {
String statusCodeValue = BeanUtils.getProperty(object, logIgnore.codeFieldName());
String messageValue = BeanUtils.getProperty(object, logIgnore.messageFieldName());
String[] excludeStatusCodes = logIgnore.excludeSuccessCodes();
//当排除了这个状态码不打印响应的具体内容只会打印状态码和状态描述信息
//当返回code在不打印的范围,则将打印信息变更为只打印code和message
if (this.containStatusCode(excludeStatusCodes, statusCodeValue)) {
logObj = object.getClass().newInstance();
BeanUtils.setProperty(logObj, logIgnore.codeFieldName(), 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 cn.freemud.annotations.LogIgnore;
import cn.freemud.annotations.LogIgnoreFeign;
import cn.freemud.entities.vo.ThirdPartLogVo;
import cn.freemud.utils.LogUtil;
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.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.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.lang.reflect.Method;
/**
* @author freemud
* @title: LogIgnoreFeignAop
* @projectName order-group
* @description: TODO
* @date 2021/6/9上午10:53
*/
@Aspect
@Component
@Slf4j
public class LogIgnoreFeignAspect {
/**
* 是否打印响应报文日志,默认是false,若为true会覆盖注解里面的{@link LogIgnore}配置,输出响应报文里面所有的信息
*/
@Value("${print-feign-response-body-log-order-application-service:true}")
private volatile boolean printFeignResponseBodyLog = true;
@Pointcut("execution(* cn.freemud.service.thirdparty..*.*(..))")
public void clientLog() {
}
@Around("clientLog()")
public Object doAround(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());
Object logReult = result;
ThirdPartLogVo thirdPartLogVo = LogUtil.createThirdPartLogVo(joinPoint);
// 打印第三方出参日志
if (!this.printFeignResponseBodyLog) {
LogIgnoreFeign logIgnore = currentMethod.getAnnotation(LogIgnoreFeign.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) {
LogUtil.error("WebAspect Feign Log Ignore error {}", "","",e);
}
return result;
}
// @Around("clientLog()")
// public Object doAround(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;
// }
// ThirdPartLogVo thirdPartLogVo = LogUtil.createThirdPartLogVo(joinPoint);
// // 打印第三方出参日志
// ThirdPartyLog.infoConvertJson(LogThreadLocal.getTrackingNo(), SDKCommonBaseContextWare.getAppName(),start,System.currentTimeMillis(),
// thirdPartLogVo.getUri(),thirdPartLogVo.getRequestBody(),result);
// return result;
// }
/**
* 过滤返参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;
}
}
......@@ -133,27 +133,7 @@ public class WebAspect {
return result;
}
@Pointcut("execution(* cn.freemud.service.thirdparty..*.*(..)) || execution(* cn.freemud.service.mccafe.thirdparty..*.*(..)) || execution(* cn.freemud.management.thirdparty..*.*(..))")
public void clientLog() {
}
@Around("clientLog()")
public Object doAround(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;
}
ThirdPartLogVo thirdPartLogVo = LogUtil.createThirdPartLogVo(joinPoint);
// 打印第三方出参日志
ThirdPartyLog.infoConvertJson(LogThreadLocal.getTrackingNo(), SDKCommonBaseContextWare.getAppName(),start,System.currentTimeMillis(),
thirdPartLogVo.getUri(),thirdPartLogVo.getRequestBody(),result);
return result;
}
public String getNotFilterUrl(String redisKey, String configKey) {
String notFilterUrl;
......
......@@ -19,12 +19,28 @@ import java.util.HashSet;
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";
/**
* errcode名称来源根据 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<>();
......
package cn.freemud.service.thirdparty;
import cn.freemud.annotations.LogIgnoreFeign;
import cn.freemud.constant.ResponseCodeKeyConstant;
import cn.freemud.entities.dto.MCCafeDeliveryBaseResponse;
import cn.freemud.entities.dto.delivery.*;
import cn.freemud.entities.dto.delivery.QueryDeliveryAmountRequestDto;
......@@ -14,27 +16,35 @@ import org.springframework.web.bind.annotation.RequestBody;
public interface DeliveryFeiginClient {
@PostMapping("/deliveryLogisticsAmount/queryDeliveryAmount")
@LogIgnoreFeign(messageFieldName=ResponseCodeKeyConstant.MSG)
QueryDeliveryAmountResponseDto queryDeliveryAmount(@RequestBody QueryDeliveryAmountRequestDto request);
@PostMapping("/delivery/orderRemind")
@LogIgnoreFeign(messageFieldName=ResponseCodeKeyConstant.MSG)
QueryDeliveryAmountResponseDto orderRemind(@RequestBody OrderRemindRequestDto request);
@PostMapping("/delivery/listFreeRider")
@LogIgnoreFeign(messageFieldName=ResponseCodeKeyConstant.MSG)
MCCafeDeliveryBaseResponse<ResRiderTrackDto> listFreeRider(@RequestBody QueryLocusRiderTrackDto request);
@PostMapping("/delivery/create")
@LogIgnoreFeign(messageFieldName=ResponseCodeKeyConstant.MSG)
CreateDeliveryOrderResponseDto deliveryOrderAdd(@RequestBody CreateDeliveryVo request);
@PostMapping("/delivery/getDeliveryStatusAndRiderPosition")
@LogIgnoreFeign(messageFieldName=ResponseCodeKeyConstant.MSG)
DeliveryBaseResponse<DeliveryStatusAndRiderPositionDto> getDeliveryStatusAndRiderPosition(@RequestBody QueryDeliveryBaseRequest queryDeliveryBaseRequest);
@PostMapping("/delivery/getThirdDeliveryFlag")
@LogIgnoreFeign(messageFieldName=ResponseCodeKeyConstant.MSG)
DeliveryBaseResponse<GetDeliveryFlagResponseDto> getThirdDeliveryFlag(@RequestBody GetDeliveryFlagRequest getDeliveryFlagRequest);
@PostMapping("/delivery/queryDeliveryTemplate")
@LogIgnoreFeign(messageFieldName=ResponseCodeKeyConstant.MSG)
QueryDeliveryTemplateResponse queryDeliveryTemplate(@RequestBody QueryDeliveryTemplateRequest queryDeliveryTemplateRequest);
@PostMapping("/delivery/isFreightRefundSupported")
@LogIgnoreFeign(messageFieldName=ResponseCodeKeyConstant.MSG)
QueryFreightRefundSupportedResponse isFreightRefundSupported(@RequestBody QueryFreightRefundSupportedVo queryDeliveryTemplateVo);
......
......@@ -269,7 +269,6 @@ public class CouponServiceImpl implements CouponService {
@Override
public GetCouponDetailResponseDto getMemberCoupon(GetMemberCouponRequestVo requestVo) {
ApiLog.debug("getMemberCoupon:" + gson.toJson(requestVo));
//TODO 券详情查券服务
Map<String, String> map = new TreeMap<String, String>();
if (StringUtils.isBlank(requestVo.getPartnerId()) || StringUtils.isBlank(requestVo.getCouponCode())) {
......@@ -286,7 +285,6 @@ public class CouponServiceImpl implements CouponService {
String sign = SignUtil.createMD5Sign(map, appSecret);
map.put(Finals.SIGN, sign);
GetCouponDetailResponseDto responseDto = couponOnlineClient.getCouponDetails(map);
LogUtil.info("couponOnlineClient.getCouponDetails****", map, gson.toJson(responseDto));
if (ResponseCodeConstant.RESPONSE_SUCCESS_1.equals(responseDto.getResult())) {
return responseDto;
}
......@@ -913,7 +911,7 @@ public class CouponServiceImpl implements CouponService {
*/
@Override
public CheckSpqInfoResponseDto checkSpqInfo(CheckSpqInfoRequestDto requestDto, String goodsId) {
ApiLog.debug("checkSpqInfo****" + gson.toJson(requestDto));
// ApiLog.debug("checkSpqInfo****" + gson.toJson(requestDto));
String partnerId = requestDto.getPartnerId();
String couponCode = requestDto.getCouponCode();
String storeId = requestDto.getStoreId();
......@@ -1006,7 +1004,6 @@ public class CouponServiceImpl implements CouponService {
dto.setStockLimit(ObjectUtils.equals(1, productsVo.getStockLimit()));
dto.setExtras(productsVo.getExtra());
dto.setCouponType(couponType);
ApiLog.debug("dto***" + dto);
return dto;
}
......@@ -1059,7 +1056,6 @@ public class CouponServiceImpl implements CouponService {
*/
@Override
public GetProductsVo getSpqProductInfo(CheckSpqInfoRequestDto requestDto, String goodsId) {
ApiLog.debug("checkSpqInfo****" + gson.toJson(requestDto));
String partnerId = requestDto.getPartnerId();
String couponCode = requestDto.getCouponCode();
String storeId = requestDto.getStoreId();
......@@ -1069,7 +1065,6 @@ public class CouponServiceImpl implements CouponService {
requestVo.setCouponCode(couponCode);
requestVo.setStoreId(requestDto.getStoreId());
GetCouponDetailResponseDto couponDetailResponseDto = couponService.getMemberCoupon(requestVo);
LogUtil.info("couponService.getMemberCoupon", gson.toJson(requestVo), gson.toJson(couponDetailResponseDto));
if (couponDetailResponseDto == null || !couponDetailResponseDto.getResult().equals(ResponseCodeConstant.RESPONSE_SUCCESS_1) || CollectionUtils.isEmpty(couponDetailResponseDto.getDetails())) {
return null;
}
......
......@@ -83,8 +83,6 @@ public class ItemServiceImpl implements ItemService {
GetProductInfoDto getProductInfoDto = storeItemAdapter.convert2ProductInfoDto(partnerId, shopId, ProductInfoType.ALL.getCode(), productIds,menuType);
ProductInfosDto productInfosDto = storeItemClient.listProductInfos(getProductInfoDto);
if (!RESPONSE_SUCCESS_CODE.equals(productInfosDto.getErrcode()) || CollectionUtils.isEmpty(productInfosDto.getData().getProducts())) {
log.error("getShoppingCartInfo checkProductValidate is error , getProductValidateDto:{} , productCheckVaildDto:{}",
gson.toJson(getProductValidateDto), gson.toJson(productInfosDto));
return ResponseUtil.error(ResponseResult.STORE_ITEM_QUERY_ERROR);
}
List<String> productInfoIds = productInfosDto.getData().getProducts().stream()
......
......@@ -332,7 +332,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// 获取商品详细信息
List<ProductBean> productBeanListSpuClass = assortmentSdkService.getProductsInfo(partnerId, storeId
, Collections.singletonList(spuId2),addShoppingCartGoodsRequestVo.getMenuType(), this.shoppingCartBaseService);
LogUtil.info("productBeanListSpuClass", spuId2,JSON.toJSONString(productBeanListSpuClass));
// LogUtil.info("productBeanListSpuClass", spuId2,JSON.toJSONString(productBeanListSpuClass));
// 没有查到商品
if(productBeanListSpuClass == null || productBeanListSpuClass.isEmpty()){
......@@ -691,7 +691,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
buildCoupons(coupons,shoppingCartInfoRequestVo.getCouponCodes());
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList = shoppingCartInfoRequestVo.getSendGoods();
List<ShoppingCartInfoRequestVo.SendGoods> sendGoods = new ArrayList<>();
if (CollectionUtils.isNotEmpty(sendGoodsList)) {
......@@ -1480,7 +1479,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
activityCalculationDiscountRequestDto.setProductChannel(BusinessTypeEnum.SAAS_DELIVERY.getCode());
}
try {
ApiLog.debug("activityClient discount :{}", JSON.toJSONString(activityCalculationDiscountRequestDto));
activityCalculationDiscountResponseDto = activityClient.calculationDiscount(activityCalculationDiscountRequestDto);
} catch (Exception ex) {
ErrorLog.printErrorLog("calculation_discount_error", "/calculation/discount", activityCalculationDiscountRequestDto, ex);
......@@ -1960,9 +1958,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
private void addProductGoods(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo
, CartGoods cartGoods, String spuId2, String userId, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, String spuId
, List<CartGoods> allCartGoodsList, List<ProductBean> productBeanListSpuClass, CouponProductDto couponProductDto, String couponCode, Integer todayAvailableTimes) {
// 设置商品类型为商品券
if (CouponTypeEnum.TYPE_4.getCode().equals(couponProductDto.getType())) {
cartGoods.setGoodsType(GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType());
......
......@@ -134,7 +134,6 @@ public class CalculationSharingDiscountService {
CalculationSharingDiscountRequestDto.CalculationDiscountCoupon coupon = new CalculationSharingDiscountRequestDto.CalculationDiscountCoupon();
coupon.setCode(checkSpqInfo.getCouponCode());
coupon.setActivityCode(checkSpqInfo.getActiveCode());
ApiLog.debug("coupons={},coupon={}", JSON.toJSONString(coupons), JSON.toJSONString(coupon));
CalculationSharingDiscountRequestDto.CalculationDiscountCoupon calculationDiscountCoupon = coupons.stream().filter(p -> coupon.getActivityCode().equals(p.getActivityCode()) && coupon.getCode().equals(p.getCode())).findFirst().orElse(null);
if (calculationDiscountCoupon == null){
coupons.add(coupon);
......@@ -149,7 +148,6 @@ public class CalculationSharingDiscountService {
}
}
if (GoodsTypeEnum.SET_MEAL_GOODS.getGoodsType().equals(cartGoods.getGoodsType())) {
if (CollectionUtils.isEmpty(cartGoods.getProductGroupList()) && CollectionUtils.isEmpty(cartGoods.getProductComboList())) {
cartGoodsList.remove(i);
......@@ -194,22 +192,17 @@ public class CalculationSharingDiscountService {
calculationSharingDiscountRequestDto.setOrgIds(commonService.getOrgIdsForCoupon(partnerId,storeId));
calculationSharingDiscountRequestDto.setDistributionFee(deliveryAmount);
calculationSharingDiscountRequestDto.setIsMember(isMember);
CalculationSharingDiscountResponseDto sharingDiscountResponseDto;
// 构建买一送一寄杯活动用户选择信息
ActiveService activeService = activeFactory.getBuildChooseGoodsService(partnerId);
activeService.buildChooseGoodsService(calculationSharingDiscountRequestDto,shoppingCartInfoRequestVo == null ? null : shoppingCartInfoRequestVo.getChooseGoods());
try {
ApiLog.debug("start sharing discount dto={}", JSON.toJSONString(calculationSharingDiscountRequestDto));
sharingDiscountResponseDto = calculationClient.calculationSharingDiscount(calculationSharingDiscountRequestDto);
}
catch (Exception e) {
ErrorLog.printErrorLog("calculation_discount_error", "/calculation/discount/sharing", calculationSharingDiscountRequestDto, e);
throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN);
}
// 返回成功
if (sharingDiscountResponseDto != null && StringUtils.equals(sharingDiscountResponseDto.getStatusCode(), ResponseCodeConstant.RESPONSE_SUCCESS_STR)) {
CalculationSharingDiscountResponseDto.CalculationDiscountResult result = sharingDiscountResponseDto.getResult();
......
......@@ -2,6 +2,9 @@ package cn.freemud.service.thirdparty;
//import cn.freemud.constant.IgnoreFeignLogAnnotation;
import cn.freemud.annotations.IgnoreFeignLogAnnotation;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.constant.ResponseCodeKeyConstant;
import cn.freemud.entities.dto.GetCouponDetailResponseDto;
import cn.freemud.interceptor.FormSupportConfig;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -18,6 +21,7 @@ public interface CouponOnlineClient {
/**
* 查询券详情
*/
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.STATUS_CODE)
@PostMapping(value = "/code_v4", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}
)
......
......@@ -32,6 +32,6 @@ public interface CustomScoreClient {
* 用户可用积分
*/
@PostMapping(value = "/user/scoreUseDetail")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.CODE,messageFieldName=ResponseCodeKeyConstant.MESSAGE)
@IgnoreFeignLogAnnotation
GetUserScoreUserDetailResponse getUserScoreUseDetail(@RequestBody GetUserScoreUseDetailRequest getUserScoreUseDetailRequest);
}
......@@ -29,8 +29,10 @@ public interface CustomerApplicationClient {
@PostMapping(value = "/membercard/getPaidRule")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR})
BaseResponse<GetPaidRuleResponseDto> getPaidRule(GetPaidRuleRequestDto getPaidRuleRequestDto);
@PostMapping(value = "/user/getSessionUserInfo")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR})
BaseResponse<CustomerInfoVo>getSessionUserInfo(GetSessionUserInfoDto getSessionUserInfoDto);
......
......@@ -13,6 +13,9 @@
package cn.freemud.service.thirdparty;
import cn.freemud.annotations.IgnoreFeignLogAnnotation;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.constant.ResponseCodeKeyConstant;
import cn.freemud.entities.dto.GetMemberCouponListRequestDto;
import cn.freemud.entities.dto.GetMemberCouponListResponseDto;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -26,6 +29,7 @@ public interface CustomerExtendClient {
/**
* 会员优惠券列表
*/
@IgnoreFeignLogAnnotation()
@PostMapping(value = "/customerextendservice/coupon/getCoupons")
GetMemberCouponListResponseDto getMemberCouponListRequestDto(@RequestBody GetMemberCouponListRequestDto getMemberCouponListRequestDto);
}
package cn.freemud.service.thirdparty;
import cn.freemud.annotations.IgnoreFeignLogAnnotation;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.constant.ResponseCodeKeyConstant;
import cn.freemud.entities.dto.GetMemberListRequestDto;
import cn.freemud.entities.dto.GetMemberListResponseDto;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -17,6 +20,7 @@ public interface MemberToolsClient {
/**
* 根据会员手机号和商户获取会员信息
*/
@IgnoreFeignLogAnnotation
@PostMapping(value = "/customerservice/getMembers")
GetMemberListResponseDto getMemberList(@RequestBody GetMemberListRequestDto getMemberListRequestDto);
}
package cn.freemud.service.thirdparty;
import cn.freemud.annotations.IgnoreFeignLogAnnotation;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.constant.ResponseCodeKeyConstant;
import cn.freemud.entities.dto.ProductBaseResponse;
import cn.freemud.entities.dto.RequiredProductRequest;
import cn.freemud.entities.dto.product.ValiadShopProductResponse;
......@@ -29,10 +32,12 @@ import java.util.List;
public interface ProductClient {
@PostMapping({"/Shop/ListMenuMustProduct"})
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.ERR_CODE,messageFieldName = ResponseCodeKeyConstant.ERR_MSG)
ProductBaseResponse<List<String>> getRequiredProductList(@RequestBody RequiredProductRequest request);
@PostMapping({"/Shop/ValidateShopProduct/Reason"})
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.ERR_CODE,messageFieldName = ResponseCodeKeyConstant.ERR_MSG)
ProductBaseResponse<ValiadShopProductResponse> validateShopProductAboutReason(@RequestBody ValidateShopProductRequest request);
}
......@@ -32,7 +32,7 @@ public interface StockClient {
* 前端查询多个商品库存信息
*/
@PostMapping("/getAvailableStocks")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.CODE,messageFieldName=ResponseCodeKeyConstant.MESSAGE)
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR})
GetProductStockResponseDto getAvailableStocks(@RequestBody GetProductStockRequestDto requestDto);
/**
......
......@@ -42,35 +42,35 @@ public interface StoreItemClient {
* 根据商品id查询门店特定时间段菜单
*/
@PostMapping(value = "/Menu/GetMenuByIds")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.ERR_CODE,messageFieldName=ResponseCodeKeyConstant.MEG)
GetMenuByIdsResponseDto getMenuCategoryByIds(@RequestBody GetMenuCategoryByIdsDto getMenuCategoryByIdsDto);
/**
* 获取商品的详细信息
*/
@PostMapping("/Shop/ListProductInfoByIdList")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.ERR_CODE,messageFieldName=ResponseCodeKeyConstant.MEG)
ProductInfosDto listProductInfos(@RequestBody GetProductInfoDto getProductInfoDto);
/**
* 根据skuid查询spu信息
* @return
*/
@PostMapping("/Product/GetSpectionProductBySkuId")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.ERR_CODE,messageFieldName=ResponseCodeKeyConstant.MEG)
ProductListDto getSpuIdsBySkuIds(@RequestBody GetSpuIdsBySkuIdsDto requestDto);
/**
* 校验商品可用性
*/
@PostMapping("Shop/ValidateShopProduct")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.ERR_CODE,messageFieldName=ResponseCodeKeyConstant.MEG)
ProductResponseDTO<ValiadShopProductResponse> validateShopProduct(@RequestBody ValidateShopProductRequest request);
/**
* 校验商品在当前门店是否可售
*/
@PostMapping("/Shop/validateShopContainProduct")
@IgnoreFeignLogAnnotation(excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.ERR_CODE,messageFieldName=ResponseCodeKeyConstant.MEG)
ValidateProductInfosDto validateShopContainProduct(@RequestBody GetValidateProductInfoDto 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