<?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.social.mapper.TProvidentFundMapper">

  <resultMap id="tProvidentFundMap" type="com.yifu.cloud.plus.v1.yifu.social.entity.TProvidentFund">
    <id property="id" column="ID"/>
    <result property="providentHousehold" column="PROVIDENT_HOUSEHOLD"/>
	<result property="providentHouseholdName" column="PROVIDENT_HOUSEHOLD_NAME"/>
    <result property="providentStart" column="PROVIDENT_START"/>
    <result property="unitProvidengCardinal" column="UNIT_PROVIDENG_CARDINAL"/>
    <result property="personalProvidentCardinal" column="PERSONAL_PROVIDENT_CARDINAL"/>
    <result property="unitProvidentPer" column="UNIT_PROVIDENT_PER"/>
    <result property="personalProvidentPer" column="PERSONAL_PROVIDENT_PER"/>
    <result property="unitProvidentFee" column="UNIT_PROVIDENT_FEE"/>
    <result property="personalProvidentFee" column="PERSONAL_PROVIDENT_FEE"/>
    <result property="oldId" column="OLD_ID"/>
    <result property="auditStatus" column="AUDIT_STATUS"/>
    <result property="handleStatus" column="HANDLE_STATUS"/>
    <result property="draftStatus" column="DRAFT_STATUS"/>
    <result property="empId" column="EMP_ID"/>
    <result property="empNo" column="EMP_NO"/>
    <result property="empName" column="EMP_NAME"/>
    <result property="empIdcard" column="EMP_IDCARD"/>
    <result property="settleDomain" column="SETTLE_DOMAIN"/>
    <result property="settleDomainCode" column="SETTLE_DOMAIN_CODE"/>
    <result property="fundProvince" column="FUND_PROVINCE"/>
    <result property="fundCity" column="FUND_CITY"/>
    <result property="fundTown" column="FUND_TOWN"/>
    <result property="remark" column="REMARK"/>
    <result property="deleteFlag" column="DELETE_FLAG"/>
    <result property="fundBaseSetId" column="FUND_BASE_SET_ID"/>
    <result property="fundPayPoint" column="FUND_PAY_POINT"/>
    <result property="processInstId" column="PROCESS_INST_ID"/>
    <result property="auditUser" column="AUDIT_USER"/>
	  <result property="auditUserName" column="AUDIT_USER_NAME"/>
    <result property="auditTime" column="AUDIT_TIME"/>
    <result property="handleUser" column="HANDLE_USER"/>
	  <result property="handleUserName" column="HANDLE_USER_NAME"/>
    <result property="handleTime" column="HANDLE_TIME"/>
    <result property="applyUser" column="APPLY_USER"/>
    <result property="applyTime" column="APPLY_TIME"/>
    <result property="belongUnit" column="BELONG_UNIT"/>
    <result property="fundReduceDate" column="FUND_REDUCE_DATE"/>
    <result property="canOverpay" column="CAN_OVERPAY"/>
    <result property="overpayNumber" column="OVERPAY_NUMBER"/>
    <result property="insuranceIsLatestCardinality" column="INSURANCE_IS_LATEST_CARDINALITY"/>
    <result property="haveThisMonth" column="HAVE_THIS_MONTH"/>
    <result property="reduceHandleUser" column="REDUCE_HANDLE_USER"/>
    <result property="reduceHandleTime" column="REDUCE_HANDLE_TIME"/>
    <result property="trustRemark" column="TRUST_REMARK"/>
    <result property="reduceCan" column="REDUCE_CAN"/>
    <result property="inauguralTeam" column="INAUGURAL_TEAM"/>
    <result property="telecomNumber" column="TELECOM_NUMBER"/>
    <result property="createBy" column="CREATE_BY"/>
    <result property="updateBy" column="UPDATE_BY"/>
    <result property="createName" column="CREATE_NAME"/>
    <result property="updateTime" column="UPDATE_TIME"/>
	<result property="payPolicy" column="PAY_POLICY"/>
	<result property="lowerLimit" column="LOWER_LIMIT"/>
	<result property="upperLimit" column="UPPER_LIMIT"/>
  </resultMap>
    <sql id="Base_Column_List">
                a.ID,
                a.PROVIDENT_HOUSEHOLD,
				a.PROVIDENT_HOUSEHOLD_NAME,
                a.PROVIDENT_START,
                a.UNIT_PROVIDENG_CARDINAL,
                a.PERSONAL_PROVIDENT_CARDINAL,
                a.UNIT_PROVIDENT_PER,
                a.PERSONAL_PROVIDENT_PER,
                a.UNIT_PROVIDENT_FEE,
                a.PERSONAL_PROVIDENT_FEE,
                a.OLD_ID,
                a.AUDIT_STATUS,
                a.HANDLE_STATUS,
                a.DRAFT_STATUS,
                a.EMP_ID,
                a.EMP_NO,
                a.EMP_NAME,
                a.EMP_IDCARD,
                a.SETTLE_DOMAIN,
                a.FUND_PROVINCE,
                a.FUND_CITY,
                a.FUND_TOWN,
                a.REMARK,
                a.DELETE_FLAG,
                a.FUND_BASE_SET_ID,
                a.FUND_PAY_POINT,
                a.PROCESS_INST_ID,
                a.AUDIT_USER,
                a.AUDIT_TIME,
                a.HANDLE_USER,
                a.HANDLE_TIME,
                a.APPLY_USER,
                a.APPLY_TIME,
                a.BELONG_UNIT,
                a.FUND_REDUCE_DATE,
                a.CAN_OVERPAY,
                a.OVERPAY_NUMBER,
                a.INSURANCE_IS_LATEST_CARDINALITY,
                a.HAVE_THIS_MONTH,
                a.REDUCE_HANDLE_USER,
                a.REDUCE_HANDLE_TIME,
                a.TRUST_REMARK,
                a.REDUCE_CAN,
                a.INAUGURAL_TEAM,
                a.TELECOM_NUMBER,
                a.CREATE_BY,
                a.UPDATE_BY,
                a.CREATE_NAME,
                a.UPDATE_TIME,
				a.PAY_POLICY,
				a.LOWER_LIMIT,
				a.UPPER_LIMIT
    </sql>
    <sql id="tProvidentFund_where">
        <if test="tProvidentFund != null">
                    <if test="tProvidentFund.id != null and tProvidentFund.id.trim() != ''">
                        AND a.ID = #{tProvidentFund.id}
                    </if>
                    <if test="tProvidentFund.providentHousehold != null and tProvidentFund.providentHousehold.trim() != ''">
                        AND a.PROVIDENT_HOUSEHOLD = #{tProvidentFund.providentHousehold}
                    </if>
                    <if test="tProvidentFund.providentStart != null">
                        AND a.PROVIDENT_START = #{tProvidentFund.providentStart}
                    </if>
                    <if test="tProvidentFund.unitProvidengCardinal != null">
                        AND a.UNIT_PROVIDENG_CARDINAL = #{tProvidentFund.unitProvidengCardinal}
                    </if>
                    <if test="tProvidentFund.personalProvidentCardinal != null">
                        AND a.PERSONAL_PROVIDENT_CARDINAL = #{tProvidentFund.personalProvidentCardinal}
                    </if>
                    <if test="tProvidentFund.unitProvidentPer != null">
                        AND a.UNIT_PROVIDENT_PER = #{tProvidentFund.unitProvidentPer}
                    </if>
                    <if test="tProvidentFund.personalProvidentPer != null">
                        AND a.PERSONAL_PROVIDENT_PER = #{tProvidentFund.personalProvidentPer}
                    </if>
                    <if test="tProvidentFund.unitProvidentFee != null">
                        AND a.UNIT_PROVIDENT_FEE = #{tProvidentFund.unitProvidentFee}
                    </if>
                    <if test="tProvidentFund.personalProvidentFee != null">
                        AND a.PERSONAL_PROVIDENT_FEE = #{tProvidentFund.personalProvidentFee}
                    </if>
                    <if test="tProvidentFund.oldId != null and tProvidentFund.oldId.trim() != ''">
                        AND a.OLD_ID = #{tProvidentFund.oldId}
                    </if>
                    <if test="tProvidentFund.auditStatus != null and tProvidentFund.auditStatus.trim() != ''">
                        AND a.AUDIT_STATUS = #{tProvidentFund.auditStatus}
                    </if>
                    <if test="tProvidentFund.handleStatus != null and tProvidentFund.handleStatus.trim() != ''">
                        AND a.HANDLE_STATUS = #{tProvidentFund.handleStatus}
                    </if>
                    <if test="tProvidentFund.draftStatus != null and tProvidentFund.draftStatus.trim() != ''">
                        AND a.DRAFT_STATUS = #{tProvidentFund.draftStatus}
                    </if>
                    <if test="tProvidentFund.empId != null and tProvidentFund.empId.trim() != ''">
                        AND a.EMP_ID = #{tProvidentFund.empId}
                    </if>
                    <if test="tProvidentFund.empNo != null and tProvidentFund.empNo.trim() != ''">
                        AND a.EMP_NO = #{tProvidentFund.empNo}
                    </if>
                    <if test="tProvidentFund.empName != null and tProvidentFund.empName.trim() != ''">
                        AND a.EMP_NAME = #{tProvidentFund.empName}
                    </if>
                    <if test="tProvidentFund.empIdcard != null and tProvidentFund.empIdcard.trim() != ''">
                        AND a.EMP_IDCARD = #{tProvidentFund.empIdcard}
                    </if>
                    <if test="tProvidentFund.settleDomain != null and tProvidentFund.settleDomain.trim() != ''">
                        AND a.SETTLE_DOMAIN = #{tProvidentFund.settleDomain}
                    </if>
                    <if test="tProvidentFund.fundProvince != null and tProvidentFund.fundProvince.trim() != ''">
                        AND a.FUND_PROVINCE = #{tProvidentFund.fundProvince}
                    </if>
                    <if test="tProvidentFund.fundCity != null and tProvidentFund.fundCity.trim() != ''">
                        AND a.FUND_CITY = #{tProvidentFund.fundCity}
                    </if>
                    <if test="tProvidentFund.fundTown != null and tProvidentFund.fundTown.trim() != ''">
                        AND a.FUND_TOWN = #{tProvidentFund.fundTown}
                    </if>
                    <if test="tProvidentFund.remark != null and tProvidentFund.remark.trim() != ''">
                        AND a.REMARK = #{tProvidentFund.remark}
                    </if>
                    <if test="tProvidentFund.deleteFlag != null and tProvidentFund.deleteFlag.trim() != ''">
                        AND a.DELETE_FLAG = #{tProvidentFund.deleteFlag}
                    </if>
                    <if test="tProvidentFund.fundBaseSetId != null and tProvidentFund.fundBaseSetId.trim() != ''">
                        AND a.FUND_BASE_SET_ID = #{tProvidentFund.fundBaseSetId}
                    </if>
                    <if test="tProvidentFund.fundPayPoint != null and tProvidentFund.fundPayPoint.trim() != ''">
                        AND a.FUND_PAY_POINT = #{tProvidentFund.fundPayPoint}
                    </if>
                    <if test="tProvidentFund.processInstId != null and tProvidentFund.processInstId.trim() != ''">
                        AND a.PROCESS_INST_ID = #{tProvidentFund.processInstId}
                    </if>
                    <if test="tProvidentFund.auditUser != null and tProvidentFund.auditUser.trim() != ''">
                        AND a.AUDIT_USER = #{tProvidentFund.auditUser}
                    </if>
                    <if test="tProvidentFund.auditTime != null">
                        AND a.AUDIT_TIME = #{tProvidentFund.auditTime}
                    </if>
                    <if test="tProvidentFund.handleUser != null and tProvidentFund.handleUser.trim() != ''">
                        AND a.HANDLE_USER = #{tProvidentFund.handleUser}
                    </if>
                    <if test="tProvidentFund.handleTime != null">
                        AND a.HANDLE_TIME = #{tProvidentFund.handleTime}
                    </if>
                    <if test="tProvidentFund.applyUser != null and tProvidentFund.applyUser.trim() != ''">
                        AND a.APPLY_USER = #{tProvidentFund.applyUser}
                    </if>
                    <if test="tProvidentFund.applyTime != null">
                        AND a.APPLY_TIME = #{tProvidentFund.applyTime}
                    </if>
                    <if test="tProvidentFund.belongUnit != null and tProvidentFund.belongUnit.trim() != ''">
                        AND a.BELONG_UNIT = #{tProvidentFund.belongUnit}
                    </if>
                    <if test="tProvidentFund.fundReduceDate != null">
                        AND a.FUND_REDUCE_DATE = #{tProvidentFund.fundReduceDate}
                    </if>
                    <if test="tProvidentFund.canOverpay != null and tProvidentFund.canOverpay.trim() != ''">
                        AND a.CAN_OVERPAY = #{tProvidentFund.canOverpay}
                    </if>
                    <if test="tProvidentFund.overpayNumber != null">
                        AND a.OVERPAY_NUMBER = #{tProvidentFund.overpayNumber}
                    </if>
                    <if test="tProvidentFund.insuranceIsLatestCardinality != null and tProvidentFund.insuranceIsLatestCardinality.trim() != ''">
                        AND a.INSURANCE_IS_LATEST_CARDINALITY = #{tProvidentFund.insuranceIsLatestCardinality}
                    </if>
                    <if test="tProvidentFund.haveThisMonth != null and tProvidentFund.haveThisMonth.trim() != ''">
                        AND a.HAVE_THIS_MONTH = #{tProvidentFund.haveThisMonth}
                    </if>
                    <if test="tProvidentFund.reduceHandleUser != null and tProvidentFund.reduceHandleUser.trim() != ''">
                        AND a.REDUCE_HANDLE_USER = #{tProvidentFund.reduceHandleUser}
                    </if>
                    <if test="tProvidentFund.reduceHandleTime != null">
                        AND a.REDUCE_HANDLE_TIME = #{tProvidentFund.reduceHandleTime}
                    </if>
                    <if test="tProvidentFund.trustRemark != null and tProvidentFund.trustRemark.trim() != ''">
                        AND a.TRUST_REMARK = #{tProvidentFund.trustRemark}
                    </if>
                    <if test="tProvidentFund.reduceCan != null and tProvidentFund.reduceCan.trim() != ''">
                        AND a.REDUCE_CAN = #{tProvidentFund.reduceCan}
                    </if>
                    <if test="tProvidentFund.inauguralTeam != null and tProvidentFund.inauguralTeam.trim() != ''">
                        AND a.INAUGURAL_TEAM = #{tProvidentFund.inauguralTeam}
                    </if>
                    <if test="tProvidentFund.telecomNumber != null and tProvidentFund.telecomNumber.trim() != ''">
                        AND a.TELECOM_NUMBER = #{tProvidentFund.telecomNumber}
                    </if>
                    <if test="tProvidentFund.createBy != null and tProvidentFund.createBy.trim() != ''">
                        AND a.CREATE_BY = #{tProvidentFund.createBy}
                    </if>
                    <if test="tProvidentFund.updateBy != null and tProvidentFund.updateBy.trim() != ''">
                        AND a.UPDATE_BY = #{tProvidentFund.updateBy}
                    </if>
                    <if test="tProvidentFund.createName != null and tProvidentFund.createName.trim() != ''">
                        AND a.CREATE_NAME = #{tProvidentFund.createName}
                    </if>
                    <if test="tProvidentFund.updateTime != null">
                        AND a.UPDATE_TIME = #{tProvidentFund.updateTime}
                    </if>
        </if>
    </sql>
    <!--tProvidentFund简单分页查询-->
    <select id="getTProvidentFundPage" resultMap="tProvidentFundMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_provident_fund a
        <where>
            1=1
            <include refid="tProvidentFund_where"/>
        </where>
    </select>

	<update id="updateFundInfoById">
		update t_provident_fund
		<trim prefix="set" suffixOverrides=",">
			<if test="tProvidentFund.handleStatus != null">HANDLE_STATUS=#{tProvidentFund.handleStatus},</if>
			<if test="tProvidentFund.reduceHandleTime != null">REDUCE_HANDLE_TIME=#{tProvidentFund.reduceHandleTime},</if>
			<if test="tProvidentFund.reduceHandleUser != null">REDUCE_HANDLE_USER=#{tProvidentFund.reduceHandleUser},</if>
			<if test="tProvidentFund.fundReduceDate != null">FUND_REDUCE_DATE=#{tProvidentFund.fundReduceDate},</if>
			<if test="tProvidentFund.reduceCan != null">REDUCE_CAN=#{tProvidentFund.reduceCan},</if>
			<if test="tProvidentFund.handleTime != null">HANDLE_TIME=#{tProvidentFund.handleTime},</if>
			<if test="tProvidentFund.handleUser != null">HANDLE_USER=#{tProvidentFund.handleUser},</if>
		</trim>
		WHERE id=#{tProvidentFund.id}
	</update>

	<update id="updateByIdOfAudit">
		update t_provident_fund
		<trim prefix="set" suffixOverrides=",">
			<if test="tProvidentFund.reduceCan != null">REDUCE_CAN=#{tProvidentFund.reduceCan},</if>
			<if test="tProvidentFund.auditTime != null">AUDIT_TIME=#{tProvidentFund.auditTime},</if>
			<if test="tProvidentFund.auditUser != null">AUDIT_USER=#{tProvidentFund.auditUser},</if>
			<if test="tProvidentFund.auditUserName != null">AUDIT_USER_NAME=#{tProvidentFund.auditUserName},</if>
			<if test="tProvidentFund.auditStatus != null">AUDIT_STATUS=#{tProvidentFund.auditStatus},</if>
			<if test="tProvidentFund.deleteFlag != null">DELETE_FLAG=#{tProvidentFund.deleteFlag},</if>
		</trim>
		WHERE id=#{tProvidentFund.id}
	</update>
</mapper>