<?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.TAutoPaymentDetailMapper">

  <resultMap id="tAutoPaymentDetailMap" type="com.yifu.cloud.plus.v1.yifu.social.entity.TAutoPaymentDetail">
    <id property="id" column="ID"/>
    <result property="repeatHandleFlag" column="REPEAT_HANDLE_FLAG"/>
    <result property="empName" column="EMP_NAME"/>
    <result property="certType" column="CERT_TYPE"/>
    <result property="certNum" column="CERT_NUM"/>
    <result property="paymentSalary" column="PAYMENT_SALARY"/>
    <result property="paymentBase" column="PAYMENT_BASE"/>
    <result property="rate" column="RATE"/>
    <result property="payLimit" column="PAY_LIMIT"/>
    <result property="empCode" column="EMP_CODE"/>
    <result property="insuranceType" column="INSURANCE_TYPE"/>
    <result property="payMonth" column="PAY_MONTH"/>
    <result property="createMonth" column="CREATE_MONTH"/>
    <result property="socialAddress" column="SOCIAL_ADDRESS"/>
    <result property="socialSecurityAccount" column="SOCIAL_SECURITY_ACCOUNT"/>
    <result property="createBy" column="CREATE_BY"/>
    <result property="createName" column="CREATE_NAME"/>
    <result property="createTime" column="CREATE_TIME"/>
    <result property="updateBy" column="UPDATE_BY"/>
    <result property="updateTime" column="UPDATE_TIME"/>
    <result property="parentId" column="PARENT_ID"/>
    <result property="sourceType" column="SOURCE_TYPE"/>
  </resultMap>
    <sql id="Base_Column_List">
                a.ID,
                a.REPEAT_HANDLE_FLAG,
                a.EMP_NAME,
                a.CERT_TYPE,
                a.CERT_NUM,
                a.PAYMENT_SALARY,
                a.PAYMENT_BASE,
                a.RATE,
                a.PAY_LIMIT,
                a.EMP_CODE,
                a.INSURANCE_TYPE,
                a.PAY_MONTH,
                a.CREATE_MONTH,
                a.SOCIAL_ADDRESS,
                a.SOCIAL_SECURITY_ACCOUNT,
                a.CREATE_BY,
                a.CREATE_NAME,
                a.CREATE_TIME,
                a.UPDATE_BY,
                a.UPDATE_TIME,
                a.SOURCE_TYPE,
                a.PARENT_ID
    </sql>
    <sql id="tAutoPaymentDetail_where">
        <if test="tAutoPaymentDetail != null">
                    <if test="tAutoPaymentDetail.id != null and tAutoPaymentDetail.id.trim() != ''">
                        AND a.ID = #{tAutoPaymentDetail.id}
                    </if>
                    <if test="tAutoPaymentDetail.repeatHandleFlag != null and tAutoPaymentDetail.repeatHandleFlag.trim() != ''">
                        AND a.REPEAT_HANDLE_FLAG = #{tAutoPaymentDetail.repeatHandleFlag}
                    </if>
                    <if test="tAutoPaymentDetail.empName != null and tAutoPaymentDetail.empName.trim() != ''">
                        AND a.EMP_NAME = #{tAutoPaymentDetail.empName}
                    </if>
                    <if test="tAutoPaymentDetail.certType != null and tAutoPaymentDetail.certType.trim() != ''">
                        AND a.CERT_TYPE = #{tAutoPaymentDetail.certType}
                    </if>
                    <if test="tAutoPaymentDetail.certNum != null and tAutoPaymentDetail.certNum.trim() != ''">
                        AND a.CERT_NUM = #{tAutoPaymentDetail.certNum}
                    </if>
                    <if test="tAutoPaymentDetail.paymentSalary != null">
                        AND a.PAYMENT_SALARY = #{tAutoPaymentDetail.paymentSalary}
                    </if>
                    <if test="tAutoPaymentDetail.paymentBase != null">
                        AND a.PAYMENT_BASE = #{tAutoPaymentDetail.paymentBase}
                    </if>
                    <if test="tAutoPaymentDetail.rate != null and tAutoPaymentDetail.rate.trim() != ''">
                        AND a.RATE = #{tAutoPaymentDetail.rate}
                    </if>
                    <if test="tAutoPaymentDetail.payLimit != null">
                        AND a.PAY_LIMIT = #{tAutoPaymentDetail.payLimit}
                    </if>
                    <if test="tAutoPaymentDetail.empCode != null and tAutoPaymentDetail.empCode.trim() != ''">
                        AND a.EMP_CODE = #{tAutoPaymentDetail.empCode}
                    </if>
                    <if test="tAutoPaymentDetail.insuranceType != null and tAutoPaymentDetail.insuranceType.trim() != ''">
                        AND a.INSURANCE_TYPE = #{tAutoPaymentDetail.insuranceType}
                    </if>
                    <if test="tAutoPaymentDetail.payMonth != null and tAutoPaymentDetail.payMonth.trim() != ''">
                        AND a.PAY_MONTH = #{tAutoPaymentDetail.payMonth}
                    </if>
                    <if test="tAutoPaymentDetail.createMonth != null and tAutoPaymentDetail.createMonth.trim() != ''">
                        AND a.CREATE_MONTH = #{tAutoPaymentDetail.createMonth}
                    </if>
                    <if test="tAutoPaymentDetail.socialAddress != null and tAutoPaymentDetail.socialAddress.trim() != ''">
                        AND a.SOCIAL_ADDRESS = #{tAutoPaymentDetail.socialAddress}
                    </if>
                    <if test="tAutoPaymentDetail.socialSecurityAccount != null and tAutoPaymentDetail.socialSecurityAccount.trim() != ''">
                        AND a.SOCIAL_SECURITY_ACCOUNT = #{tAutoPaymentDetail.socialSecurityAccount}
                    </if>
                    <if test="tAutoPaymentDetail.createBy != null and tAutoPaymentDetail.createBy.trim() != ''">
                        AND a.CREATE_BY = #{tAutoPaymentDetail.createBy}
                    </if>
                    <if test="tAutoPaymentDetail.createName != null and tAutoPaymentDetail.createName.trim() != ''">
                        AND a.CREATE_NAME = #{tAutoPaymentDetail.createName}
                    </if>
                    <if test="tAutoPaymentDetail.createTime != null">
                        AND a.CREATE_TIME = #{tAutoPaymentDetail.createTime}
                    </if>
                    <if test="tAutoPaymentDetail.updateBy != null and tAutoPaymentDetail.updateBy.trim() != ''">
                        AND a.UPDATE_BY = #{tAutoPaymentDetail.updateBy}
                    </if>
                    <if test="tAutoPaymentDetail.updateTime != null">
                        AND a.UPDATE_TIME = #{tAutoPaymentDetail.updateTime}
                    </if>
                    <if test="tAutoPaymentDetail.parentId != null and tAutoPaymentDetail.parentId.trim() != ''">
                        AND a.PARENT_ID = #{tAutoPaymentDetail.parentId}
                    </if>
        </if>
    </sql>
    <!--tAutoPaymentDetail简单分页查询-->
    <select id="getTAutoPaymentDetailPage" resultMap="tAutoPaymentDetailMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_auto_payment_detail a
        <where>
            1=1
            <include refid="tAutoPaymentDetail_where"/>
        </where>
    </select>

	<delete id="deleteByParentId">
		delete from t_auto_payment_detail where PARENT_ID = #{parentId} and SOURCE_TYPE = #{sourceType}
	</delete>


	<!--tAutoPaymentDetail简单分页查询-->
	<select id="getListByParentId" resultMap="tAutoPaymentDetailMap">
		SELECT
			<include refid="Base_Column_List"/>
		FROM t_auto_payment_detail a
		where PARENT_ID = #{parentId} and REPEAT_HANDLE_FLAG = '0'
		order by a.SOURCE_TYPE,a.CERT_NUM
	</select>

	<!--tAutoPaymentDetail简单分页查询-->
	<select id="getCountByParentId" resultType="java.lang.Integer">
		SELECT
			count(1)
		FROM t_auto_payment_detail a
		where PARENT_ID = #{parentId} and REPEAT_HANDLE_FLAG = '0'
	</select>

</mapper>