package com.fs.company.mapper;

import java.util.List;
import com.fs.company.domain.CompanyProfit;
import com.fs.company.vo.CompanyProfitVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 提现Mapper接口
 * 
 * @author fs
 * @date 2022-07-04
 */
public interface CompanyProfitMapper 
{
    /**
     * 查询提现
     * 
     * @param profitId 提现ID
     * @return 提现
     */
    public CompanyProfit selectCompanyProfitById(Long profitId);

    /**
     * 查询提现列表
     * 
     * @param companyProfit 提现
     * @return 提现集合
     */
    public List<CompanyProfit> selectCompanyProfitList(CompanyProfit companyProfit);

    /**
     * 新增提现
     * 
     * @param companyProfit 提现
     * @return 结果
     */
    public int insertCompanyProfit(CompanyProfit companyProfit);

    /**
     * 修改提现
     * 
     * @param companyProfit 提现
     * @return 结果
     */
    public int updateCompanyProfit(CompanyProfit companyProfit);

    /**
     * 删除提现
     * 
     * @param profitId 提现ID
     * @return 结果
     */
    public int deleteCompanyProfitById(Long profitId);

    /**
     * 批量删除提现
     * 
     * @param profitIds 需要删除的数据ID
     * @return 结果
     */
    public int deleteCompanyProfitByIds(Long[] profitIds);
    @Select({"<script> " +
            "select p.*,c.company_name " +
            "from company_profit p left join company c on c.company_id=p.company_id " +
            "where 1=1 " +
            "<if test = 'maps.companyId != null  '> " +
            "and p.company_id = #{maps.companyId}" +
            "</if>" +
            "<if test = 'maps.profitStatus != null  '> " +
            "and p.profit_status = #{maps.profitStatus}" +
            "</if>" +
            "<if test = 'maps.beginTime != null and maps.beginTime != \"\" '> " +
            "and date_format(p.create_time,'%y%m%d') &gt;= date_format(#{maps.beginTime},'%y%m%d') " +
            "</if>" +
            "<if test = 'maps.endTime != null and maps.endTime != \"\" '> " +
            "and date_format(p.create_time,'%y%m%d') &lt;= date_format(#{maps.endTime},'%y%m%d') " +
            "</if>" +
            "order by p.profit_id desc " +
            "</script>"})
    List<CompanyProfitVO> selectCompanyProfitListVO(@Param("maps")CompanyProfit companyProfit);
    @Delete("delete from company_profit where company_id=#{companyId}")
    int deleteCompanyProfitByCompanyId(Long companyId);
}
