package com.dgtly.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dgtly.system.mapper.SysUserExtMapper;
import com.dgtly.system.domain.SysUserExt;
import com.dgtly.system.service.ISysUserExtService;
import com.dgtly.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;

/**
 * 用户销售信息扩展Service业务层处理
 * 
 * @author qxp
 * @date 2020-07-29
 */
@Service
public class SysUserExtServiceImpl implements ISysUserExtService
{
    @Autowired
    private SysUserExtMapper sysUserExtMapper;

    /**
     * 查询用户销售信息扩展
     * 
     * @param userId 用户销售信息扩展ID
     * @return 用户销售信息扩展
     */
    @Override
    public SysUserExt selectSysUserExtById(Long userId)
    {
        return sysUserExtMapper.selectSysUserExtById(userId);
    }

    @Override
    public SysUserExt selectSysUserCustomerExtById(Long userId) {
        return sysUserExtMapper.selectSysUserCustomerExtById(userId);
    }

    /**
     * 查询用户销售信息扩展列表
     * 
     * @param sysUserExt 用户销售信息扩展
     * @return 用户销售信息扩展
     */
    @Override
    public List<SysUserExt> selectSysUserExtList(SysUserExt sysUserExt)
    {
        return sysUserExtMapper.selectSysUserExtList(sysUserExt);
    }

    /**
     * 新增用户销售信息扩展
     * 
     * @param sysUserExt 用户销售信息扩展
     * @return 结果
     */
    @Override
    public int insertSysUserExt(SysUserExt sysUserExt)
    {
        return sysUserExtMapper.insertSysUserExt(sysUserExt);
    }

    /**
     * 根据领导EmployeeId查询所有下属用户id
     *
     * @param bossEmployeeId 领导EmployeeId
     * @return 结果
     */
    @Override
    public List<String> selectEmployeeIdsByBossEmployeeId(String bossEmployeeId) {
        return sysUserExtMapper.selectEmployeeIdsByBossEmployeeId(bossEmployeeId);
    }

    /**
     * 修改用户销售信息扩展
     * 
     * @param sysUserExt 用户销售信息扩展
     * @return 结果
     */
    @Override
    public int updateSysUserExt(SysUserExt sysUserExt)
    {
        return sysUserExtMapper.updateSysUserExt(sysUserExt);
    }

    /**
     * 删除用户销售信息扩展对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteSysUserExtByIds(String ids)
    {
        return sysUserExtMapper.deleteSysUserExtByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除用户销售信息扩展信息
     * 
     * @param userId 用户销售信息扩展ID
     * @return 结果
     */
    @Override
    public int deleteSysUserExtById(Long userId)
    {
        return sysUserExtMapper.deleteSysUserExtById(userId);
    }
    /**
     * 插入或更新用户销售信息扩展
     *
     * @param sysUserExt 用户销售信息扩展
     * @return 结果
     */
    @Override
    public int insertOrUpSysUserExt(SysUserExt ext) {
        return sysUserExtMapper.insertOrUpSysUserExt(ext);
    }

    @Override
    @Transactional
    public int delAndInsertSysUserExt(SysUserExt ext) {
        sysUserExtMapper.deleteSysUserExtById(ext.getUserId());
        return sysUserExtMapper.insertSysUserExt(ext);
    }

    /**
     * @description: 根据userid查询多经销商列表
     * @param: [userId]
     * @return: java.util.List<com.dgtly.system.domain.SysUserExt>
     * @author: qxm
     * @date: 2021/4/9 9:39
     */
    @Override
    public List<SysUserExt> selectSysUserExtListByUserId(Long userId) {
        return sysUserExtMapper.selectSysUserExtListByUserId(userId);
    }

    /**
     * @description: 切换经销商
     * @param: [userId, orgCode, orgName]
     * @return: com.dgtly.system.domain.SysUserExt
     * @author: qxm
     * @date: 2021/4/9 9:39
     */
    @Override
    public int switchCustomer(String userId, String orgCode, String orgName) {
        return sysUserExtMapper.switchCustomer(userId,orgCode,orgName);
    }

    @Override
    public int selectSysUserExtBySapEmployeeId(String sapEmployeeId) {
        return sysUserExtMapper.selectSysUserExtBySapEmployeeId(sapEmployeeId);
    }


}
