com.macro.mall.model.OmsCartItem Java Examples

The following examples show how to use com.macro.mall.model.OmsCartItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OmsPromotionServiceImpl.java    From mall-swarm with Apache License 2.0 6 votes vote down vote up
/**
 * 对没满足优惠条件的商品进行处理
 */
private void handleNoReduce(List<CartPromotionItem> cartPromotionItemList, List<OmsCartItem> itemList,PromotionProduct promotionProduct) {
    for (OmsCartItem item : itemList) {
        CartPromotionItem cartPromotionItem = new CartPromotionItem();
        BeanUtils.copyProperties(item,cartPromotionItem);
        cartPromotionItem.setPromotionMessage("无优惠");
        cartPromotionItem.setReduceAmount(new BigDecimal(0));
        PmsSkuStock skuStock = getOriginalPrice(promotionProduct,item.getProductSkuId());
        if(skuStock!=null){
            cartPromotionItem.setRealStock(skuStock.getStock()-skuStock.getLockStock());
        }
        cartPromotionItem.setIntegration(promotionProduct.getGiftPoint());
        cartPromotionItem.setGrowth(promotionProduct.getGiftGrowth());
        cartPromotionItemList.add(cartPromotionItem);
    }
}
 
Example #2
Source File: OmsCartItemServiceImpl.java    From macrozheng-mall with MIT License 6 votes vote down vote up
@Override
public int add(OmsCartItem cartItem) {
    int count;
    UmsMember currentMember =memberService.getCurrentMember();
    cartItem.setMemberId(currentMember.getId());
    cartItem.setMemberNickname(currentMember.getNickname());
    cartItem.setDeleteStatus(0);
    OmsCartItem existCartItem = getCartItem(cartItem);
    if (existCartItem == null) {
        cartItem.setCreateDate(new Date());
        count = cartItemMapper.insert(cartItem);
    } else {
        cartItem.setModifyDate(new Date());
        existCartItem.setQuantity(existCartItem.getQuantity() + cartItem.getQuantity());
        count = cartItemMapper.updateByPrimaryKey(existCartItem);
    }
    return count;
}
 
Example #3
Source File: OmsCartItemServiceImpl.java    From mall-swarm with Apache License 2.0 6 votes vote down vote up
@Override
public int add(OmsCartItem cartItem) {
    int count;
    UmsMember currentMember =memberService.getCurrentMember();
    cartItem.setMemberId(currentMember.getId());
    cartItem.setMemberNickname(currentMember.getNickname());
    cartItem.setDeleteStatus(0);
    OmsCartItem existCartItem = getCartItem(cartItem);
    if (existCartItem == null) {
        cartItem.setCreateDate(new Date());
        count = cartItemMapper.insert(cartItem);
    } else {
        cartItem.setModifyDate(new Date());
        existCartItem.setQuantity(existCartItem.getQuantity() + cartItem.getQuantity());
        count = cartItemMapper.updateByPrimaryKey(existCartItem);
    }
    return count;
}
 
Example #4
Source File: OmsPromotionServiceImpl.java    From mall with Apache License 2.0 6 votes vote down vote up
/**
 * 对没满足优惠条件的商品进行处理
 */
private void handleNoReduce(List<CartPromotionItem> cartPromotionItemList, List<OmsCartItem> itemList,PromotionProduct promotionProduct) {
    for (OmsCartItem item : itemList) {
        CartPromotionItem cartPromotionItem = new CartPromotionItem();
        BeanUtils.copyProperties(item,cartPromotionItem);
        cartPromotionItem.setPromotionMessage("无优惠");
        cartPromotionItem.setReduceAmount(new BigDecimal(0));
        PmsSkuStock skuStock = getOriginalPrice(promotionProduct,item.getProductSkuId());
        if(skuStock!=null){
            cartPromotionItem.setRealStock(skuStock.getStock()-skuStock.getLockStock());
        }
        cartPromotionItem.setIntegration(promotionProduct.getGiftPoint());
        cartPromotionItem.setGrowth(promotionProduct.getGiftGrowth());
        cartPromotionItemList.add(cartPromotionItem);
    }
}
 
