package com.zbf.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zbf.system.domain.TckOrderdetailBak;
import com.zbf.system.domain.TckXnOrderdetailBak;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

/**
 * 出库物料明细Mapper接口
 *
 * @author tony
 * @date 2024-09-09
 */
public interface TckXnOrderdetailBakMapper extends BaseMapper<TckXnOrderdetailBak> //修改
{



    @Select("SELECT COALESCE(SUM(to_money), 0) FROM t_ck_orderdetail_bak WHERE YEAR(create_time) = #{year} AND MONTH(create_time) = #{month}")
    BigDecimal getTotalMoneyForYearMonth(@Param("year") int year, @Param("month") int month);

    @Select("SELECT COALESCE(SUM(to_money), 0) FROM t_ck_orderdetail_bak WHERE YEAR(create_time) = #{year} AND MONTH(create_time) = #{month} and not level_type = '1'")
    BigDecimal getTotalMoneyForYearMonth1(@Param("year") int year, @Param("month") int month);

    @Select("SELECT COALESCE(SUM(to_money), 0) FROM t_ck_orderdetail_bak WHERE YEAR(create_time) = #{year} AND MONTH(create_time) = #{month} and level_type = '1'")
    BigDecimal getTotalMoneyForYearMonth2(@Param("year") int year, @Param("month") int month);

    @Select("SELECT COALESCE(SUM(to_money), 0) FROM t_ck_orderdetail_bak WHERE YEAR(create_time) = #{year}")
    BigDecimal getTotalMoneyForYear(@Param("year") int year);

    @Select("SELECT COALESCE(SUM(to_money), 0) FROM t_ck_orderdetail_bak WHERE YEAR(create_time) = #{year} and  not level_type = '1'")
    BigDecimal getTotalMoneyForYear1(@Param("year") int year);

    @Select("SELECT COALESCE(SUM(to_money), 0) FROM t_ck_orderdetail_bak WHERE YEAR(create_time) = #{year} and level_type = '1'")
    BigDecimal getTotalMoneyForYear2(@Param("year") int year);
    /**
     * 查询出库物料明细
     *
     * @param id 出库物料明细主键
     * @return 出库物料明细
     */
    public TckXnOrderdetailBak selectTckOrderdetailBakById(String id);

    /**
     * 查询出库物料明细列表
     *
     * @param tckOrderdetailBak 出库物料明细
     * @return 出库物料明细集合
     */
    public List<TckXnOrderdetailBak> selectTckOrderdetailBakList(TckXnOrderdetailBak tckOrderdetailBak);

    /**
     * 新增出库物料明细
     *
     * @param tckOrderdetailBak 出库物料明细
     * @return 结果
     */
    public int insertTckOrderdetailBak(TckXnOrderdetailBak tckOrderdetailBak);

    /**
     * 修改出库物料明细
     *
     * @param tckOrderdetailBak 出库物料明细
     * @return 结果
     */
    public int updateTckOrderdetailBak(TckXnOrderdetailBak tckOrderdetailBak);

    public List<TckXnOrderdetailBak> selectTMiStockList(TckXnOrderdetailBak tckOrderdetailBak);

    /**
     * 删除出库物料明细
     *
     * @param id 出库物料明细主键
     * @return 结果
     */
    public int deleteTckOrderdetailBakById(String id);

    /**
     * 批量删除出库物料明细
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteTckOrderdetailBakByIds(String[] ids);

    /**
     * 批量启用出库物料明细
     *
     * @param ids 需要启用的数据主键集合
     * @return 结果
     */
    public int enableTckOrderdetailBakByIds(String[] ids);

    /**
     * 批量禁用出库物料明细
     *
     * @param ids 需要禁用的数据主键集合
     * @return 结果
     */
    public int disabledTckOrderdetailBakByIds(String[] ids);

}
