Commit 2f55378a by ping.wu

新增麦咖啡购物车

parent 9acc200b
package cn.freemud.service.impl.mcoffee; package cn.freemud.service.impl.mcoffee;
import cn.freemud.adapter.ActivityAdapter; import cn.freemud.adapter.ActivityAdapter;
import cn.freemud.adapter.CouponAdapter;
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.constant.ResponseCodeConstant; import cn.freemud.constant.ResponseCodeConstant;
...@@ -77,26 +78,25 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -77,26 +78,25 @@ public class ShoppingCartMCoffeeServiceImpl {
// private long goodsCacheSeconds; // private long goodsCacheSeconds;
@Autowired @Autowired
private ActivityAdapter activityAdapter; 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;
...@@ -104,17 +104,17 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -104,17 +104,17 @@ public class ShoppingCartMCoffeeServiceImpl {
private StockClient stockClient; private StockClient stockClient;
@Autowired @Autowired
private AssortmentSdkService assortmentSdkService; private AssortmentSdkService assortmentSdkService;
// @Autowired @Autowired
// private CouponAdapter couponAdapter; private CouponAdapter couponAdapter;
@Autowired @Autowired
private CustomerApplicationClient customerApplicationClient; private CustomerApplicationClient customerApplicationClient;
// @Autowired // @Autowired
// 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;
...@@ -135,10 +135,10 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -135,10 +135,10 @@ 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())) {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY); return ResponseUtil.error(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
} }
if (addShoppingCartGoodsRequestVo.getQty() != null && addShoppingCartGoodsRequestVo.getQty() < 0){ if (addShoppingCartGoodsRequestVo.getQty() != null && addShoppingCartGoodsRequestVo.getQty() < 0) {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_ADD_ERROR); return ResponseUtil.error(ResponseResult.SHOPPING_CART_ADD_ERROR);
} }
String sessionId = addShoppingCartGoodsRequestVo.getSessionId(); String sessionId = addShoppingCartGoodsRequestVo.getSessionId();
...@@ -177,12 +177,12 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -177,12 +177,12 @@ public class ShoppingCartMCoffeeServiceImpl {
productIds.add(Long.parseLong(goodsId)); productIds.add(Long.parseLong(goodsId));
// 获取商品详细信息 // 获取商品详细信息
List<ProductBeanDTO> productBeanListSpuClass = assortmentSdkService.getProductsInfoSdk(partnerId, storeId List<ProductBeanDTO> productBeanListSpuClass = assortmentSdkService.getProductsInfoSdk(partnerId, storeId
, Collections.singletonList(spuId2),menuType, this.shoppingCartBaseService); , Collections.singletonList(spuId2), menuType, this.shoppingCartBaseService);
//查询多个商品库存信息 //查询多个商品库存信息
ShoppingCartConvertAdapter.setClassification(addCartGoods, productBeanListSpuClass); ShoppingCartConvertAdapter.setClassification(addCartGoods, productBeanListSpuClass);
Integer checkQty = this.checkSkuQty(oldCartGoodsList, addCartGoods); Integer checkQty = this.checkSkuQty(oldCartGoodsList, addCartGoods);
queryManyGoodsStocks(partnerId,storeId,menuType, productIds, productBeanListSpuClass, skuId, checkQty); queryManyGoodsStocks(partnerId, storeId, menuType, productIds, productBeanListSpuClass, skuId, checkQty);
// 如果购物车中有商品券,则当前添加的商品是特价商品时,需要提示“已选商品券,与其他优惠商品不同享,商品将恢复原价” // 如果购物车中有商品券,则当前添加的商品是特价商品时,需要提示“已选商品券,与其他优惠商品不同享,商品将恢复原价”
boolean haveCouponProduct = oldCartGoodsList.parallelStream().anyMatch(k -> k.getCartGoodsUid().startsWith(CommonsConstant.COUPON_PREFIX)); boolean haveCouponProduct = oldCartGoodsList.parallelStream().anyMatch(k -> k.getCartGoodsUid().startsWith(CommonsConstant.COUPON_PREFIX));
...@@ -193,22 +193,24 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -193,22 +193,24 @@ public class ShoppingCartMCoffeeServiceImpl {
// TODO: 2020/7/21 促销活动等价格计算 // TODO: 2020/7/21 促销活动等价格计算
Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo); 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); ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult =
// getCalculationDiscountResult(menuType,partnerId,storeId,userId,userLoginInfoDto.getWxAppid(),orderType,assortmentCustomerInfoVo.isMemberPaid(), oldCartGoodsList,new ArrayList<>(),new ArrayList<>(),null,deliveryAmount);
getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), oldCartGoodsList, new ArrayList<>(), new ArrayList<>(), BusinessTypeEnum.getByType(menuType).getCode(), deliveryAmount);
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, addShoppingCartGoodsRequestVo.getOrderType()); ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, addShoppingCartGoodsRequestVo.getOrderType());
// 促销活动的优惠金额计算 // 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, oldCartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto,addShoppingCartGoodsRequestVo.getMenuType(),deliveryAmount); updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, oldCartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto, addShoppingCartGoodsRequestVo.getMenuType(), deliveryAmount);
// TODO: 2020/7/21 购物车数据更新 // TODO: 2020/7/21 购物车数据更新
List<CartGoods> newCartGoods = new ArrayList<>(); List<CartGoods> newCartGoods = new ArrayList<>();
newCartGoods.add(addCartGoods); newCartGoods.add(addCartGoods);
// 校验合法性,更新缓存中购物车信息 // 校验合法性,更新缓存中购物车信息
updateCartGoodsLegal(partnerId,storeId,orderType,tableNumber,menuType, userId, newCartGoods,shoppingCartGoodsResponseVo, oldCartGoodsList); 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); setAddAndUpdateResponse(shoppingCartGoodsResponseVo, oldCartGoodsList, null, ShoppingCartConstant.ADD_AND_UPDATE, null);
// //埋点添加购物车行为 // //埋点添加购物车行为
// this.buriedPointShoppingCart(addShoppingCartGoodsRequestVo, spuId, productName); // this.buriedPointShoppingCart(addShoppingCartGoodsRequestVo, spuId, productName);
...@@ -222,10 +224,10 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -222,10 +224,10 @@ 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);
} }
if (updateShoppingCartGoodsQtyRequestVo.getQty() != null && updateShoppingCartGoodsQtyRequestVo.getQty() < 0){ if (updateShoppingCartGoodsQtyRequestVo.getQty() != null && updateShoppingCartGoodsQtyRequestVo.getQty() < 0) {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_ADD_ERROR); return ResponseUtil.error(ResponseResult.SHOPPING_CART_ADD_ERROR);
} }
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo(); ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
...@@ -238,17 +240,15 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -238,17 +240,15 @@ public class ShoppingCartMCoffeeServiceImpl {
String cartGoodsUid = updateShoppingCartGoodsQtyRequestVo.getCartGoodsUid(); String cartGoodsUid = updateShoppingCartGoodsQtyRequestVo.getCartGoodsUid();
Integer qty = updateShoppingCartGoodsQtyRequestVo.getQty(); Integer qty = updateShoppingCartGoodsQtyRequestVo.getQty();
String menuType = updateShoppingCartGoodsQtyRequestVo.getMenuType(); String menuType = updateShoppingCartGoodsQtyRequestVo.getMenuType();
Integer orderType=updateShoppingCartGoodsQtyRequestVo.getOrderType(); Integer orderType = updateShoppingCartGoodsQtyRequestVo.getOrderType();
String receiveId = updateShoppingCartGoodsQtyRequestVo.getReceiveId(); String receiveId = updateShoppingCartGoodsQtyRequestVo.getReceiveId();
// 先验证商品是否存在 // 先验证商品是否存在
List<CartGoods> cartGoodsList = assortmentSdkService.getShoppingCart(partnerId, storeId,userId,null,null,shoppingCartBaseService); List<CartGoods> cartGoodsList = assortmentSdkService.getShoppingCart(partnerId, storeId, userId, null, null, shoppingCartBaseService);
CartGoods cartGoods = null; CartGoods cartGoods = null;
for (CartGoods cartGoods_ : cartGoodsList){ for (CartGoods cartGoods_ : cartGoodsList) {
if(cartGoodsUid.equals(cartGoods_.getCartGoodsUid())){ if (cartGoodsUid.equals(cartGoods_.getCartGoodsUid())) {
cartGoods =cartGoods_; cartGoods = cartGoods_;
// 检查购物车商品库存数量
checkUpdateStock(partnerId,storeId,menuType,qty,cartGoods);
cartGoods_.setQty(qty); cartGoods_.setQty(qty);
break; break;
} }
...@@ -258,25 +258,27 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -258,25 +258,27 @@ public class ShoppingCartMCoffeeServiceImpl {
throw new ServiceException(ResponseResult.SHOPPING_CART_UPDATE_ERROR); throw new ServiceException(ResponseResult.SHOPPING_CART_UPDATE_ERROR);
} }
// 检查购物车商品库存数量
checkUpdateStock(partnerId, storeId, menuType, qty, cartGoods);
// 更新购物车中数量 // 更新购物车中数量
// 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,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);
getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, new ArrayList<>(), new ArrayList<>(), BusinessTypeEnum.getByType(menuType).getCode(), deliveryAmount);
if (calculationDiscountResult == null) { if (calculationDiscountResult == null) {
shoppingCartGoodsResponseVo.setProducts(cartGoodsList); shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
} }
...@@ -284,11 +286,11 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -284,11 +286,11 @@ public class ShoppingCartMCoffeeServiceImpl {
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, menuType, deliveryAmount);
//设置更新响应信息 //设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.ADD_AND_UPDATE, null); setAddAndUpdateResponse(shoppingCartGoodsResponseVo, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), ShoppingCartConstant.ADD_AND_UPDATE, null);
return ResponseUtil.success(); return ResponseUtil.success(shoppingCartGoodsResponseVo);
} }
/** /**
...@@ -302,7 +304,7 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -302,7 +304,7 @@ public class ShoppingCartMCoffeeServiceImpl {
//查询商品信息 //查询商品信息
List<String> pids = new ArrayList<>(); List<String> pids = new ArrayList<>();
pids.add(cartGoods.getGoodsId()); pids.add(cartGoods.getGoodsId());
Map<String, GetProductsVo> products = itemService.getProducts(pids, partnerId, storeId,BusinessTypeEnum.getByType(menuType).getCode()); Map<String, GetProductsVo> products = itemService.getProducts(pids, partnerId, storeId, BusinessTypeEnum.getByType(menuType).getCode());
GetProductsVo getProductsVo = products.get(cartGoods.getGoodsId()); GetProductsVo getProductsVo = products.get(cartGoods.getGoodsId());
// 商品没有库存限制 // 商品没有库存限制
...@@ -336,65 +338,65 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -336,65 +338,65 @@ public class ShoppingCartMCoffeeServiceImpl {
* @return * @return
*/ */
public BaseResponse getGoodsList(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) { public BaseResponse getGoodsList(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
// if (StringUtils.isEmpty(shoppingCartInfoRequestVo.getShopId())){ if (StringUtils.isEmpty(shoppingCartInfoRequestVo.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(); ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
// // 获取用户信息 // 获取用户信息
// CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(shoppingCartInfoRequestVo.getSessionId()); CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(shoppingCartInfoRequestVo.getSessionId());
// UserLoginInfoDto userLoginInfoDto = convert2UserLoginInfoDto(assortmentCustomerInfoVo); UserLoginInfoDto userLoginInfoDto = convert2UserLoginInfoDto(assortmentCustomerInfoVo);
// String userId = userLoginInfoDto.getMemberId(); String userId = userLoginInfoDto.getMemberId();
// String partnerId = shoppingCartInfoRequestVo.getPartnerId(); String partnerId = shoppingCartInfoRequestVo.getPartnerId();
// String storeId = shoppingCartInfoRequestVo.getShopId(); String storeId = shoppingCartInfoRequestVo.getShopId();
// String appId = shoppingCartInfoRequestVo.getAppId(); String appId = shoppingCartInfoRequestVo.getAppId();
// String couponCode = shoppingCartInfoRequestVo.getCouponCode(); String couponCode = shoppingCartInfoRequestVo.getCouponCode();
// String activityCode = shoppingCartInfoRequestVo.getActivityCode(); String activityCode = shoppingCartInfoRequestVo.getActivityCode();
// String menuType = shoppingCartInfoRequestVo.getMenuType(); String menuType = shoppingCartInfoRequestVo.getMenuType();
// Integer orderType = shoppingCartInfoRequestVo.getOrderType(); Integer orderType = shoppingCartInfoRequestVo.getOrderType();
// String receiveId = shoppingCartInfoRequestVo.getReceiveId(); String receiveId = shoppingCartInfoRequestVo.getReceiveId();
//
// // 获取购物车商品 // 获取购物车商品
// List<CartGoods> cartGoodsList = assortmentSdkService.getShoppingCart(partnerId, storeId, userId, null, "", shoppingCartBaseService); List<CartGoods> cartGoodsList = assortmentSdkService.getShoppingCart(partnerId, storeId, userId, null, "", shoppingCartBaseService);
// // 如果购物车商品不为空, 则check购物车中所有商品 // 如果购物车商品不为空, 则check购物车中所有商品
// if (CollectionUtils.isNotEmpty(cartGoodsList)){ if (CollectionUtils.isNotEmpty(cartGoodsList)) {
// CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(cartGoodsList, partnerId, storeId, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo.getOrderType(), "", shoppingCartInfoRequestVo.getMenuType() ,shoppingCartBaseService); CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(cartGoodsList, partnerId, storeId, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo.getOrderType(), "", shoppingCartInfoRequestVo.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, assortmentCustomerInfoVo.getSessionId(), "", this.shoppingCartBaseService); assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, assortmentCustomerInfoVo.getSessionId(), "", this.shoppingCartBaseService);
// } }
// List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = new ArrayList<>(); List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = new ArrayList<>();
// // 当couponCode不为空时,需参与价格计算 // 当couponCode不为空时,需参与价格计算
// if (StringUtils.isNotEmpty(couponCode)) { if (StringUtils.isNotEmpty(couponCode)) {
// ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon coupon = new ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon(); ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon coupon = new ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon();
// coupon.setCode(couponCode); coupon.setCode(couponCode);
// coupon.setActivityCode(activityCode); coupon.setActivityCode(activityCode);
// coupons.add(coupon); coupons.add(coupon);
// } }
// Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo); Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo);
//
// // 获取优惠信息 // 获取优惠信息
// ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,assortmentCustomerInfoVo.isMemberPaid(),cartGoodsList,coupons,null,shoppingCartInfoRequestVo.getReceiveId(),deliveryAmount); ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult =
// // getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,assortmentCustomerInfoVo.isMemberPaid(),cartGoodsList,coupons,null,shoppingCartInfoRequestVo.getReceiveId(),deliveryAmount);
// if (calculationDiscountResult == null) { getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, new ArrayList<>(), new ArrayList<>(), BusinessTypeEnum.getByType(menuType).getCode(), deliveryAmount);
// shoppingCartGoodsResponseVo.setProducts(cartGoodsList); if (calculationDiscountResult == null) {
// } shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
// }
// ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, shoppingCartInfoRequestVo.getOrderType());
// ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, shoppingCartInfoRequestVo.getOrderType());
// CouponPromotionVO couponPromotionVO = couponAdapter.getCouponPromotionVO(shoppingCartInfoRequestVo, userLoginInfoDto);
// // 促销活动的优惠金额计算 CouponPromotionVO couponPromotionVO = couponAdapter.getCouponPromotionVO(shoppingCartInfoRequestVo, userLoginInfoDto);
// this.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto,shoppingCartInfoRequestVo.getMenuType(),deliveryAmount); // 促销活动的优惠金额计算
// //设置更新响应信息 this.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto, shoppingCartInfoRequestVo.getMenuType(), deliveryAmount);
// setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.QUERY_INFO, shoppingCartInfoRequestVo); //设置更新响应信息
// // 在原价、现价、折扣价上增加第一次使用会员卡的费用 setAddAndUpdateResponse(shoppingCartGoodsResponseVo, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), ShoppingCartConstant.QUERY_INFO, shoppingCartInfoRequestVo);
// this.addNeedCardAmount(shoppingCartInfoRequestVo, shoppingCartGoodsResponseVo); // 在原价、现价、折扣价上增加第一次使用会员卡的费用
// this.addNeedCardAmount(shoppingCartInfoRequestVo, shoppingCartGoodsResponseVo);
// return ResponseUtil.success(shoppingCartGoodsResponseVo);
return ResponseUtil.success(); return ResponseUtil.success(shoppingCartGoodsResponseVo);
} }
/** /**
...@@ -437,14 +439,14 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -437,14 +439,14 @@ public class ShoppingCartMCoffeeServiceImpl {
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();
com.freemud.sdk.api.assortment.shoppingcart.domain.CartParamDto cartParamDto = assortmentSdkService.getCartParamDto(partnerId, storeId, userId); com.freemud.sdk.api.assortment.shoppingcart.domain.CartParamDto cartParamDto = assortmentSdkService.getCartParamDto(partnerId, storeId, userId);
shoppingCartBaseService.clear(cartParamDto,LogThreadLocal.getTrackingNo()); shoppingCartBaseService.clear(cartParamDto, LogThreadLocal.getTrackingNo());
if (ObjectUtils.equals(shoppingCartClearRequestVo.getOperationType(), OperationTypeEnum.PAY_SUCCESS.getOperationType())) { if (ObjectUtils.equals(shoppingCartClearRequestVo.getOperationType(), OperationTypeEnum.PAY_SUCCESS.getOperationType())) {
return ResponseUtil.success(); return ResponseUtil.success();
} }
...@@ -628,9 +630,13 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -628,9 +630,13 @@ public class ShoppingCartMCoffeeServiceImpl {
* @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) {
if (BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)) {
distributionFee = null;
}
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<>();
...@@ -641,13 +647,13 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -641,13 +647,13 @@ public class ShoppingCartMCoffeeServiceImpl {
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) {
...@@ -665,13 +671,13 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -665,13 +671,13 @@ public class ShoppingCartMCoffeeServiceImpl {
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)));
...@@ -706,7 +712,7 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -706,7 +712,7 @@ public class ShoppingCartMCoffeeServiceImpl {
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);
...@@ -721,7 +727,7 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -721,7 +727,7 @@ public class ShoppingCartMCoffeeServiceImpl {
* @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);
...@@ -819,7 +825,7 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -819,7 +825,7 @@ public class ShoppingCartMCoffeeServiceImpl {
* @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) {
} }
...@@ -963,7 +969,7 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -963,7 +969,7 @@ public class ShoppingCartMCoffeeServiceImpl {
* @param productBeanListSpuClass * @param productBeanListSpuClass
* @param skuId * @param skuId
*/ */
private void queryManyGoodsStocks(String partnerId,String storeId,String menuType, 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(menuType).getCode()); requestDto.setChannel(BusinessTypeEnum.getByType(menuType).getCode());
...@@ -1002,81 +1008,76 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -1002,81 +1008,76 @@ public class ShoppingCartMCoffeeServiceImpl {
* 查询购物车计算包装费 * 查询购物车计算包装费
* *
* @param shoppingCartGoodsResponseVo * @param shoppingCartGoodsResponseVo
* @param calculationDiscountResult
* @param cartGoodsList * @param cartGoodsList
* @param toastMsg * @param toastMsg
* @param userId
* @param opt * @param opt
* @param shoppingCartInfoRequestVo * @param shoppingCartInfoRequestVo
*/ */
private void setAddAndUpdateResponse(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult private void setAddAndUpdateResponse(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, List<CartGoods> cartGoodsList,
, List<CartGoods> cartGoodsList, String toastMsg, String partnerId, String storeId, String userId, String opt, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) { String toastMsg, 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表示去结算 if (shoppingCartGoodsResponseVo.getNewPackAmount() == null || shoppingCartGoodsResponseVo.getNewPackAmount() == 0L) {
// 兼容老版本判断null return;
if (Objects.equals(shoppingCartInfoRequestVo.getOrderType(), CreateOrderType.COLLECT_GOODS.getCode()) }
&& (Objects.equals(shoppingCartInfoRequestVo.getReachStoreType(), null) if (shoppingCartInfoRequestVo != 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 {
|| Objects.equals(shoppingCartInfoRequestVo.getReachStoreType(), OrderType.COLLECT_GOODS.getCode())) Long packAmount = shoppingCartGoodsResponseVo.getNewPackAmount();
&& Objects.equals(shoppingCartInfoRequestVo.getFlag(), CouponFlag.YES.getCode())) {
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);
} }
} }
/** /**
* 在原价、现价、折扣价上增加第一次使用会员卡的费用 * 在原价、现价、折扣价上增加第一次使用会员卡的费用
*/ */
// private void addNeedCardAmount(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) { private void addNeedCardAmount(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
// ShoppingCartInfoRequestVo.BuyMemberCard buyMemberCard = shoppingCartInfoRequestVo.getBuyMemberCard(); ShoppingCartInfoRequestVo.BuyMemberCard buyMemberCard = shoppingCartInfoRequestVo.getBuyMemberCard();
// if (shoppingCartInfoRequestVo.getBuyMemberCard() == null || StringUtils.isEmpty(buyMemberCard.getPaidId()) || StringUtils.isEmpty(buyMemberCard.getRuleId())) { if (shoppingCartInfoRequestVo.getBuyMemberCard() == null || StringUtils.isEmpty(buyMemberCard.getPaidId()) || StringUtils.isEmpty(buyMemberCard.getRuleId())) {
// return; return;
// } }
// GetPaidRuleRequestDto getPaidRuleRequestDto = new GetPaidRuleRequestDto(); GetPaidRuleRequestDto getPaidRuleRequestDto = new GetPaidRuleRequestDto();
// getPaidRuleRequestDto.setPartnerId(shoppingCartInfoRequestVo.getPartnerId()); getPaidRuleRequestDto.setPartnerId(shoppingCartInfoRequestVo.getPartnerId());
// getPaidRuleRequestDto.setPaidId(buyMemberCard.getPaidId()); getPaidRuleRequestDto.setPaidId(buyMemberCard.getPaidId());
// getPaidRuleRequestDto.setRuleId(buyMemberCard.getRuleId()); getPaidRuleRequestDto.setRuleId(buyMemberCard.getRuleId());
// BaseResponse<GetPaidRuleResponseDto> baseResponse = customerApplicationClient.getPaidRule(getPaidRuleRequestDto); BaseResponse<GetPaidRuleResponseDto> baseResponse = customerApplicationClient.getPaidRule(getPaidRuleRequestDto);
// if (baseResponse == null || !ResponseResult.SUCCESS.getCode().equals(baseResponse.getCode()) || baseResponse.getResult() == null if (baseResponse == null || !ResponseResult.SUCCESS.getCode().equals(baseResponse.getCode()) || baseResponse.getResult() == null
// || baseResponse.getResult().getActivityPrice() == null) { || baseResponse.getResult().getActivityPrice() == null) {
// return; return;
// } }
// // 购买会员卡的金额 // 购买会员卡的金额
// Integer activityPrice = baseResponse.getResult().getActivityPrice(); Integer activityPrice = baseResponse.getResult().getActivityPrice();
// // 首次使用会员卡享受的折扣金额 // 首次使用会员卡享受的折扣金额
// Integer firstCouponAmount = baseResponse.getResult().getFirstCouponAmount() == null ? 0 : baseResponse.getResult().getFirstCouponAmount(); Integer firstCouponAmount = baseResponse.getResult().getFirstCouponAmount() == null ? 0 : baseResponse.getResult().getFirstCouponAmount();
// Long originalTotalAmount = shoppingCartGoodsResponseVo.getOriginalTotalAmount() + activityPrice; Long originalTotalAmount = shoppingCartGoodsResponseVo.getOriginalTotalAmount() + activityPrice;
// Long totalAmount = shoppingCartGoodsResponseVo.getTotalAmount() + (activityPrice - firstCouponAmount); Long totalAmount = shoppingCartGoodsResponseVo.getTotalAmount() + (activityPrice - firstCouponAmount);
// Long totalDiscountAmount = shoppingCartGoodsResponseVo.getTotalDiscountAmount() + firstCouponAmount; Long totalDiscountAmount = shoppingCartGoodsResponseVo.getTotalDiscountAmount() + firstCouponAmount;
// shoppingCartGoodsResponseVo.setOriginalTotalAmount(originalTotalAmount); shoppingCartGoodsResponseVo.setOriginalTotalAmount(originalTotalAmount);
// shoppingCartGoodsResponseVo.setTotalAmount(totalAmount); shoppingCartGoodsResponseVo.setTotalAmount(totalAmount);
// shoppingCartGoodsResponseVo.setTotalDiscountAmount(totalDiscountAmount); shoppingCartGoodsResponseVo.setTotalDiscountAmount(totalDiscountAmount);
// shoppingCartGoodsResponseVo.setCardOriginalAmount(activityPrice); shoppingCartGoodsResponseVo.setCardOriginalAmount(activityPrice);
// shoppingCartGoodsResponseVo.setCardDiscountAmount(firstCouponAmount); shoppingCartGoodsResponseVo.setCardDiscountAmount(firstCouponAmount);
// } }
private UserLoginInfoDto convert2UserLoginInfoDto(CustomerInfoVo assortmentCustomerInfoVo) { private UserLoginInfoDto convert2UserLoginInfoDto(CustomerInfoVo assortmentCustomerInfoVo) {
if (assortmentCustomerInfoVo == null || assortmentCustomerInfoVo.getMemberId() == null) { if (assortmentCustomerInfoVo == null || assortmentCustomerInfoVo.getMemberId() == null) {
...@@ -1219,23 +1220,22 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -1219,23 +1220,22 @@ public class ShoppingCartMCoffeeServiceImpl {
/** /**
* 获取优惠 * 获取优惠
*/ */
private ActivityCalculationDiscountResponseDto.CalculationDiscountResult getCalculationDiscountResult(String menuType // private ActivityCalculationDiscountResponseDto.CalculationDiscountResult getCalculationDiscountResult(String menuType
,String partnerId,String storeId,String userId,String appId,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); // calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),deliveryAmount);
}else{ // }else{
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),null); // calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),null);
} // }
//
return calculationDiscountResult; // return calculationDiscountResult;
} // }
private Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, String wxappid, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) { private Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, String wxappid, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
Long deliveryAmount = 0L; Long deliveryAmount = 0L;
if (StringUtils.isBlank(receiveId)) { if (StringUtils.isBlank(receiveId)) {
...@@ -1264,7 +1264,7 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -1264,7 +1264,7 @@ public class ShoppingCartMCoffeeServiceImpl {
if (queryDeliverDetailResponse == null || !ResponseResult.SUCCESS.getCode().equals(queryDeliverDetailResponse.getCode()) || queryDeliverDetailResponse.getData() == null) { if (queryDeliverDetailResponse == null || !ResponseResult.SUCCESS.getCode().equals(queryDeliverDetailResponse.getCode()) || queryDeliverDetailResponse.getData() == null) {
throw new ServiceException(ResponseResult.STORE_ITEM_NOT_DELIVERY); throw new ServiceException(ResponseResult.STORE_ITEM_NOT_DELIVERY);
} }
if(queryDeliverDetailResponse.getData().getDeliveryAmount() == null) { if (queryDeliverDetailResponse.getData().getDeliveryAmount() == null) {
throw new ServiceException(ResponseResult.STORE_DELIVERY_AMOUNT_ERROR); throw new ServiceException(ResponseResult.STORE_DELIVERY_AMOUNT_ERROR);
} }
shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(queryDeliverDetailResponse.getData().getDeliveryFeeZeroReason() != null ? queryDeliverDetailResponse.getData().getDeliveryFeeZeroReason() : 0); shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(queryDeliverDetailResponse.getData().getDeliveryFeeZeroReason() != null ? queryDeliverDetailResponse.getData().getDeliveryFeeZeroReason() : 0);
...@@ -1342,5 +1342,4 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -1342,5 +1342,4 @@ public class ShoppingCartMCoffeeServiceImpl {
} }
} }
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