Commit 9acc200b by ping.wu

新增麦咖啡购物车

parent e682632b
......@@ -2,20 +2,11 @@ package cn.freemud.controller;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.entities.vo.*;
import cn.freemud.enums.OrderChannelType;
import cn.freemud.enums.ResponseResult;
import cn.freemud.service.ShoppingCartNewService;
import cn.freemud.service.impl.ShoppingCartMCoffeeServiceImpl;
import cn.freemud.service.impl.ShoppingCartMallServiceImpl;
import cn.freemud.utils.ResponseUtil;
import com.freemud.api.assortment.datamanager.enums.IappIdType;
import com.freemud.api.assortment.datamanager.manager.customer.AssortmentCustomerInfoManager;
import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare;
import cn.freemud.service.impl.mcoffee.ShoppingCartMCoffeeServiceImpl;
import com.freemud.application.sdk.api.log.ApiAnnotation;
import com.freemud.application.sdk.api.log.LogParams;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
......@@ -72,17 +63,6 @@ public class MCoffeeShoppingCartController {
return shoppingCartMCoffeeService.getGoodsList(request);
}
// /**
// * 查询购车信息无配送费
// * SVC卡支付check,check购物车金额加配送费小于储值卡金额
// */
// @ApiAnnotation(logMessage = "listCartGoodsCheck")
// @PostMapping(value = "/listCartGoodsCheck")
// public BaseResponse listCartGoodsCheck(@Validated @LogParams @RequestBody ShoppingCartInfoRequestVo request) {
// return shoppingCartMCoffeeService.getGoodsListCheck(request);
// }
/**
* 清空购物车
*/
......
......@@ -32,7 +32,7 @@ public class UpdateShoppingCartGoodsQtyRequestVo extends BaseRequestVo {
private String cartGoodsUid;
/**
* 商品数量
* 更新后商品数量
*/
@NotNull(message = "qty不能为空")
private Integer qty;
......
package cn.freemud.service.impl;
package cn.freemud.service.impl.mcoffee;
import cn.freemud.adapter.ActivityAdapter;
import cn.freemud.adapter.ShoppingCartConvertAdapter;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.entities.dto.UserLoginInfoDto;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.constant.ShoppingCartConstant;
import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.activity.ActivityQueryResponseDto;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.dto.user.GetSessionUserInfoDto;
import cn.freemud.entities.vo.*;
import cn.freemud.enums.ResponseResult;
import cn.freemud.enums.*;
import cn.freemud.interceptor.BizServiceException;
import cn.freemud.interceptor.ServiceException;
import cn.freemud.service.*;
import cn.freemud.service.impl.AssortmentSdkService;
import cn.freemud.service.impl.FullSubtractionActivityServiceImpl;
import cn.freemud.service.thirdparty.ActivityClient;
import cn.freemud.service.thirdparty.CustomerApplicationClient;
import cn.freemud.service.thirdparty.StockClient;
import cn.freemud.utils.PromotionFactory;
import cn.freemud.utils.PropertyConvertUtil;
import cn.freemud.utils.ResponseUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo;
import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare;
import com.freemud.application.sdk.api.log.ErrorLog;
import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.freemud.application.sdk.api.membercenter.request.QueryReceiveAddressRequest;
import com.freemud.application.sdk.api.membercenter.response.QueryReceiveAddressResponse;
import com.freemud.application.sdk.api.membercenter.service.MemberCenterService;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import com.freemud.application.sdk.api.storecenter.request.QueryDeliveryRequest;
import com.freemud.application.sdk.api.storecenter.response.QueryDeliverDetailResponse;
import com.freemud.application.sdk.api.storecenter.service.StoreCenterService;
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;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.*;
import static cn.freemud.constant.ShoppingCartConstant.SHOPPING_CART_EMPTY_GOODS_LIST;
import static cn.freemud.constant.ShoppingCartConstant.SHOPPING_CART_INVALIAD_GOODS;
/**
* All rights Reserved, Designed By www.freemud.cn
*
......@@ -34,36 +71,39 @@ import org.springframework.stereotype.Service;
public class ShoppingCartMCoffeeServiceImpl {
// 配送费逻辑是否使用旧的
// @Value("${store.delivery.use.old:true}")
// private boolean storeDeliveryUseOld;
// @Autowired
// private ActivityAdapter activityAdapter;
@Value("${store.delivery.use.old:true}")
private boolean storeDeliveryUseOld;
// @Value("${goods.cache.second}")
// private long goodsCacheSeconds;
@Autowired
private ActivityAdapter activityAdapter;
// @Autowired
// private StoreItemClient storeItemClient;
// @Autowired
// private ActivityClient activityClient;
// @Autowired
// private ItemService itemService;
@Autowired
private ActivityClient activityClient;
@Autowired
private ItemService itemService;
// @Autowired
// private ShoppingCartNewBaseService shoppingCartNewBaseService;
// @Autowired
// private ShoppingCartBaseServiceImpl shoppingCartBaseService;
// @Autowired
// private CouponService couponService;
@Autowired
private ShoppingCartBaseServiceImpl shoppingCartBaseService;
@Autowired
private CouponService couponService;
// @Autowired
// private ShoppingCartConvertAdapter shoppingCartConvertAdapter;
// @Autowired
// private FullSubtractionActivityServiceImpl fullSubtractionActivityService;
@Autowired
private FullSubtractionActivityServiceImpl fullSubtractionActivityService;
// @Autowired
// private BuriedPointService buriedPointService;
// @Autowired
// private OpenPlatformClient openPlatformClient;
// @Autowired
// private StockClient stockClient;
// @Value("${goods.cache.second}")
// private long goodsCacheSeconds;
// @Autowired
// private AssortmentSdkService assortmentSdkService;
@Autowired
private StockClient stockClient;
@Autowired
private AssortmentSdkService assortmentSdkService;
// @Autowired
// private CouponAdapter couponAdapter;
@Autowired
......@@ -72,16 +112,16 @@ public class ShoppingCartMCoffeeServiceImpl {
// private AssortmentCustomerInfoManager customerInfoManager;
// @Autowired
// private PaymentNewService paymentNewService;
// @Autowired
// private MemberCenterService memberCenterService;
@Autowired
private MemberCenterService memberCenterService;
// @Autowired
// private AssortmentOpenPlatformPartnerStoreDeliveryConfigManager deliveryConfigManager;
// @Autowired
// private StoreServiceImpl storeService;
// @Autowired
// private StoreCenterService storeCenterService;
// @Autowired
// private CommonService commonService;
@Autowired
private StoreCenterService storeCenterService;
@Autowired
private CommonService commonService;
// @Autowired
// private ProductService productService;
// @Autowired
......@@ -96,130 +136,85 @@ public class ShoppingCartMCoffeeServiceImpl {
public BaseResponse addGoods(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo) {
// TODO: 2020/7/21 参数校验
if (StringUtils.isEmpty(addShoppingCartGoodsRequestVo.getShopId())){
throw new ServiceException(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
return ResponseUtil.error(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
}
ShoppingCartConvertAdapter.convent2SkuId(addShoppingCartGoodsRequestVo);
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
if (addShoppingCartGoodsRequestVo.getQty() != null && addShoppingCartGoodsRequestVo.getQty() < 0){
return ResponseUtil.error(ResponseResult.SHOPPING_CART_ADD_ERROR);
}
String sessionId = addShoppingCartGoodsRequestVo.getSessionId();
// 获取用户信息
CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(addShoppingCartGoodsRequestVo.getSessionId());
CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(sessionId);
if (assortmentCustomerInfoVo == null || StringUtils.isEmpty(assortmentCustomerInfoVo.getMemberId())) {
return ResponseUtil.error(ResponseResult.NOT_LOGIN);
}
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
UserLoginInfoDto userLoginInfoDto = convert2UserLoginInfoDto(assortmentCustomerInfoVo);
String userId = userLoginInfoDto.getMemberId();
String partnerId = addShoppingCartGoodsRequestVo.getPartnerId();
String storeId = addShoppingCartGoodsRequestVo.getShopId();
String appId = addShoppingCartGoodsRequestVo.getAppId();
String spuId = addShoppingCartGoodsRequestVo.getSpuId();
String skuId = addShoppingCartGoodsRequestVo.getSkuId();
String skuId = StringUtils.isNotBlank(addShoppingCartGoodsRequestVo.getSkuId()) ? addShoppingCartGoodsRequestVo.getSkuId() : "";
String goodsId = StringUtils.isEmpty(skuId) ? spuId : skuId;
String tableNumber = addShoppingCartGoodsRequestVo.getTableNumber();
String menuType = addShoppingCartGoodsRequestVo.getMenuType();
Integer orderType = addShoppingCartGoodsRequestVo.getOrderType();
String receiveId = addShoppingCartGoodsRequestVo.getReceiveId();
CartGoods addCartGoods = ShoppingCartConvertAdapter.convent2CartGoods(addShoppingCartGoodsRequestVo);
// TODO: 2020/7/21 查询购物车缓存
// 注意,围餐和点餐redis数据结构不一样
List<CartGoods> oldCartGoodsList = assortmentSdkService.getShoppingCart(partnerId, storeId, userId, null, null, shoppingCartBaseService);
if (CollectionUtils.isEmpty(oldCartGoodsList)) {
oldCartGoodsList = new ArrayList<>();
}
// 当商品数量被设为0时
if (Objects.equals(addCartGoods.getQty(), 0)) {
assortmentSdkService.updateGoodsQtyBySdk(partnerId, userId, storeId, addCartGoods.getCartGoodsUid(), 0, "", shoppingCartBaseService);
}
String spuId2 = spuId;
List<Long> productIds = new ArrayList<>();
productIds.add(Long.parseLong(goodsId));
// 获取商品详细信息
List<ProductBeanDTO> productBeanListSpuClass = assortmentSdkService.getProductsInfoSdk(partnerId, storeId
, Collections.singletonList(spuId2),menuType, this.shoppingCartBaseService);
//查询多个商品库存信息
ShoppingCartConvertAdapter.setClassification(addCartGoods, productBeanListSpuClass);
Integer checkQty = this.checkSkuQty(oldCartGoodsList, addCartGoods);
queryManyGoodsStocks(partnerId,storeId,menuType, productIds, productBeanListSpuClass, skuId, checkQty);
// TODO: 2020/7/21 查询购物车缓存
// 如果购物车中有商品券,则当前添加的商品是特价商品时,需要提示“已选商品券,与其他优惠商品不同享,商品将恢复原价”
boolean haveCouponProduct = oldCartGoodsList.parallelStream().anyMatch(k -> k.getCartGoodsUid().startsWith(CommonsConstant.COUPON_PREFIX));
if (haveCouponProduct && isSpecialGoods(partnerId, storeId, userId, appId, goodsId, orderType)) {
// 如果购物车先加入商品券,再加入促销商品,toast提示“已选商品券,与其他优惠商品不同享,商品将恢复原价”
setToastMsgIfNotExist(shoppingCartGoodsResponseVo, ShoppingCartConstant.HAS_GOODS_COUPON_WHEN_ADD_SPECIAL_GOODS);
}
// TODO: 2020/7/21 促销活动等价格计算
Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo);
// 获取优惠信息
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult
=getCalculationDiscountResult(menuType,partnerId,storeId,userId,userLoginInfoDto.getWxAppid(),orderType,assortmentCustomerInfoVo.isMemberPaid(), oldCartGoodsList,new ArrayList(),new ArrayList<>(),null,deliveryAmount);
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, addShoppingCartGoodsRequestVo.getOrderType());
// TODO: 2020/7/21 价格计算
// 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, oldCartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto,addShoppingCartGoodsRequestVo.getMenuType(),deliveryAmount);
// TODO: 2020/7/21 购物车数据更新
List<CartGoods> newCartGoods = new ArrayList<>();
newCartGoods.add(addCartGoods);
// 校验合法性,更新缓存中购物车信息
updateCartGoodsLegal(partnerId,storeId,orderType,tableNumber,menuType, userId, newCartGoods,shoppingCartGoodsResponseVo, oldCartGoodsList);
// TODO: 2020/7/21 返回购物车数据
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, oldCartGoodsList, null, partnerId, storeId, userId, ShoppingCartConstant.ADD_AND_UPDATE, null);
//
// CartGoods cartGoods = ShoppingCartConvertAdapter.convent2CartGoods(addShoppingCartGoodsRequestVo);
// List<Long> productIds = new ArrayList<>();
// //商品skuId或者商品券的商品id
// String spuId2 = spuId;
// if (!spuId.startsWith(CommonsConstant.COUPON_PREFIX)) {
// productIds.add(Long.parseLong(goodsId));
// } else {
// //校验券是否有效
// spuId2 = validCoupon(partnerId, storeId, spuId, productIds,BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode());
// }
// // 获取商品详细信息
// List<ProductBeanDTO> productBeanListSpuClass = assortmentSdkService.getProductsInfoSdk(partnerId, storeId
// , Collections.singletonList(spuId2),addShoppingCartGoodsRequestVo.getMenuType(), this.shoppingCartBaseService);
//
// //缓存中获取购物车商品信息
// // 注意,围餐和点餐redis数据结构不一样
// List<CartGoods> allCartGoodsList = assortmentSdkService.getShoppingCart(partnerId, storeId, userId, addShoppingCartGoodsRequestVo.getSessionId(), null, shoppingCartBaseService);
// if (CollectionUtils.isEmpty(allCartGoodsList)) {
// allCartGoodsList = new ArrayList<>();
// }
// /**
// Integer checkQty = allCartGoodsList.indexOf(cartGoods) != -1 ?
// allCartGoodsList.get(allCartGoodsList.indexOf(cartGoods)).getQty() + cartGoods.getQty() : cartGoods.getQty();
// */
// Integer checkQty = this.checkSkuQty(allCartGoodsList, cartGoods);
//
// //查询多个商品库存信息
// queryManyGoodsStocks(addShoppingCartGoodsRequestVo, productIds, productBeanListSpuClass, skuId, checkQty);
//
// ShoppingCartConvertAdapter.setClassification(cartGoods, productBeanListSpuClass);
// String productName = null;
// // 当添加的商品不是商品券时
// if (!spuId.startsWith(CommonsConstant.COUPON_PREFIX)) {
// //添加非商品券商品
// addNotProductGoods(addShoppingCartGoodsRequestVo, cartGoods, goodsId, userId, shoppingCartGoodsResponseVo, allCartGoodsList);
// } else {
// // 当商品是商品券,里面会判断如果购物车中已有商品券,会将cartGoods的CartGoodsUid设为null
// this.addProductGoods(addShoppingCartGoodsRequestVo, cartGoods, spuId2, userId, shoppingCartGoodsResponseVo,
// spuId, allCartGoodsList, productBeanListSpuClass);
// }
//
// Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo);
//
// // 获取优惠信息
// ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult
// =getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,assortmentCustomerInfoVo.isMemberPaid(), allCartGoodsList,new ArrayList(),new ArrayList<>(),null,deliveryAmount);
//
//
// // 当商品数量被设为0时
// if (Objects.equals(cartGoods.getQty(), 0)) {
// assortmentSdkService.updateGoodsQtyBySdk(partnerId, userId, storeId, cartGoods.getCartGoodsUid(), 0, "", shoppingCartBaseService);
// }
//
// ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, addShoppingCartGoodsRequestVo.getOrderType());
//
// // 促销活动的优惠金额计算
// updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto,addShoppingCartGoodsRequestVo.getMenuType(),deliveryAmount);
//
// //设置更新响应信息
// setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, allCartGoodsList, null, partnerId, storeId, userId, ShoppingCartConstant.ADD_AND_UPDATE, null);
//
// //埋点添加购物车行为
// this.buriedPointShoppingCart(addShoppingCartGoodsRequestVo, spuId, productName);
return ResponseUtil.success(shoppingCartGoodsResponseVo);
}
/**
* 埋点添加购物车行为
*
* @param addShoppingCartGoodsRequestVo
* @param spuId
* @param productName
*/
// private void buriedPointShoppingCart(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo, String spuId, String productName) {
// if (StringUtils.isEmpty(productName)) {
// return;
// }
//
// List<ShoppingCartSkuAddRequestVo.ShoppingCartSkuProductVo> productVos = Lists.newArrayList();
// ShoppingCartSkuAddRequestVo.ShoppingCartSkuProductVo productVo = new ShoppingCartSkuAddRequestVo.ShoppingCartSkuProductVo();
// productVo.setProductName(productName);
// productVo.setProductId(spuId);
// productVo.setSpuId(spuId);
// productVos.add(productVo);
// BuriedPointShoppingCartRequestDto shoppingCartRequestDto = BuriedPointShoppingCartRequestDto.builder()
// .sessionId(addShoppingCartGoodsRequestVo.getSessionId()).partnerId(addShoppingCartGoodsRequestVo.getPartnerId())
// .storeId(addShoppingCartGoodsRequestVo.getShopId()).build();
// buriedPointService.buriedPointAddShoppingCart(productVos, shoppingCartRequestDto);
// }
/**
* 更新商品数量
*
......@@ -227,105 +222,111 @@ public class ShoppingCartMCoffeeServiceImpl {
* @return
*/
public BaseResponse updateGoodsQty(UpdateShoppingCartGoodsQtyRequestVo updateShoppingCartGoodsQtyRequestVo) {
// if (StringUtils.isEmpty(updateShoppingCartGoodsQtyRequestVo.getShopId())){
// throw new ServiceException(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
// }
// ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
// CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(updateShoppingCartGoodsQtyRequestVo.getSessionId());
// UserLoginInfoDto userLoginInfoDto = convert2UserLoginInfoDto(assortmentCustomerInfoVo);
// String userId = userLoginInfoDto.getMemberId();
// String partnerId = updateShoppingCartGoodsQtyRequestVo.getPartnerId();
// String storeId = updateShoppingCartGoodsQtyRequestVo.getShopId();
// String appId = updateShoppingCartGoodsQtyRequestVo.getAppId();
// String cartGoodsUid = updateShoppingCartGoodsQtyRequestVo.getCartGoodsUid();
// Integer qty = updateShoppingCartGoodsQtyRequestVo.getQty();
// String menuType = updateShoppingCartGoodsQtyRequestVo.getMenuType();
// Integer orderType=updateShoppingCartGoodsQtyRequestVo.getOrderType();
// String receiveId = updateShoppingCartGoodsQtyRequestVo.getReceiveId();
//
// // 先验证商品是否存在
// CartGoods cartGoods = assortmentSdkService.getCartGoodsBySdk(partnerId, userId, storeId, cartGoodsUid, "", shoppingCartBaseService);
// if (cartGoods == null) {
// throw new ServiceException(ResponseResult.SHOPPING_CART_UPDATE_ERROR);
// }
// // 检查购物车商品库存数量
// checkUpdateStock(updateShoppingCartGoodsQtyRequestVo, cartGoods);
//
// // 更新购物车中数量
if (StringUtils.isEmpty(updateShoppingCartGoodsQtyRequestVo.getShopId())){
throw new ServiceException(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
}
if (updateShoppingCartGoodsQtyRequestVo.getQty() != null && updateShoppingCartGoodsQtyRequestVo.getQty() < 0){
return ResponseUtil.error(ResponseResult.SHOPPING_CART_ADD_ERROR);
}
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(updateShoppingCartGoodsQtyRequestVo.getSessionId());
UserLoginInfoDto userLoginInfoDto = convert2UserLoginInfoDto(assortmentCustomerInfoVo);
String userId = userLoginInfoDto.getMemberId();
String partnerId = updateShoppingCartGoodsQtyRequestVo.getPartnerId();
String storeId = updateShoppingCartGoodsQtyRequestVo.getShopId();
String appId = updateShoppingCartGoodsQtyRequestVo.getAppId();
String cartGoodsUid = updateShoppingCartGoodsQtyRequestVo.getCartGoodsUid();
Integer qty = updateShoppingCartGoodsQtyRequestVo.getQty();
String menuType = updateShoppingCartGoodsQtyRequestVo.getMenuType();
Integer orderType=updateShoppingCartGoodsQtyRequestVo.getOrderType();
String receiveId = updateShoppingCartGoodsQtyRequestVo.getReceiveId();
// 先验证商品是否存在
List<CartGoods> cartGoodsList = assortmentSdkService.getShoppingCart(partnerId, storeId,userId,null,null,shoppingCartBaseService);
CartGoods cartGoods = null;
for (CartGoods cartGoods_ : cartGoodsList){
if(cartGoodsUid.equals(cartGoods_.getCartGoodsUid())){
cartGoods =cartGoods_;
// 检查购物车商品库存数量
checkUpdateStock(partnerId,storeId,menuType,qty,cartGoods);
cartGoods_.setQty(qty);
break;
}
}
if (cartGoods == null) {
throw new ServiceException(ResponseResult.SHOPPING_CART_UPDATE_ERROR);
}
// 更新购物车中数量
// List<CartGoods> cartGoodsList = assortmentSdkService.updateGoodsQtyBySdk(partnerId, userId, storeId, cartGoodsUid, qty<0?0:qty, "", shoppingCartBaseService);
//
// // check购物车中所有商品
// CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(cartGoodsList, partnerId, storeId, shoppingCartGoodsResponseVo, updateShoppingCartGoodsQtyRequestVo.getOrderType(), "", updateShoppingCartGoodsQtyRequestVo.getMenuType(), shoppingCartBaseService);
// if (checkCartRequest.getShoppingCartGoodsResponseVo() != null) {
// shoppingCartGoodsResponseVo.setChanged(checkCartRequest.getShoppingCartGoodsResponseVo().getChanged());
// shoppingCartGoodsResponseVo.setToastMsg(checkCartRequest.getShoppingCartGoodsResponseVo().getToastMsg());
// }
// cartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
// // 重新存储最新购物车
// assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, updateShoppingCartGoodsQtyRequestVo.getSessionId(), "", shoppingCartBaseService);
//
//
// Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo);
// // 获取优惠信息
// ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult
// =getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,assortmentCustomerInfoVo.isMemberPaid(),cartGoodsList,new ArrayList(),new ArrayList<>(),null,deliveryAmount);
// if (calculationDiscountResult == null) {
// shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
//// return shoppingCartGoodsResponseVo;
// }
//
// ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, updateShoppingCartGoodsQtyRequestVo.getOrderType());
//
// // 促销活动的优惠金额计算
// updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto,updateShoppingCartGoodsQtyRequestVo.getMenuType(),deliveryAmount);
//
// //设置更新响应信息
// setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.ADD_AND_UPDATE, null);
// check购物车中所有商品
CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(cartGoodsList, partnerId, storeId, shoppingCartGoodsResponseVo, updateShoppingCartGoodsQtyRequestVo.getOrderType(), "", updateShoppingCartGoodsQtyRequestVo.getMenuType(), shoppingCartBaseService);
if (checkCartRequest.getShoppingCartGoodsResponseVo() != null) {
shoppingCartGoodsResponseVo.setChanged(checkCartRequest.getShoppingCartGoodsResponseVo().getChanged());
shoppingCartGoodsResponseVo.setToastMsg(checkCartRequest.getShoppingCartGoodsResponseVo().getToastMsg());
}
cartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
// 重新存储最新购物车
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, updateShoppingCartGoodsQtyRequestVo.getSessionId(), "", shoppingCartBaseService);
Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo);
// 获取优惠信息
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult
=getCalculationDiscountResult(menuType,partnerId,storeId,userId,userLoginInfoDto.getWxAppid(),orderType,assortmentCustomerInfoVo.isMemberPaid(),cartGoodsList,new ArrayList(),new ArrayList<>(),null,deliveryAmount);
if (calculationDiscountResult == null) {
shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
}
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, updateShoppingCartGoodsQtyRequestVo.getOrderType());
// 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto,updateShoppingCartGoodsQtyRequestVo.getMenuType(),deliveryAmount);
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.ADD_AND_UPDATE, null);
return ResponseUtil.success();
}
/**
* 检查购物车商品库存数量
*
* @param updateShoppingCartGoodsQtyRequestVo
* @param cartGoods
*/
// private void checkUpdateStock(UpdateShoppingCartGoodsQtyRequestVo updateShoppingCartGoodsQtyRequestVo, CartGoods cartGoods) {
// Integer qty = updateShoppingCartGoodsQtyRequestVo.getQty();
// // 购物车商品数量减少
// if (cartGoods.getQty() > qty) {
// return;
// }
// String partnerId = updateShoppingCartGoodsQtyRequestVo.getPartnerId();
// String storeId = updateShoppingCartGoodsQtyRequestVo.getShopId();
// //查询商品信息
// List<String> pids = new ArrayList<>();
// pids.add(cartGoods.getGoodsId());
// Map<String, GetProductsVo> products = itemService.getProducts(pids, partnerId, storeId,BusinessTypeEnum.getByType(updateShoppingCartGoodsQtyRequestVo.getMenuType()).getCode());
//
// GetProductsVo getProductsVo = products.get(cartGoods.getGoodsId());
// // 商品没有库存限制
// if ((getProductsVo == null) || (getProductsVo.getStockLimit() != 1)) {
// return;
// }
// ShoppingCartConvertAdapter.setClassification(cartGoods, getProductsVo);
// GetProductStockRequestDto requestDto = new GetProductStockRequestDto();
// requestDto.setChannel(BusinessTypeEnum.getByType(updateShoppingCartGoodsQtyRequestVo.getMenuType()).getCode());
// requestDto.setPartnerId(partnerId);
// requestDto.setStoreId(storeId);
// requestDto.setProductIds(Collections.singletonList(Long.parseLong(cartGoods.getGoodsId())));
// GetProductStockResponseDto availableStocks = stockClient.getAvailableStocks(requestDto);
// if ((availableStocks != null) && (ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode()))) {
// if ((CollectionUtils.isEmpty(availableStocks.getResult())) || (availableStocks.getResult().get(0).getQty() != null &&
// qty > availableStocks.getResult().get(0).getQty())) {
// Integer stock = 0;
// if (!CollectionUtils.isEmpty(availableStocks.getResult()) && (stock = availableStocks.getResult().get(0).getQty()) > 0) {
// throw new BizServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE, "仅剩" + stock + "件库存了");
// }
// throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
// }
// }
// }
private void checkUpdateStock(String partnerId, String storeId, String menuType, Integer qty, CartGoods cartGoods) {
// 购物车商品数量减少
if (cartGoods.getQty() > qty) {
return;
}
//查询商品信息
List<String> pids = new ArrayList<>();
pids.add(cartGoods.getGoodsId());
Map<String, GetProductsVo> products = itemService.getProducts(pids, partnerId, storeId,BusinessTypeEnum.getByType(menuType).getCode());
GetProductsVo getProductsVo = products.get(cartGoods.getGoodsId());
// 商品没有库存限制
if ((getProductsVo == null) || (getProductsVo.getStockLimit() != 1)) {
return;
}
ShoppingCartConvertAdapter.setClassification(cartGoods, getProductsVo);
GetProductStockRequestDto requestDto = new GetProductStockRequestDto();
requestDto.setChannel(BusinessTypeEnum.getByType(menuType).getCode());
requestDto.setPartnerId(partnerId);
requestDto.setStoreId(storeId);
requestDto.setProductIds(Collections.singletonList(Long.parseLong(cartGoods.getGoodsId())));
GetProductStockResponseDto availableStocks = stockClient.getAvailableStocks(requestDto);
if ((availableStocks != null) && (ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode()))) {
if ((CollectionUtils.isEmpty(availableStocks.getResult())) || (availableStocks.getResult().get(0).getQty() != null &&
qty > availableStocks.getResult().get(0).getQty())) {
Integer stock = 0;
if (!CollectionUtils.isEmpty(availableStocks.getResult()) && (stock = availableStocks.getResult().get(0).getQty()) > 0) {
throw new BizServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE, "仅剩" + stock + "件库存了");
}
throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
}
}
}
/**
......@@ -431,40 +432,39 @@ public class ShoppingCartMCoffeeServiceImpl {
*/
public BaseResponse clear(ShoppingCartClearRequestVo shoppingCartClearRequestVo) {
// String appId = shoppingCartClearRequestVo.getAppId();
// if (StringUtils.isBlank(appId)) {
// return ResponseUtil.error(ResponseResult.PARAMETER_MISSING, "appId不能为空");
// }
// String userId = shoppingCartClearRequestVo.getUserId();
// if (StringUtils.isEmpty(userId)){
// CustomerInfoVo userLoginInfoDto =getCustomerInfoVo(shoppingCartClearRequestVo.getSessionId());
// userId=userLoginInfoDto.getMemberId();
// }
// String partnerId = shoppingCartClearRequestVo.getPartnerId();
// String storeId = shoppingCartClearRequestVo.getShopId();
// shoppingCartNewBaseService.clear(partnerId, storeId, userId);
// if (ObjectUtils.equals(shoppingCartClearRequestVo.getOperationType(), OperationTypeEnum.PAY_SUCCESS.getOperationType())) {
// return ResponseUtil.success();
// }
//
// ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
// ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, shoppingCartClearRequestVo.getOrderType());
// ArrayList<ActivityList> activityList = new ArrayList<>();
// PromotionMessageDto promotionMessageDto = fullSubtractionActivityService.getFullPromotionActivityInfo(activityQueryDto, null, activityList);
//
// ActivityTip activityTip = new ActivityTip();
// if (promotionMessageDto != null) {
// activityTip.setActivityCode(promotionMessageDto.getActivityId());
// activityTip.setActivityType(promotionMessageDto.getActivityType());
// activityTip.setActivityName(promotionMessageDto.getPromotionMessage());
// activityTip.setActivityList(activityList);
// }
// shoppingCartGoodsResponseVo.setActivityTip(activityTip);
// shoppingCartGoodsResponseVo.setProducts(new ArrayList<>());
// shoppingCartGoodsResponseVo.setProductsCount(0);
// return ResponseUtil.success(shoppingCartGoodsResponseVo);
String appId = shoppingCartClearRequestVo.getAppId();
if (StringUtils.isBlank(appId)) {
return ResponseUtil.error(ResponseResult.PARAMETER_MISSING, "appId不能为空");
}
String userId = shoppingCartClearRequestVo.getUserId();
if (StringUtils.isEmpty(userId)){
CustomerInfoVo userLoginInfoDto =getCustomerInfoVo(shoppingCartClearRequestVo.getSessionId());
userId=userLoginInfoDto.getMemberId();
}
String partnerId = shoppingCartClearRequestVo.getPartnerId();
String storeId = shoppingCartClearRequestVo.getShopId();
com.freemud.sdk.api.assortment.shoppingcart.domain.CartParamDto cartParamDto = assortmentSdkService.getCartParamDto(partnerId, storeId, userId);
shoppingCartBaseService.clear(cartParamDto,LogThreadLocal.getTrackingNo());
if (ObjectUtils.equals(shoppingCartClearRequestVo.getOperationType(), OperationTypeEnum.PAY_SUCCESS.getOperationType())) {
return ResponseUtil.success();
}
return ResponseUtil.success();
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, shoppingCartClearRequestVo.getOrderType());
ArrayList<ActivityList> activityList = new ArrayList<>();
PromotionMessageDto promotionMessageDto = fullSubtractionActivityService.getFullPromotionActivityInfo(activityQueryDto, null, activityList);
ActivityTip activityTip = new ActivityTip();
if (promotionMessageDto != null) {
activityTip.setActivityCode(promotionMessageDto.getActivityId());
activityTip.setActivityType(promotionMessageDto.getActivityType());
activityTip.setActivityName(promotionMessageDto.getPromotionMessage());
activityTip.setActivityList(activityList);
}
shoppingCartGoodsResponseVo.setActivityTip(activityTip);
shoppingCartGoodsResponseVo.setProducts(new ArrayList<>());
shoppingCartGoodsResponseVo.setProductsCount(0);
return ResponseUtil.success(shoppingCartGoodsResponseVo);
}
public BaseResponse<ShoppingCartGoodsDto> getShoppingCartGoods(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo,
......@@ -627,90 +627,90 @@ public class ShoppingCartMCoffeeServiceImpl {
* @param cartGoodsList
* @return
*/
// public ActivityCalculationDiscountResponseDto.CalculationDiscountResult getActivityCalculationDiscountResponse(
// String partnerId, String storeId, String userId, String appId, Integer orderType,boolean isMember, List<CartGoods> cartGoodsList,
// List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons,
// List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList,String menuType,Long distributionFee) {
//
// ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = getActivityCalculationDiscountRequestDto(partnerId, storeId, userId, appId, orderType);
// List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList = new ArrayList<>();
// // 校验后有效的商品券map
// Map<String, CheckSpqInfoResponseDto> validCouponMap = new HashMap<>(16);
// for (int i = cartGoodsList.size() - 1; i >= 0; i--) {
// CartGoods cartGoods = cartGoodsList.get(i);
// String cartGoodsUid = cartGoods.getCartGoodsUid();
// // 商品不是商品券
// if (!cartGoodsUid.startsWith(CommonsConstant.COUPON_PREFIX)) {
// this.addCalculationDiscountGoods(calculationDiscountGoodsList, cartGoods.getGoodsId(), cartGoods.getQty(), cartGoods.getFinalPrice(),cartGoods.getMemberDiscount());
// }
// // 商品是商品券
// else {
// // 商品券ID换取商品
// String spqId = cartGoods.getCartGoodsUid().substring(CommonsConstant.COUPON_PREFIX.length());
// CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, spqId,menuType);
// CheckSpqInfoResponseDto checkSpqInfoResponseDto = couponService.checkSpqInfo(checkSpqInfoRequestDto);
// // 商品券不存在时,将商品券从购物车移除
// if (checkSpqInfoResponseDto == null) {
// cartGoodsList.remove(i);
// assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, null, null, this.shoppingCartBaseService);
// throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_NOT_EXIST);
// }
// validCouponMap.put(spqId, checkSpqInfoResponseDto);
// cartGoods.setName(checkSpqInfoResponseDto.getCouponName());
// cartGoods.setSpuName(checkSpqInfoResponseDto.getCouponName());
// // 添加请求的优惠券信息
// ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon coupon = new ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon();
// coupon.setCode(checkSpqInfoResponseDto.getCouponCode());
// coupon.setActivityCode(checkSpqInfoResponseDto.getActiveCode());
// coupons.add(coupon);
// // 添加商品券代表的商品
// String goodsId = StringUtils.isEmpty(checkSpqInfoResponseDto.getSkuId()) ? checkSpqInfoResponseDto.getSpuId() : checkSpqInfoResponseDto.getSkuId();
// this.addCalculationDiscountGoods(calculationDiscountGoodsList, goodsId, 1, checkSpqInfoResponseDto.getPrice(),100);
// }
// }
// // 当加价购商品不为空时
// if (CollectionUtils.isNotEmpty(sendGoodsList)) {
// for (ShoppingCartInfoRequestVo.SendGoods sendGoods : sendGoodsList) {
// this.addCalculationDiscountGoods(calculationDiscountGoodsList, sendGoods.getGoodsId(), sendGoods.getQty(), sendGoods.getOriginalPrice(),100);
// }
// }
// calculationDiscountGoodsList.removeIf(calculationDiscountGoods -> (calculationDiscountGoods.getGoodsQuantity().equals(0)));
// if (CollectionUtils.isEmpty(calculationDiscountGoodsList)) {
// return null;
// }
// activityCalculationDiscountRequestDto.setGoods(calculationDiscountGoodsList);
// activityCalculationDiscountRequestDto.setCoupons(coupons);
// activityCalculationDiscountRequestDto.setOrgIds(commonService.getOrgIds(partnerId, storeId));
// activityCalculationDiscountRequestDto.setDistributionFee(distributionFee);
// activityCalculationDiscountRequestDto.setIsMember(isMember);
// ActivityCalculationDiscountResponseDto activityCalculationDiscountResponseDto;
// try {
// activityCalculationDiscountResponseDto = activityClient.calculationDiscount(activityCalculationDiscountRequestDto);
// } catch (Exception ex) {
// ErrorLog.printErrorLog("calculation_discount_error", "/calculation/discount", activityCalculationDiscountRequestDto, ex);
// throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN);
// }
// // 返回成功
// if (activityCalculationDiscountResponseDto != null && StringUtils.equals(activityCalculationDiscountResponseDto.getStatusCode(), ResponseCodeConstant.RESPONSE_SUCCESS_STR)) {
// ActivityCalculationDiscountResponseDto.CalculationDiscountResult result = activityCalculationDiscountResponseDto.getResult();
// result.setValidCouponMap(validCouponMap);
// result.setDeliveryAmount(distributionFee);
// result.setDistributionFee(result.getDistributionFee());
// return result;
// }
// // 支付宝华莱士紧急修改代码,当促销返回103错误码时,需要报券不适用于该门店,且清空购物车
// ShoppingCartClearRequestVo shoppingCartClearRequestVo = new ShoppingCartClearRequestVo();
// shoppingCartClearRequestVo.setAppId(appId);
// shoppingCartClearRequestVo.setPartnerId(partnerId);
// shoppingCartClearRequestVo.setUserId(userId);
// shoppingCartClearRequestVo.setShopId(storeId);
// shoppingCartClearRequestVo.setOperationType(1);
// clear(shoppingCartClearRequestVo);
// if (activityCalculationDiscountResponseDto != null && StringUtils.equals(activityCalculationDiscountResponseDto.getStatusCode(), "103")){
// throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_CAN_NOT_USE_THIS_SHOP);
// }
// throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN);
// }
public ActivityCalculationDiscountResponseDto.CalculationDiscountResult getActivityCalculationDiscountResponse(
String partnerId, String storeId, String userId, String appId, Integer orderType,boolean isMember, List<CartGoods> cartGoodsList,
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons,
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList,String menuType,Long distributionFee) {
ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = getActivityCalculationDiscountRequestDto(partnerId, storeId, userId, appId, orderType);
List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList = new ArrayList<>();
// 校验后有效的商品券map
Map<String, CheckSpqInfoResponseDto> validCouponMap = new HashMap<>(16);
for (int i = cartGoodsList.size() - 1; i >= 0; i--) {
CartGoods cartGoods = cartGoodsList.get(i);
String cartGoodsUid = cartGoods.getCartGoodsUid();
// 商品不是商品券
if (!cartGoodsUid.startsWith(CommonsConstant.COUPON_PREFIX)) {
this.addCalculationDiscountGoods(calculationDiscountGoodsList, cartGoods.getGoodsId(), cartGoods.getQty(), cartGoods.getFinalPrice(),cartGoods.getMemberDiscount());
}
// 商品是商品券
else {
// 商品券ID换取商品
String spqId = cartGoods.getCartGoodsUid().substring(CommonsConstant.COUPON_PREFIX.length());
CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, spqId,menuType);
CheckSpqInfoResponseDto checkSpqInfoResponseDto = couponService.checkSpqInfo(checkSpqInfoRequestDto);
// 商品券不存在时,将商品券从购物车移除
if (checkSpqInfoResponseDto == null) {
cartGoodsList.remove(i);
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, null, null, this.shoppingCartBaseService);
throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_NOT_EXIST);
}
validCouponMap.put(spqId, checkSpqInfoResponseDto);
cartGoods.setName(checkSpqInfoResponseDto.getCouponName());
cartGoods.setSpuName(checkSpqInfoResponseDto.getCouponName());
// 添加请求的优惠券信息
ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon coupon = new ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon();
coupon.setCode(checkSpqInfoResponseDto.getCouponCode());
coupon.setActivityCode(checkSpqInfoResponseDto.getActiveCode());
coupons.add(coupon);
// 添加商品券代表的商品
String goodsId = StringUtils.isEmpty(checkSpqInfoResponseDto.getSkuId()) ? checkSpqInfoResponseDto.getSpuId() : checkSpqInfoResponseDto.getSkuId();
this.addCalculationDiscountGoods(calculationDiscountGoodsList, goodsId, 1, checkSpqInfoResponseDto.getPrice(),100);
}
}
// 当加价购商品不为空时
if (CollectionUtils.isNotEmpty(sendGoodsList)) {
for (ShoppingCartInfoRequestVo.SendGoods sendGoods : sendGoodsList) {
this.addCalculationDiscountGoods(calculationDiscountGoodsList, sendGoods.getGoodsId(), sendGoods.getQty(), sendGoods.getOriginalPrice(),100);
}
}
calculationDiscountGoodsList.removeIf(calculationDiscountGoods -> (calculationDiscountGoods.getGoodsQuantity().equals(0)));
if (CollectionUtils.isEmpty(calculationDiscountGoodsList)) {
return null;
}
activityCalculationDiscountRequestDto.setGoods(calculationDiscountGoodsList);
activityCalculationDiscountRequestDto.setCoupons(coupons);
activityCalculationDiscountRequestDto.setOrgIds(commonService.getOrgIds(partnerId, storeId));
activityCalculationDiscountRequestDto.setDistributionFee(distributionFee);
activityCalculationDiscountRequestDto.setIsMember(isMember);
ActivityCalculationDiscountResponseDto activityCalculationDiscountResponseDto;
try {
activityCalculationDiscountResponseDto = activityClient.calculationDiscount(activityCalculationDiscountRequestDto);
} catch (Exception ex) {
ErrorLog.printErrorLog("calculation_discount_error", "/calculation/discount", activityCalculationDiscountRequestDto, ex);
throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN);
}
// 返回成功
if (activityCalculationDiscountResponseDto != null && StringUtils.equals(activityCalculationDiscountResponseDto.getStatusCode(), ResponseCodeConstant.RESPONSE_SUCCESS_STR)) {
ActivityCalculationDiscountResponseDto.CalculationDiscountResult result = activityCalculationDiscountResponseDto.getResult();
result.setValidCouponMap(validCouponMap);
result.setDeliveryAmount(distributionFee);
result.setDistributionFee(result.getDistributionFee());
return result;
}
// 支付宝华莱士紧急修改代码,当促销返回103错误码时,需要报券不适用于该门店,且清空购物车
ShoppingCartClearRequestVo shoppingCartClearRequestVo = new ShoppingCartClearRequestVo();
shoppingCartClearRequestVo.setAppId(appId);
shoppingCartClearRequestVo.setPartnerId(partnerId);
shoppingCartClearRequestVo.setUserId(userId);
shoppingCartClearRequestVo.setShopId(storeId);
shoppingCartClearRequestVo.setOperationType(1);
clear(shoppingCartClearRequestVo);
if (activityCalculationDiscountResponseDto != null && StringUtils.equals(activityCalculationDiscountResponseDto.getStatusCode(), "103")){
throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_CAN_NOT_USE_THIS_SHOP);
}
throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN);
}
/**
* 将calculationDiscountGoods 封装后加入 calculationDiscountGoodsList
......@@ -720,15 +720,15 @@ public class ShoppingCartMCoffeeServiceImpl {
* @param goodsQuantity
* @param originalPrice
*/
// private void addCalculationDiscountGoods(List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList,
// String goodsId, Integer goodsQuantity, Long originalPrice,Integer memberDiscount) {
// ActivityCalculationDiscountRequestDto.CalculationDiscountGoods calculationDiscountGoods = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods();
// calculationDiscountGoods.setGoodsId(goodsId);
// calculationDiscountGoods.setGoodsQuantity(goodsQuantity);
// calculationDiscountGoods.setOriginalPrice(originalPrice);
// calculationDiscountGoods.setMemberDiscount(memberDiscount);
// this.addCalculationDiscountGoods(calculationDiscountGoodsList, calculationDiscountGoods);
// }
private void addCalculationDiscountGoods(List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList,
String goodsId, Integer goodsQuantity, Long originalPrice,Integer memberDiscount) {
ActivityCalculationDiscountRequestDto.CalculationDiscountGoods calculationDiscountGoods = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods();
calculationDiscountGoods.setGoodsId(goodsId);
calculationDiscountGoods.setGoodsQuantity(goodsQuantity);
calculationDiscountGoods.setOriginalPrice(originalPrice);
calculationDiscountGoods.setMemberDiscount(memberDiscount);
this.addCalculationDiscountGoods(calculationDiscountGoodsList, calculationDiscountGoods);
}
/**
* 构建 ActivityCalculationDiscountRequestDto
......@@ -740,20 +740,20 @@ public class ShoppingCartMCoffeeServiceImpl {
* @param orderType
* @return
*/
// private ActivityCalculationDiscountRequestDto getActivityCalculationDiscountRequestDto(String partnerId, String storeId, String userId, String appId, Integer orderType) {
// ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = new ActivityCalculationDiscountRequestDto();
// activityCalculationDiscountRequestDto.setPartnerCode(partnerId);
// activityCalculationDiscountRequestDto.setStoreId(storeId);
// activityCalculationDiscountRequestDto.setIsShowGoodsActivity(1);
// activityCalculationDiscountRequestDto.setUserId(userId);
// activityCalculationDiscountRequestDto.setVer(1);
// activityCalculationDiscountRequestDto.setAppId(appId);
// ActivityChannelEnum activityChannelEnum = PropertyConvertUtil.orderTypeConvert2ActivityChannel(orderType);
// if (!Objects.isNull(activityChannelEnum)) {
// activityCalculationDiscountRequestDto.setChannel(activityChannelEnum.getCode());
// }
// return activityCalculationDiscountRequestDto;
// }
private ActivityCalculationDiscountRequestDto getActivityCalculationDiscountRequestDto(String partnerId, String storeId, String userId, String appId, Integer orderType) {
ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = new ActivityCalculationDiscountRequestDto();
activityCalculationDiscountRequestDto.setPartnerCode(partnerId);
activityCalculationDiscountRequestDto.setStoreId(storeId);
activityCalculationDiscountRequestDto.setIsShowGoodsActivity(1);
activityCalculationDiscountRequestDto.setUserId(userId);
activityCalculationDiscountRequestDto.setVer(1);
activityCalculationDiscountRequestDto.setAppId(appId);
ActivityChannelEnum activityChannelEnum = PropertyConvertUtil.orderTypeConvert2ActivityChannel(orderType);
if (!Objects.isNull(activityChannelEnum)) {
activityCalculationDiscountRequestDto.setChannel(activityChannelEnum.getCode());
}
return activityCalculationDiscountRequestDto;
}
/**
......@@ -762,17 +762,17 @@ public class ShoppingCartMCoffeeServiceImpl {
* @param calculationDiscountGoodsList
* @param calculationDiscountGoods
*/
// private void addCalculationDiscountGoods(List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList,
// ActivityCalculationDiscountRequestDto.CalculationDiscountGoods calculationDiscountGoods) {
// int index;
// // 当商品已存在时,需累加数量
// if ((index = calculationDiscountGoodsList.indexOf(calculationDiscountGoods)) >= 0) {
// ActivityCalculationDiscountRequestDto.CalculationDiscountGoods oldCalculationDiscountGoods = calculationDiscountGoodsList.get(index);
// oldCalculationDiscountGoods.setGoodsQuantity(oldCalculationDiscountGoods.getGoodsQuantity() + calculationDiscountGoods.getGoodsQuantity());
// } else {
// calculationDiscountGoodsList.add(calculationDiscountGoods);
// }
// }
private void addCalculationDiscountGoods(List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList,
ActivityCalculationDiscountRequestDto.CalculationDiscountGoods calculationDiscountGoods) {
int index;
// 当商品已存在时,需累加数量
if ((index = calculationDiscountGoodsList.indexOf(calculationDiscountGoods)) >= 0) {
ActivityCalculationDiscountRequestDto.CalculationDiscountGoods oldCalculationDiscountGoods = calculationDiscountGoodsList.get(index);
oldCalculationDiscountGoods.setGoodsQuantity(oldCalculationDiscountGoods.getGoodsQuantity() + calculationDiscountGoods.getGoodsQuantity());
} else {
calculationDiscountGoodsList.add(calculationDiscountGoods);
}
}
/**
* 处理加价购商品
......@@ -809,11 +809,7 @@ public class ShoppingCartMCoffeeServiceImpl {
* @param shoppingCartGoodsResponseVo
* @param message
*/
// private void setToastMsgIfNotExist(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, String message) {
// if (StringUtils.isEmpty(shoppingCartGoodsResponseVo.getToastMsg())) {
// shoppingCartGoodsResponseVo.setToastMsg(message);
// }
// }
/**
* 促销活动的优惠金额计算
......@@ -822,150 +818,10 @@ public class ShoppingCartMCoffeeServiceImpl {
* @param cartGoodsList
* @param shoppingCartGoodsResponseVo
*/
// private void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList
// , ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, UserLoginInfoDto userLoginInfoDto,String menuType,Long deliveryAmount) {
// //默认计算优惠
// DefaultPromotionService defaultPromotionService = (DefaultPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.DEFAULT_PROMOTION);
// defaultPromotionService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
//
// // 优惠券
// CouponPromotionService couponPromotionService = (CouponPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.COUPON_DISCOUNT);
// couponPromotionService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
//
// // 满减
// FullPromotionService fullPromotionService = (FullPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.FULL_REDUCTION);
// fullPromotionService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
//
// if (calculationDiscountResult != null && CollectionUtils.isNotEmpty(calculationDiscountResult.getSendGoods())) {
// if (calculationDiscountResult.getSendGoods().stream()
// .anyMatch(sendActivity -> Objects.equals(sendActivity.getActivityType(), ActivityTypeEnum.TYPE_6.getCode())
// || Objects.equals(sendActivity.getActivityType(), ActivityTypeEnum.TYPE_61.getCode()))) {
// // 买赠
// BuySendPromotionService buySendPromotionService = (BuySendPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.BUY_ONE_SEND);
// buySendPromotionService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
// }
// if (calculationDiscountResult.getSendGoods().stream()
// .anyMatch(sendActivity -> Objects.equals(sendActivity.getActivityType(), ActivityTypeEnum.TYPE_81.getCode()))) {
// // 加价购
// AdditionalPromotionService additionalPromotionService = (AdditionalPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.ADDITIONAL_BUY);
// additionalPromotionService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
// }
// }
//
// /**
// * 第x件y折活动计算方式:
// * 1. 从calculationDiscountResult.discounts中,type=104&discount>0则走下面的代码逻辑
// * 2. calculationDiscountResult.apportionGoods中,找到商品的所有的活动,然后把apportionAmount相加,把均摊放到当前的购物车商品里
// * 3. 限时特价和第x件y折活动冲突,故在第x件y折活动中去掉这个104type的活动
// *
// */
// if (calculationDiscountResult != null && CollectionUtils.isNotEmpty(calculationDiscountResult.getDiscounts())) {
// if (calculationDiscountResult.getDiscounts().stream()
// .anyMatch(discount -> Objects.equals(discount.getType(), ActivityTypeEnum.TYPE_104.getCode())
// && discount.getDiscount() > 0)) {
// XyDiscountServiceImpl xyDiscountService = (XyDiscountServiceImpl) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.XY_DISCOUNT);
// xyDiscountService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
// }
// }
//
// // 限时特价
// TimeSalePromotionService timeSalePromotionService = (TimeSalePromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.TIME_SALE);
// timeSalePromotionService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
//
// //套餐
// SetMealServiceImpl setMealService = (SetMealServiceImpl) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.SET_MEAL);
// setMealService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
//
// //积分兑换
// CustomerScoreService customerScoreService = (CustomerScoreService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.CUSTOMER_SCORE);
// customerScoreService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
//
// /**
// * 第2件N折计算划线价
// */
// if (calculationDiscountResult != null && CollectionUtils.isNotEmpty(calculationDiscountResult.getDiscounts())) {
// if (calculationDiscountResult.getDiscounts().stream()
// .anyMatch(discount -> Objects.equals(discount.getType(), ActivityTypeEnum.TYPE_53.getCode())
// && discount.getDiscount() > 0)) {
// TwoNDiscountServiceImpl twoNDiscountService = (TwoNDiscountServiceImpl) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.TwoN_DISCOUNT);
// twoNDiscountService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
// }
// }
// // 买赠活动
// BuyAndGiftsPromotionService buyAndGiftsPromotionService =(BuyAndGiftsPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.BUY_GIFTS);
// buyAndGiftsPromotionService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
//
// //会员价
// MemberDiscountServiceImpl memberDiscountService=(MemberDiscountServiceImpl) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.MEMBER_DISCOUNT);
// memberDiscountService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
//
// /**
// * 满额减配送费
// */
//
// if(BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)) {
// DecimalFormat df = new DecimalFormat("###.##");
// List<ActivityTypeEnum> activityTypeEnums = new LinkedList<>();
// activityTypeEnums.add(ActivityTypeEnum.TYPE_14);
//
// ActivityQueryResponseDto activityQueryResponseDto = activityService.queryActivityByType(activityQueryDto, activityTypeEnums, null);
// ActivityResponseDto activityResponse =null;
// BenefitBeanDto beanDto=null;
// if (activityQueryResponseDto != null &&activityQueryResponseDto.getResult()!=null && activityQueryResponseDto.getResult().size()>0) {
// activityResponse = activityQueryResponseDto.getResult().get(0);
// shoppingCartGoodsResponseVo.setDiscountDeliveryActivityCode(activityResponse.getActivityCode());
// beanDto=activityResponse.getBenefits().get(0);
// }
//
// ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount discount=null;
// if (calculationDiscountResult != null && CollectionUtils.isNotEmpty(calculationDiscountResult.getDiscounts())) {
// Optional<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount> discountop
// = calculationDiscountResult.getDiscounts().stream()
// .filter(discount1 -> {
// return ActivityTypeEnum.TYPE_14.getCode().equals(discount1.getType());
// })
// .findFirst();
// discount=discountop.orElseGet(() -> {return null ;});
// }
// if(discount!=null){
// if(beanDto.getBenefitType() == 1){
// String desc = DELIVERY_DISCOUNT_DESC2;
// shoppingCartGoodsResponseVo.setDeliveryDiscountDesc(String.format(desc, df.format(beanDto.getThresholdAmount().doubleValue() /100) ));
// }else{
// String desc = DELIVERY_DISCOUNT_DESC1;
// shoppingCartGoodsResponseVo.setDeliveryDiscountDesc(String.format(desc, df.format(beanDto.getThresholdAmount().doubleValue() /100) ,df.format(beanDto.getDiscountAmount().doubleValue() / 100)));
// }
// shoppingCartGoodsResponseVo.setDeliveryAmount(calculationDiscountResult.getDeliveryAmount());
// shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(calculationDiscountResult.getDistributionFee());
// shoppingCartGoodsResponseVo.setThresholdAmount(discount.getThresholdAmount());
// shoppingCartGoodsResponseVo.setIsDiscountDelivery(true);
// }else{
//
// if (activityResponse!=null) {
//
// if(beanDto.getBenefitType() == 1){
// String desc = DELIVERY_DISCOUNT_DESC2;
// shoppingCartGoodsResponseVo.setDeliveryDiscountDesc(String.format(desc, df.format(beanDto.getThresholdAmount().doubleValue() /100) ));
// }else{
// String desc = DELIVERY_DISCOUNT_DESC1;
// shoppingCartGoodsResponseVo.setDeliveryDiscountDesc(String.format(desc, df.format(beanDto.getThresholdAmount().doubleValue() /100 ),df.format(beanDto.getDiscountAmount().doubleValue() / 100)));
// }
//
// shoppingCartGoodsResponseVo.setDeliveryAmount(deliveryAmount);
// shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(deliveryAmount);
// shoppingCartGoodsResponseVo.setIsDiscountDelivery(false);
//
// }else{
// String desc = DELIVERY_DISCOUNT_DESC3;
// shoppingCartGoodsResponseVo.setDeliveryDiscountDesc(String.format(desc, df.format(deliveryAmount.doubleValue() / 100)));
// shoppingCartGoodsResponseVo.setDeliveryAmount(deliveryAmount);
// shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(deliveryAmount);
// shoppingCartGoodsResponseVo.setIsDiscountDelivery(false);
// }
// }
// }
//
// }
private void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList
, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, UserLoginInfoDto userLoginInfoDto,String menuType,Long deliveryAmount) {
}
/**
* 促销均摊计算
......@@ -1017,42 +873,40 @@ public class ShoppingCartMCoffeeServiceImpl {
/**
* 获取购物车商品,添加商品,校验商品合法性,合并商品行,重新set购物车信息到缓存中
*
* @param cartGoods
* @param newCartGoods
* @param userId
* @param shoppingCartGoodsResponseVo
* @param addShoppingCartGoodsRequestVo
*/
// public List<CartGoods> updateCartGoodsLegal(CartGoods cartGoods, String userId, ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo, AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo, List<CartGoods> oldAllCartGoodsList) {
// //存储新添加的购物车信息
// List<CartGoods> nowCartGoodsList = new ArrayList<>();
// oldAllCartGoodsList.add(cartGoods);
//
// //当商品全部添加完毕,校验购物车商品(是否合法,上下架,点餐方式,是否在当前菜单中...),并移除非法商品
// CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(oldAllCartGoodsList, addShoppingCartGoodsRequestVo.getPartnerId(),
// addShoppingCartGoodsRequestVo.getShopId(), shoppingCartGoodsResponseVo, addShoppingCartGoodsRequestVo.getOrderType(),
// "", addShoppingCartGoodsRequestVo.getMenuType(),shoppingCartBaseService);
// 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);
//
// //判断当前商品在购物车是否已存在,存在则数量+1,不存在商品行 + 1
// allCartGoodsList.forEach(oldCartGoods -> {
// int index;
// if ((index = nowCartGoodsList.indexOf(oldCartGoods)) >= 0) {
// nowCartGoodsList.get(index).setQty(nowCartGoodsList.get(index).getQty() + cartGoods.getQty());
// } else {
// nowCartGoodsList.add(oldCartGoods);
// }
// });
// // 重新set购物车信息到缓存中
// assortmentSdkService.setShoppingCart(addShoppingCartGoodsRequestVo.getPartnerId(), addShoppingCartGoodsRequestVo.getShopId(),
// userId, nowCartGoodsList, addShoppingCartGoodsRequestVo.getSessionId(), addShoppingCartGoodsRequestVo.getTableNumber(), this.shoppingCartBaseService);
// oldAllCartGoodsList.clear();
// oldAllCartGoodsList.addAll(nowCartGoodsList);
// return nowCartGoodsList;
// }
public List<CartGoods> updateCartGoodsLegal(String partnerId, String storeId, Integer orderType, String tableNumber, String menuType, String userId,
List<CartGoods> newCartGoods, ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo, List<CartGoods> oldAllCartGoodsList) {
//存储新添加的购物车信息
List<CartGoods> nowCartGoodsList = new ArrayList<>();
oldAllCartGoodsList.addAll(newCartGoods);
//当商品全部添加完毕,校验购物车商品(是否合法,上下架,点餐方式,是否在当前菜单中...),并移除非法商品
CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(oldAllCartGoodsList, partnerId,
storeId, shoppingCartGoodsResponseVo, orderType, "", menuType, shoppingCartBaseService);
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);
//判断当前商品在购物车是否已存在,存在则数量+1,不存在商品行 + 1
allCartGoodsList.forEach(oldCartGoods -> {
int index;
if ((index = nowCartGoodsList.indexOf(oldCartGoods)) >= 0) {
nowCartGoodsList.get(index).setQty(nowCartGoodsList.get(index).getQty() + newCartGoods.get(0).getQty());
} else {
nowCartGoodsList.add(oldCartGoods);
}
});
// 重新set购物车信息到缓存中
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, nowCartGoodsList, null, tableNumber, this.shoppingCartBaseService);
oldAllCartGoodsList.clear();
oldAllCartGoodsList.addAll(nowCartGoodsList);
return nowCartGoodsList;
}
/**
* 添加商品券商品
......@@ -1105,43 +959,42 @@ public class ShoppingCartMCoffeeServiceImpl {
/**
* 查询多个商品库存信息
*
* @param addShoppingCartGoodsRequestVo
* @param productIds
* @param productBeanListSpuClass
* @param skuId
*/
// private void queryManyGoodsStocks(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo, List<Long> productIds
// , List<ProductBeanDTO> productBeanListSpuClass, String skuId, Integer qty) {
// GetProductStockRequestDto requestDto = new GetProductStockRequestDto();
// requestDto.setChannel(BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode());
// requestDto.setPartnerId(addShoppingCartGoodsRequestVo.getPartnerId());
// requestDto.setStoreId(addShoppingCartGoodsRequestVo.getShopId());
// requestDto.setProductIds(productIds);
// GetProductStockResponseDto availableStocks = null;
// if (productBeanListSpuClass.get(0).getType() == ProductType.NOSPEC.getCode()
// && productBeanListSpuClass.get(0).getStockLimit() == 1) {
// availableStocks = stockClient.getAvailableStocks(requestDto);
// } else {
// for (ProductBeanDTO.SkuProductBean skuProductBean : productBeanListSpuClass.get(0).getSkuList()) {
// if (skuId.equals(skuProductBean.getSkuId()) && skuProductBean.getStockLimit() == 1) {
// availableStocks = stockClient.getAvailableStocks(requestDto);
// break;
// }
// }
// }
// if (availableStocks != null && !ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode())) {
// throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
// }
// if (availableStocks != null && ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode()) &&
// (CollectionUtils.isEmpty(availableStocks.getResult()) || availableStocks.getResult().get(0).getQty() == null
// || availableStocks.getResult().get(0).getQty() < qty)) {
// Integer stock = 0;
// if (!CollectionUtils.isEmpty(availableStocks.getResult()) && (stock = availableStocks.getResult().get(0).getQty()) > 0) {
// throw new BizServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE, "仅剩" + stock + "件库存了");
// }
// throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
// }
// }
private void queryManyGoodsStocks(String partnerId,String storeId,String menuType, List<Long> productIds
, List<ProductBeanDTO> productBeanListSpuClass, String skuId, Integer qty) {
GetProductStockRequestDto requestDto = new GetProductStockRequestDto();
requestDto.setChannel(BusinessTypeEnum.getByType(menuType).getCode());
requestDto.setPartnerId(partnerId);
requestDto.setStoreId(storeId);
requestDto.setProductIds(productIds);
GetProductStockResponseDto availableStocks = null;
if (productBeanListSpuClass.get(0).getType() == ProductType.NOSPEC.getCode()
&& productBeanListSpuClass.get(0).getStockLimit() == 1) {
availableStocks = stockClient.getAvailableStocks(requestDto);
} else {
for (ProductBeanDTO.SkuProductBean skuProductBean : productBeanListSpuClass.get(0).getSkuList()) {
if (skuId.equals(skuProductBean.getSkuId()) && skuProductBean.getStockLimit() == 1) {
availableStocks = stockClient.getAvailableStocks(requestDto);
break;
}
}
}
if (availableStocks != null && !ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
}
if (availableStocks != null && ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode()) &&
(CollectionUtils.isEmpty(availableStocks.getResult()) || availableStocks.getResult().get(0).getQty() == null
|| availableStocks.getResult().get(0).getQty() < qty)) {
Integer stock = 0;
if (!CollectionUtils.isEmpty(availableStocks.getResult()) && (stock = availableStocks.getResult().get(0).getQty()) > 0) {
throw new BizServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE, "仅剩" + stock + "件库存了");
}
throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
}
}
/**
* 组装添加商品和更新商品和查询的响应信息
......@@ -1156,49 +1009,46 @@ public class ShoppingCartMCoffeeServiceImpl {
* @param opt
* @param shoppingCartInfoRequestVo
*/
// private void setAddAndUpdateResponse(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult
// , List<CartGoods> cartGoodsList, String toastMsg, String partnerId, String storeId, String userId, String opt, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
// shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
// shoppingCartGoodsResponseVo.setProductsCount(cartGoodsList.size());
// if (StringUtils.isNotEmpty(toastMsg)) {
// toastMsg=shoppingCartInfoRequestVo!=null && ObjectUtils.equals(1, shoppingCartInfoRequestVo.getFlag())?SHOPPING_CART_EMPTY_GOODS_LIST:SHOPPING_CART_INVALIAD_GOODS;
// setToastMsgIfNotExist(shoppingCartGoodsResponseVo, toastMsg);
// //结算页,只有商品全部非法(即products为空)时,才提示changed为true toastMsg 不为空
// if (shoppingCartInfoRequestVo!=null && ObjectUtils.equals(1, shoppingCartInfoRequestVo.getFlag())){
// shoppingCartGoodsResponseVo.setChanged(CollectionUtils.isEmpty(cartGoodsList));
// shoppingCartGoodsResponseVo.setToastMsg(CollectionUtils.isEmpty(cartGoodsList)?toastMsg:"");
// }
//
// }
// // 更新和添加商品时不需要包装费
// if (ShoppingCartConstant.ADD_AND_UPDATE.equals(opt)) {
// shoppingCartGoodsResponseVo.setNewPackAmount(null);
// return;
// }
// //========================== 购物车查询特有逻辑 =================================
// // 到店自取包装费设为null,外卖要计算包装费,flag为1表示去结算
// // 兼容老版本判断null
// if (Objects.equals(shoppingCartInfoRequestVo.getOrderType(), CreateOrderType.COLLECT_GOODS.getCode())
// && (Objects.equals(shoppingCartInfoRequestVo.getReachStoreType(), null)
// || Objects.equals(shoppingCartInfoRequestVo.getReachStoreType(), OrderType.EAT_IN.getCode()))) {
// shoppingCartGoodsResponseVo.setNewPackAmount(null);
// } else if ((Objects.equals(shoppingCartInfoRequestVo.getOrderType(), CreateOrderType.TAKE_OUT.getCode())
// || Objects.equals(shoppingCartInfoRequestVo.getReachStoreType(), OrderType.COLLECT_GOODS.getCode()))
// && Objects.equals(shoppingCartInfoRequestVo.getFlag(), CouponFlag.YES.getCode())) {
// Long packAmount = shoppingCartGoodsResponseVo.getNewPackAmount() == null ? 0 : shoppingCartGoodsResponseVo.getNewPackAmount();
// Long originalTotalAmount = shoppingCartGoodsResponseVo.getOriginalTotalAmount() + packAmount;
// Long totalAmount = shoppingCartGoodsResponseVo.getTotalAmount() + packAmount;
// shoppingCartGoodsResponseVo.setOriginalTotalAmount(originalTotalAmount);
// shoppingCartGoodsResponseVo.setTotalAmount(totalAmount);
// }
//
// }
private void setAddAndUpdateResponse(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult
, List<CartGoods> cartGoodsList, String toastMsg, String partnerId, String storeId, String userId, String opt, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
shoppingCartGoodsResponseVo.setProductsCount(cartGoodsList.size());
if (StringUtils.isNotEmpty(toastMsg)) {
toastMsg=shoppingCartInfoRequestVo!=null && ObjectUtils.equals(1, shoppingCartInfoRequestVo.getFlag())?SHOPPING_CART_EMPTY_GOODS_LIST:SHOPPING_CART_INVALIAD_GOODS;
setToastMsgIfNotExist(shoppingCartGoodsResponseVo, toastMsg);
//结算页,只有商品全部非法(即products为空)时,才提示changed为true toastMsg 不为空
if (shoppingCartInfoRequestVo!=null && ObjectUtils.equals(1, shoppingCartInfoRequestVo.getFlag())){
shoppingCartGoodsResponseVo.setChanged(CollectionUtils.isEmpty(cartGoodsList));
shoppingCartGoodsResponseVo.setToastMsg(CollectionUtils.isEmpty(cartGoodsList)?toastMsg:"");
}
}
// 更新和添加商品时不需要包装费
if (ShoppingCartConstant.ADD_AND_UPDATE.equals(opt)) {
shoppingCartGoodsResponseVo.setNewPackAmount(null);
return;
}
//========================== 购物车查询特有逻辑 =================================
// 到店自取包装费设为null,外卖要计算包装费,flag为1表示去结算
// 兼容老版本判断null
if (Objects.equals(shoppingCartInfoRequestVo.getOrderType(), CreateOrderType.COLLECT_GOODS.getCode())
&& (Objects.equals(shoppingCartInfoRequestVo.getReachStoreType(), null)
|| Objects.equals(shoppingCartInfoRequestVo.getReachStoreType(), OrderType.EAT_IN.getCode()))) {
shoppingCartGoodsResponseVo.setNewPackAmount(null);
} else if ((Objects.equals(shoppingCartInfoRequestVo.getOrderType(), CreateOrderType.TAKE_OUT.getCode())
|| Objects.equals(shoppingCartInfoRequestVo.getReachStoreType(), OrderType.COLLECT_GOODS.getCode()))
&& Objects.equals(shoppingCartInfoRequestVo.getFlag(), CouponFlag.YES.getCode())) {
Long packAmount = shoppingCartGoodsResponseVo.getNewPackAmount() == null ? 0 : shoppingCartGoodsResponseVo.getNewPackAmount();
Long originalTotalAmount = shoppingCartGoodsResponseVo.getOriginalTotalAmount() + packAmount;
Long totalAmount = shoppingCartGoodsResponseVo.getTotalAmount() + packAmount;
shoppingCartGoodsResponseVo.setOriginalTotalAmount(originalTotalAmount);
shoppingCartGoodsResponseVo.setTotalAmount(totalAmount);
}
}
/**
* 在原价、现价、折扣价上增加第一次使用会员卡的费用
*
* @param shoppingCartInfoRequestVo
* @param shoppingCartGoodsResponseVo
*/
// private void addNeedCardAmount(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
// ShoppingCartInfoRequestVo.BuyMemberCard buyMemberCard = shoppingCartInfoRequestVo.getBuyMemberCard();
......@@ -1341,35 +1191,6 @@ public class ShoppingCartMCoffeeServiceImpl {
// amount = storeService.getUserRealDeliveryAmount(storeDeliveryInfoDto, userLongitude, userLatitude).intValue();
// return amount;
// }
//
// private Long getNewDeliveryAmount(String receiveId, String partnerId, String storeId, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
// String trackingNo = LogThreadLocal.getTrackingNo();
// Long amount = 0L;
// if (StringUtils.isBlank(receiveId)) {
// return amount;
// }
// QueryReceiveAddressRequest queryReceive = new QueryReceiveAddressRequest(receiveId, partnerId);
// //查询会员后货地址经纬度
// com.freemud.application.sdk.api.base.BaseResponse<QueryReceiveAddressResponse> queryReceiveAddressResponse = memberCenterService.queryReceiveAddressById(queryReceive, trackingNo);
// if (!ResponseResult.SUCCESS.getCode().equals(queryReceiveAddressResponse.getCode()) || queryReceiveAddressResponse.getData() == null) {
// throw new ServiceException(ResponseResult.USER_GETRECEIVEADDRESS_ERROR);
// }
//
// QueryDeliveryRequest queryDeliveryRequest = new QueryDeliveryRequest();
// queryDeliveryRequest.setPartnerId(partnerId);
// queryDeliveryRequest.setStoreCode(storeId);
// queryDeliveryRequest.setUserLatitude(queryReceiveAddressResponse.getData().getLatitude());
// queryDeliveryRequest.setUserLongitude(queryReceiveAddressResponse.getData().getLongitude());
// com.freemud.application.sdk.api.base.BaseResponse<QueryDeliverDetailResponse> queryDeliverDetailResponse = storeCenterService.queryDeliverDetail(queryDeliveryRequest, trackingNo);
// if (queryDeliverDetailResponse == null || !ResponseResult.SUCCESS.getCode().equals(queryDeliverDetailResponse.getCode()) || queryDeliverDetailResponse.getData() == null) {
// throw new ServiceException(ResponseResult.STORE_ITEM_NOT_DELIVERY);
// }
// if(queryDeliverDetailResponse.getData().getDeliveryAmount() == null) {
// throw new ServiceException(ResponseResult.STORE_DELIVERY_AMOUNT_ERROR);
// }
// shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(queryDeliverDetailResponse.getData().getDeliveryFeeZeroReason() != null ? queryDeliverDetailResponse.getData().getDeliveryFeeZeroReason() : 0);
// return queryDeliverDetailResponse.getData().getDeliveryAmount();
// }
/**
* 获取配送范围内集合
......@@ -1398,38 +1219,89 @@ public class ShoppingCartMCoffeeServiceImpl {
/**
* 获取优惠
*/
// private ActivityCalculationDiscountResponseDto.CalculationDiscountResult getCalculationDiscountResult(String menuType
// ,String partnerId,String storeId,String userId,String appId,String wxappid,Integer orderType,boolean isMember
// ,List<CartGoods> cartGoodsList,List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons
// ,List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList,String receiveId,Long deliveryAmount){
// // 获取优惠信息
// ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult=null;
// //外卖场景下 查询门店配送信息
// if(BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)){
//
// calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),deliveryAmount);
// }else{
// calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),null);
// }
//
// return calculationDiscountResult;
// }
private ActivityCalculationDiscountResponseDto.CalculationDiscountResult getCalculationDiscountResult(String menuType
,String partnerId,String storeId,String userId,String appId,Integer orderType,boolean isMember
,List<CartGoods> cartGoodsList,List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons
,List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList,String receiveId,Long deliveryAmount){
// 获取优惠信息
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult=null;
//外卖场景下 查询门店配送信息
if(BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)){
// private Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, String wxappid, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
// Long deliveryAmount = 0L;
// if (StringUtils.isBlank(receiveId)) {
// return deliveryAmount;
// }
// log.info("获取配送配逻辑 tackingNo:{},storeDeliveryUseOld:{},receiveId:{},partnerId:{},storeId:{}", LogThreadLocal.getTrackingNo(), storeDeliveryUseOld, receiveId, partnerId, storeId);
// if (storeDeliveryUseOld) {
// deliveryAmount = Long.parseLong(getDeliveryAmount(receiveId, partnerId, storeId).toString());
// shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(0);
// } else {
// deliveryAmount = getNewDeliveryAmount(receiveId, partnerId, storeId, shoppingCartGoodsResponseVo);
// }
// return deliveryAmount;
//
// }
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),deliveryAmount);
}else{
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),null);
}
return calculationDiscountResult;
}
private Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, String wxappid, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
Long deliveryAmount = 0L;
if (StringUtils.isBlank(receiveId)) {
return deliveryAmount;
}
log.info("获取配送配逻辑 tackingNo:{},storeDeliveryUseOld:{},receiveId:{},partnerId:{},storeId:{}", LogThreadLocal.getTrackingNo(), storeDeliveryUseOld, receiveId, partnerId, storeId);
String trackingNo = LogThreadLocal.getTrackingNo();
Long amount = 0L;
if (StringUtils.isBlank(receiveId)) {
return amount;
}
QueryReceiveAddressRequest queryReceive = new QueryReceiveAddressRequest(receiveId, partnerId);
//查询会员后货地址经纬度
com.freemud.application.sdk.api.base.BaseResponse<QueryReceiveAddressResponse> queryReceiveAddressResponse = memberCenterService.queryReceiveAddressById(queryReceive, trackingNo);
if (!ResponseResult.SUCCESS.getCode().equals(queryReceiveAddressResponse.getCode()) || queryReceiveAddressResponse.getData() == null) {
throw new ServiceException(ResponseResult.USER_GETRECEIVEADDRESS_ERROR);
}
QueryDeliveryRequest queryDeliveryRequest = new QueryDeliveryRequest();
queryDeliveryRequest.setPartnerId(partnerId);
queryDeliveryRequest.setStoreCode(storeId);
queryDeliveryRequest.setUserLatitude(queryReceiveAddressResponse.getData().getLatitude());
queryDeliveryRequest.setUserLongitude(queryReceiveAddressResponse.getData().getLongitude());
com.freemud.application.sdk.api.base.BaseResponse<QueryDeliverDetailResponse> queryDeliverDetailResponse = storeCenterService.queryDeliverDetail(queryDeliveryRequest, trackingNo);
if (queryDeliverDetailResponse == null || !ResponseResult.SUCCESS.getCode().equals(queryDeliverDetailResponse.getCode()) || queryDeliverDetailResponse.getData() == null) {
throw new ServiceException(ResponseResult.STORE_ITEM_NOT_DELIVERY);
}
if(queryDeliverDetailResponse.getData().getDeliveryAmount() == null) {
throw new ServiceException(ResponseResult.STORE_DELIVERY_AMOUNT_ERROR);
}
shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(queryDeliverDetailResponse.getData().getDeliveryFeeZeroReason() != null ? queryDeliverDetailResponse.getData().getDeliveryFeeZeroReason() : 0);
deliveryAmount = queryDeliverDetailResponse.getData().getDeliveryAmount();
return deliveryAmount;
}
/**
* 检查sku数量
*
* @param allCartGoodsList
* @param cartGoods
* @return
*/
private Integer checkSkuQty(List<CartGoods> allCartGoodsList, CartGoods cartGoods) {
Integer qty = 0;
if (CollectionUtils.isEmpty(allCartGoodsList)) {
qty = cartGoods.getQty();
} else {
qty = cartGoods.getQty();
for (CartGoods goods : allCartGoodsList) {
if (goods.getSkuId().equals(cartGoods.getSkuId()) && goods.getSpuId().equals(cartGoods.getSpuId())) {
qty += goods.getQty();
}
}
}
return qty;
}
private void setToastMsgIfNotExist(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, String message) {
if (StringUtils.isEmpty(shoppingCartGoodsResponseVo.getToastMsg())) {
shoppingCartGoodsResponseVo.setToastMsg(message);
}
}
private CustomerInfoVo getCustomerInfoVo(String sessionId) {
GetSessionUserInfoDto getSessionUserInfoDto = new GetSessionUserInfoDto();
......@@ -1442,27 +1314,32 @@ public class ShoppingCartMCoffeeServiceImpl {
return sessionUserInfo.getResult();
}
/**
* 检查sku数量
*
* @param allCartGoodsList
* @param cartGoods
* @return
*/
// private Integer checkSkuQty(List<CartGoods> allCartGoodsList, CartGoods cartGoods) {
// Integer qty = 0;
// if (CollectionUtils.isEmpty(allCartGoodsList)) {
// qty = cartGoods.getQty();
// } else {
// qty = cartGoods.getQty();
// for (CartGoods goods : allCartGoodsList) {
// if (goods.getSkuId().equals(cartGoods.getSkuId()) && goods.getSpuId().equals(cartGoods.getSpuId())) {
// qty += goods.getQty();
// }
// }
// }
// return qty;
// }
private boolean isSpecialGoods(String partnerId, String storeId, String userId, String appId, String goodsId, Integer orderType) {
boolean isSpecialGoods = false;
ActivityAdapter activityAdapter = SDKCommonBaseContextWare.getBean(ActivityAdapter.class);
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, orderType);
ActivityService activityService = SDKCommonBaseContextWare.getBean(ActivityService.class);
ActivityQueryResponseDto activityQueryResponseDto = activityService.queryActivitys(activityQueryDto, ActivityTypeEnum.TYPE_2, null);
if (activityQueryResponseDto == null || activityQueryResponseDto.getResult() == null) {
return isSpecialGoods;
}
List<ActivityResponseDto> activityResponseDtoList = activityQueryResponseDto.getResult();
for (int i = 0, len = activityResponseDtoList.size(); i < len; i++) {
List<GoodsBeanDto> goodsBeanDtos = activityResponseDtoList.get(i).getGoods();
if (CollectionUtils.isEmpty(goodsBeanDtos)) {
continue;
}
boolean match = goodsBeanDtos.stream().anyMatch(k -> k.getGoodsId().equals(goodsId));
if (match) {
isSpecialGoods = true;
break;
}
}
return isSpecialGoods;
}
......
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