Commit 9acc200b by ping.wu

新增麦咖啡购物车

parent e682632b
...@@ -2,20 +2,11 @@ package cn.freemud.controller; ...@@ -2,20 +2,11 @@ package cn.freemud.controller;
import cn.freemud.base.entity.BaseResponse; import cn.freemud.base.entity.BaseResponse;
import cn.freemud.entities.vo.*; import cn.freemud.entities.vo.*;
import cn.freemud.enums.OrderChannelType; import cn.freemud.service.impl.mcoffee.ShoppingCartMCoffeeServiceImpl;
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 com.freemud.application.sdk.api.log.ApiAnnotation; import com.freemud.application.sdk.api.log.ApiAnnotation;
import com.freemud.application.sdk.api.log.LogParams; import com.freemud.application.sdk.api.log.LogParams;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -72,17 +63,6 @@ public class MCoffeeShoppingCartController { ...@@ -72,17 +63,6 @@ public class MCoffeeShoppingCartController {
return shoppingCartMCoffeeService.getGoodsList(request); 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 { ...@@ -32,7 +32,7 @@ public class UpdateShoppingCartGoodsQtyRequestVo extends BaseRequestVo {
private String cartGoodsUid; private String cartGoodsUid;
/** /**
* 商品数量 * 更新后商品数量
*/ */
@NotNull(message = "qty不能为空") @NotNull(message = "qty不能为空")
private Integer 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.adapter.ShoppingCartConvertAdapter;
import cn.freemud.base.entity.BaseResponse; 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.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.dto.user.GetSessionUserInfoDto; import cn.freemud.entities.dto.user.GetSessionUserInfoDto;
import cn.freemud.entities.vo.*; 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.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.CustomerApplicationClient;
import cn.freemud.service.thirdparty.StockClient;
import cn.freemud.utils.PromotionFactory;
import cn.freemud.utils.PropertyConvertUtil;
import cn.freemud.utils.ResponseUtil; 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.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 lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; 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 * All rights Reserved, Designed By www.freemud.cn
* *
...@@ -34,36 +71,39 @@ import org.springframework.stereotype.Service; ...@@ -34,36 +71,39 @@ import org.springframework.stereotype.Service;
public class ShoppingCartMCoffeeServiceImpl { public class ShoppingCartMCoffeeServiceImpl {
// 配送费逻辑是否使用旧的 // 配送费逻辑是否使用旧的
// @Value("${store.delivery.use.old:true}") @Value("${store.delivery.use.old:true}")
// private boolean storeDeliveryUseOld; private boolean storeDeliveryUseOld;
// @Autowired // @Value("${goods.cache.second}")
// private ActivityAdapter activityAdapter; // private long goodsCacheSeconds;
@Autowired
private ActivityAdapter activityAdapter;
// @Autowired // @Autowired
// private StoreItemClient storeItemClient; // private StoreItemClient storeItemClient;
// @Autowired @Autowired
// private ActivityClient activityClient; private ActivityClient activityClient;
// @Autowired @Autowired
// private ItemService itemService; private ItemService itemService;
// @Autowired // @Autowired
// private ShoppingCartNewBaseService shoppingCartNewBaseService; // private ShoppingCartNewBaseService shoppingCartNewBaseService;
// @Autowired @Autowired
// private ShoppingCartBaseServiceImpl shoppingCartBaseService; private ShoppingCartBaseServiceImpl shoppingCartBaseService;
// @Autowired @Autowired
// private CouponService couponService; private CouponService couponService;
// @Autowired // @Autowired
// private ShoppingCartConvertAdapter shoppingCartConvertAdapter; // private ShoppingCartConvertAdapter shoppingCartConvertAdapter;
// @Autowired @Autowired
// private FullSubtractionActivityServiceImpl fullSubtractionActivityService; private FullSubtractionActivityServiceImpl fullSubtractionActivityService;
// @Autowired // @Autowired
// private BuriedPointService buriedPointService; // private BuriedPointService buriedPointService;
// @Autowired // @Autowired
// private OpenPlatformClient openPlatformClient; // private OpenPlatformClient openPlatformClient;
// @Autowired @Autowired
// private StockClient stockClient; private StockClient stockClient;
// @Value("${goods.cache.second}") @Autowired
// private long goodsCacheSeconds; private AssortmentSdkService assortmentSdkService;
// @Autowired
// private AssortmentSdkService assortmentSdkService;
// @Autowired // @Autowired
// private CouponAdapter couponAdapter; // private CouponAdapter couponAdapter;
@Autowired @Autowired
...@@ -72,16 +112,16 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -72,16 +112,16 @@ public class ShoppingCartMCoffeeServiceImpl {
// private AssortmentCustomerInfoManager customerInfoManager; // private AssortmentCustomerInfoManager customerInfoManager;
// @Autowired // @Autowired
// private PaymentNewService paymentNewService; // private PaymentNewService paymentNewService;
// @Autowired @Autowired
// private MemberCenterService memberCenterService; private MemberCenterService memberCenterService;
// @Autowired // @Autowired
// private AssortmentOpenPlatformPartnerStoreDeliveryConfigManager deliveryConfigManager; // private AssortmentOpenPlatformPartnerStoreDeliveryConfigManager deliveryConfigManager;
// @Autowired // @Autowired
// private StoreServiceImpl storeService; // private StoreServiceImpl storeService;
// @Autowired @Autowired
// private StoreCenterService storeCenterService; private StoreCenterService storeCenterService;
// @Autowired @Autowired
// private CommonService commonService; private CommonService commonService;
// @Autowired // @Autowired
// private ProductService productService; // private ProductService productService;
// @Autowired // @Autowired
...@@ -96,130 +136,85 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -96,130 +136,85 @@ public class ShoppingCartMCoffeeServiceImpl {
public BaseResponse addGoods(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo) { public BaseResponse addGoods(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo) {
// TODO: 2020/7/21 参数校验 // TODO: 2020/7/21 参数校验
if (StringUtils.isEmpty(addShoppingCartGoodsRequestVo.getShopId())){ 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); if (addShoppingCartGoodsRequestVo.getQty() != null && addShoppingCartGoodsRequestVo.getQty() < 0){
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo(); 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())) { if (assortmentCustomerInfoVo == null || StringUtils.isEmpty(assortmentCustomerInfoVo.getMemberId())) {
return ResponseUtil.error(ResponseResult.NOT_LOGIN); return ResponseUtil.error(ResponseResult.NOT_LOGIN);
} }
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
UserLoginInfoDto userLoginInfoDto = convert2UserLoginInfoDto(assortmentCustomerInfoVo); UserLoginInfoDto userLoginInfoDto = convert2UserLoginInfoDto(assortmentCustomerInfoVo);
String userId = userLoginInfoDto.getMemberId(); String userId = userLoginInfoDto.getMemberId();
String partnerId = addShoppingCartGoodsRequestVo.getPartnerId(); String partnerId = addShoppingCartGoodsRequestVo.getPartnerId();
String storeId = addShoppingCartGoodsRequestVo.getShopId(); String storeId = addShoppingCartGoodsRequestVo.getShopId();
String appId = addShoppingCartGoodsRequestVo.getAppId(); String appId = addShoppingCartGoodsRequestVo.getAppId();
String spuId = addShoppingCartGoodsRequestVo.getSpuId(); String spuId = addShoppingCartGoodsRequestVo.getSpuId();
String skuId = addShoppingCartGoodsRequestVo.getSkuId(); String skuId = StringUtils.isNotBlank(addShoppingCartGoodsRequestVo.getSkuId()) ? addShoppingCartGoodsRequestVo.getSkuId() : "";
String goodsId = StringUtils.isEmpty(skuId) ? spuId : skuId; String goodsId = StringUtils.isEmpty(skuId) ? spuId : skuId;
String tableNumber = addShoppingCartGoodsRequestVo.getTableNumber();
String menuType = addShoppingCartGoodsRequestVo.getMenuType(); String menuType = addShoppingCartGoodsRequestVo.getMenuType();
Integer orderType = addShoppingCartGoodsRequestVo.getOrderType(); Integer orderType = addShoppingCartGoodsRequestVo.getOrderType();
String receiveId = addShoppingCartGoodsRequestVo.getReceiveId(); 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 购物车数据更新 // 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 返回购物车数据 // 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); // this.buriedPointShoppingCart(addShoppingCartGoodsRequestVo, spuId, productName);
return ResponseUtil.success(shoppingCartGoodsResponseVo); 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 { ...@@ -227,105 +222,111 @@ public class ShoppingCartMCoffeeServiceImpl {
* @return * @return
*/ */
public BaseResponse updateGoodsQty(UpdateShoppingCartGoodsQtyRequestVo updateShoppingCartGoodsQtyRequestVo) { public BaseResponse updateGoodsQty(UpdateShoppingCartGoodsQtyRequestVo updateShoppingCartGoodsQtyRequestVo) {
// if (StringUtils.isEmpty(updateShoppingCartGoodsQtyRequestVo.getShopId())){ if (StringUtils.isEmpty(updateShoppingCartGoodsQtyRequestVo.getShopId())){
// throw new ServiceException(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY); throw new ServiceException(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
// } }
// ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo(); if (updateShoppingCartGoodsQtyRequestVo.getQty() != null && updateShoppingCartGoodsQtyRequestVo.getQty() < 0){
// CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(updateShoppingCartGoodsQtyRequestVo.getSessionId()); return ResponseUtil.error(ResponseResult.SHOPPING_CART_ADD_ERROR);
// UserLoginInfoDto userLoginInfoDto = convert2UserLoginInfoDto(assortmentCustomerInfoVo); }
// String userId = userLoginInfoDto.getMemberId(); ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
// String partnerId = updateShoppingCartGoodsQtyRequestVo.getPartnerId(); CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(updateShoppingCartGoodsQtyRequestVo.getSessionId());
// String storeId = updateShoppingCartGoodsQtyRequestVo.getShopId(); UserLoginInfoDto userLoginInfoDto = convert2UserLoginInfoDto(assortmentCustomerInfoVo);
// String appId = updateShoppingCartGoodsQtyRequestVo.getAppId(); String userId = userLoginInfoDto.getMemberId();
// String cartGoodsUid = updateShoppingCartGoodsQtyRequestVo.getCartGoodsUid(); String partnerId = updateShoppingCartGoodsQtyRequestVo.getPartnerId();
// Integer qty = updateShoppingCartGoodsQtyRequestVo.getQty(); String storeId = updateShoppingCartGoodsQtyRequestVo.getShopId();
// String menuType = updateShoppingCartGoodsQtyRequestVo.getMenuType(); String appId = updateShoppingCartGoodsQtyRequestVo.getAppId();
// Integer orderType=updateShoppingCartGoodsQtyRequestVo.getOrderType(); String cartGoodsUid = updateShoppingCartGoodsQtyRequestVo.getCartGoodsUid();
// String receiveId = updateShoppingCartGoodsQtyRequestVo.getReceiveId(); Integer qty = updateShoppingCartGoodsQtyRequestVo.getQty();
// String menuType = updateShoppingCartGoodsQtyRequestVo.getMenuType();
// // 先验证商品是否存在 Integer orderType=updateShoppingCartGoodsQtyRequestVo.getOrderType();
// CartGoods cartGoods = assortmentSdkService.getCartGoodsBySdk(partnerId, userId, storeId, cartGoodsUid, "", shoppingCartBaseService); String receiveId = updateShoppingCartGoodsQtyRequestVo.getReceiveId();
// if (cartGoods == null) {
// throw new ServiceException(ResponseResult.SHOPPING_CART_UPDATE_ERROR); // 先验证商品是否存在
// } List<CartGoods> cartGoodsList = assortmentSdkService.getShoppingCart(partnerId, storeId,userId,null,null,shoppingCartBaseService);
// // 检查购物车商品库存数量 CartGoods cartGoods = null;
// checkUpdateStock(updateShoppingCartGoodsQtyRequestVo, cartGoods); 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); // List<CartGoods> cartGoodsList = assortmentSdkService.updateGoodsQtyBySdk(partnerId, userId, storeId, cartGoodsUid, qty<0?0:qty, "", shoppingCartBaseService);
//
// // check购物车中所有商品 // check购物车中所有商品
// CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(cartGoodsList, partnerId, storeId, shoppingCartGoodsResponseVo, updateShoppingCartGoodsQtyRequestVo.getOrderType(), "", updateShoppingCartGoodsQtyRequestVo.getMenuType(), shoppingCartBaseService); CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(cartGoodsList, partnerId, storeId, shoppingCartGoodsResponseVo, updateShoppingCartGoodsQtyRequestVo.getOrderType(), "", updateShoppingCartGoodsQtyRequestVo.getMenuType(), shoppingCartBaseService);
// if (checkCartRequest.getShoppingCartGoodsResponseVo() != null) { if (checkCartRequest.getShoppingCartGoodsResponseVo() != null) {
// shoppingCartGoodsResponseVo.setChanged(checkCartRequest.getShoppingCartGoodsResponseVo().getChanged()); shoppingCartGoodsResponseVo.setChanged(checkCartRequest.getShoppingCartGoodsResponseVo().getChanged());
// shoppingCartGoodsResponseVo.setToastMsg(checkCartRequest.getShoppingCartGoodsResponseVo().getToastMsg()); shoppingCartGoodsResponseVo.setToastMsg(checkCartRequest.getShoppingCartGoodsResponseVo().getToastMsg());
// } }
// cartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class); cartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
// // 重新存储最新购物车 // 重新存储最新购物车
// assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, updateShoppingCartGoodsQtyRequestVo.getSessionId(), "", shoppingCartBaseService); assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, updateShoppingCartGoodsQtyRequestVo.getSessionId(), "", shoppingCartBaseService);
//
//
// Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo); Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo);
// // 获取优惠信息 // 获取优惠信息
// ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult
// =getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,assortmentCustomerInfoVo.isMemberPaid(),cartGoodsList,new ArrayList(),new ArrayList<>(),null,deliveryAmount); =getCalculationDiscountResult(menuType,partnerId,storeId,userId,userLoginInfoDto.getWxAppid(),orderType,assortmentCustomerInfoVo.isMemberPaid(),cartGoodsList,new ArrayList(),new ArrayList<>(),null,deliveryAmount);
// if (calculationDiscountResult == null) { if (calculationDiscountResult == null) {
// shoppingCartGoodsResponseVo.setProducts(cartGoodsList); shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
//// return shoppingCartGoodsResponseVo; }
// }
// ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, updateShoppingCartGoodsQtyRequestVo.getOrderType());
// ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, updateShoppingCartGoodsQtyRequestVo.getOrderType());
// // 促销活动的优惠金额计算
// // 促销活动的优惠金额计算 updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto,updateShoppingCartGoodsQtyRequestVo.getMenuType(),deliveryAmount);
// 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);
// setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.ADD_AND_UPDATE, null);
return ResponseUtil.success(); return ResponseUtil.success();
} }
/** /**
* 检查购物车商品库存数量 * 检查购物车商品库存数量
*
* @param updateShoppingCartGoodsQtyRequestVo
* @param cartGoods
*/ */
// private void checkUpdateStock(UpdateShoppingCartGoodsQtyRequestVo updateShoppingCartGoodsQtyRequestVo, CartGoods cartGoods) { private void checkUpdateStock(String partnerId, String storeId, String menuType, Integer qty, CartGoods cartGoods) {
// Integer qty = updateShoppingCartGoodsQtyRequestVo.getQty(); // 购物车商品数量减少
// // 购物车商品数量减少 if (cartGoods.getQty() > qty) {
// if (cartGoods.getQty() > qty) { return;
// return; }
// } //查询商品信息
// String partnerId = updateShoppingCartGoodsQtyRequestVo.getPartnerId(); List<String> pids = new ArrayList<>();
// String storeId = updateShoppingCartGoodsQtyRequestVo.getShopId(); pids.add(cartGoods.getGoodsId());
// //查询商品信息 Map<String, GetProductsVo> products = itemService.getProducts(pids, partnerId, storeId,BusinessTypeEnum.getByType(menuType).getCode());
// List<String> pids = new ArrayList<>();
// pids.add(cartGoods.getGoodsId()); GetProductsVo getProductsVo = products.get(cartGoods.getGoodsId());
// Map<String, GetProductsVo> products = itemService.getProducts(pids, partnerId, storeId,BusinessTypeEnum.getByType(updateShoppingCartGoodsQtyRequestVo.getMenuType()).getCode()); // 商品没有库存限制
// if ((getProductsVo == null) || (getProductsVo.getStockLimit() != 1)) {
// GetProductsVo getProductsVo = products.get(cartGoods.getGoodsId()); return;
// // 商品没有库存限制 }
// if ((getProductsVo == null) || (getProductsVo.getStockLimit() != 1)) { ShoppingCartConvertAdapter.setClassification(cartGoods, getProductsVo);
// return; GetProductStockRequestDto requestDto = new GetProductStockRequestDto();
// } requestDto.setChannel(BusinessTypeEnum.getByType(menuType).getCode());
// ShoppingCartConvertAdapter.setClassification(cartGoods, getProductsVo); requestDto.setPartnerId(partnerId);
// GetProductStockRequestDto requestDto = new GetProductStockRequestDto(); requestDto.setStoreId(storeId);
// requestDto.setChannel(BusinessTypeEnum.getByType(updateShoppingCartGoodsQtyRequestVo.getMenuType()).getCode()); requestDto.setProductIds(Collections.singletonList(Long.parseLong(cartGoods.getGoodsId())));
// requestDto.setPartnerId(partnerId); GetProductStockResponseDto availableStocks = stockClient.getAvailableStocks(requestDto);
// requestDto.setStoreId(storeId); if ((availableStocks != null) && (ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode()))) {
// requestDto.setProductIds(Collections.singletonList(Long.parseLong(cartGoods.getGoodsId()))); if ((CollectionUtils.isEmpty(availableStocks.getResult())) || (availableStocks.getResult().get(0).getQty() != null &&
// GetProductStockResponseDto availableStocks = stockClient.getAvailableStocks(requestDto); qty > availableStocks.getResult().get(0).getQty())) {
// if ((availableStocks != null) && (ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode()))) { Integer stock = 0;
// if ((CollectionUtils.isEmpty(availableStocks.getResult())) || (availableStocks.getResult().get(0).getQty() != null && if (!CollectionUtils.isEmpty(availableStocks.getResult()) && (stock = availableStocks.getResult().get(0).getQty()) > 0) {
// qty > availableStocks.getResult().get(0).getQty())) { throw new BizServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE, "仅剩" + stock + "件库存了");
// Integer stock = 0; }
// if (!CollectionUtils.isEmpty(availableStocks.getResult()) && (stock = availableStocks.getResult().get(0).getQty()) > 0) { throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
// 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 { ...@@ -431,40 +432,39 @@ public class ShoppingCartMCoffeeServiceImpl {
*/ */
public BaseResponse clear(ShoppingCartClearRequestVo shoppingCartClearRequestVo) { public BaseResponse clear(ShoppingCartClearRequestVo shoppingCartClearRequestVo) {
// String appId = shoppingCartClearRequestVo.getAppId(); String appId = shoppingCartClearRequestVo.getAppId();
// if (StringUtils.isBlank(appId)) { if (StringUtils.isBlank(appId)) {
// return ResponseUtil.error(ResponseResult.PARAMETER_MISSING, "appId不能为空"); return ResponseUtil.error(ResponseResult.PARAMETER_MISSING, "appId不能为空");
// } }
// String userId = shoppingCartClearRequestVo.getUserId(); String userId = shoppingCartClearRequestVo.getUserId();
// if (StringUtils.isEmpty(userId)){ if (StringUtils.isEmpty(userId)){
// CustomerInfoVo userLoginInfoDto =getCustomerInfoVo(shoppingCartClearRequestVo.getSessionId()); CustomerInfoVo userLoginInfoDto =getCustomerInfoVo(shoppingCartClearRequestVo.getSessionId());
// userId=userLoginInfoDto.getMemberId(); userId=userLoginInfoDto.getMemberId();
// } }
// String partnerId = shoppingCartClearRequestVo.getPartnerId(); String partnerId = shoppingCartClearRequestVo.getPartnerId();
// String storeId = shoppingCartClearRequestVo.getShopId(); String storeId = shoppingCartClearRequestVo.getShopId();
// shoppingCartNewBaseService.clear(partnerId, storeId, userId); com.freemud.sdk.api.assortment.shoppingcart.domain.CartParamDto cartParamDto = assortmentSdkService.getCartParamDto(partnerId, storeId, userId);
// if (ObjectUtils.equals(shoppingCartClearRequestVo.getOperationType(), OperationTypeEnum.PAY_SUCCESS.getOperationType())) { shoppingCartBaseService.clear(cartParamDto,LogThreadLocal.getTrackingNo());
// return ResponseUtil.success(); 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);
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, public BaseResponse<ShoppingCartGoodsDto> getShoppingCartGoods(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo,
...@@ -627,90 +627,90 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -627,90 +627,90 @@ public class ShoppingCartMCoffeeServiceImpl {
* @param cartGoodsList * @param cartGoodsList
* @return * @return
*/ */
// public ActivityCalculationDiscountResponseDto.CalculationDiscountResult getActivityCalculationDiscountResponse( public ActivityCalculationDiscountResponseDto.CalculationDiscountResult getActivityCalculationDiscountResponse(
// String partnerId, String storeId, String userId, String appId, Integer orderType,boolean isMember, List<CartGoods> cartGoodsList, String partnerId, String storeId, String userId, String appId, Integer orderType,boolean isMember, List<CartGoods> cartGoodsList,
// List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons,
// List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList,String menuType,Long distributionFee) { List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList,String menuType,Long distributionFee) {
//
// ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = getActivityCalculationDiscountRequestDto(partnerId, storeId, userId, appId, orderType); ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = getActivityCalculationDiscountRequestDto(partnerId, storeId, userId, appId, orderType);
// List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList = new ArrayList<>(); List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList = new ArrayList<>();
// // 校验后有效的商品券map // 校验后有效的商品券map
// Map<String, CheckSpqInfoResponseDto> validCouponMap = new HashMap<>(16); Map<String, CheckSpqInfoResponseDto> validCouponMap = new HashMap<>(16);
// for (int i = cartGoodsList.size() - 1; i >= 0; i--) { for (int i = cartGoodsList.size() - 1; i >= 0; i--) {
// CartGoods cartGoods = cartGoodsList.get(i); CartGoods cartGoods = cartGoodsList.get(i);
// String cartGoodsUid = cartGoods.getCartGoodsUid(); String cartGoodsUid = cartGoods.getCartGoodsUid();
// // 商品不是商品券 // 商品不是商品券
// if (!cartGoodsUid.startsWith(CommonsConstant.COUPON_PREFIX)) { if (!cartGoodsUid.startsWith(CommonsConstant.COUPON_PREFIX)) {
// this.addCalculationDiscountGoods(calculationDiscountGoodsList, cartGoods.getGoodsId(), cartGoods.getQty(), cartGoods.getFinalPrice(),cartGoods.getMemberDiscount()); this.addCalculationDiscountGoods(calculationDiscountGoodsList, cartGoods.getGoodsId(), cartGoods.getQty(), cartGoods.getFinalPrice(),cartGoods.getMemberDiscount());
// } }
// // 商品是商品券 // 商品是商品券
// else { else {
// // 商品券ID换取商品 // 商品券ID换取商品
// String spqId = cartGoods.getCartGoodsUid().substring(CommonsConstant.COUPON_PREFIX.length()); String spqId = cartGoods.getCartGoodsUid().substring(CommonsConstant.COUPON_PREFIX.length());
// CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, spqId,menuType); CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, spqId,menuType);
// CheckSpqInfoResponseDto checkSpqInfoResponseDto = couponService.checkSpqInfo(checkSpqInfoRequestDto); CheckSpqInfoResponseDto checkSpqInfoResponseDto = couponService.checkSpqInfo(checkSpqInfoRequestDto);
// // 商品券不存在时,将商品券从购物车移除 // 商品券不存在时,将商品券从购物车移除
// if (checkSpqInfoResponseDto == null) { if (checkSpqInfoResponseDto == null) {
// cartGoodsList.remove(i); cartGoodsList.remove(i);
// assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, null, null, this.shoppingCartBaseService); assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, null, null, this.shoppingCartBaseService);
// throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_NOT_EXIST); throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_NOT_EXIST);
// } }
// validCouponMap.put(spqId, checkSpqInfoResponseDto); validCouponMap.put(spqId, checkSpqInfoResponseDto);
// cartGoods.setName(checkSpqInfoResponseDto.getCouponName()); cartGoods.setName(checkSpqInfoResponseDto.getCouponName());
// cartGoods.setSpuName(checkSpqInfoResponseDto.getCouponName()); cartGoods.setSpuName(checkSpqInfoResponseDto.getCouponName());
// // 添加请求的优惠券信息 // 添加请求的优惠券信息
// ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon coupon = new ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon(); ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon coupon = new ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon();
// coupon.setCode(checkSpqInfoResponseDto.getCouponCode()); coupon.setCode(checkSpqInfoResponseDto.getCouponCode());
// coupon.setActivityCode(checkSpqInfoResponseDto.getActiveCode()); coupon.setActivityCode(checkSpqInfoResponseDto.getActiveCode());
// coupons.add(coupon); coupons.add(coupon);
// // 添加商品券代表的商品 // 添加商品券代表的商品
// String goodsId = StringUtils.isEmpty(checkSpqInfoResponseDto.getSkuId()) ? checkSpqInfoResponseDto.getSpuId() : checkSpqInfoResponseDto.getSkuId(); String goodsId = StringUtils.isEmpty(checkSpqInfoResponseDto.getSkuId()) ? checkSpqInfoResponseDto.getSpuId() : checkSpqInfoResponseDto.getSkuId();
// this.addCalculationDiscountGoods(calculationDiscountGoodsList, goodsId, 1, checkSpqInfoResponseDto.getPrice(),100); this.addCalculationDiscountGoods(calculationDiscountGoodsList, goodsId, 1, checkSpqInfoResponseDto.getPrice(),100);
// } }
// } }
// // 当加价购商品不为空时 // 当加价购商品不为空时
// if (CollectionUtils.isNotEmpty(sendGoodsList)) { if (CollectionUtils.isNotEmpty(sendGoodsList)) {
// for (ShoppingCartInfoRequestVo.SendGoods sendGoods : sendGoodsList) { for (ShoppingCartInfoRequestVo.SendGoods sendGoods : sendGoodsList) {
// this.addCalculationDiscountGoods(calculationDiscountGoodsList, sendGoods.getGoodsId(), sendGoods.getQty(), sendGoods.getOriginalPrice(),100); this.addCalculationDiscountGoods(calculationDiscountGoodsList, sendGoods.getGoodsId(), sendGoods.getQty(), sendGoods.getOriginalPrice(),100);
// } }
// } }
// calculationDiscountGoodsList.removeIf(calculationDiscountGoods -> (calculationDiscountGoods.getGoodsQuantity().equals(0))); calculationDiscountGoodsList.removeIf(calculationDiscountGoods -> (calculationDiscountGoods.getGoodsQuantity().equals(0)));
// if (CollectionUtils.isEmpty(calculationDiscountGoodsList)) { if (CollectionUtils.isEmpty(calculationDiscountGoodsList)) {
// return null; return null;
// } }
// activityCalculationDiscountRequestDto.setGoods(calculationDiscountGoodsList); activityCalculationDiscountRequestDto.setGoods(calculationDiscountGoodsList);
// activityCalculationDiscountRequestDto.setCoupons(coupons); activityCalculationDiscountRequestDto.setCoupons(coupons);
// activityCalculationDiscountRequestDto.setOrgIds(commonService.getOrgIds(partnerId, storeId)); activityCalculationDiscountRequestDto.setOrgIds(commonService.getOrgIds(partnerId, storeId));
// activityCalculationDiscountRequestDto.setDistributionFee(distributionFee); activityCalculationDiscountRequestDto.setDistributionFee(distributionFee);
// activityCalculationDiscountRequestDto.setIsMember(isMember); activityCalculationDiscountRequestDto.setIsMember(isMember);
// ActivityCalculationDiscountResponseDto activityCalculationDiscountResponseDto; ActivityCalculationDiscountResponseDto activityCalculationDiscountResponseDto;
// try { try {
// activityCalculationDiscountResponseDto = activityClient.calculationDiscount(activityCalculationDiscountRequestDto); activityCalculationDiscountResponseDto = activityClient.calculationDiscount(activityCalculationDiscountRequestDto);
// } catch (Exception ex) { } catch (Exception ex) {
// ErrorLog.printErrorLog("calculation_discount_error", "/calculation/discount", activityCalculationDiscountRequestDto, ex); ErrorLog.printErrorLog("calculation_discount_error", "/calculation/discount", activityCalculationDiscountRequestDto, ex);
// throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN); throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN);
// } }
// // 返回成功 // 返回成功
// if (activityCalculationDiscountResponseDto != null && StringUtils.equals(activityCalculationDiscountResponseDto.getStatusCode(), ResponseCodeConstant.RESPONSE_SUCCESS_STR)) { if (activityCalculationDiscountResponseDto != null && StringUtils.equals(activityCalculationDiscountResponseDto.getStatusCode(), ResponseCodeConstant.RESPONSE_SUCCESS_STR)) {
// ActivityCalculationDiscountResponseDto.CalculationDiscountResult result = activityCalculationDiscountResponseDto.getResult(); ActivityCalculationDiscountResponseDto.CalculationDiscountResult result = activityCalculationDiscountResponseDto.getResult();
// result.setValidCouponMap(validCouponMap); result.setValidCouponMap(validCouponMap);
// result.setDeliveryAmount(distributionFee); result.setDeliveryAmount(distributionFee);
// result.setDistributionFee(result.getDistributionFee()); result.setDistributionFee(result.getDistributionFee());
// return result; return result;
// } }
// // 支付宝华莱士紧急修改代码,当促销返回103错误码时,需要报券不适用于该门店,且清空购物车 // 支付宝华莱士紧急修改代码,当促销返回103错误码时,需要报券不适用于该门店,且清空购物车
// ShoppingCartClearRequestVo shoppingCartClearRequestVo = new ShoppingCartClearRequestVo(); ShoppingCartClearRequestVo shoppingCartClearRequestVo = new ShoppingCartClearRequestVo();
// shoppingCartClearRequestVo.setAppId(appId); shoppingCartClearRequestVo.setAppId(appId);
// shoppingCartClearRequestVo.setPartnerId(partnerId); shoppingCartClearRequestVo.setPartnerId(partnerId);
// shoppingCartClearRequestVo.setUserId(userId); shoppingCartClearRequestVo.setUserId(userId);
// shoppingCartClearRequestVo.setShopId(storeId); shoppingCartClearRequestVo.setShopId(storeId);
// shoppingCartClearRequestVo.setOperationType(1); shoppingCartClearRequestVo.setOperationType(1);
// clear(shoppingCartClearRequestVo); clear(shoppingCartClearRequestVo);
// if (activityCalculationDiscountResponseDto != null && StringUtils.equals(activityCalculationDiscountResponseDto.getStatusCode(), "103")){ if (activityCalculationDiscountResponseDto != null && StringUtils.equals(activityCalculationDiscountResponseDto.getStatusCode(), "103")){
// throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_CAN_NOT_USE_THIS_SHOP); throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_CAN_NOT_USE_THIS_SHOP);
// } }
// throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN); throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN);
// } }
/** /**
* 将calculationDiscountGoods 封装后加入 calculationDiscountGoodsList * 将calculationDiscountGoods 封装后加入 calculationDiscountGoodsList
...@@ -720,15 +720,15 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -720,15 +720,15 @@ public class ShoppingCartMCoffeeServiceImpl {
* @param goodsQuantity * @param goodsQuantity
* @param originalPrice * @param originalPrice
*/ */
// private void addCalculationDiscountGoods(List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList, private void addCalculationDiscountGoods(List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList,
// String goodsId, Integer goodsQuantity, Long originalPrice,Integer memberDiscount) { String goodsId, Integer goodsQuantity, Long originalPrice,Integer memberDiscount) {
// ActivityCalculationDiscountRequestDto.CalculationDiscountGoods calculationDiscountGoods = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods(); ActivityCalculationDiscountRequestDto.CalculationDiscountGoods calculationDiscountGoods = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods();
// calculationDiscountGoods.setGoodsId(goodsId); calculationDiscountGoods.setGoodsId(goodsId);
// calculationDiscountGoods.setGoodsQuantity(goodsQuantity); calculationDiscountGoods.setGoodsQuantity(goodsQuantity);
// calculationDiscountGoods.setOriginalPrice(originalPrice); calculationDiscountGoods.setOriginalPrice(originalPrice);
// calculationDiscountGoods.setMemberDiscount(memberDiscount); calculationDiscountGoods.setMemberDiscount(memberDiscount);
// this.addCalculationDiscountGoods(calculationDiscountGoodsList, calculationDiscountGoods); this.addCalculationDiscountGoods(calculationDiscountGoodsList, calculationDiscountGoods);
// } }
/** /**
* 构建 ActivityCalculationDiscountRequestDto * 构建 ActivityCalculationDiscountRequestDto
...@@ -740,20 +740,20 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -740,20 +740,20 @@ public class ShoppingCartMCoffeeServiceImpl {
* @param orderType * @param orderType
* @return * @return
*/ */
// private ActivityCalculationDiscountRequestDto getActivityCalculationDiscountRequestDto(String partnerId, String storeId, String userId, String appId, Integer orderType) { private ActivityCalculationDiscountRequestDto getActivityCalculationDiscountRequestDto(String partnerId, String storeId, String userId, String appId, Integer orderType) {
// ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = new ActivityCalculationDiscountRequestDto(); ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = new ActivityCalculationDiscountRequestDto();
// activityCalculationDiscountRequestDto.setPartnerCode(partnerId); activityCalculationDiscountRequestDto.setPartnerCode(partnerId);
// activityCalculationDiscountRequestDto.setStoreId(storeId); activityCalculationDiscountRequestDto.setStoreId(storeId);
// activityCalculationDiscountRequestDto.setIsShowGoodsActivity(1); activityCalculationDiscountRequestDto.setIsShowGoodsActivity(1);
// activityCalculationDiscountRequestDto.setUserId(userId); activityCalculationDiscountRequestDto.setUserId(userId);
// activityCalculationDiscountRequestDto.setVer(1); activityCalculationDiscountRequestDto.setVer(1);
// activityCalculationDiscountRequestDto.setAppId(appId); activityCalculationDiscountRequestDto.setAppId(appId);
// ActivityChannelEnum activityChannelEnum = PropertyConvertUtil.orderTypeConvert2ActivityChannel(orderType); ActivityChannelEnum activityChannelEnum = PropertyConvertUtil.orderTypeConvert2ActivityChannel(orderType);
// if (!Objects.isNull(activityChannelEnum)) { if (!Objects.isNull(activityChannelEnum)) {
// activityCalculationDiscountRequestDto.setChannel(activityChannelEnum.getCode()); activityCalculationDiscountRequestDto.setChannel(activityChannelEnum.getCode());
// } }
// return activityCalculationDiscountRequestDto; return activityCalculationDiscountRequestDto;
// } }
/** /**
...@@ -762,17 +762,17 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -762,17 +762,17 @@ public class ShoppingCartMCoffeeServiceImpl {
* @param calculationDiscountGoodsList * @param calculationDiscountGoodsList
* @param calculationDiscountGoods * @param calculationDiscountGoods
*/ */
// private void addCalculationDiscountGoods(List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList, private void addCalculationDiscountGoods(List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList,
// ActivityCalculationDiscountRequestDto.CalculationDiscountGoods calculationDiscountGoods) { ActivityCalculationDiscountRequestDto.CalculationDiscountGoods calculationDiscountGoods) {
// int index; int index;
// // 当商品已存在时,需累加数量 // 当商品已存在时,需累加数量
// if ((index = calculationDiscountGoodsList.indexOf(calculationDiscountGoods)) >= 0) { if ((index = calculationDiscountGoodsList.indexOf(calculationDiscountGoods)) >= 0) {
// ActivityCalculationDiscountRequestDto.CalculationDiscountGoods oldCalculationDiscountGoods = calculationDiscountGoodsList.get(index); ActivityCalculationDiscountRequestDto.CalculationDiscountGoods oldCalculationDiscountGoods = calculationDiscountGoodsList.get(index);
// oldCalculationDiscountGoods.setGoodsQuantity(oldCalculationDiscountGoods.getGoodsQuantity() + calculationDiscountGoods.getGoodsQuantity()); oldCalculationDiscountGoods.setGoodsQuantity(oldCalculationDiscountGoods.getGoodsQuantity() + calculationDiscountGoods.getGoodsQuantity());
// } else { } else {
// calculationDiscountGoodsList.add(calculationDiscountGoods); calculationDiscountGoodsList.add(calculationDiscountGoods);
// } }
// } }
/** /**
* 处理加价购商品 * 处理加价购商品
...@@ -809,11 +809,7 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -809,11 +809,7 @@ public class ShoppingCartMCoffeeServiceImpl {
* @param shoppingCartGoodsResponseVo * @param shoppingCartGoodsResponseVo
* @param message * @param message
*/ */
// private void setToastMsgIfNotExist(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, String message) {
// if (StringUtils.isEmpty(shoppingCartGoodsResponseVo.getToastMsg())) {
// shoppingCartGoodsResponseVo.setToastMsg(message);
// }
// }
/** /**
* 促销活动的优惠金额计算 * 促销活动的优惠金额计算
...@@ -822,150 +818,10 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -822,150 +818,10 @@ public class ShoppingCartMCoffeeServiceImpl {
* @param cartGoodsList * @param cartGoodsList
* @param shoppingCartGoodsResponseVo * @param shoppingCartGoodsResponseVo
*/ */
// private void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList private void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList
// , ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, UserLoginInfoDto userLoginInfoDto,String menuType,Long deliveryAmount) { , 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);
// }
// }
// }
//
// }
/** /**
* 促销均摊计算 * 促销均摊计算
...@@ -1017,42 +873,40 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -1017,42 +873,40 @@ public class ShoppingCartMCoffeeServiceImpl {
/** /**
* 获取购物车商品,添加商品,校验商品合法性,合并商品行,重新set购物车信息到缓存中 * 获取购物车商品,添加商品,校验商品合法性,合并商品行,重新set购物车信息到缓存中
* *
* @param cartGoods * @param newCartGoods
* @param userId * @param userId
* @param shoppingCartGoodsResponseVo * @param shoppingCartGoodsResponseVo
* @param addShoppingCartGoodsRequestVo
*/ */
// public List<CartGoods> updateCartGoodsLegal(CartGoods cartGoods, String userId, ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo, AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo, List<CartGoods> oldAllCartGoodsList) { 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.add(cartGoods); List<CartGoods> nowCartGoodsList = new ArrayList<>();
// oldAllCartGoodsList.addAll(newCartGoods);
// //当商品全部添加完毕,校验购物车商品(是否合法,上下架,点餐方式,是否在当前菜单中...),并移除非法商品
// CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(oldAllCartGoodsList, addShoppingCartGoodsRequestVo.getPartnerId(), //当商品全部添加完毕,校验购物车商品(是否合法,上下架,点餐方式,是否在当前菜单中...),并移除非法商品
// addShoppingCartGoodsRequestVo.getShopId(), shoppingCartGoodsResponseVo, addShoppingCartGoodsRequestVo.getOrderType(), CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(oldAllCartGoodsList, partnerId,
// "", addShoppingCartGoodsRequestVo.getMenuType(),shoppingCartBaseService); storeId, shoppingCartGoodsResponseVo, orderType, "", menuType, shoppingCartBaseService);
// if (checkCartRequest.getShoppingCartGoodsResponseVo() != null) { if (checkCartRequest.getShoppingCartGoodsResponseVo() != null) {
// shoppingCartGoodsResponseVo.setToastMsg(checkCartRequest.getShoppingCartGoodsResponseVo().getToastMsg()); shoppingCartGoodsResponseVo.setToastMsg(checkCartRequest.getShoppingCartGoodsResponseVo().getToastMsg());
// shoppingCartGoodsResponseVo.setChanged(checkCartRequest.getShoppingCartGoodsResponseVo().getChanged()); shoppingCartGoodsResponseVo.setChanged(checkCartRequest.getShoppingCartGoodsResponseVo().getChanged());
// } }
// List<CartGoods> allCartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class); List<CartGoods> allCartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
//
// //判断当前商品在购物车是否已存在,存在则数量+1,不存在商品行 + 1 //判断当前商品在购物车是否已存在,存在则数量+1,不存在商品行 + 1
// allCartGoodsList.forEach(oldCartGoods -> { allCartGoodsList.forEach(oldCartGoods -> {
// int index; int index;
// if ((index = nowCartGoodsList.indexOf(oldCartGoods)) >= 0) { if ((index = nowCartGoodsList.indexOf(oldCartGoods)) >= 0) {
// nowCartGoodsList.get(index).setQty(nowCartGoodsList.get(index).getQty() + cartGoods.getQty()); nowCartGoodsList.get(index).setQty(nowCartGoodsList.get(index).getQty() + newCartGoods.get(0).getQty());
// } else { } else {
// nowCartGoodsList.add(oldCartGoods); nowCartGoodsList.add(oldCartGoods);
// } }
// }); });
// // 重新set购物车信息到缓存中 // 重新set购物车信息到缓存中
// assortmentSdkService.setShoppingCart(addShoppingCartGoodsRequestVo.getPartnerId(), addShoppingCartGoodsRequestVo.getShopId(), assortmentSdkService.setShoppingCart(partnerId, storeId, userId, nowCartGoodsList, null, tableNumber, this.shoppingCartBaseService);
// userId, nowCartGoodsList, addShoppingCartGoodsRequestVo.getSessionId(), addShoppingCartGoodsRequestVo.getTableNumber(), this.shoppingCartBaseService); oldAllCartGoodsList.clear();
// oldAllCartGoodsList.clear(); oldAllCartGoodsList.addAll(nowCartGoodsList);
// oldAllCartGoodsList.addAll(nowCartGoodsList); return nowCartGoodsList;
// return nowCartGoodsList; }
// }
/** /**
* 添加商品券商品 * 添加商品券商品
...@@ -1105,43 +959,42 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -1105,43 +959,42 @@ public class ShoppingCartMCoffeeServiceImpl {
/** /**
* 查询多个商品库存信息 * 查询多个商品库存信息
* *
* @param addShoppingCartGoodsRequestVo
* @param productIds * @param productIds
* @param productBeanListSpuClass * @param productBeanListSpuClass
* @param skuId * @param skuId
*/ */
// private void queryManyGoodsStocks(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo, List<Long> productIds private void queryManyGoodsStocks(String partnerId,String storeId,String menuType, List<Long> productIds
// , List<ProductBeanDTO> productBeanListSpuClass, String skuId, Integer qty) { , List<ProductBeanDTO> productBeanListSpuClass, String skuId, Integer qty) {
// GetProductStockRequestDto requestDto = new GetProductStockRequestDto(); GetProductStockRequestDto requestDto = new GetProductStockRequestDto();
// requestDto.setChannel(BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode()); requestDto.setChannel(BusinessTypeEnum.getByType(menuType).getCode());
// requestDto.setPartnerId(addShoppingCartGoodsRequestVo.getPartnerId()); requestDto.setPartnerId(partnerId);
// requestDto.setStoreId(addShoppingCartGoodsRequestVo.getShopId()); requestDto.setStoreId(storeId);
// requestDto.setProductIds(productIds); requestDto.setProductIds(productIds);
// GetProductStockResponseDto availableStocks = null; GetProductStockResponseDto availableStocks = null;
// if (productBeanListSpuClass.get(0).getType() == ProductType.NOSPEC.getCode() if (productBeanListSpuClass.get(0).getType() == ProductType.NOSPEC.getCode()
// && productBeanListSpuClass.get(0).getStockLimit() == 1) { && productBeanListSpuClass.get(0).getStockLimit() == 1) {
// availableStocks = stockClient.getAvailableStocks(requestDto); availableStocks = stockClient.getAvailableStocks(requestDto);
// } else { } else {
// for (ProductBeanDTO.SkuProductBean skuProductBean : productBeanListSpuClass.get(0).getSkuList()) { for (ProductBeanDTO.SkuProductBean skuProductBean : productBeanListSpuClass.get(0).getSkuList()) {
// if (skuId.equals(skuProductBean.getSkuId()) && skuProductBean.getStockLimit() == 1) { if (skuId.equals(skuProductBean.getSkuId()) && skuProductBean.getStockLimit() == 1) {
// availableStocks = stockClient.getAvailableStocks(requestDto); availableStocks = stockClient.getAvailableStocks(requestDto);
// break; break;
// } }
// } }
// } }
// if (availableStocks != null && !ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode())) { if (availableStocks != null && !ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode())) {
// throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE); throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
// } }
// if (availableStocks != null && ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode()) && if (availableStocks != null && ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode()) &&
// (CollectionUtils.isEmpty(availableStocks.getResult()) || availableStocks.getResult().get(0).getQty() == null (CollectionUtils.isEmpty(availableStocks.getResult()) || availableStocks.getResult().get(0).getQty() == null
// || availableStocks.getResult().get(0).getQty() < qty)) { || availableStocks.getResult().get(0).getQty() < qty)) {
// Integer stock = 0; Integer stock = 0;
// if (!CollectionUtils.isEmpty(availableStocks.getResult()) && (stock = availableStocks.getResult().get(0).getQty()) > 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 BizServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE, "仅剩" + stock + "件库存了");
// } }
// throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE); throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
// } }
// } }
/** /**
* 组装添加商品和更新商品和查询的响应信息 * 组装添加商品和更新商品和查询的响应信息
...@@ -1156,49 +1009,46 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -1156,49 +1009,46 @@ public class ShoppingCartMCoffeeServiceImpl {
* @param opt * @param opt
* @param shoppingCartInfoRequestVo * @param shoppingCartInfoRequestVo
*/ */
// private void setAddAndUpdateResponse(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult private void setAddAndUpdateResponse(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult
// , List<CartGoods> cartGoodsList, String toastMsg, String partnerId, String storeId, String userId, String opt, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) { , List<CartGoods> cartGoodsList, String toastMsg, String partnerId, String storeId, String userId, String opt, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
// shoppingCartGoodsResponseVo.setProducts(cartGoodsList); shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
// shoppingCartGoodsResponseVo.setProductsCount(cartGoodsList.size()); shoppingCartGoodsResponseVo.setProductsCount(cartGoodsList.size());
// if (StringUtils.isNotEmpty(toastMsg)) { if (StringUtils.isNotEmpty(toastMsg)) {
// toastMsg=shoppingCartInfoRequestVo!=null && ObjectUtils.equals(1, shoppingCartInfoRequestVo.getFlag())?SHOPPING_CART_EMPTY_GOODS_LIST:SHOPPING_CART_INVALIAD_GOODS; toastMsg=shoppingCartInfoRequestVo!=null && ObjectUtils.equals(1, shoppingCartInfoRequestVo.getFlag())?SHOPPING_CART_EMPTY_GOODS_LIST:SHOPPING_CART_INVALIAD_GOODS;
// setToastMsgIfNotExist(shoppingCartGoodsResponseVo, toastMsg); setToastMsgIfNotExist(shoppingCartGoodsResponseVo, toastMsg);
// //结算页,只有商品全部非法(即products为空)时,才提示changed为true toastMsg 不为空 //结算页,只有商品全部非法(即products为空)时,才提示changed为true toastMsg 不为空
// if (shoppingCartInfoRequestVo!=null && ObjectUtils.equals(1, shoppingCartInfoRequestVo.getFlag())){ if (shoppingCartInfoRequestVo!=null && ObjectUtils.equals(1, shoppingCartInfoRequestVo.getFlag())){
// shoppingCartGoodsResponseVo.setChanged(CollectionUtils.isEmpty(cartGoodsList)); shoppingCartGoodsResponseVo.setChanged(CollectionUtils.isEmpty(cartGoodsList));
// shoppingCartGoodsResponseVo.setToastMsg(CollectionUtils.isEmpty(cartGoodsList)?toastMsg:""); shoppingCartGoodsResponseVo.setToastMsg(CollectionUtils.isEmpty(cartGoodsList)?toastMsg:"");
// } }
//
// } }
// // 更新和添加商品时不需要包装费 // 更新和添加商品时不需要包装费
// if (ShoppingCartConstant.ADD_AND_UPDATE.equals(opt)) { if (ShoppingCartConstant.ADD_AND_UPDATE.equals(opt)) {
// shoppingCartGoodsResponseVo.setNewPackAmount(null); shoppingCartGoodsResponseVo.setNewPackAmount(null);
// return; return;
// } }
// //========================== 购物车查询特有逻辑 ================================= //========================== 购物车查询特有逻辑 =================================
// // 到店自取包装费设为null,外卖要计算包装费,flag为1表示去结算 // 到店自取包装费设为null,外卖要计算包装费,flag为1表示去结算
// // 兼容老版本判断null // 兼容老版本判断null
// if (Objects.equals(shoppingCartInfoRequestVo.getOrderType(), CreateOrderType.COLLECT_GOODS.getCode()) if (Objects.equals(shoppingCartInfoRequestVo.getOrderType(), CreateOrderType.COLLECT_GOODS.getCode())
// && (Objects.equals(shoppingCartInfoRequestVo.getReachStoreType(), null) && (Objects.equals(shoppingCartInfoRequestVo.getReachStoreType(), null)
// || Objects.equals(shoppingCartInfoRequestVo.getReachStoreType(), OrderType.EAT_IN.getCode()))) { || Objects.equals(shoppingCartInfoRequestVo.getReachStoreType(), OrderType.EAT_IN.getCode()))) {
// shoppingCartGoodsResponseVo.setNewPackAmount(null); shoppingCartGoodsResponseVo.setNewPackAmount(null);
// } else if ((Objects.equals(shoppingCartInfoRequestVo.getOrderType(), CreateOrderType.TAKE_OUT.getCode()) } else if ((Objects.equals(shoppingCartInfoRequestVo.getOrderType(), CreateOrderType.TAKE_OUT.getCode())
// || Objects.equals(shoppingCartInfoRequestVo.getReachStoreType(), OrderType.COLLECT_GOODS.getCode())) || Objects.equals(shoppingCartInfoRequestVo.getReachStoreType(), OrderType.COLLECT_GOODS.getCode()))
// && Objects.equals(shoppingCartInfoRequestVo.getFlag(), CouponFlag.YES.getCode())) { && Objects.equals(shoppingCartInfoRequestVo.getFlag(), CouponFlag.YES.getCode())) {
// Long packAmount = shoppingCartGoodsResponseVo.getNewPackAmount() == null ? 0 : shoppingCartGoodsResponseVo.getNewPackAmount(); Long packAmount = shoppingCartGoodsResponseVo.getNewPackAmount() == null ? 0 : shoppingCartGoodsResponseVo.getNewPackAmount();
// Long originalTotalAmount = shoppingCartGoodsResponseVo.getOriginalTotalAmount() + packAmount; Long originalTotalAmount = shoppingCartGoodsResponseVo.getOriginalTotalAmount() + packAmount;
// Long totalAmount = shoppingCartGoodsResponseVo.getTotalAmount() + packAmount; Long totalAmount = shoppingCartGoodsResponseVo.getTotalAmount() + packAmount;
// shoppingCartGoodsResponseVo.setOriginalTotalAmount(originalTotalAmount); shoppingCartGoodsResponseVo.setOriginalTotalAmount(originalTotalAmount);
// shoppingCartGoodsResponseVo.setTotalAmount(totalAmount); shoppingCartGoodsResponseVo.setTotalAmount(totalAmount);
// } }
//
// } }
/** /**
* 在原价、现价、折扣价上增加第一次使用会员卡的费用 * 在原价、现价、折扣价上增加第一次使用会员卡的费用
*
* @param shoppingCartInfoRequestVo
* @param shoppingCartGoodsResponseVo
*/ */
// private void addNeedCardAmount(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) { // private void addNeedCardAmount(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
// ShoppingCartInfoRequestVo.BuyMemberCard buyMemberCard = shoppingCartInfoRequestVo.getBuyMemberCard(); // ShoppingCartInfoRequestVo.BuyMemberCard buyMemberCard = shoppingCartInfoRequestVo.getBuyMemberCard();
...@@ -1341,35 +1191,6 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -1341,35 +1191,6 @@ public class ShoppingCartMCoffeeServiceImpl {
// amount = storeService.getUserRealDeliveryAmount(storeDeliveryInfoDto, userLongitude, userLatitude).intValue(); // amount = storeService.getUserRealDeliveryAmount(storeDeliveryInfoDto, userLongitude, userLatitude).intValue();
// return amount; // 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 { ...@@ -1398,38 +1219,89 @@ public class ShoppingCartMCoffeeServiceImpl {
/** /**
* 获取优惠 * 获取优惠
*/ */
// private ActivityCalculationDiscountResponseDto.CalculationDiscountResult getCalculationDiscountResult(String menuType private ActivityCalculationDiscountResponseDto.CalculationDiscountResult getCalculationDiscountResult(String menuType
// ,String partnerId,String storeId,String userId,String appId,String wxappid,Integer orderType,boolean isMember ,String partnerId,String storeId,String userId,String appId,Integer orderType,boolean isMember
// ,List<CartGoods> cartGoodsList,List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons ,List<CartGoods> cartGoodsList,List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons
// ,List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList,String receiveId,Long deliveryAmount){ ,List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList,String receiveId,Long deliveryAmount){
// // 获取优惠信息 // 获取优惠信息
// ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult=null; ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult=null;
// //外卖场景下 查询门店配送信息 //外卖场景下 查询门店配送信息
// if(BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)){ 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 Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, String wxappid, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) { calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),deliveryAmount);
// Long deliveryAmount = 0L; }else{
// if (StringUtils.isBlank(receiveId)) { calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),null);
// return deliveryAmount; }
// }
// log.info("获取配送配逻辑 tackingNo:{},storeDeliveryUseOld:{},receiveId:{},partnerId:{},storeId:{}", LogThreadLocal.getTrackingNo(), storeDeliveryUseOld, receiveId, partnerId, storeId); return calculationDiscountResult;
// if (storeDeliveryUseOld) { }
// deliveryAmount = Long.parseLong(getDeliveryAmount(receiveId, partnerId, storeId).toString());
// shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(0); private Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, String wxappid, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
// } else { Long deliveryAmount = 0L;
// deliveryAmount = getNewDeliveryAmount(receiveId, partnerId, storeId, shoppingCartGoodsResponseVo); if (StringUtils.isBlank(receiveId)) {
// } return deliveryAmount;
// 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) { private CustomerInfoVo getCustomerInfoVo(String sessionId) {
GetSessionUserInfoDto getSessionUserInfoDto = new GetSessionUserInfoDto(); GetSessionUserInfoDto getSessionUserInfoDto = new GetSessionUserInfoDto();
...@@ -1442,27 +1314,32 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -1442,27 +1314,32 @@ public class ShoppingCartMCoffeeServiceImpl {
return sessionUserInfo.getResult(); return sessionUserInfo.getResult();
} }
/** private boolean isSpecialGoods(String partnerId, String storeId, String userId, String appId, String goodsId, Integer orderType) {
* 检查sku数量 boolean isSpecialGoods = false;
* ActivityAdapter activityAdapter = SDKCommonBaseContextWare.getBean(ActivityAdapter.class);
* @param allCartGoodsList ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, orderType);
* @param cartGoods ActivityService activityService = SDKCommonBaseContextWare.getBean(ActivityService.class);
* @return ActivityQueryResponseDto activityQueryResponseDto = activityService.queryActivitys(activityQueryDto, ActivityTypeEnum.TYPE_2, null);
*/
// private Integer checkSkuQty(List<CartGoods> allCartGoodsList, CartGoods cartGoods) { if (activityQueryResponseDto == null || activityQueryResponseDto.getResult() == null) {
// Integer qty = 0; return isSpecialGoods;
// if (CollectionUtils.isEmpty(allCartGoodsList)) { }
// qty = cartGoods.getQty();
// } else { List<ActivityResponseDto> activityResponseDtoList = activityQueryResponseDto.getResult();
// qty = cartGoods.getQty(); for (int i = 0, len = activityResponseDtoList.size(); i < len; i++) {
// for (CartGoods goods : allCartGoodsList) { List<GoodsBeanDto> goodsBeanDtos = activityResponseDtoList.get(i).getGoods();
// if (goods.getSkuId().equals(cartGoods.getSkuId()) && goods.getSpuId().equals(cartGoods.getSpuId())) { if (CollectionUtils.isEmpty(goodsBeanDtos)) {
// qty += goods.getQty(); continue;
// } }
// } boolean match = goodsBeanDtos.stream().anyMatch(k -> k.getGoodsId().equals(goodsId));
// } if (match) {
// return qty; 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