Commit 12c89263 by ping.wu

买M赠N券

parent 2e6f613c
...@@ -21,6 +21,11 @@ public enum GoodsTypeEnum { ...@@ -21,6 +21,11 @@ public enum GoodsTypeEnum {
SET_MEAL_GOODS(3, "套餐商品"), SET_MEAL_GOODS(3, "套餐商品"),
SKU_GOODS(4, "sku商品"), SKU_GOODS(4, "sku商品"),
SPU_GOODS(5, "spu商品"), SPU_GOODS(5, "spu商品"),
REDUCE_PRICE_GOODS(6,"超值加购商品"),
ALL_COUPON_GOODS(8, "万能券商品"),
VIRTUAL_GOODS(9,"虚拟商品"),
BUY_M_SEND_N_COUPON(10, "买M送N券"),
MATERIAL(88, "有加料的商品"),
EXCEPTION_GOODS(99, "异常商品:商品菜单变化导致和购物车不商品匹配"); EXCEPTION_GOODS(99, "异常商品:商品菜单变化导致和购物车不商品匹配");
private Integer goodsType; private Integer goodsType;
......
...@@ -232,7 +232,9 @@ public interface ShoppingCartBaseService { ...@@ -232,7 +232,9 @@ public interface ShoppingCartBaseService {
CartGoodsStates cartGoodsStates = new CartGoodsStates(); CartGoodsStates cartGoodsStates = new CartGoodsStates();
for (CartGoods cartGoods : checkCartRequest.getCartGoodsList()) { for (CartGoods cartGoods : checkCartRequest.getCartGoodsList()) {
// 当goodsId为空或商品是商品券时直接跳过 // 当goodsId为空或商品是商品券时直接跳过
if (StringUtils.isEmpty(cartGoods.getGoodsId()) || Objects.equals(cartGoods.getGoodsType(), GoodsTypeEnum.COUPON_GOODS.getGoodsType()) || Objects.equals(cartGoods.getGoodsType(), GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType())) { if (StringUtils.isEmpty(cartGoods.getGoodsId()) || Objects.equals(cartGoods.getGoodsType(), GoodsTypeEnum.COUPON_GOODS.getGoodsType())
|| Objects.equals(cartGoods.getGoodsType(), GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType())
|| Objects.equals(cartGoods.getGoodsType(), GoodsTypeEnum.BUY_M_SEND_N_COUPON.getGoodsType())) {
continue; continue;
} }
shoppingCartAdapter.updateCartGoodsInfoNew(cartGoods, productList); shoppingCartAdapter.updateCartGoodsInfoNew(cartGoods, productList);
......
...@@ -36,6 +36,7 @@ public enum ActivityTypeEnum { ...@@ -36,6 +36,7 @@ public enum ActivityTypeEnum {
TYPE_31(31, "折扣券"), TYPE_31(31, "折扣券"),
TYPE_32(32, "商品券"), TYPE_32(32, "商品券"),
TYPE_33(33, "换购券"), TYPE_33(33, "换购券"),
TYPE_330(330, "买M赠N券"),
TYPE_34(34, "配送券"), TYPE_34(34, "配送券"),
TYPE_37(37, "月享卡种子券"), TYPE_37(37, "月享卡种子券"),
TYPE_35(35, "买3赠1券"), TYPE_35(35, "买3赠1券"),
......
...@@ -28,6 +28,7 @@ public enum ShoppingCartPromotionEnum { ...@@ -28,6 +28,7 @@ public enum ShoppingCartPromotionEnum {
Material(12, "MaterialPromotionService"), Material(12, "MaterialPromotionService"),
// 集点活动类 // 集点活动类
GATHER_SPOT(13, "gatherSpotPromotionService"), GATHER_SPOT(13, "gatherSpotPromotionService"),
BUY_M_SEND_N_COUPON(14, "buyMSendNCouponDiscountService"),
MEMBER_DISCOUNT_NEw(27, "memberDiscountService"); MEMBER_DISCOUNT_NEw(27, "memberDiscountService");
private Integer type; private Integer type;
......
package cn.freemud.service.impl;
import cn.freemud.entities.dto.ActivityCalculationDiscountResponseDto;
import cn.freemud.entities.dto.UserLoginInfoDto;
import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.vo.*;
import cn.freemud.enums.ActivityTypeEnum;
import cn.freemud.service.IPromotionService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@Service("buyMSendNCouponDiscountService")
public class BuyMSendNCouponDiscountServiceImpl implements IPromotionService {
@Override
public void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto,
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult,
List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo,
UserLoginInfoDto userLoginInfoDto, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
if (calculationDiscountResult == null || CollectionUtils.isEmpty(calculationDiscountResult.getCouponDiscounts())) {
return;
}
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.CouponResults> couponResultsList = calculationDiscountResult.getCouponDiscounts();
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.CouponResults> collect = couponResultsList.stream().filter(c -> ActivityTypeEnum.TYPE_330.getCode().equals(c.getActivityType())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(collect)) {
return;
}
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods goods : calculationDiscountResult.getGoods()){
if(CollectionUtils.isEmpty(goods.getDiscounts())){
continue;
}
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount> goodsDiscounts = goods.getDiscounts().stream().filter(c -> ActivityTypeEnum.TYPE_330.getCode().equals(c.getType())).collect(Collectors.toList());
if(CollectionUtils.isEmpty(goodsDiscounts)){
continue;
}
List<CartGoods> addSendGoodsList = new ArrayList<>();
for (CartGoods cartGoods : cartGoodsList) {
if(Objects.equals(goods.getCartGoodsUid(),cartGoods.getCartGoodsUid())){
Integer actualGoodsNumber = goodsDiscounts.get(0).getActualGoodsNumber();
if(cartGoods.getQty() > actualGoodsNumber){
CartGoods cartGood = new CartGoods();
BeanUtils.copyProperties(cartGoods,cartGood);
cartGood.setQty(actualGoodsNumber);
cartGood.setAmount(0L);
cartGoods.setQty(cartGoods.getQty()-actualGoodsNumber);
cartGoods.setAmount(cartGoods.getAmount()-goodsDiscounts.get(0).getDiscount());
addSendGoodsList.add(cartGood);
}
if(cartGoods.getQty() == actualGoodsNumber){
cartGoods.setAmount(0L);
}
}
}
cartGoodsList.addAll(addSendGoodsList);
}
}
@Override
public void updateShoppingCartGoodsApportion(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo,
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult,
ShoppingCartGoodsDto shoppingCartGoodsDto, CreateOrderVo.PremiumExchangeActivity premiumExchangeActivity,
ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
}
}
...@@ -279,7 +279,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -279,7 +279,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
*/ */
@Override @Override
public BaseResponse addGoods(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo) { public BaseResponse addGoods(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo) {
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);
// throw new ServiceException(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY); // throw new ServiceException(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
} }
...@@ -330,18 +330,15 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -330,18 +330,15 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// 获取商品详细信息 // 获取商品详细信息
List<ProductBean> productBeanListSpuClass = assortmentSdkService.getProductsInfo(partnerId, storeId List<ProductBean> productBeanListSpuClass = assortmentSdkService.getProductsInfo(partnerId, storeId
, Collections.singletonList(spuId2), addShoppingCartGoodsRequestVo.getMenuType(), this.shoppingCartBaseService); , Collections.singletonList(spuId2), addShoppingCartGoodsRequestVo.getMenuType(), this.shoppingCartBaseService);
// LogUtil.info("productBeanListSpuClass", spuId2,JSON.toJSONString(productBeanListSpuClass));
// 没有查到商品 // 没有查到商品
if (productBeanListSpuClass == null || productBeanListSpuClass.isEmpty()) { if (productBeanListSpuClass == null || productBeanListSpuClass.isEmpty()) {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_PRODUCT_NOT_EXIST); return ResponseUtil.error(ResponseResult.SHOPPING_CART_PRODUCT_NOT_EXIST);
// throw new ServiceException(ResponseResult.SHOPPING_CART_PRODUCT_NOT_EXIST);
} }
// 检查商品小料数量 // 检查商品小料数量
if (checkMaterialQty(addShoppingCartGoodsRequestVo, productBeanListSpuClass)) { if (checkMaterialQty(addShoppingCartGoodsRequestVo, productBeanListSpuClass)) {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_MATERIA_QTY_LIMIT_ERR); return ResponseUtil.error(ResponseResult.SHOPPING_CART_MATERIA_QTY_LIMIT_ERR);
// throw new ServiceException(ResponseResult.SHOPPING_CART_MATERIA_QTY_LIMIT_ERR);
} }
//缓存中获取购物车商品信息 //缓存中获取购物车商品信息
...@@ -354,7 +351,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -354,7 +351,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
Integer checkQty = this.checkSkuQty(allCartGoodsList, cartGoods); Integer checkQty = this.checkSkuQty(allCartGoodsList, cartGoods);
//购物车添加数量限制 //购物车添加数量限制
Integer productsCount = limitGoodsQty(allCartGoodsList, cartGoods, appId,partnerId); Integer productsCount = limitGoodsQty(allCartGoodsList, cartGoods, appId, partnerId);
//查询多个商品库存信息 TODO //查询多个商品库存信息 TODO
queryManyGoodsStocks(addShoppingCartGoodsRequestVo, productIds, productBeanListSpuClass, skuId, checkQty); queryManyGoodsStocks(addShoppingCartGoodsRequestVo, productIds, productBeanListSpuClass, skuId, checkQty);
String productName = null; String productName = null;
...@@ -733,7 +730,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -733,7 +730,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, shoppingCartInfoRequestVo.getFlag() , shoppingCartInfoRequestVo.getFlag()
, userId , userId
, storeId); , storeId);
buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo,calculationSharingDiscountResult,shoppingCartInfoRequestVo.getFlag(),partnerId); buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo, calculationSharingDiscountResult, shoppingCartInfoRequestVo.getFlag(), partnerId);
} else { } else {
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = new ArrayList<>(); List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = new ArrayList<>();
// 当couponCode不为空时,需参与价格计算 // 当couponCode不为空时,需参与价格计算
...@@ -1210,7 +1207,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1210,7 +1207,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// if (activityClassifyCouponBean != null && CollectionUtils.isNotEmpty(activityClassifyCouponBean.getUsableCoupons())) { // if (activityClassifyCouponBean != null && CollectionUtils.isNotEmpty(activityClassifyCouponBean.getUsableCoupons())) {
// List<GetMemberInfoResponseVo.Coupon> coupons = activityClassifyCouponBean.getUsableCoupons().stream().map(each -> convert2MemberCoupon(each)).collect(toList()); // List<GetMemberInfoResponseVo.Coupon> coupons = activityClassifyCouponBean.getUsableCoupons().stream().map(each -> convert2MemberCoupon(each)).collect(toList());
// , memberId, request.getStoreId(), new CouponPromotionVO(), false, request.getOrderType(), 0,"","", ""); // , memberId, request.getStoreId(), new CouponPromotionVO(), false, request.getOrderType(), 0,"","", "");
if (activityClassifyCouponBean != null && CollectionUtils.isNotEmpty(activityClassifyCouponBean.getUsableCoupons())){ if (activityClassifyCouponBean != null && CollectionUtils.isNotEmpty(activityClassifyCouponBean.getUsableCoupons())) {
List<GetMemberInfoResponseVo.Coupon> coupons = activityClassifyCouponBean.getUsableCoupons().stream().map(this::convert2MemberCoupon).collect(toList()); List<GetMemberInfoResponseVo.Coupon> coupons = activityClassifyCouponBean.getUsableCoupons().stream().map(this::convert2MemberCoupon).collect(toList());
responseData.setCoupons(coupons); responseData.setCoupons(coupons);
} }
...@@ -1290,17 +1287,17 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1290,17 +1287,17 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
coupon.setCuoponType(each.getCouponType()); coupon.setCuoponType(each.getCouponType());
coupon.setCouponName(each.getCouponName()); coupon.setCouponName(each.getCouponName());
// 折扣券使用折扣字段 // 折扣券使用折扣字段
if(Objects.equals(each.getCouponType(),CouponTypeEnum.TYPE_3.getCode())){ if (Objects.equals(each.getCouponType(), CouponTypeEnum.TYPE_3.getCode())) {
int discountAmount = Integer.parseInt(Optional.ofNullable(each.getDiscountAmount()).orElse("0")); int discountAmount = Integer.parseInt(Optional.ofNullable(each.getDiscountAmount()).orElse("0"));
BigDecimal discount = BigDecimal.ZERO; BigDecimal discount = BigDecimal.ZERO;
// 转换千分比为小数 // 转换千分比为小数
if (discountAmount != 0){ if (discountAmount != 0) {
discount = new BigDecimal(discountAmount).divide(BigDecimal.valueOf(100),1,BigDecimal.ROUND_DOWN); discount = new BigDecimal(discountAmount).divide(BigDecimal.valueOf(100), 1, BigDecimal.ROUND_DOWN);
} }
coupon.setDiscount(discount); coupon.setDiscount(discount);
// 暂时先不上 // 暂时先不上
coupon.setDiscountAmount(0); coupon.setDiscountAmount(0);
}else { } else {
coupon.setDiscount(BigDecimal.ZERO); coupon.setDiscount(BigDecimal.ZERO);
coupon.setDiscountAmount(Integer.valueOf(each.getDiscountAmount())); coupon.setDiscountAmount(Integer.valueOf(each.getDiscountAmount()));
} }
...@@ -1522,8 +1519,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1522,8 +1519,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_CAN_NOT_USE_THIS_SHOP); throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_CAN_NOT_USE_THIS_SHOP);
} }
// 新增算价失败提示 // 新增算价失败提示
if (activityCalculationDiscountResponseDto != null && StringUtils.equals(activityCalculationDiscountResponseDto.getStatusCode(), "104")){ if (activityCalculationDiscountResponseDto != null && StringUtils.equals(activityCalculationDiscountResponseDto.getStatusCode(), "104")) {
throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_CAN_NOT_USE_THIS_SHOP,activityCalculationDiscountResponseDto.getMsg()); throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_CAN_NOT_USE_THIS_SHOP, activityCalculationDiscountResponseDto.getMsg());
} }
throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN); throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN);
} }
...@@ -1788,9 +1785,13 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1788,9 +1785,13 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
memberDiscountService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo); memberDiscountService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
//促销会员价 //促销会员价
MemberDiscountServiceImpl memberDiscountServiceNew=(MemberDiscountServiceImpl) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.MEMBER_DISCOUNT_NEw); MemberDiscountServiceImpl memberDiscountServiceNew = (MemberDiscountServiceImpl) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.MEMBER_DISCOUNT_NEw);
memberDiscountServiceNew.updateShoppingCartGoodsDiscountNew(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo); memberDiscountServiceNew.updateShoppingCartGoodsDiscountNew(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
BuyMSendNCouponDiscountServiceImpl buyMSendNCouponDiscountService = (BuyMSendNCouponDiscountServiceImpl) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.BUY_M_SEND_N_COUPON);
buyMSendNCouponDiscountService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
/** /**
* 满额减配送费 优选活动 再配送券 * 满额减配送费 优选活动 再配送券
*/ */
...@@ -1981,7 +1982,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1981,7 +1982,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
//当商品全部添加完毕,校验购物车商品(是否合法,上下架,点餐方式,是否在当前菜单中...),并移除非法商品 //当商品全部添加完毕,校验购物车商品(是否合法,上下架,点餐方式,是否在当前菜单中...),并移除非法商品
CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(oldAllCartGoodsList, addShoppingCartGoodsRequestVo.getPartnerId(), CheckCartRequest checkCartRequest = assortmentSdkService.checkShoppingCartSdk(oldAllCartGoodsList, addShoppingCartGoodsRequestVo.getPartnerId(),
addShoppingCartGoodsRequestVo.getShopId(), shoppingCartGoodsResponseVo, addShoppingCartGoodsRequestVo.getOrderType(), addShoppingCartGoodsRequestVo.getShopId(), shoppingCartGoodsResponseVo, addShoppingCartGoodsRequestVo.getOrderType(),
"", addShoppingCartGoodsRequestVo.getMenuType(),shoppingCartBaseService); "", addShoppingCartGoodsRequestVo.getMenuType(), shoppingCartBaseService);
if (checkCartRequest.getShoppingCartGoodsResponseVo() != null) { if (checkCartRequest.getShoppingCartGoodsResponseVo() != null) {
shoppingCartGoodsResponseVo.setToastMsg(checkCartRequest.getShoppingCartGoodsResponseVo().getToastMsg()); shoppingCartGoodsResponseVo.setToastMsg(checkCartRequest.getShoppingCartGoodsResponseVo().getToastMsg());
...@@ -2025,9 +2026,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2025,9 +2026,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// 设置商品类型为商品券 // 设置商品类型为商品券
if (CouponTypeEnum.TYPE_4.getCode().equals(couponProductDto.getType())) { if (CouponTypeEnum.TYPE_4.getCode().equals(couponProductDto.getType())) {
cartGoods.setGoodsType(GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType()); cartGoods.setGoodsType(GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType());
}else if (CouponTypeEnum.TYPE_7.getCode().equals(couponProductDto.getType())) { } else if (CouponTypeEnum.TYPE_7.getCode().equals(couponProductDto.getType())) {
cartGoods.setGoodsType(GoodsTypeEnum.BUY_M_SEND_N_COUPON.getGoodsType()); cartGoods.setGoodsType(GoodsTypeEnum.BUY_M_SEND_N_COUPON.getGoodsType());
}else { } else {
cartGoods.setGoodsType(GoodsTypeEnum.COUPON_GOODS.getGoodsType()); cartGoods.setGoodsType(GoodsTypeEnum.COUPON_GOODS.getGoodsType());
} }
if (StringUtils.isBlank(addShoppingCartGoodsRequestVo.getCouponCode())) { //老商品券 if (StringUtils.isBlank(addShoppingCartGoodsRequestVo.getCouponCode())) { //老商品券
...@@ -2038,11 +2039,21 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2038,11 +2039,21 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// 商品券Id // 商品券Id
String spqId = spuId.substring(CommonsConstant.COUPON_PREFIX.length()); String spqId = spuId.substring(CommonsConstant.COUPON_PREFIX.length());
if (CollectionUtils.isNotEmpty(allCartGoodsList)) { if (CollectionUtils.isNotEmpty(allCartGoodsList)) {
if(Objects.equals(CouponTypeEnum.TYPE_0.getCode(),couponProductDto.getType())
|| Objects.equals(CouponTypeEnum.TYPE_4.getCode(),couponProductDto.getType())){
int sum = allCartGoodsList.stream().filter(p -> p.getSpuId().equals(spqId)).mapToInt(CartGoods::getQty).sum(); int sum = allCartGoodsList.stream().filter(p -> p.getSpuId().equals(spqId)).mapToInt(CartGoods::getQty).sum();
if (sum + cartGoods.getQty() > todayAvailableTimes) { if (sum + cartGoods.getQty() > todayAvailableTimes) {
throw new ServiceException(ResponseResult.SHOPPING_CART_GOODS_COUPON_CAN_NOT_USE); throw new ServiceException(ResponseResult.SHOPPING_CART_GOODS_COUPON_CAN_NOT_USE);
} }
} }
// if(Objects.equals(GoodsTypeEnum.BUY_M_SEND_N_COUPON.getGoodsType(),couponProductDto.getType()) ){
// int sum = allCartGoodsList.stream().filter(p -> p.getSpuId().equals(spqId)).mapToInt(CartGoods::getQty).sum();
// if (sum + cartGoods.getQty() > todayAvailableTimes) {
// throw new ServiceException(ResponseResult.SHOPPING_CART_GOODS_COUPON_CAN_NOT_USE);
// }
// }
}
cartGoods.setSpuId(spqId); cartGoods.setSpuId(spqId);
cartGoods.setSkuId(spuId2); cartGoods.setSkuId(spuId2);
cartGoods.setOriginalPrice(0L); cartGoods.setOriginalPrice(0L);
...@@ -2169,7 +2180,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2169,7 +2180,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
//fisherman 【ID1033456】自提根据模板配置计算餐具包装费 //fisherman 【ID1033456】自提根据模板配置计算餐具包装费
Long packAmount = commonFunctionHandle.getPackAmountByStoreConfig(shoppingCartInfoRequestVo, shoppingCartGoodsResponseVo.getNewPackAmount()); Long packAmount = commonFunctionHandle.getPackAmountByStoreConfig(shoppingCartInfoRequestVo, shoppingCartGoodsResponseVo.getNewPackAmount());
shoppingCartGoodsResponseVo.setNewPackAmount(packAmount); shoppingCartGoodsResponseVo.setNewPackAmount(packAmount);
if (Objects.equals(shoppingCartInfoRequestVo.getFlag(), SubmitPageEnum.YES.getCode())){ if (Objects.equals(shoppingCartInfoRequestVo.getFlag(), SubmitPageEnum.YES.getCode())) {
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);
...@@ -2179,7 +2190,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2179,7 +2190,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} }
/** /**
* 在原价、现价、折扣价上增加第一次使用会员卡的费用 * 在原价、现价、折扣价上增加第一次使用会员卡的费用
* *
...@@ -2501,7 +2511,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2501,7 +2511,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
AssortmentCustomerInfoVo customerInfoVo = customerInfoManager.getCustomerInfoByObject(sessionId); AssortmentCustomerInfoVo customerInfoVo = customerInfoManager.getCustomerInfoByObject(sessionId);
if (customerInfoVo == null) throw new ServiceException(ResponseResult.NOT_LOGIN); if (customerInfoVo == null) throw new ServiceException(ResponseResult.NOT_LOGIN);
String jsonObject = JSON.toJSONString(customerInfoVo); String jsonObject = JSON.toJSONString(customerInfoVo);
CustomerInfoVo customerInfoVo1 = JSON.parseObject(jsonObject,CustomerInfoVo.class); CustomerInfoVo customerInfoVo1 = JSON.parseObject(jsonObject, CustomerInfoVo.class);
return customerInfoVo1; return customerInfoVo1;
} }
...@@ -2623,7 +2633,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2623,7 +2633,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if (Objects.nonNull(cartGoods)) { if (Objects.nonNull(cartGoods)) {
qty += cartGoods.getQty(); qty += cartGoods.getQty();
} }
int limitCount = queryLimitCount(partnerId,appid); int limitCount = queryLimitCount(partnerId, appid);
if (limitCount != 0 && qty > limitCount) { if (limitCount != 0 && qty > limitCount) {
throw new ServiceException(ResponseResult.SHOPPING_CART_LIMIT_ADD); throw new ServiceException(ResponseResult.SHOPPING_CART_LIMIT_ADD);
} }
...@@ -2633,7 +2643,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2633,7 +2643,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
/** /**
* 查询购物车限购数量 * 查询购物车限购数量
*/ */
public int queryLimitCount(String partnerId,String appid) { public int queryLimitCount(String partnerId, String appid) {
int limitCount = 0; int limitCount = 0;
String redisKey = RedisUtil.limitCart + partnerId + "_" + appid; String redisKey = RedisUtil.limitCart + partnerId + "_" + appid;
//购物车内部缓存 //购物车内部缓存
...@@ -2693,7 +2703,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2693,7 +2703,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
sendQty += sendGoods.getSendNumber(); sendQty += sendGoods.getSendNumber();
} }
} }
int cartLimitCount = queryLimitCount(partnerId,appid); int cartLimitCount = queryLimitCount(partnerId, appid);
if (cartLimitCount != 0 && checkQty + sendQty > cartLimitCount) { if (cartLimitCount != 0 && checkQty + sendQty > cartLimitCount) {
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, oldCartGoodsList, null, tableNumber, shoppingCartService); assortmentSdkService.setShoppingCart(partnerId, storeId, userId, oldCartGoodsList, null, tableNumber, shoppingCartService);
throw new ServiceException(ResponseResult.SHOPPING_CART_LIMIT_ADD); throw new ServiceException(ResponseResult.SHOPPING_CART_LIMIT_ADD);
...@@ -2711,7 +2721,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2711,7 +2721,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} }
} }
int cartLimitCount = queryLimitCount(partnerId,appid); int cartLimitCount = queryLimitCount(partnerId, appid);
int sendQty = 0; int sendQty = 0;
if (CollectionUtils.isNotEmpty(sendActivitys)) { if (CollectionUtils.isNotEmpty(sendActivitys)) {
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.SendActivity sendActivity : sendActivitys) { for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.SendActivity sendActivity : sendActivitys) {
...@@ -2786,7 +2796,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2786,7 +2796,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
private List<CalculationSharingDiscountRequestDto.CalculationDiscountCoupon> buildCoupons(List<CalculationSharingDiscountRequestDto.CalculationDiscountCoupon> oldCoupons, private List<CalculationSharingDiscountRequestDto.CalculationDiscountCoupon> buildCoupons(List<CalculationSharingDiscountRequestDto.CalculationDiscountCoupon> oldCoupons,
List<ChooseCouponVo> coupons) { List<ChooseCouponVo> coupons) {
for(int i = 0 ; i < oldCoupons.size() ; i++){ for (int i = 0; i < oldCoupons.size(); i++) {
CalculationSharingDiscountRequestDto.CalculationDiscountCoupon oldCoupon = oldCoupons.get(i); CalculationSharingDiscountRequestDto.CalculationDiscountCoupon oldCoupon = oldCoupons.get(i);
oldCoupon.setUseIndex(i); oldCoupon.setUseIndex(i);
} }
...@@ -2822,7 +2832,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2822,7 +2832,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
try { try {
getMemberCouponListResponseDto = customerExtendClient.getMemberCouponListRequestDto(getMemberCouponListRequestDto); getMemberCouponListResponseDto = customerExtendClient.getMemberCouponListRequestDto(getMemberCouponListRequestDto);
} catch (Exception ex) { } catch (Exception ex) {
ErrorLog.errorConvertJson(this.getClass(),"会员服务优惠券接口调用失败",ex); ErrorLog.errorConvertJson(this.getClass(), "会员服务优惠券接口调用失败", ex);
} }
if (getMemberCouponListResponseDto != null && Objects.equals(getMemberCouponListResponseDto.getCode(), ResponseResult.SUCCESS.getCode())) { if (getMemberCouponListResponseDto != null && Objects.equals(getMemberCouponListResponseDto.getCode(), ResponseResult.SUCCESS.getCode())) {
return getMemberCouponListResponseDto.getData(); return getMemberCouponListResponseDto.getData();
...@@ -3253,7 +3263,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -3253,7 +3263,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
Integer checkQty = this.checkSkuQty(allCartGoodsList, cartGoods); Integer checkQty = this.checkSkuQty(allCartGoodsList, cartGoods);
//购物车添加数量限制 //购物车添加数量限制
Integer productsCount = limitGoodsQty(allCartGoodsList, cartGoods, appId,partnerId); Integer productsCount = limitGoodsQty(allCartGoodsList, cartGoods, appId, partnerId);
//查询多个商品库存信息 TODO //查询多个商品库存信息 TODO
queryManyGoodsStocks(replaceGoodsRequestVo.getMenuType(), replaceGoodsRequestVo.getPartnerId(), replaceGoodsRequestVo.getShopId(), productIds, productBeanListSpuClass, skuId, checkQty); queryManyGoodsStocks(replaceGoodsRequestVo.getMenuType(), replaceGoodsRequestVo.getPartnerId(), replaceGoodsRequestVo.getShopId(), productIds, productBeanListSpuClass, skuId, checkQty);
...@@ -3361,12 +3371,12 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -3361,12 +3371,12 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
requestDto.setStoreId(replaceGoodsRequestVo.getShopId()); requestDto.setStoreId(replaceGoodsRequestVo.getShopId());
requestDto.setProductIds(goodsId); requestDto.setProductIds(goodsId);
GetProductStockResponseDto availableStocks = stockClient.getAvailableStocks(requestDto); GetProductStockResponseDto availableStocks = stockClient.getAvailableStocks(requestDto);
if (availableStocks != null ) { if (availableStocks != null) {
if (!ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode())){ if (!ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode())) {
// 没有请求数据 // 没有请求数据
fullReplace = false; fullReplace = false;
} }
if (CollectionUtils.isEmpty(availableStocks.getResult())){ if (CollectionUtils.isEmpty(availableStocks.getResult())) {
fullReplace = false; fullReplace = false;
} }
...@@ -3386,7 +3396,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -3386,7 +3396,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// 获取到最新的 库存 stockLimitGoods 数据 放入 nowCartGoodsList 中 // 获取到最新的 库存 stockLimitGoods 数据 放入 nowCartGoodsList 中
notCheckStock.addAll(stockLimitGoods); notCheckStock.addAll(stockLimitGoods);
}else { } else {
fullReplace = false; fullReplace = false;
} }
} }
......
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