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.BizCarModel;
import com.cpxt.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cpxt.biz.mapper.BizCustomerMapper;
import com.cpxt.biz.domain.BizCustomer;
import com.cpxt.biz.service.IBizCustomerService;

/**
 * 客户Service业务层处理
 * 
 * @author YIN
 * @date 2024-12-16
 */
@Service
public class BizCustomerServiceImpl implements IBizCustomerService 
{
    @Autowired
    private BizCustomerMapper bizCustomerMapper;

    /**
     * 查询客户
     * 
     * @param id 客户主键
     * @return 客户
     */
    @Override
    public BizCustomer selectBizCustomerById(Long id)
    {
        return bizCustomerMapper.selectById(id);
    }

    /**
     * 查询客户列表
     * 
     * @param bizCustomer 客户
     * @return 客户
     */
    @Override
    public List<BizCustomer> selectBizCustomerList(BizCustomer bizCustomer)
    {
        LambdaQueryWrapper<BizCustomer> queryWrapper= new LambdaQueryWrapper<>();

        return bizCustomerMapper.selectList(queryWrapper);
    }

    /**
     * 新增客户
     * 
     * @param bizCustomer 客户
     * @return 结果
     */
    @Override
    public int insertBizCustomer(BizCustomer bizCustomer)
    {
        return bizCustomerMapper.insert(bizCustomer);
    }

    /**
     * 修改客户
     * 
     * @param bizCustomer 客户
     * @return 结果
     */
    @Override
    public int updateBizCustomer(BizCustomer bizCustomer)
    {
        return bizCustomerMapper.updateById(bizCustomer);
    }

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

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