Commit 85dd75b3 by ping.wu

Merge branches 'develop' and 'feature/20200721_麦咖啡购物车_wuping' of…

Merge branches 'develop' and 'feature/20200721_麦咖啡购物车_wuping' of http://gitlab.freemud.com/order-group-application/order-group into develop
parents f0b4428e 94637acb
......@@ -13,6 +13,7 @@ import cn.freemud.entities.vo.*;
import cn.freemud.enums.*;
import cn.freemud.interceptor.ServiceException;
import cn.freemud.service.ActivityService;
import cn.freemud.service.CouponService;
import cn.freemud.service.impl.AssortmentSdkService;
import cn.freemud.service.impl.FullSubtractionActivityServiceImpl;
import cn.freemud.service.impl.mcoffee.calculation.CalculationServiceImpl;
......@@ -33,6 +34,7 @@ import com.freemud.application.sdk.api.ordercenter.response.orderInfo.QueryByCod
import com.freemud.application.sdk.api.ordercenter.service.OrderSdkService;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
import com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum;
import com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest;
import com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
......@@ -116,6 +118,10 @@ public class ShoppingCartMCoffeeServiceImpl {
productIds.add(Long.parseLong(goodsId));
CartGoods addCartGoods = convent2CartGoods(addShoppingCartGoodsRequestVo);
if(StringUtils.isNotBlank(couponCode)){
String couponCodespq = CommonsConstant.COUPON_PREFIX + couponCode;
spuId2 = validCoupon(partnerId, storeId, couponCodespq, productIds,BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode());
}
// 获取添加商品的详细信息
List<ProductBeanDTO> productBeanListSpuClass = assortmentSdkService.getProductsInfoSdk(partnerId, storeId, Collections.singletonList(spuId2), menuType, this.shoppingCartBaseService);
......@@ -124,6 +130,9 @@ public class ShoppingCartMCoffeeServiceImpl {
if (CollectionUtils.isEmpty(oldCartGoodsList)) {
oldCartGoodsList = new ArrayList<>();
}
//商品券已添加情况校验
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = checkGoodsCoupon(oldCartGoodsList, operationType, couponCode);
setClassificationAndPrice(addCartGoods, productBeanListSpuClass);
......@@ -151,6 +160,19 @@ public class ShoppingCartMCoffeeServiceImpl {
return ResponseUtil.success(shoppingCartGoodsResponseVo);
}
private String validCoupon(String partnerId, String storeId, String spuId, List<Long> productIds,String menuType) {
String spuId2;
CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, spuId.substring(CommonsConstant.COUPON_PREFIX.length()),menuType);
CouponService couponService = SDKCommonBaseContextWare.getBean(CouponService.class);
CheckSpqInfoResponseDto checkSpqInfoResponseDto = couponService.checkSpqInfo(checkSpqInfoRequestDto);
if (checkSpqInfoResponseDto == null) {
throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_NOT_EXIST);
}
productIds.add(Long.parseLong(checkSpqInfoResponseDto.getSkuId()));
spuId2 = checkSpqInfoResponseDto.getSkuId();
return spuId2;
}
private List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> checkGoodsCoupon(List<CartGoods> oldCartGoodsList, Integer operationType, String couponCode) {
if (operationType != null && operationType == 1 && StringUtils.isBlank(couponCode)) {
......@@ -648,9 +670,21 @@ public class ShoppingCartMCoffeeServiceImpl {
}
}
List<CartGoods> nowCartGoodsList = new ArrayList<>();
//判断当前商品在购物车是否已存在,存在则数量+1,不存在商品行 + 1
allCartGoodsList.forEach(oldCartGoods -> {
int index;
if ((index = nowCartGoodsList.indexOf(oldCartGoods)) >= 0) {
nowCartGoodsList.get(index).setQty(nowCartGoodsList.get(index).getQty() + addCartGoods.getQty());
} else {
nowCartGoodsList.add(oldCartGoods);
}
});
// 重新set购物车信息到缓存中
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, allCartGoodsList, null, tableNumber, this.shoppingCartBaseService);
return allCartGoodsList;
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, nowCartGoodsList, null, tableNumber, this.shoppingCartBaseService);
return nowCartGoodsList;
}
/**
......@@ -723,14 +757,18 @@ public class ShoppingCartMCoffeeServiceImpl {
private List<CartGoods> checkNewCartGoods(List<CartGoods> newCartGoods, CartGoods addCartGoods) {
Integer qty = addCartGoods.getQty() == null ? 0 : addCartGoods.getQty();
if(StringUtils.isNotBlank(addCartGoods.getCouponCode())){
newCartGoods.add(addCartGoods);
return newCartGoods;
}
boolean isadd = true;
if (CollectionUtils.isNotEmpty(newCartGoods) && StringUtils.isBlank(addCartGoods.getCouponCode())) {
if (CollectionUtils.isNotEmpty(newCartGoods)) {
for (CartGoods goods : newCartGoods) {
if (goods.getSkuId().equals(addCartGoods.getSkuId()) && goods.getSpuId().equals(addCartGoods.getSpuId()) && StringUtils.isBlank(goods.getCouponCode())) {
qty += goods.getQty();
goods.setQty(qty);
isadd = false;
break;
if (goods.getSkuId().equals(addCartGoods.getSkuId()) && goods.getSpuId().equals(addCartGoods.getSpuId())){
if(goods.getProductGroupList() != null && addCartGoods.getProductGroupList() !=null && goods.getProductGroupList().size() == addCartGoods.getProductGroupList().size()){
}
}
}
if (isadd) {
......
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