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

import com.xingxi.business.Order.domain.OrderDelivery;
import com.xingxi.business.Order.mapper.OrderDeliveryMapper;
import com.xingxi.business.Order.service.IOrderDeliveryService;
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 OrderDeliveryServiceImpl implements IOrderDeliveryService {
    @Resource
    private OrderDeliveryMapper orderDeliveryMapper;

    /**
     * 查询订单明细发货单
     *
     * @param orderDeliveryId 订单明细发货单主键
     * @return 订单明细发货单
     */
    @Override
    public OrderDelivery selectOrderDeliveryByOrderDeliveryId(Long orderDeliveryId) {
        return orderDeliveryMapper.selectOrderDeliveryByOrderDeliveryId(orderDeliveryId);
    }

    /**
     * 查询订单明细发货单列表
     *
     * @param orderDelivery 订单明细发货单
     * @return 订单明细发货单
     */
    @Override
    public List<OrderDelivery> selectOrderDeliveryList(OrderDelivery orderDelivery) {
        return orderDeliveryMapper.selectOrderDeliveryList(orderDelivery);
    }

    /**
     * 新增订单明细发货单
     *
     * @param orderDelivery 订单明细发货单
     * @return 结果
     */
    @Override
    public int insertOrderDelivery(OrderDelivery orderDelivery) {
        orderDelivery.setCreateTime(DateUtils.getNowDate());
        return orderDeliveryMapper.insertOrderDelivery(orderDelivery);
    }

    /**
     * 新增订单明细发货单
     *
     * @param orderDeliveryList 订单明细发货单
     * @return 结果
     */
    @Override
    public int batchInsertOrderDelivery(List<OrderDelivery> orderDeliveryList) {
        return orderDeliveryMapper.batchInsertOrderDelivery(orderDeliveryList);
    }

    /**
     * 修改订单明细发货单
     *
     * @param orderDelivery 订单明细发货单
     * @return 结果
     */
    @Override
    public int updateOrderDelivery(OrderDelivery orderDelivery) {
        orderDelivery.setUpdateTime(DateUtils.getNowDate());
        return orderDeliveryMapper.updateOrderDelivery(orderDelivery);
    }

    /**
     * 批量删除订单明细发货单
     *
     * @param orderDeliveryIds 需要删除的订单明细发货单主键
     * @return 结果
     */
    @Override
    public int deleteOrderDeliveryByOrderDeliveryIds(String orderDeliveryIds) {
        return orderDeliveryMapper.deleteOrderDeliveryByOrderDeliveryIds(Convert.toStrArray(orderDeliveryIds));
    }

    /**
     * 删除订单明细发货单信息
     *
     * @param orderDeliveryId 订单明细发货单主键
     * @return 结果
     */
    @Override
    public int deleteOrderDeliveryByOrderDeliveryId(Long orderDeliveryId) {
        return orderDeliveryMapper.deleteOrderDeliveryByOrderDeliveryId(orderDeliveryId);
    }

    /**
     * 逻辑删除订单明细发货单
     *
     * @param orderDeliveryId 订单明细发货单主键
     * @return 结果
     */
    @Override
    public int logicDeleteOrderDeliveryByOrderDeliveryId(Long orderDeliveryId) {
        return orderDeliveryMapper.logicDeleteOrderDeliveryByOrderDeliveryId(orderDeliveryId);
    }

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

    /**
     * 逻辑批量删除订单明细发货单
     *
     * @param orderDelivery 订单明细发货单
     * @return 结果
     */
    @Override
    public int logicDeleteOrderDeliveryByCondition(OrderDelivery orderDelivery) {
        return orderDeliveryMapper.logicDeleteOrderDeliveryByCondition(orderDelivery);
    }
}