Example #5
Source File: OmsCartItemServiceImpl.java    From macrozheng-mall with MIT License 6 votes vote down vote up
/**
 * 根据会员id,商品id和规格获取购物车中商品
 */
private OmsCartItem getCartItem(OmsCartItem cartItem) {
    OmsCartItemExample example = new OmsCartItemExample();
    OmsCartItemExample.Criteria criteria = example.createCriteria().andMemberIdEqualTo(cartItem.getMemberId())
            .andProductIdEqualTo(cartItem.getProductId()).andDeleteStatusEqualTo(0);
    if (!StringUtils.isEmpty(cartItem.getSp1())) {
        criteria.andSp1EqualTo(cartItem.getSp1());
    }
    if (!StringUtils.isEmpty(cartItem.getSp2())) {
        criteria.andSp2EqualTo(cartItem.getSp2());
    }
    if (!StringUtils.isEmpty(cartItem.getSp3())) {
        criteria.andSp3EqualTo(cartItem.getSp3());
    }
    List<OmsCartItem> cartItemList = cartItemMapper.selectByExample(example);
    if (!CollectionUtils.isEmpty(cartItemList)) {
        return cartItemList.get(0);
    }
    return null;
}
 
Example #6
Source File: OmsCartItemServiceImpl.java    From macrozheng with Apache License 2.0 6 votes vote down vote up
@Override
public int add(OmsCartItem cartItem) {
    int count;
    UmsMember currentMember =memberService.getCurrentMember();
    cartItem.setMemberId(currentMember.getId());
    cartItem.setMemberNickname(currentMember.getNickname());
    cartItem.setDeleteStatus(0);
    OmsCartItem existCartItem = getCartItem(cartItem);
    if (existCartItem == null) {
        cartItem.setCreateDate(new Date());
        count = cartItemMapper.insert(cartItem);
    } else {
        cartItem.setModifyDate(new Date());
        existCartItem.setQuantity(existCartItem.getQuantity() + cartItem.getQuantity());
        count = cartItemMapper.updateByPrimaryKey(existCartItem);
    }
    return count;
}
 
Example #7
Source File: OmsCartItemServiceImpl.java    From macrozheng with Apache License 2.0 6 votes vote down vote up
/**
 * 根据会员id,商品id和规格获取购物车中商品
 */
private OmsCartItem getCartItem(OmsCartItem cartItem) {
    OmsCartItemExample example = new OmsCartItemExample();
    OmsCartItemExample.Criteria criteria = example.createCriteria().andMemberIdEqualTo(cartItem.getMemberId())
            .andProductIdEqualTo(cartItem.getProductId()).andDeleteStatusEqualTo(0);
    if (!StringUtils.isEmpty(cartItem.getSp1())) {
        criteria.andSp1EqualTo(cartItem.getSp1());
    }
    if (!StringUtils.isEmpty(cartItem.getSp2())) {
        criteria.andSp2EqualTo(cartItem.getSp2());
    }
    if (!StringUtils.isEmpty(cartItem.getSp3())) {
        criteria.andSp3EqualTo(cartItem.getSp3());
    }
    List<OmsCartItem> cartItemList = cartItemMapper.selectByExample(example);
    if (!CollectionUtils.isEmpty(cartItemList)) {
        return cartItemList.get(0);
    }
    return null;
}
 
Example #8
Source File: OmsPromotionServiceImpl.java    From mall with Apache License 2.0 5 votes vote down vote up
/**
 * 查询所有商品的优惠相关信息
 */
