package com.dgtly.sync.service.impl;

import java.util.List;
import com.dgtly.common.utils.DateUtils;
import com.dgtly.sync.domain.Customers;
import com.dgtly.sync.mapper.CustomersMapper;
import com.dgtly.sync.service.ICustomersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dgtly.common.core.text.Convert;

/**
 * 经销商 Service业务层处理
 * 
 * @author dgtly
 * @date 2020-08-27
 */
@Service
public class CustomersServiceImpl implements ICustomersService
{
    @Autowired
    private CustomersMapper customersMapper;

    /**
     * 查询经销商 
     * 
     * @param id 经销商 ID
     * @return 经销商 
     */
    @Override
    public Customers selectCustomersById(Long id)
    {
        return customersMapper.selectCustomersById(id);
    }

    /**
     * 查询经销商 列表
     * 
     * @param customers 经销商 
     * @return 经销商 
     */
    @Override
    public List<Customers> selectCustomersList(Customers customers)
    {
        return customersMapper.selectCustomersList(customers);
    }

    /**
     * 新增经销商 
     * 
     * @param customers 经销商 
     * @return 结果
     */
    @Override
    public int insertCustomers(Customers customers)
    {
        customers.setCreateTime(DateUtils.getNowDate());
        return customersMapper.insertCustomers(customers);
    }

    /**
     * 修改经销商 
     * 
     * @param customers 经销商 
     * @return 结果
     */
    @Override
    public int updateCustomers(Customers customers)
    {
        customers.setUpdateTime(DateUtils.getNowDate());
        return customersMapper.updateCustomers(customers);
    }

    /**
     * 删除经销商 对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteCustomersByIds(String ids)
    {
        return customersMapper.deleteCustomersByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除经销商 信息
     * 
     * @param id 经销商 ID
     * @return 结果
     */
    @Override
    public int deleteCustomersById(Long id)
    {
        return customersMapper.deleteCustomersById(id);
    }

    /**
     * @param customerCode
     * @description:根据经销商code查询名称
     * @param:
     * @return:
     * @author: njs
     * @date: 2023/8/29 9:32
     */
    @Override
    public String selectCustomerNameByCustomerCode(String customerCode) {
        return customersMapper.selectCustomerNameByCustomerCode(customerCode);
    }
}
