Commit b2776672 by ping.wu

套餐商品空键位修改

parent 5d32fc3b
...@@ -84,6 +84,7 @@ public enum ResponseResult { ...@@ -84,6 +84,7 @@ public enum ResponseResult {
SHOPPING_CART_GIFTS_PRODUCT_NOT_EXIST("44018", "买赠商品不存在"), SHOPPING_CART_GIFTS_PRODUCT_NOT_EXIST("44018", "买赠商品不存在"),
SHOPPING_CART_SHOP_ID_NOT_EMPTY("44019", "门店编号不能为空"), SHOPPING_CART_SHOP_ID_NOT_EMPTY("44019", "门店编号不能为空"),
SHOPPING_CART_COUPON_CAN_NOT_USE_THIS_SHOP("44020", "券不适用于该门店"), SHOPPING_CART_COUPON_CAN_NOT_USE_THIS_SHOP("44020", "券不适用于该门店"),
SHOPPING_CART_SEAT_EMPTY("44020", "键位为空"),
/** /**
* 订单状态码 * 订单状态码
......
...@@ -84,6 +84,8 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -84,6 +84,8 @@ public class ShoppingCartMCoffeeServiceImpl {
@Autowired @Autowired
private OrderSdkService orderSdkService; private OrderSdkService orderSdkService;
private static final String nullSeat = "508106";
/** /**
* 添加商品、超值加购、商品券 * 添加商品、超值加购、商品券
*/ */
...@@ -243,7 +245,7 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -243,7 +245,7 @@ public class ShoppingCartMCoffeeServiceImpl {
} }
//商品券行商品数量不可增加 //商品券行商品数量不可增加
if (cartGoods.getCouponCode() != null && qty >1) { if (cartGoods.getCouponCode() != null && qty > 1) {
throw new ServiceException(ResponseResult.NOT_SUPPORTED); throw new ServiceException(ResponseResult.NOT_SUPPORTED);
} }
...@@ -342,7 +344,7 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -342,7 +344,7 @@ public class ShoppingCartMCoffeeServiceImpl {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_ADD_INVAILD); return ResponseUtil.error(ResponseResult.SHOPPING_CART_ADD_INVAILD);
} }
// 获取购物车商品-查询用户券-券码校验可用券 // 获取购物车商品-查询用户券-券码校验可用券
availableCoupon = couponDiscountCalculation.availableCoupon(partnerId, storeId, userId, thirdPartyMemberID, unionId,appId, couponCode, orderType, cartGoodsList); availableCoupon = couponDiscountCalculation.availableCoupon(partnerId, storeId, userId, thirdPartyMemberID, unionId, appId, couponCode, orderType, cartGoodsList);
return ResponseUtil.success(availableCoupon); return ResponseUtil.success(availableCoupon);
} }
...@@ -660,23 +662,11 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -660,23 +662,11 @@ public class ShoppingCartMCoffeeServiceImpl {
CartGoods addCartGoods, ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo, List<CartGoods> oldCartGoodsList) { CartGoods addCartGoods, ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo, List<CartGoods> oldCartGoodsList) {
List<CartGoods> newCartGoods = new ArrayList<>(); List<CartGoods> newCartGoods = new ArrayList<>();
newCartGoods.addAll(oldCartGoodsList); newCartGoods.addAll(oldCartGoodsList);
//商品券单独设置一行 newCartGoods.add(addCartGoods);
newCartGoods = checkNewCartGoods(newCartGoods, addCartGoods);
//加购商品校验 //加购商品校验
List<CartGoods> allCartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, newCartGoods); List<CartGoods> allCartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, newCartGoods);
//添加商品为商品券时,商品校验接口券号未设置,设置商品券号
// if (StringUtils.isNotBlank(addCartGoods.getCouponCode())) {
// for (CartGoods cartGoods : allCartGoodsList) {
// if (cartGoods.getGoodsId().equals(addCartGoods.getGoodsId()) && cartGoods.getCouponCode() == null) {
// cartGoods.setCouponCode(addCartGoods.getCouponCode());
// cartGoods.setGoodsType(2);
// break;
// }
// }
// }
List<CartGoods> nowCartGoodsList = new ArrayList<>(); List<CartGoods> nowCartGoodsList = new ArrayList<>();
//判断当前商品在购物车是否已存在,存在则数量+1,不存在商品行 + 1 //判断当前商品在购物车是否已存在,存在则数量+1,不存在商品行 + 1
allCartGoodsList.forEach(oldCartGoods -> { allCartGoodsList.forEach(oldCartGoods -> {
...@@ -758,32 +748,47 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -758,32 +748,47 @@ public class ShoppingCartMCoffeeServiceImpl {
} }
/** /**
* 商品券单独设置一行 * 套餐空键位处理
*/ */
private List<CartGoods> checkNewCartGoods(List<CartGoods> newCartGoods, CartGoods addCartGoods) { private Map<String, String> checkNewCartGoods(List<CartGoods> newCartGoods,Integer oper,Map<String, String> result) {
Integer qty = addCartGoods.getQty() == null ? 0 : addCartGoods.getQty();
if (StringUtils.isNotBlank(addCartGoods.getCouponCode())) { Map<String, String> map = new HashMap<>();
newCartGoods.add(addCartGoods);
return newCartGoods;
}
boolean isadd = true; //删除套餐空键位
if (CollectionUtils.isNotEmpty(newCartGoods)) { if(oper == 1){
for (CartGoods goods : newCartGoods) { for (CartGoods goods : newCartGoods) {
if (goods.getSkuId().equals(addCartGoods.getSkuId()) && goods.getSpuId().equals(addCartGoods.getSpuId())) { if (CollectionUtils.isNotEmpty(goods.getProductGroupList())) {
if (goods.getProductGroupList() != null && addCartGoods.getProductGroupList() != null && goods.getProductGroupList().size() == addCartGoods.getProductGroupList().size()) { List<CartGoods.ComboxGoods> productGroupList = new ArrayList<>();
for (CartGoods.ComboxGoods comboxGoods : goods.getProductGroupList()) {
if (nullSeat.equals(comboxGoods.getGoodsId())) {
map.put(goods.getCartGoodsUid(), goods.getGoodsId());
} else {
productGroupList.add(comboxGoods);
}
} }
goods.setProductGroupList(productGroupList);
} }
} }
if (isadd) { return map;
newCartGoods.add(addCartGoods); }
//恢复套餐空键位
if(oper == 2 && result.size() != 0){
for (CartGoods cartGoods : newCartGoods) {
if (result.get(cartGoods.getCartGoodsUid()) != null) {
CartGoods.ComboxGoods comboxGoods = new CartGoods.ComboxGoods();
comboxGoods.setGoodsId(nullSeat);
comboxGoods.setSkuId(nullSeat);
comboxGoods.setCustomerCode(nullSeat);
comboxGoods.setQty(1);
comboxGoods.setOriginalPrice(0L);
comboxGoods.setFinalPrice(0L);
cartGoods.getProductGroupList().add(comboxGoods);
}
} }
} else {
newCartGoods.add(addCartGoods);
} }
return newCartGoods;
return map;
} }
...@@ -846,7 +851,7 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -846,7 +851,7 @@ public class ShoppingCartMCoffeeServiceImpl {
cartGoods.setClassificationName(productBeanListSpuClass.get(0).getCategoryName()); cartGoods.setClassificationName(productBeanListSpuClass.get(0).getCategoryName());
if (StringUtils.isBlank(productBeanListSpuClass.get(0).getCustomerCode())) { if (StringUtils.isBlank(productBeanListSpuClass.get(0).getCustomerCode())) {
throw new ServiceException(ResponseResult.PARAMETER_MISSING, "商品键位编号为空"); throw new ServiceException(ResponseResult.SHOPPING_CART_SEAT_EMPTY);
} }
//超值加购商品赋值 //超值加购商品赋值
...@@ -865,7 +870,6 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -865,7 +870,6 @@ public class ShoppingCartMCoffeeServiceImpl {
cartGoods.setTaxId(productBeanListSpuClass.get(0).getTaxId()); cartGoods.setTaxId(productBeanListSpuClass.get(0).getTaxId());
} }
} }
...@@ -931,6 +935,9 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -931,6 +935,9 @@ public class ShoppingCartMCoffeeServiceImpl {
private List<CartGoods> checkCartGoods(String partnerId, String storeId, Integer orderType, String menuType, private List<CartGoods> checkCartGoods(String partnerId, String storeId, Integer orderType, String menuType,
ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo, List<CartGoods> cartGoodsList) { ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo, List<CartGoods> cartGoodsList) {
//去除套餐商品空键位
// Map<String, String> map = checkNewCartGoods(cartGoodsList,1,null);
//筛选数量不为0商品 //筛选数量不为0商品
cartGoodsList = cartGoodsList.stream().filter(cartGoods -> cartGoods.getQty() != 0).collect(Collectors.toList()); cartGoodsList = cartGoodsList.stream().filter(cartGoods -> cartGoods.getQty() != 0).collect(Collectors.toList());
...@@ -955,7 +962,8 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -955,7 +962,8 @@ public class ShoppingCartMCoffeeServiceImpl {
if (CollectionUtils.isNotEmpty(reduceGoods)) { if (CollectionUtils.isNotEmpty(reduceGoods)) {
allCartGoodsList.addAll(reduceGoods); allCartGoodsList.addAll(reduceGoods);
} }
//恢复套餐商品空键位
// checkNewCartGoods(allCartGoodsList,2,map);
return allCartGoodsList; return allCartGoodsList;
} }
......
...@@ -134,9 +134,19 @@ public class CouponDiscountCalculation { ...@@ -134,9 +134,19 @@ public class CouponDiscountCalculation {
||(ActivityTypeEnum.TYPE_31.getCode().equals(discount.getActivityType())) || (ActivityTypeEnum.TYPE_32.getCode().equals(discount.getActivityType())) ))) { ||(ActivityTypeEnum.TYPE_31.getCode().equals(discount.getActivityType())) || (ActivityTypeEnum.TYPE_32.getCode().equals(discount.getActivityType())) ))) {
return; return;
} }
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.CouponResults> couponDiscounts = calculationDiscountResult == null ? new ArrayList<>() : calculationDiscountResult.getCouponDiscounts(); //订单级别券优惠
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.CouponResults> couponDiscounts = calculationDiscountResult.getCouponDiscounts();
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods> goodsList = calculationDiscountResult.getGoods();
if (CollectionUtils.isEmpty(goodsList)) {
return;
}
Map<String, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods> goodsMap = goodsList.parallelStream()
.collect(Collectors.toMap(ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods::getGoodsId, Function.identity(), (k1, k2) -> k1));
for (ShoppingCartGoodsDto.CartGoodsDetailDto cartGoods : shoppingCartGoodsDto.getProducts()) { for (ShoppingCartGoodsDto.CartGoodsDetailDto cartGoods : shoppingCartGoodsDto.getProducts()) {
//商品券商品
if (StringUtils.isNotEmpty(cartGoods.getCouponCode())) { if (StringUtils.isNotEmpty(cartGoods.getCouponCode())) {
List<ActivityDiscountsDto> productActivityDiscountsDtos = new ArrayList<>(); List<ActivityDiscountsDto> productActivityDiscountsDtos = new ArrayList<>();
for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.CouponResults couponDiscount : couponDiscounts) { for (ActivityCalculationDiscountResponseDto.CalculationDiscountResult.CouponResults couponDiscount : couponDiscounts) {
...@@ -153,30 +163,18 @@ public class CouponDiscountCalculation { ...@@ -153,30 +163,18 @@ public class CouponDiscountCalculation {
cartGoods.setActivityDiscountsDtos(productActivityDiscountsDtos); cartGoods.setActivityDiscountsDtos(productActivityDiscountsDtos);
} }
} }
if (goodsMap.get(cartGoods.getSkuId()) == null) {
continue;
}
//商品券键位编号为空
if(StringUtils.isBlank(goodsMap.get(cartGoods.getSkuId()).getArtNo())){
throw new ServiceException(ResponseResult.SHOPPING_CART_SEAT_EMPTY);
}
cartGoods.setCustomerCode(goodsMap.get(cartGoods.getSkuId()).getArtNo());
} }
} }
// List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods> goodsList = calculationDiscountResult.getGoods();
// if (CollectionUtils.isEmpty(goodsList)) {
// return;
// }
//
// Map<String, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods> goodsMap = goodsList.parallelStream()
// .collect(Collectors.toMap(ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods::getGoodsId, Function.identity(), (k1, k2) -> k1));
//
// for (ShoppingCartGoodsDto.CartGoodsDetailDto cartGoods : shoppingCartGoodsDto.getProducts()) {
// //商品券商品
// if (StringUtils.isNotBlank(cartGoods.getCouponCode())) {
// if (goodsMap.get(cartGoods.getSkuId()) == null) {
// continue;
// }
// //商品券键位编号为空
// if(StringUtils.isBlank(goodsMap.get(cartGoods.getSkuId()).getArtNo())){
// throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN);
// }
// cartGoods.setCustomerCode(goodsMap.get(cartGoods.getSkuId()).getArtNo());
// }
// }
} }
// public void getCoupon(CouponPromotionVO couponPromotionVO, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo){ // public void getCoupon(CouponPromotionVO couponPromotionVO, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo){
......
...@@ -127,7 +127,7 @@ public class TimeSaleCalculation { ...@@ -127,7 +127,7 @@ public class TimeSaleCalculation {
} }
//活动商品键位编号为空 //活动商品键位编号为空
if(CollectionUtils.isNotEmpty(goods.getDiscounts()) && StringUtils.isBlank(goods.getArtNo())){ if(CollectionUtils.isNotEmpty(goods.getDiscounts()) && StringUtils.isBlank(goods.getArtNo())){
throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN); throw new ServiceException(ResponseResult.SHOPPING_CART_SEAT_EMPTY);
} }
cartGoods.setCustomerCode(goods.getArtNo()); cartGoods.setCustomerCode(goods.getArtNo());
Long totalDiscountAmount = goodsDiscount.getDiscount(); Long totalDiscountAmount = goodsDiscount.getDiscount();
......
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