private List<PromotionProduct> getPromotionProductList(List<OmsCartItem> cartItemList) {
    List<Long> productIdList = new ArrayList<>();
    for(OmsCartItem cartItem:cartItemList){
        productIdList.add(cartItem.getProductId());
    }
    return portalProductDao.getPromotionProductList(productIdList);
}
 
Example #9
Source File: OmsCartItemServiceImpl.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
@Override
public int clear(Long memberId) {
    OmsCartItem record = new OmsCartItem();
    record.setDeleteStatus(1);
    OmsCartItemExample example = new OmsCartItemExample();
    example.createCriteria().andMemberIdEqualTo(memberId);
    return cartItemMapper.updateByExampleSelective(record,example);
}
 
Example #10
Source File: OmsCartItemServiceImpl.java    From mall with Apache License 2.0 5 votes vote down vote up
@Override
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);
    }
    return cartPromotionItemList;
}
 
Example #11
Source File: OmsCartItemServiceImpl.java    From mall with Apache License 2.0 5 votes vote down vote up
/**
 * 根据会员id,商品id和规格获取购物车中商品
 */
private OmsCartItem getCartItem(OmsCartItem cartItem) {
    OmsCartItemExample example = new OmsCartItemExample();
    OmsCartItemExample.Criteria criteria = example.createCriteria().andMemberIdEqualTo(cartItem.getMemberId())
            .andProductIdEqualTo(cartItem.getProductId()).andDeleteStatusEqualTo(0);
    if (!StringUtils.isEmpty(cartItem.getProductSkuId())) {
        criteria.andProductSkuIdEqualTo(cartItem.getProductSkuId());
    }
    List<OmsCartItem> cartItemList = cartItemMapper.selectByExample(example);
    if (!CollectionUtils.isEmpty(cartItemList)) {
        return cartItemList.get(0);
    }
    return null;
}
 
Example #12
Source File: OmsCartItemServiceImpl.java    From mall with Apache License 2.0 5 votes vote down vote up
@Override
public int updateAttr(OmsCartItem cartItem) {
    //删除原购物车信息
    OmsCartItem updateCart = new OmsCartItem();
    updateCart.setId(cartItem.getId());
    updateCart.setModifyDate(new Date());
    updateCart.setDeleteStatus(1);
    cartItemMapper.updateByPrimaryKeySelective(updateCart);
    cartItem.setId(null);
    add(cartItem);
    return 1;
}
 
Example #13
Source File: OmsPromotionServiceImpl.java    From mall with Apache License 2.0 5 votes vote down vote up
/**
 * 获取购物车中指定商品的总价
 */
private BigDecimal getCartItemAmount(List<OmsCartItem> itemList, List<PromotionProduct> promotionProductList) {
    BigDecimal amount = new BigDecimal(0);
    for (OmsCartItem item : itemList) {
        //计算出商品原价
        PromotionProduct promotionProduct = getPromotionProductById(item.getProductId(), promotionProductList);
        PmsSkuStock skuStock = getOriginalPrice(promotionProduct,item.getProductSkuId());
        amount = amount.add(skuStock.getPrice().multiply(new BigDecimal(item.getQuantity())));
    }
    return amount;
}
 
Example #14
Source File: OmsCartItemController.java    From macrozheng-mall with MIT License 5 votes vote down vote up
@ApiOperation("获取某个会员的购物车列表")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public Object list() {
    List<OmsCartItem> cartItemList = cartItemService.list(memberService.getCurrentMember().getId());
    return new CommonResult().success(cartItemList);
}
 
Example #15
Source File: OmsPromotionServiceImpl.java    From mall with Apache License 2.0 5 votes vote down vote up
/**
 * 以spu为单位对购物车中商品进行分组
 */
