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

import com.xingxi.business.Order.domain.Order;
import com.xingxi.business.Order.mapper.OrderMapper;
import com.xingxi.business.Order.service.IOrderService;
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 OrderServiceImpl implements IOrderService {
    @Resource
    private OrderMapper orderMapper;

    /**
     * 查询订单
     *
     * @param orderId 订单主键
     * @return 订单
     */
    @Override
    public Order selectOrderByOrderId(Long orderId) {
        return orderMapper.selectOrderByOrderId(orderId);
    }

    /**
     * 查询订单列表
     *
     * @param order 订单
     * @return 订单
     */
    @Override
    public List<Order> selectOrderList(Order order) {
        return orderMapper.selectOrderList(order);
    }

    /**
     * 新增订单
     *
     * @param order 订单
     * @return 结果
     */
    @Override
    public int insertOrder(Order order) {
        order.setCreateTime(DateUtils.getNowDate());
        return orderMapper.insertOrder(order);
    }

    /**
     * 新增订单
     *
     * @param orderList 订单
     * @return 结果
     */
    @Override
    public int batchInsertOrder(List<Order> orderList) {
        return orderMapper.batchInsertOrder(orderList);
    }

    /**
     * 修改订单
     *
     * @param order 订单
     * @return 结果
     */
    @Override
    public int updateOrder(Order order) {
        order.setUpdateTime(DateUtils.getNowDate());
        return orderMapper.updateOrder(order);
    }

    /**
     * 批量删除订单
     *
     * @param orderIds 需要删除的订单主键
     * @return 结果
     */
    @Override
    public int deleteOrderByOrderIds(String orderIds) {
        return orderMapper.deleteOrderByOrderIds(Convert.toStrArray(orderIds));
    }

    /**
     * 删除订单信息
     *
     * @param orderId 订单主键
     * @return 结果
     */
    @Override
    public int deleteOrderByOrderId(Long orderId) {
        return orderMapper.deleteOrderByOrderId(orderId);
    }

    /**
     * 逻辑删除订单
     *
     * @param orderId 订单主键
     * @return 结果
     */
    @Override
    public int logicDeleteOrderByOrderId(Long orderId) {
        return orderMapper.logicDeleteOrderByOrderId(orderId);
    }

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

    /**
     * 逻辑批量删除订单
     *
     * @param order 订单
     * @return 结果
     */
    @Override
    public int logicDeleteOrderByCondition(Order order) {
        return orderMapper.logicDeleteOrderByCondition(order);
    }

}
