/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the yifu4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */

package com.yifu.cloud.plus.v1.yifu.salary.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryZero;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryZeroExportVo;
import com.yifu.cloud.plus.v1.yifu.salary.vo.TSalaryZeroSearchVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 0申报
 *
 * @author hgw
 * @date 2026-03-18 14:47:00
 */
@Mapper
public interface TSalaryZeroMapper extends BaseMapper<TSalaryZero> {
    // 单个查询
    TSalaryZero getTSalaryZeroById(@Param("tableName") String tableName, @Param("id") String id);
	// 单个删除
    int deleteTSalaryZeroById(@Param("tableName") String tableName, @Param("id") String id);
	// 批量删除
    int deleteTSalaryZeroByIdList(@Param("tableName") String tableName, @Param("idList") String idList);
	// 分页查询
    IPage<TSalaryZero> getTSalaryZeroPage(Page<TSalaryZero> page, @Param("tableName") String tableName, @Param("tSalaryZero") TSalaryZeroSearchVo searchVo);

	// 批量更新状态(deleteFlag0,1,2：0：正常；1：已删除；2存在报账假删除)
    int updateDeleteFlagByIdList(@Param("tableName") String tableName, @Param("deleteFlag") Integer deleteFlag
			, @Param("cardList") List<String> cardList, @Param("invoiceTitle") String invoiceTitle, @Param("settleMonth") String settleMonth);

	// 导出获取数据总数
    long getTSalaryZeroCount(@Param("tableName") String tableName, @Param("tSalaryZero") TSalaryZeroSearchVo searchVo);
	// 导出获取数据
	List<TSalaryZeroExportVo> getTSalaryZeroExport(@Param("tableName") String tableName, @Param("tSalaryZero") TSalaryZeroSearchVo searchVo);

	// 获取已存在的身份证去重
	List<String> getIdListByCardAndTitleAndMonth(@Param("tableName") String tableName
			, @Param("invoiceTitle") String invoiceTitle, @Param("settleMonth") String settleMonth, @Param("cardList") List<String> cardList);

	/**
	 * @Description: 自动创建年度0申报表
	 * @Author: hgw
	 * @Date: 2026/3/18 16:32
	 **/
	void createSalaryZeroYear(@Param("tableName") String tableName);

	// 0：自动清理临时表
	void clearTempZeroYear();
	// 1：自动创建临时表（1月创建含去年12月的计税月份）（2月更新成当年的上月的计税月份）
	void createTempZeroYearView(@Param("viewYearName") String viewYearName);
	void createTempZeroYear(@Param("viewYearName") String viewYearName);
	// 2：更新减除费用与计税月
	void updateTempZeroYear(@Param("tableNameOrLastTable") String tableNameOrLastTable);
	// 3：复制到0申报表
	void insertIntoSalaryZeroYear(@Param("tableName") String tableName);

	// 0：自动清理临时表Day
	void clearTempZeroDay();
	// 1：自动创建临时表（1月创建含去年12月的计税月份）（2月更新成当年的上月的计税月份）
	void createTempZeroDayView(@Param("viewDayName") String viewDayName);
	void createTempZeroDay(@Param("viewDayName") String viewDayName);
	// 2.1：将已存在0申报表的数据清理掉
	void deleteCurTempZeroDay(@Param("tableName") String tableName);
	// 2.2：将已存在报账的数据更新掉
	void updateTempZeroDayDelete();
	// 2.3：更新减除费用与计税月
	void updateTempZeroDay(@Param("tableNameOrLastTable") String tableNameOrLastTable);
	// 3：复制到0申报表
	void insertIntoSalaryZeroDay(@Param("tableName") String tableName);

	// 每天23点生成当天0申报表
	void insertIntoSalaryZeroNowDay(@Param("tableName") String tableName, @Param("viewDayName") String viewDayName);

	// 判断表是否存在
	int getTableExists(@Param("tableName") String tableName);

}