private Map<Long, List<OmsCartItem>> groupCartItemBySpu(List<OmsCartItem> cartItemList) {
    Map<Long, List<OmsCartItem>> productCartMap = new TreeMap<>();
    for (OmsCartItem cartItem : cartItemList) {
        List<OmsCartItem> productCartItemList = productCartMap.get(cartItem.getProductId());
        if (productCartItemList == null) {
            productCartItemList = new ArrayList<>();
            productCartItemList.add(cartItem);
            productCartMap.put(cartItem.getProductId(), productCartItemList);
        } else {
            productCartItemList.add(cartItem);
        }
    }
    return productCartMap;
}
 
Example #16
Source File: OmsCartItemController.java    From macrozheng-mall with MIT License 5 votes vote down vote up
@ApiOperation("添加商品到购物车")
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public Object add(@RequestBody OmsCartItem cartItem) {
    int count = cartItemService.add(cartItem);
    if (count > 0) {
        return new CommonResult().success(count);
    }
    return new CommonResult().failed();
}
 
Example #17
Source File: OmsPromotionServiceImpl.java    From macrozheng-mall with MIT License 5 votes vote down vote up
/**
 * 查询所有商品的优惠相关信息
 */
private List<PromotionProduct> getPromotionProductList(List<OmsCartItem> cartItemList) {
    List<Long> productIdList = new ArrayList<>();
    for(OmsCartItem cartItem:cartItemList){
        productIdList.add(cartItem.getProductId());
    }
    return portalProductDao.getPromotionProductList(productIdList);
}
 
Example #18
Source File: OmsPromotionServiceImpl.java    From macrozheng-mall with MIT License 5 votes vote down vote up
/**
 * 获取购物车中指定商品的数量
 */
private int getCartItemCount(List<OmsCartItem> itemList) {
    int count = 0;
    for (OmsCartItem item : itemList) {
        count += item.getQuantity();
    }
    return count;
}
 
Example #19
Source File: OmsCartItemController.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
@ApiOperation("添加商品到购物车")
@RequestMapping(value = "/add", method = RequestMethod.POST)
@ResponseBody
public CommonResult add(@RequestBody OmsCartItem cartItem) {
    int count = cartItemService.add(cartItem);
    if (count > 0) {
        return CommonResult.success(count);
    }
    return CommonResult.failed();
}
 
Example #20
Source File: OmsCartItemServiceImpl.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
@Override
public int delete(Long memberId, List<Long> ids) {
    OmsCartItem record = new OmsCartItem();
    record.setDeleteStatus(1);
    OmsCartItemExample example = new OmsCartItemExample();
    example.createCriteria().andIdIn(ids).andMemberIdEqualTo(memberId);
    return cartItemMapper.updateByExampleSelective(record, example);
}
 
Example #21
Source File: OmsCartItemServiceImpl.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
@Override
public int updateQuantity(Long id, Long memberId, Integer quantity) {
    OmsCartItem cartItem = new OmsCartItem();
    cartItem.setQuantity(quantity);
    OmsCartItemExample example = new OmsCartItemExample();
    example.createCriteria().andDeleteStatusEqualTo(0)
            .andIdEqualTo(id).andMemberIdEqualTo(memberId);
    return cartItemMapper.updateByExampleSelective(cartItem, example);
}
 
Example #22
Source File: OmsCartItemServiceImpl.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
@Override
public List<CartPromotionItem> listPromotion(Long memberId) {
    List<OmsCartItem> cartItemList = list(memberId);
    List<CartPromotionItem> cartPromotionItemList = new ArrayList<>();
    if(!CollectionUtils.isEmpty(cartItemList)){
        cartPromotionItemList = promotionService.calcCartPromotion(cartItemList);
    }
    return cartPromotionItemList;
}
 
Example #23
Source File: OmsCartItemController.java    From macrozheng-mall with MIT License 5 votes vote down vote up
@ApiOperation("修改购物车中商品的规格")
@RequestMapping(value = "/update/attr", method = RequestMethod.POST)
@ResponseBody
public Object updateAttr(@RequestBody OmsCartItem cartItem) {
    int count = cartItemService.updateAttr(cartItem);
    if (count > 0) {
        return new CommonResult().success(count);
    }
    return new CommonResult().failed();
}
 
