package com.cpxt.biz.service.impl;

import java.util.Arrays;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.cpxt.biz.domain.BizDriver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cpxt.biz.mapper.BizOrderMapper;
import com.cpxt.biz.domain.BizOrder;
import com.cpxt.biz.service.IBizOrderService;

/**
 * 订单Service业务层处理
 * 
 * @author YIN
 * @date 2024-12-16
 */
@Service
public class BizOrderServiceImpl implements IBizOrderService 
{
    @Autowired
    private BizOrderMapper bizOrderMapper;

    /**
     * 查询订单
     * 
     * @param id 订单主键
     * @return 订单
     */
    @Override
    public BizOrder selectBizOrderById(Long id)
    {
        return bizOrderMapper.selectById(id);
    }

    /**
     * 查询订单列表
     * 
     * @param bizOrder 订单
     * @return 订单
     */
    @Override
    public List<BizOrder> selectBizOrderList(BizOrder bizOrder)
    {
        LambdaQueryWrapper<BizOrder> queryWrapper = new LambdaQueryWrapper<>();

        return bizOrderMapper.selectList(queryWrapper);
    }

    /**
     * 新增订单
     * 
     * @param bizOrder 订单
     * @return 结果
     */
    @Override
    public int insertBizOrder(BizOrder bizOrder)
    {
        return bizOrderMapper.insert(bizOrder);
    }

    /**
     * 修改订单
     * 
     * @param bizOrder 订单
     * @return 结果
     */
    @Override
    public int updateBizOrder(BizOrder bizOrder)
    {
        return bizOrderMapper.updateById(bizOrder);
    }

    /**
     * 批量删除订单
     * 
     * @param ids 需要删除的订单主键
     * @return 结果
     */
    @Override
    public int deleteBizOrderByIds(Long[] ids)
    {
        UpdateWrapper<BizOrder> updateWrapper = new UpdateWrapper<>();
        updateWrapper.in("id", (Object) ids);
        updateWrapper.set("status","2"); //状态改为删除
        return bizOrderMapper.update(null,updateWrapper);
    }

    /**
     * 删除订单信息
     * 
     * @param id 订单主键
     * @return 结果
     */
    @Override
    public int deleteBizOrderById(Long id)
    {
        UpdateWrapper<BizOrder> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("id", id);
        updateWrapper.set("status","2"); //状态改为删除
        return bizOrderMapper.update(null,updateWrapper);
    }
}
