package com.xingxi.business.Order.service.impl;

import com.xingxi.business.Order.domain.OrderDetail;
import com.xingxi.business.Order.mapper.OrderDetailMapper;
import com.xingxi.business.Order.service.IOrderDetailService;
import com.xingxi.common.core.text.Convert;
import com.xingxi.common.utils.DateUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 订单明细Service业务层处理
 *
 * @author xingxi
 * @date 2025-03-06
 */
@Service
public class OrderDetailServiceImpl implements IOrderDetailService {
    @Resource
    private OrderDetailMapper orderDetailMapper;

    /**
     * 查询订单明细
     *
     * @param orderDetailId 订单明细主键
     * @return 订单明细
     */
    @Override
    public OrderDetail selectOrderDetailByOrderDetailId(Long orderDetailId) {
        return orderDetailMapper.selectOrderDetailByOrderDetailId(orderDetailId);
    }

    /**
     * 查询订单明细列表
     *
     * @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);
    }

    /**
     * 新增订单明细
     *
     * @param orderDetailList 订单明细
     * @return 结果
     */
    @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 orderDetailIds 需要删除的订单明细主键
     * @return 结果
     */
    @Override
    public int deleteOrderDetailByOrderDetailIds(String orderDetailIds) {
        return orderDetailMapper.deleteOrderDetailByOrderDetailIds(Convert.toStrArray(orderDetailIds));
    }

    /**
     * 删除订单明细信息
     *
     * @param orderDetailId 订单明细主键
     * @return 结果
     */
    @Override
    public int deleteOrderDetailByOrderDetailId(Long orderDetailId) {
        return orderDetailMapper.deleteOrderDetailByOrderDetailId(orderDetailId);
    }

    /**
     * 逻辑删除订单明细
     *
     * @param orderDetailId 订单明细主键
     * @return 结果
     */
    @Override
    public int logicDeleteOrderDetailByOrderDetailId(Long orderDetailId) {
        return orderDetailMapper.logicDeleteOrderDetailByOrderDetailId(orderDetailId);
    }

    /**
     * 逻辑批量删除订单明细
     *
     * @param orderDetailIds 需要删除的数据主键集合
     * @return 结果
     */
    @Override
    public int logicDeleteOrderDetailByOrderDetailIds(String[] orderDetailIds) {
        return orderDetailMapper.logicDeleteOrderDetailByOrderDetailIds(orderDetailIds);
    }

    /**
     * 逻辑批量删除订单明细
     *
     * @param orderDetail 订单明细
     * @return 结果
     */
    @Override
    public int logicDeleteOrderDetailByCondition(OrderDetail orderDetail) {
        return orderDetailMapper.logicDeleteOrderDetailByCondition(orderDetail);
    }
}