Example #24
Source File: OmsPromotionServiceImpl.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
/**
 * 获取购物车中指定商品的总价
 */
private BigDecimal getCartItemAmount(List<OmsCartItem> itemList, List<PromotionProduct> promotionProductList) {
    BigDecimal amount = new BigDecimal(0);
    for (OmsCartItem item : itemList) {
        //计算出商品原价
        PromotionProduct promotionProduct = getPromotionProductById(item.getProductId(), promotionProductList);
        PmsSkuStock skuStock = getOriginalPrice(promotionProduct,item.getProductSkuId());
        amount = amount.add(skuStock.getPrice().multiply(new BigDecimal(item.getQuantity())));
    }
    return amount;
}
 
Example #25
Source File: OmsCartItemServiceImpl.java    From macrozheng-mall with MIT License 5 votes vote down vote up
@Override
public List<CartPromotionItem> listPromotion(Long memberId) {
    List<OmsCartItem> cartItemList = list(memberId);
    List<CartPromotionItem> cartPromotionItemList = new ArrayList<>();
    if(!CollectionUtils.isEmpty(cartItemList)){
        cartPromotionItemList = promotionService.calcCartPromotion(cartItemList);
    }
    return cartPromotionItemList;
}
 
Example #26
Source File: OmsPromotionServiceImpl.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
/**
 * 以spu为单位对购物车中商品进行分组
 */
private Map<Long, List<OmsCartItem>> groupCartItemBySpu(List<OmsCartItem> cartItemList) {
    Map<Long, List<OmsCartItem>> productCartMap = new TreeMap<>();
    for (OmsCartItem cartItem : cartItemList) {
        List<OmsCartItem> productCartItemList = productCartMap.get(cartItem.getProductId());
        if (productCartItemList == null) {
            productCartItemList = new ArrayList<>();
            productCartItemList.add(cartItem);
            productCartMap.put(cartItem.getProductId(), productCartItemList);
        } else {
            productCartItemList.add(cartItem);
        }
    }
    return productCartMap;
}
 
Example #27
Source File: OmsPromotionServiceImpl.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
/**
 * 查询所有商品的优惠相关信息
 */
private List<PromotionProduct> getPromotionProductList(List<OmsCartItem> cartItemList) {
    List<Long> productIdList = new ArrayList<>();
    for(OmsCartItem cartItem:cartItemList){
        productIdList.add(cartItem.getProductId());
    }
    return portalProductDao.getPromotionProductList(productIdList);
}
 
Example #28
Source File: OmsCartItemController.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
@ApiOperation("修改购物车中商品的规格")
@RequestMapping(value = "/update/attr", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateAttr(@RequestBody OmsCartItem cartItem) {
    int count = cartItemService.updateAttr(cartItem);
    if (count > 0) {
        return CommonResult.success(count);
    }
    return CommonResult.failed();
}
 
Example #29
Source File: OmsCartItemController.java    From macrozheng with Apache License 2.0 5 votes vote down vote up
@ApiOperation("获取某个会员的购物车列表")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<OmsCartItem>> list() {
    List<OmsCartItem> cartItemList = cartItemService.list(memberService.getCurrentMember().getId());
    return CommonResult.success(cartItemList);
}
 
Example #30
Source File: OmsCartItemServiceImpl.java    From macrozheng-mall with MIT License 5 votes vote down vote up
@Override
public int updateAttr(OmsCartItem cartItem) {
    //删除原购物车信息
    OmsCartItem updateCart = new OmsCartItem();
    updateCart.setId(cartItem.getId());
    updateCart.setModifyDate(new Date());
    updateCart.setDeleteStatus(1);
    cartItemMapper.updateByPrimaryKeySelective(updateCart);
    cartItem.setId(null);
    add(cartItem);
    return 1;
}