<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~
  ~      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)
  ~
  -->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.yifu.cloud.plus.v1.yifu.salary.mapper.TStatisticsCurrentReportMarketMapper">

  <resultMap id="tStatisticsCurrentReportMarketMap" type="com.yifu.cloud.plus.v1.yifu.salary.entity.TStatisticsCurrentReportMarket">
    <id property="id" column="id"/>
    <result property="invoiceTitle" column="INVOICE_TITLE"/>
    <result property="settleDepartId" column="SETTLE_DEPART_ID"/>
    <result property="settleDepartNo" column="SETTLE_DEPART_NO"/>
    <result property="settleDepartName" column="SETTLE_DEPART_NAME"/>
    <result property="declareMonth" column="declare_MONTH"/>
    <result property="empName" column="EMP_NAME"/>
    <result property="empIdcardType" column="EMP_IDCARD_type"/>
    <result property="empIdcard" column="EMP_IDCARD"/>
    <result property="createStart" column="CREATE_START"/>
    <result property="createEnd" column="CREATE_END"/>
    <result property="item" column="item"/>
    <result property="realSalary" column="REAL_SALARY"/>
    <result property="currentExpenses" column="current_expenses"/>
    <result property="currentTaxFreeIncome" column="current_tax_free_income"/>
    <result property="costReduction" column="cost_reduction"/>
    <result property="specialDeduction" column="special_deduction"/>
    <result property="childEduinfoMoney" column="child_eduInfo_money"/>
    <result property="housingRentalinfoMoney" column="housing_rentalInfo_money"/>
    <result property="housingLoanInterestExpenseMoney" column="housing_loan_Interest_expense_money"/>
    <result property="supportElderlyExpenseMoney" column="support_elderly_expense_money"/>
    <result property="continuingEducationExpenseMoney" column="continuing_education_expense_money"/>
    <result property="personalPensionMoney" column="PERSONAL_PENSION_MONEY"/>
    <result property="personalMedicalMoney" column="PERSONAL_MEDICAL_MONEY"/>
    <result property="personalUnemploymentMoney" column="PERSONAL_UNEMPLOYMENT_MONEY"/>
    <result property="personalBigmailmentMoney" column="PERSONAL_BIGMAILMENT_MONEY"/>
    <result property="personalProvidentFee" column="PERSONAL_PROVIDENT_FEE"/>
    <result property="enterpriseAnnuity" column="enterprise_annuity"/>
    <result property="taxable" column="taxable"/>
    <result property="nowTakingRisks" column="now_taking_risks"/>
    <result property="nowTaxDeferred" column="now_tax_deferred"/>
    <result property="nowOther" column="now_other"/>
    <result property="allIncome" column="all_income"/>
    <result property="allOther" column="all_other"/>
    <result property="allDonate" column="all_donate"/>
    <result property="taxFee" column="tax_fee"/>
    <result property="quickDeducation" column="QUICK_DEDUCATION"/>
    <result property="salaryTax" column="salary_tax"/>
    <result property="allTaxDeduction" column="all_tax_deduction"/>
    <result property="allWithholdingTax" column="all_withholding_tax"/>
    <result property="allTaxPrepaid" column="all_tax_prepaid"/>
    <result property="allTaxPayable" column="all_tax_payable"/>
    <result property="remark" column="remark"/>
    <result property="unitId" column="UNIT_ID"/>
    <result property="unitNo" column="UNIT_NO"/>
    <result property="unitName" column="UNIT_NAME"/>
    <result property="sumBabyMoney" column="sum_baby_money"/>
	<result property="sumPrivatePension" column="SUM_PRIVATE_PENSION"/>
  </resultMap>
    <sql id="Base_Column_List">
                a.id,
                a.INVOICE_TITLE,
                a.SETTLE_DEPART_ID,
                a.SETTLE_DEPART_NO,
                a.SETTLE_DEPART_NAME,
                a.declare_MONTH,
                a.EMP_NAME,
                a.EMP_IDCARD_type,
                a.EMP_IDCARD,
                a.CREATE_START,
                a.CREATE_END,
                a.item,
                a.REAL_SALARY,
                a.current_expenses,
                a.current_tax_free_income,
                a.cost_reduction,
                a.special_deduction,
                a.child_eduInfo_money,
                a.housing_rentalInfo_money,
                a.housing_loan_Interest_expense_money,
                a.support_elderly_expense_money,
                a.continuing_education_expense_money,
                a.PERSONAL_PENSION_MONEY,
                a.PERSONAL_MEDICAL_MONEY,
                a.PERSONAL_UNEMPLOYMENT_MONEY,
                a.PERSONAL_BIGMAILMENT_MONEY,
                a.PERSONAL_PROVIDENT_FEE,
                a.enterprise_annuity,
                a.taxable,
                a.now_taking_risks,
                a.now_tax_deferred,
                a.now_other,
                a.all_income,
                a.all_other,
                a.all_donate,
                a.tax_fee,
                a.QUICK_DEDUCATION,
                a.salary_tax,
                a.all_tax_deduction,
                a.all_withholding_tax,
                a.all_tax_prepaid,
                a.all_tax_payable,
                a.remark,
                a.UNIT_ID,
                a.UNIT_NO,
                a.UNIT_NAME,
                a.sum_baby_money,
                a.SUM_PRIVATE_PENSION
    </sql>
    <sql id="tStatisticsCurrentReportMarket_where">
        <if test="tStatisticsCurrentReportMarket != null">
                    <if test="tStatisticsCurrentReportMarket.id != null and tStatisticsCurrentReportMarket.id.trim() != ''">
                        AND a.id = #{tStatisticsCurrentReportMarket.id}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.invoiceTitle != null and tStatisticsCurrentReportMarket.invoiceTitle.trim() != ''">
                        AND a.INVOICE_TITLE = #{tStatisticsCurrentReportMarket.invoiceTitle}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.settleDepartId != null and tStatisticsCurrentReportMarket.settleDepartId.trim() != ''">
                        AND a.SETTLE_DEPART_ID = #{tStatisticsCurrentReportMarket.settleDepartId}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.settleDepartNo != null and tStatisticsCurrentReportMarket.settleDepartNo.trim() != ''">
                        AND a.SETTLE_DEPART_NO = #{tStatisticsCurrentReportMarket.settleDepartNo}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.settleDepartName != null and tStatisticsCurrentReportMarket.settleDepartName.trim() != ''">
                        AND a.SETTLE_DEPART_NAME = #{tStatisticsCurrentReportMarket.settleDepartName}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.declareMonth != null and tStatisticsCurrentReportMarket.declareMonth.trim() != ''">
                        AND a.declare_MONTH = #{tStatisticsCurrentReportMarket.declareMonth}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.empName != null and tStatisticsCurrentReportMarket.empName.trim() != ''">
                        AND a.EMP_NAME = #{tStatisticsCurrentReportMarket.empName}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.empIdcardType != null and tStatisticsCurrentReportMarket.empIdcardType.trim() != ''">
                        AND a.EMP_IDCARD_type = #{tStatisticsCurrentReportMarket.empIdcardType}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.empIdcard != null and tStatisticsCurrentReportMarket.empIdcard.trim() != ''">
                        AND a.EMP_IDCARD = #{tStatisticsCurrentReportMarket.empIdcard}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.createStart != null and tStatisticsCurrentReportMarket.createStart.trim() != ''">
                        AND a.CREATE_START = #{tStatisticsCurrentReportMarket.createStart}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.createEnd != null and tStatisticsCurrentReportMarket.createEnd.trim() != ''">
                        AND a.CREATE_END = #{tStatisticsCurrentReportMarket.createEnd}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.item != null and tStatisticsCurrentReportMarket.item.trim() != ''">
                        AND a.item = #{tStatisticsCurrentReportMarket.item}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.realSalary != null">
                        AND a.REAL_SALARY = #{tStatisticsCurrentReportMarket.realSalary}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.currentExpenses != null">
                        AND a.current_expenses = #{tStatisticsCurrentReportMarket.currentExpenses}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.currentTaxFreeIncome != null">
                        AND a.current_tax_free_income = #{tStatisticsCurrentReportMarket.currentTaxFreeIncome}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.costReduction != null">
                        AND a.cost_reduction = #{tStatisticsCurrentReportMarket.costReduction}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.specialDeduction != null">
                        AND a.special_deduction = #{tStatisticsCurrentReportMarket.specialDeduction}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.childEduinfoMoney != null">
                        AND a.child_eduInfo_money = #{tStatisticsCurrentReportMarket.childEduinfoMoney}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.housingRentalinfoMoney != null">
                        AND a.housing_rentalInfo_money = #{tStatisticsCurrentReportMarket.housingRentalinfoMoney}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.housingLoanInterestExpenseMoney != null">
                        AND a.housing_loan_Interest_expense_money = #{tStatisticsCurrentReportMarket.housingLoanInterestExpenseMoney}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.supportElderlyExpenseMoney != null">
                        AND a.support_elderly_expense_money = #{tStatisticsCurrentReportMarket.supportElderlyExpenseMoney}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.continuingEducationExpenseMoney != null">
                        AND a.continuing_education_expense_money = #{tStatisticsCurrentReportMarket.continuingEducationExpenseMoney}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.personalPensionMoney != null">
                        AND a.PERSONAL_PENSION_MONEY = #{tStatisticsCurrentReportMarket.personalPensionMoney}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.personalMedicalMoney != null">
                        AND a.PERSONAL_MEDICAL_MONEY = #{tStatisticsCurrentReportMarket.personalMedicalMoney}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.personalUnemploymentMoney != null">
                        AND a.PERSONAL_UNEMPLOYMENT_MONEY = #{tStatisticsCurrentReportMarket.personalUnemploymentMoney}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.personalBigmailmentMoney != null">
                        AND a.PERSONAL_BIGMAILMENT_MONEY = #{tStatisticsCurrentReportMarket.personalBigmailmentMoney}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.personalProvidentFee != null">
                        AND a.PERSONAL_PROVIDENT_FEE = #{tStatisticsCurrentReportMarket.personalProvidentFee}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.enterpriseAnnuity != null">
                        AND a.enterprise_annuity = #{tStatisticsCurrentReportMarket.enterpriseAnnuity}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.taxable != null">
                        AND a.taxable = #{tStatisticsCurrentReportMarket.taxable}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.nowTakingRisks != null">
                        AND a.now_taking_risks = #{tStatisticsCurrentReportMarket.nowTakingRisks}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.nowTaxDeferred != null">
                        AND a.now_tax_deferred = #{tStatisticsCurrentReportMarket.nowTaxDeferred}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.nowOther != null">
                        AND a.now_other = #{tStatisticsCurrentReportMarket.nowOther}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.allIncome != null">
                        AND a.all_income = #{tStatisticsCurrentReportMarket.allIncome}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.allOther != null">
                        AND a.all_other = #{tStatisticsCurrentReportMarket.allOther}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.allDonate != null">
                        AND a.all_donate = #{tStatisticsCurrentReportMarket.allDonate}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.taxFee != null">
                        AND a.tax_fee = #{tStatisticsCurrentReportMarket.taxFee}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.quickDeducation != null">
                        AND a.QUICK_DEDUCATION = #{tStatisticsCurrentReportMarket.quickDeducation}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.salaryTax != null">
                        AND a.salary_tax = #{tStatisticsCurrentReportMarket.salaryTax}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.allTaxDeduction != null">
                        AND a.all_tax_deduction = #{tStatisticsCurrentReportMarket.allTaxDeduction}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.allWithholdingTax != null">
                        AND a.all_withholding_tax = #{tStatisticsCurrentReportMarket.allWithholdingTax}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.allTaxPrepaid != null">
                        AND a.all_tax_prepaid = #{tStatisticsCurrentReportMarket.allTaxPrepaid}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.allTaxPayable != null">
                        AND a.all_tax_payable = #{tStatisticsCurrentReportMarket.allTaxPayable}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.remark != null and tStatisticsCurrentReportMarket.remark.trim() != ''">
                        AND a.remark = #{tStatisticsCurrentReportMarket.remark}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.unitId != null and tStatisticsCurrentReportMarket.unitId.trim() != ''">
                        AND a.UNIT_ID = #{tStatisticsCurrentReportMarket.unitId}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.unitNo != null and tStatisticsCurrentReportMarket.unitNo.trim() != ''">
                        AND a.UNIT_NO = #{tStatisticsCurrentReportMarket.unitNo}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.unitName != null and tStatisticsCurrentReportMarket.unitName.trim() != ''">
                        AND a.UNIT_NAME = #{tStatisticsCurrentReportMarket.unitName}
                    </if>
                    <if test="tStatisticsCurrentReportMarket.sumBabyMoney != null">
                        AND a.sum_baby_money = #{tStatisticsCurrentReportMarket.sumBabyMoney}
                    </if>
					<if test="tStatisticsCurrentReportMarket.sumPrivatePension != null">
                        AND a.SUM_PRIVATE_PENSION = #{tStatisticsCurrentReportMarket.sumPrivatePension}
                    </if>
        </if>
    </sql>
    <!--tStatisticsCurrentReportMarket简单分页查询-->
    <select id="getTStatisticsCurrentReportMarketPage" resultMap="tStatisticsCurrentReportMarketMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_statistics_current_report_market a
        <where>
            1=1
            <include refid="tStatisticsCurrentReportMarket_where"/>
        </where>
    </select>

	<!-- 删除-按申报月份 -->
	<delete id="deleteByYearMonth">
		DELETE FROM t_statistics_current_report_market WHERE DECLARE_MONTH = #{yearMonth}
	</delete>

	<!-- 查重 -->
	<select id="getCountByMonthAndTitle" resultType="java.lang.Integer">
		SELECT
			count(1)
		FROM t_statistics_current_report_market a
		where a.INVOICE_TITLE = #{declareTitle} and a.declare_MONTH = #{declareMonth}
	</select>

</mapper>