Commit 802928ed by hanghang.wang

添加日志

parent 4a7ff217
......@@ -61,15 +61,15 @@ public class ActivityTip {
* 1.5.5版本添加
* 每单可以参与买一赠一商品总数
*/
private Integer activityQty;
// private Integer activityQty;
/**
* 1.5.5版本添加
* 购物车中参与买一赠一商品个数
*/
private Integer activityCartQty;
// private Integer activityCartQty;
/**
* 1.5.5版本添加
* 购物车中属于买一赠一商品的数据
*/
private List<String> activitySpuIds;
// private List<String> activitySpuIds;
}
......@@ -4,6 +4,7 @@ import ch.qos.logback.classic.Level;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.redis.RedisCache;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare;
import com.freemud.application.sdk.api.constant.ResponseResultEnum;
import com.freemud.application.sdk.api.couponcenter.online.domain.*;
......@@ -209,7 +210,9 @@ public interface ShoppingCartBaseService {
try {
ValidateShopProductRequest validateShopProductRequest = shoppingCartAdapter.getValidateShopProductRequest(checkCartRequest);
com.freemud.application.sdk.api.base.BaseResponse<ValiadShopProductResponse> valiadResponse = productService.validateShopProduct(validateShopProductRequest);
ShoppingSdkLogUtil.infoLog("替换购物车数据检验结果 1 --> validateShopProductRequest:{} valiadResponse:{}", validateShopProductRequest,valiadResponse);
// ShoppingSdkLogUtil.infoLog("替换购物车数据检验结果 1 --> validateShopProductRequest:{} valiadResponse:{}", validateShopProductRequest,valiadResponse);
ApiLog.printLog("addGoods validateShopProductRequest ---> validateShopProductRequest:{} valiadResponse:{}", JSONObject.toJSONString(validateShopProductRequest),JSON.toJSONString(valiadResponse),null);
if (valiadResponse == null || !CartResponseConstant.SUCCESS.getCode().equals(valiadResponse.getCode()) || valiadResponse.getData()==null) {
checkCartRequest.getCartGoodsList().clear();
checkCartRequest.getShoppingCartGoodsResponseVo().setChanged(true);
......
......@@ -39,6 +39,7 @@ import cn.freemud.utils.LogUtil;
import cn.freemud.utils.PropertyConvertUtil;
import cn.freemud.utils.RedisUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.freemud.application.sdk.api.log.ApiLog;
import com.freemud.application.sdk.api.productcenter.constant.ResponseConstant;
import com.freemud.application.sdk.api.productcenter.request.product.valid.ValidateShopProductRequest;
......@@ -954,10 +955,16 @@ public class CouponServiceImpl implements CouponService {
if (!productValid) {
return null;
}
//TODO 判断该券是否在这个门店下(一个券可以在多个门店下使用)
//TODO 判断该券是否在这个门店下(一个券可以在多个门店下使用) 注意点1
List<String> couponStoreIds = Lists.newArrayList();
for (GetCouponDetailResponseDto.Details detail : couponDetailResponseDto.getDetails()) {
if (!CouponStatus.STATUS_0.getCode().equals(detail.getStatus()) && !CouponStatus.STATUS_2.getCode().equals(detail.getStatus())) continue;
ApiLog.printLog("addGoods calculationDiscountResult", JSONObject.toJSONString(detail)," 10",null);
for (GetCouponDetailResponseDto.ActiveRestrictionVOS activeRestrictionVO : detail.getActiveRestrictionVOS()) {
couponStoreIds.add(activeRestrictionVO.getStoreIdPartner());
}
......@@ -984,7 +991,7 @@ public class CouponServiceImpl implements CouponService {
}
// 校验商品可用时间
ValidateShopProductRequest request = getValidateShopProductRequest(productsVo, requestDto);
ProductResponseDTO<ValiadShopProductResponse> valiadProductResponse = storeItemClient.validateShopProduct(request);
ProductResponseDTO<ValiadShopProductResponse> valiadProductResponse = storeItemClient.validateShoprProduct(request);
if (null == valiadProductResponse || !Objects.equals(ResponseConstant.SUCCESS_RESPONSE_CODE, valiadProductResponse.getErrcode())
|| valiadProductResponse.getData() == null || CollectionUtils.isEmpty(valiadProductResponse.getData().getSuccessList())) {
return null;
......
......@@ -305,6 +305,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
CartGoods cartGoods = ShoppingCartConvertAdapter.convent2CartGoods(addShoppingCartGoodsRequestVo);
ApiLog.printLog("addGoods cartGoods convent2CartGoods",JSONObject.toJSONString(cartGoods)," 1",null);
List<Long> productIds = new ArrayList<>();
//商品skuId或者商品券的商品id
String spuId2 = spuId;
......@@ -352,12 +353,16 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if (CollectionUtils.isEmpty(allCartGoodsList)) {
allCartGoodsList = new ArrayList<>();
}
ApiLog.printLog("addGoods allCartGoodsList",JSONObject.toJSONString(allCartGoodsList)," 2",null);
List<CartGoods> oldCartGoodsList = BeanUtil.convertBeans(allCartGoodsList, CartGoods::new);
/**
Integer checkQty = allCartGoodsList.indexOf(cartGoods) != -1 ?
allCartGoodsList.get(allCartGoodsList.indexOf(cartGoods)).getQty() + cartGoods.getQty() : cartGoods.getQty();
*/
Integer checkQty = this.checkSkuQty(allCartGoodsList, cartGoods);
ApiLog.printLog("addGoods checkQty",JSONObject.toJSONString(checkQty)," 3",null);
//购物车添加数量限制
Integer productsCount = limitGoodsQty(allCartGoodsList,cartGoods,appId);
//查询多个商品库存信息 TODO
......@@ -415,6 +420,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if (calculationDiscountResult != null && CollectionUtils.isNotEmpty(calculationDiscountResult.getSendGoods())) {
sendGoodsQtyCheck(productsCount, appId, partnerId, userId, storeId, tableNumber, oldCartGoodsList, shoppingCartBaseService, calculationDiscountResult.getSendGoods());
}
ApiLog.printLog("addGoods calculationDiscountResult",JSONObject.toJSONString(calculationDiscountResult)," 8",null);
// 当商品数量被设为0时
if (Objects.equals(cartGoods.getQty(), 0)) {
assortmentSdkService.updateGoodsQtyBySdk(partnerId, userId, storeId, cartGoods.getCartGoodsUid(), 0, "", shoppingCartBaseService);
......@@ -1470,6 +1478,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
}
calculationDiscountGoodsList.removeIf(calculationDiscountGoods -> (calculationDiscountGoods.getGoodsQuantity().equals(0)));
ApiLog.printLog("addGoods calculationDiscountGoodsList2", JSONObject.toJSONString(calculationDiscountGoodsList)," 12",null);
if (CollectionUtils.isEmpty(calculationDiscountGoodsList)) {
return null;
}
......@@ -1489,7 +1499,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
try {
// ApiLog.debug("activityClient discount :{}", JSON.toJSONString(activityCalculationDiscountRequestDto));
ApiLog.printLog("activityClient discount :{}", JSON.toJSONString(activityCalculationDiscountRequestDto),null,null);
ApiLog.printLog("activityClient discount :{}", JSON.toJSONString(activityCalculationDiscountRequestDto),null,null);
activityCalculationDiscountResponseDto = activityClient.calculationDiscount(activityCalculationDiscountRequestDto);
} catch (Exception ex) {
ErrorLog.printErrorLog("calculation_discount_error", "/calculation/discount", activityCalculationDiscountRequestDto, ex);
......@@ -1656,6 +1666,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} else {
calculationDiscountGoodsList.add(calculationDiscountGoods);
}
ApiLog.printLog("addGoods calculationDiscountGoodsList", JSONObject.toJSONString(calculationDiscountGoodsList)," 11",null);
}
/**
......@@ -1973,11 +1986,14 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(oldAllCartGoodsList, addShoppingCartGoodsRequestVo.getPartnerId(),
addShoppingCartGoodsRequestVo.getShopId(), shoppingCartGoodsResponseVo, addShoppingCartGoodsRequestVo.getOrderType(),
"", addShoppingCartGoodsRequestVo.getMenuType(),shoppingCartBaseService);
ApiLog.printLog("addGoods checkCartRequest",JSONObject.toJSONString(cartGoods),JSON.toJSONString(checkCartRequest)," 4");
if (checkCartRequest.getShoppingCartGoodsResponseVo() != null) {
shoppingCartGoodsResponseVo.setToastMsg(checkCartRequest.getShoppingCartGoodsResponseVo().getToastMsg());
shoppingCartGoodsResponseVo.setChanged(checkCartRequest.getShoppingCartGoodsResponseVo().getChanged());
}
List<CartGoods> allCartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
ApiLog.printLog("addGoods allCartGoodsList",JSONObject.toJSONString(allCartGoodsList)," 5",null);
//判断当前商品在购物车是否已存在,存在则数量+1,不存在商品行 + 1
allCartGoodsList.forEach(oldCartGoods -> {
......@@ -1988,11 +2004,16 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
nowCartGoodsList.add(oldCartGoods);
}
});
ApiLog.printLog("addGoods nowCartGoodsList",JSONObject.toJSONString(nowCartGoodsList)," 6",null);
// 重新set购物车信息到缓存中
assortmentSdkService.setShoppingCart(addShoppingCartGoodsRequestVo.getPartnerId(), addShoppingCartGoodsRequestVo.getShopId(),
userId, nowCartGoodsList, addShoppingCartGoodsRequestVo.getSessionId(), addShoppingCartGoodsRequestVo.getTableNumber(), this.shoppingCartBaseService);
oldAllCartGoodsList.clear();
oldAllCartGoodsList.addAll(nowCartGoodsList);
ApiLog.printLog("addGoods nowCartGoodsList2",JSONObject.toJSONString(nowCartGoodsList)," 7",null);
return nowCartGoodsList;
}
......@@ -2060,7 +2081,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
setToastMsgIfNotExist(shoppingCartGoodsResponseVo, ShoppingCartConstant.HAS_OTHER_ACTIVITY_WHEN_ADD_GOODS_COUPON);
}
//校验合法性,更新缓存中购物车信息
LogUtil.info("updateCartGoodsLegal", JSON.toJSONString(cartGoods),JSON.toJSONString(allCartGoodsList));
// LogUtil.info("updateCartGoodsLegal", JSON.toJSONString(cartGoods),JSON.toJSONString(allCartGoodsList));
ApiLog.printLog("addGoods updateCartGoodsLegal",JSONObject.toJSONString(cartGoods),JSON.toJSONString(allCartGoodsList),null);
updateCartGoodsLegal(cartGoods, userId, shoppingCartGoodsResponseVo, addShoppingCartGoodsRequestVo, allCartGoodsList);
......
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