package cn.iocoder.yudao.module.rescue.service.impl;

import cn.iocoder.yudao.module.rescue.domain.RescueConfig;
import cn.iocoder.yudao.module.rescue.mapper.RescueConfigMapper;
import cn.iocoder.yudao.module.rescue.service.IRescueConfigService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 救援司机提成配置Service业务层处理
 *
 * @author zcy
 * @date 2023-12-01
 */
@Service
public class RescueConfigServiceImpl implements IRescueConfigService
{
    @Autowired
    private RescueConfigMapper rescueConfigMapper;

    /**
     * 查询救援司机提成配置
     *
     * @return 救援司机提成配置
     */
    @Override
    public RescueConfig selectRescueConfigByDeptId()
    {
        RescueConfig rescueConfig = rescueConfigMapper.selectRescueConfigByDeptId();
        if (ObjectUtils.isEmpty(rescueConfig)){
            rescueConfig =new RescueConfig();
            //新增
            rescueConfig = new RescueConfig();
            rescueConfig.setRescueTcBig(0.6d);
            rescueConfig.setRescueTcMid(0.4d);
            rescueConfig.setRescueTcSmall(0.4d);
            rescueConfigMapper.insertRescueConfig(rescueConfig);
        }
        return rescueConfig;
    }

    /**
     * 查询救援司机提成配置列表
     *
     * @param rescueConfig 救援司机提成配置
     * @return 救援司机提成配置
     */
    @Override
    public IPage<RescueConfig> selectRescueConfigList(Page<RescueConfig> page, RescueConfig rescueConfig)
    {
        return rescueConfigMapper.selectRescueConfigList(page,rescueConfig);
    }

    /**
     * 新增救援司机提成配置
     *
     * @param rescueConfig 救援司机提成配置
     * @return 结果
     */
    @Override
    public int insertRescueConfig(RescueConfig rescueConfig)
    {
        return rescueConfigMapper.insertRescueConfig(rescueConfig);
    }

    /**
     * 修改救援司机提成配置
     *
     * @param rescueConfig 救援司机提成配置
     * @return 结果
     */
    @Override
    public int updateRescueConfig(RescueConfig rescueConfig)
    {
        return rescueConfigMapper.updateRescueConfig(rescueConfig);
    }

    /**
     * 批量删除救援司机提成配置
     *
     * @param ids 需要删除的救援司机提成配置主键
     * @return 结果
     */
    @Override
    public int deleteRescueConfigByIds(Long[] ids)
    {
        return rescueConfigMapper.deleteRescueConfigByIds(ids);
    }

    /**
     * 删除救援司机提成配置信息
     *
     * @param id 救援司机提成配置主键
     * @return 结果
     */
    @Override
    public int deleteRescueConfigById(Long id)
    {
        return rescueConfigMapper.deleteRescueConfigById(id);
    }
}
