Commit e46a6f1a authored by macro's avatar macro
Browse files

购物车支持选择商品下单

parent 13130811
......@@ -49,8 +49,8 @@ public class OmsCartItemController {
@ApiOperation("获取某个会员的购物车列表,包括促销信息")
@RequestMapping(value = "/list/promotion", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<CartPromotionItem>> listPromotion() {
List<CartPromotionItem> cartPromotionItemList = cartItemService.listPromotion(memberService.getCurrentMember().getId());
public CommonResult<List<CartPromotionItem>> listPromotion(@RequestParam(required = false) List<Long> cartIds) {
List<CartPromotionItem> cartPromotionItemList = cartItemService.listPromotion(memberService.getCurrentMember().getId(), cartIds);
return CommonResult.success(cartPromotionItemList);
}
......
......@@ -26,7 +26,7 @@ public interface OmsCartItemService {
/**
* 获取包含促销活动信息的购物车列表
*/
List<CartPromotionItem> listPromotion(Long memberId);
List<CartPromotionItem> listPromotion(Long memberId, List<Long> cartIds);
/**
* 修改某个购物车商品的数量
......
package com.macro.mall.portal.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.macro.mall.mapper.OmsCartItemMapper;
import com.macro.mall.model.OmsCartItem;
import com.macro.mall.model.OmsCartItemExample;
......@@ -18,6 +19,7 @@ import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* 购物车管理Service实现类
......@@ -78,8 +80,11 @@ public class OmsCartItemServiceImpl implements OmsCartItemService {
}
@Override
public List<CartPromotionItem> listPromotion(Long memberId) {
public List<CartPromotionItem> listPromotion(Long memberId, List<Long> cartIds) {
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<>();
if(!CollectionUtils.isEmpty(cartItemList)){
cartPromotionItemList = promotionService.calcCartPromotion(cartItemList);
......
Supports Markdown
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