package com.bonus.canteen.core.order.service.impl;

import java.util.List;

import com.bonus.canteen.core.order.domain.OrderShoppingCart;
import com.bonus.canteen.core.order.mapper.OrderShoppingCartMapper;
import com.bonus.canteen.core.order.service.IOrderShoppingCartService;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 订单购物车Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-04-14
 */
@Service
public class OrderShoppingCartServiceImpl implements IOrderShoppingCartService
{
    @Autowired
    private OrderShoppingCartMapper orderShoppingCartMapper;

    /**
     * 查询订单购物车
     * 
     * @param shoppingCartId 订单购物车主键
     * @return 订单购物车
     */
    @Override
    public OrderShoppingCart selectOrderShoppingCartByShoppingCartId(Long shoppingCartId)
    {
        return orderShoppingCartMapper.selectOrderShoppingCartByShoppingCartId(shoppingCartId);
    }

    /**
     * 查询订单购物车列表
     * 
     * @param orderShoppingCart 订单购物车
     * @return 订单购物车
     */
    @Override
    public List<OrderShoppingCart> selectOrderShoppingCartList(OrderShoppingCart orderShoppingCart)
    {
        return orderShoppingCartMapper.selectOrderShoppingCartList(orderShoppingCart);
    }

    /**
     * 新增订单购物车
     * 
     * @param orderShoppingCart 订单购物车
     * @return 结果
     */
    @Override
    public int insertOrderShoppingCart(OrderShoppingCart orderShoppingCart)
    {
        orderShoppingCart.setCreateBy(SecurityUtils.getUsername());
        return orderShoppingCartMapper.insertOrderShoppingCart(orderShoppingCart);
    }

    /**
     * 修改订单购物车
     * 
     * @param orderShoppingCart 订单购物车
     * @return 结果
     */
    @Override
    public int updateOrderShoppingCart(OrderShoppingCart orderShoppingCart)
    {
        orderShoppingCart.setUpdateTime(DateUtils.getNowDate());
        return orderShoppingCartMapper.updateOrderShoppingCart(orderShoppingCart);
    }

    /**
     * 批量删除订单购物车
     * 
     * @param shoppingCartIds 需要删除的订单购物车主键
     * @return 结果
     */
    @Override
    public int deleteOrderShoppingCartByShoppingCartIds(List<Long> shoppingCartIds)
    {
        return orderShoppingCartMapper.deleteOrderShoppingCartByShoppingCartIds(shoppingCartIds);
    }

    /**
     * 删除订单购物车信息
     * 
     * @param shoppingCartId 订单购物车主键
     * @return 结果
     */
    @Override
    public int deleteOrderShoppingCartByShoppingCartId(Long shoppingCartId)
    {
        return orderShoppingCartMapper.deleteOrderShoppingCartByShoppingCartId(shoppingCartId);
    }
}
