package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.system.domain.EpsTrafficData;
import com.ruoyi.system.mapper.EpsMethodChangeRecordMapper;
import com.ruoyi.system.mapper.EpsTrafficDataMapper;
import com.ruoyi.system.service.IEpsTrafficDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 流量相关数据Service业务层处理
 * 
 * @author gyt
 * @date 2025-08-12
 */
@Service
public class EpsTrafficDataServiceImpl implements IEpsTrafficDataService 
{
    @Autowired
    private EpsTrafficDataMapper epsTrafficDataMapper;
    @Autowired
    private EpsMethodChangeRecordMapper epsMethodChangeRecordMapper;

    /**
     * 查询流量相关数据
     * 
     * @param id 流量相关数据主键
     * @return 流量相关数据
     */
    @Override
    public EpsTrafficData selectEpsTrafficDataById(Long id)
    {
        return epsTrafficDataMapper.selectEpsTrafficDataById(id);
    }

    /**
     * 查询流量相关数据列表
     * 
     * @param epsTrafficData 流量相关数据
     * @return 流量相关数据
     */
    @Override
    public List<EpsTrafficData> selectEpsTrafficDataList(EpsTrafficData epsTrafficData)
    {
        return epsTrafficDataMapper.selectEpsTrafficDataList(epsTrafficData);
    }

    /**
     * 新增流量相关数据
     * 
     * @param epsTrafficData 流量相关数据
     * @return 结果
     */
    @Override
    public int insertEpsTrafficData(EpsTrafficData epsTrafficData)
    {
        epsTrafficData.setCreateTime(DateUtils.getNowDate());
        return epsTrafficDataMapper.insertEpsTrafficData(epsTrafficData);
    }

    /**
     * 修改流量相关数据
     * 
     * @param epsTrafficData 流量相关数据
     * @return 结果
     */
    @Override
    public int updateEpsTrafficData(EpsTrafficData epsTrafficData)
    {
        epsTrafficData.setUpdateTime(DateUtils.getNowDate());
        // 修改条数
        int rows = epsTrafficDataMapper.updateEpsTrafficData(epsTrafficData);
        return rows;
    }

    /**
     * 批量删除流量相关数据
     * 
     * @param ids 需要删除的流量相关数据主键
     * @return 结果
     */
    @Override
    public int deleteEpsTrafficDataByIds(Long[] ids)
    {
        return epsTrafficDataMapper.deleteEpsTrafficDataByIds(ids);
    }

    /**
     * 删除流量相关数据信息
     * 
     * @param id 流量相关数据主键
     * @return 结果
     */
    @Override
    public int deleteEpsTrafficDataById(Long id)
    {
        return epsTrafficDataMapper.deleteEpsTrafficDataById(id);
    }

    /**
     * 把收益方式转化为文字
     * @param method
     * @return
     */
    public String getMethodName(String method){
        String revenueMethod = "";
        if("1".equals(method)){
            revenueMethod = "流量";
        }
        if("2".equals(method)){
            revenueMethod = "包端";
        }
        return revenueMethod;
    }
}
