购物车支持选择商品下单

This commit is contained in:
macro 2020-05-23 16:33:36 +08:00
parent 1313081178
commit e46a6f1aeb
3 changed files with 9 additions and 4 deletions

View File

@ -49,8 +49,8 @@ public class OmsCartItemController {
@ApiOperation("获取某个会员的购物车列表,包括促销信息") @ApiOperation("获取某个会员的购物车列表,包括促销信息")
@RequestMapping(value = "/list/promotion", method = RequestMethod.GET) @RequestMapping(value = "/list/promotion", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public CommonResult<List<CartPromotionItem>> listPromotion() { public CommonResult<List<CartPromotionItem>> listPromotion(@RequestParam(required = false) List<Long> cartIds) {
List<CartPromotionItem> cartPromotionItemList = cartItemService.listPromotion(memberService.getCurrentMember().getId()); List<CartPromotionItem> cartPromotionItemList = cartItemService.listPromotion(memberService.getCurrentMember().getId(), cartIds);
return CommonResult.success(cartPromotionItemList); return CommonResult.success(cartPromotionItemList);
} }

View File

@ -26,7 +26,7 @@ public interface OmsCartItemService {
/** /**
* 获取包含促销活动信息的购物车列表 * 获取包含促销活动信息的购物车列表
*/ */
List<CartPromotionItem> listPromotion(Long memberId); List<CartPromotionItem> listPromotion(Long memberId, List<Long> cartIds);
/** /**
* 修改某个购物车商品的数量 * 修改某个购物车商品的数量

View File

@ -1,5 +1,6 @@
package com.macro.mall.portal.service.impl; package com.macro.mall.portal.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.macro.mall.mapper.OmsCartItemMapper; import com.macro.mall.mapper.OmsCartItemMapper;
import com.macro.mall.model.OmsCartItem; import com.macro.mall.model.OmsCartItem;
import com.macro.mall.model.OmsCartItemExample; import com.macro.mall.model.OmsCartItemExample;
@ -18,6 +19,7 @@ import org.springframework.util.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 购物车管理Service实现类 * 购物车管理Service实现类
@ -78,8 +80,11 @@ public class OmsCartItemServiceImpl implements OmsCartItemService {
} }
@Override @Override
public List<CartPromotionItem> listPromotion(Long memberId) { public List<CartPromotionItem> listPromotion(Long memberId, List<Long> cartIds) {
List<OmsCartItem> cartItemList = list(memberId); List<OmsCartItem> cartItemList = list(memberId);
if(CollUtil.isNotEmpty(cartIds)){
cartItemList = cartItemList.stream().filter(item->cartIds.contains(item.getId())).collect(Collectors.toList());
}
List<CartPromotionItem> cartPromotionItemList = new ArrayList<>(); List<CartPromotionItem> cartPromotionItemList = new ArrayList<>();
if(!CollectionUtils.isEmpty(cartItemList)){ if(!CollectionUtils.isEmpty(cartItemList)){
cartPromotionItemList = promotionService.calcCartPromotion(cartItemList); cartPromotionItemList = promotionService.calcCartPromotion(cartItemList);