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

import java.util.List;

import com.bonus.canteen.core.order.domain.OrderDetail;
import com.bonus.canteen.core.order.mapper.OrderDetailMapper;
import com.bonus.canteen.core.order.service.IOrderDetailService;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 订单详情Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-04-14
 */
@Service
public class OrderDetailServiceImpl implements IOrderDetailService
{
    @Autowired
    private OrderDetailMapper orderDetailMapper;

    /**
     * 查询订单详情
     * 
     * @param detailId 订单详情主键
     * @return 订单详情
     */
    @Override
    public OrderDetail selectOrderDetailByDetailId(Long detailId)
    {
        return orderDetailMapper.selectOrderDetailByDetailId(detailId);
    }

    /**
     * 查询订单详情列表
     * 
     * @param orderDetail 订单详情
     * @return 订单详情
     */
    @Override
    public List<OrderDetail> selectOrderDetailList(OrderDetail orderDetail)
    {
        return orderDetailMapper.selectOrderDetailList(orderDetail);
    }

    /**
     * 新增订单详情
     * 
     * @param orderDetail 订单详情
     * @return 结果
     */
    @Override
    public int insertOrderDetail(OrderDetail orderDetail)
    {
        orderDetail.setCreateTime(DateUtils.getNowDate());
        return orderDetailMapper.insertOrderDetail(orderDetail);
    }
    @Override
    public int batchInsertOrderDetail(List<OrderDetail> orderDetailList) {
        return orderDetailMapper.batchInsertOrderDetail(orderDetailList);
    }

    /**
     * 修改订单详情
     * 
     * @param orderDetail 订单详情
     * @return 结果
     */
    @Override
    public int updateOrderDetail(OrderDetail orderDetail)
    {
        orderDetail.setUpdateTime(DateUtils.getNowDate());
        return orderDetailMapper.updateOrderDetail(orderDetail);
    }

    /**
     * 批量删除订单详情
     * 
     * @param detailIds 需要删除的订单详情主键
     * @return 结果
     */
    @Override
    public int deleteOrderDetailByDetailIds(List<Long> detailIds)
    {
        return orderDetailMapper.deleteOrderDetailByDetailIds(detailIds);
    }

    /**
     * 删除订单详情信息
     * 
     * @param detailId 订单详情主键
     * @return 结果
     */
    @Override
    public int deleteOrderDetailByDetailId(Long detailId)
    {
        return orderDetailMapper.deleteOrderDetailByDetailId(detailId);
    }
}
