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

  <resultMap id="tAutoPaymentInfoMap" type="com.yifu.cloud.plus.v1.yifu.social.entity.TAutoPaymentInfo">
    <id property="id" column="ID"/>
    <result property="createMonth" column="CREATE_MONTH"/>
    <result property="dataOneFlag" column="DATA_ONE_FLAG"/>
    <result property="dataTwoFlag" column="DATA_TWO_FLAG"/>
    <result property="dataThreeFlag" column="DATA_THREE_FLAG"/>
    <result property="dataOneRemark" column="DATA_ONE_REMARK"/>
    <result property="dataTwoRemark" column="DATA_TWO_REMARK"/>
    <result property="dataThreeRemark" column="DATA_THREE_REMARK"/>
    <result property="systemReviewFlag" column="SYSTEM_REVIEW_FLAG"/>
    <result property="repeatReviewFlag" column="REPEAT_REVIEW_FLAG"/>
    <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="attaSrc" column="ATTA_SRC"/>
    <result property="attaUrl" column="ATTA_URL"/>
    <result property="attaUrlOne" column="ATTA_URL_ONE"/>
    <result property="attaUrlTwo" column="ATTA_URL_TWO"/>
    <result property="attaUrlThree" column="ATTA_URL_THREE"/>
    <result property="attaUrlFour" column="ATTA_URL_FOUR"/>
  </resultMap>
    <sql id="Base_Column_List">
                a.ID,
                a.CREATE_MONTH,
                a.DATA_ONE_FLAG,
				a.DATA_TWO_FLAG,
				a.DATA_THREE_FLAG,
				a.DATA_ONE_REMARK,
				a.DATA_TWO_REMARK,
				a.DATA_THREE_REMARK,
                a.SYSTEM_REVIEW_FLAG,
                a.REPEAT_REVIEW_FLAG,
                a.CREATE_BY,
                a.CREATE_NAME,
                a.CREATE_TIME,
                a.UPDATE_BY,
                a.UPDATE_TIME,
                a.ATTA_SRC,
                a.ATTA_URL,
                a.ATTA_URL_ONE,
                a.ATTA_URL_TWO,
                a.ATTA_URL_THREE,
                a.ATTA_URL_FOUR
	</sql>
    <sql id="tAutoPaymentInfo_where">
        <if test="tAutoPaymentInfo != null">
                    <if test="tAutoPaymentInfo.id != null and tAutoPaymentInfo.id.trim() != ''">
                        AND a.ID = #{tAutoPaymentInfo.id}
                    </if>
                    <if test="tAutoPaymentInfo.createMonth != null and tAutoPaymentInfo.createMonth.trim() != ''">
                        AND a.CREATE_MONTH = #{tAutoPaymentInfo.createMonth}
                    </if>
                    <if test="tAutoPaymentInfo.dataOneFlag != null and tAutoPaymentInfo.dataOneFlag.trim() != ''">
                        AND a.DATA_ONE_FLAG = #{tAutoPaymentInfo.dataOneFlag}
                    </if>
                    <if test="tAutoPaymentInfo.dataTwoFlag != null and tAutoPaymentInfo.dataTwoFlag.trim() != ''">
                        AND a.DATA_TWO_FLAG = #{tAutoPaymentInfo.dataTwoFlag}
                    </if>
                    <if test="tAutoPaymentInfo.dataThreeFlag != null and tAutoPaymentInfo.dataThreeFlag.trim() != ''">
                        AND a.DATA_THREE_FLAG = #{tAutoPaymentInfo.dataThreeFlag}
                    </if>
                    <if test="tAutoPaymentInfo.systemReviewFlag != null and tAutoPaymentInfo.systemReviewFlag.trim() != ''">
                        AND a.SYSTEM_REVIEW_FLAG = #{tAutoPaymentInfo.systemReviewFlag}
                    </if>
                    <if test="tAutoPaymentInfo.repeatReviewFlag != null and tAutoPaymentInfo.repeatReviewFlag.trim() != ''">
                        AND a.REPEAT_REVIEW_FLAG = #{tAutoPaymentInfo.repeatReviewFlag}
                    </if>
                    <if test="tAutoPaymentInfo.createBy != null and tAutoPaymentInfo.createBy.trim() != ''">
                        AND a.CREATE_BY = #{tAutoPaymentInfo.createBy}
                    </if>
                    <if test="tAutoPaymentInfo.createName != null and tAutoPaymentInfo.createName.trim() != ''">
                        AND a.CREATE_NAME = #{tAutoPaymentInfo.createName}
                    </if>
                    <if test="tAutoPaymentInfo.createTime != null">
                        AND a.CREATE_TIME = #{tAutoPaymentInfo.createTime}
                    </if>
                    <if test="tAutoPaymentInfo.updateBy != null and tAutoPaymentInfo.updateBy.trim() != ''">
                        AND a.UPDATE_BY = #{tAutoPaymentInfo.updateBy}
                    </if>
                    <if test="tAutoPaymentInfo.updateTime != null">
                        AND a.UPDATE_TIME = #{tAutoPaymentInfo.updateTime}
                    </if>
					<if test="tAutoPaymentInfo.createTimeStart != null">
						AND a.CREATE_TIME <![CDATA[ >= ]]> #{tAutoPaymentInfo.createTimeStart}
					</if>
					<if test="tAutoPaymentInfo.createTimeEnd != null">
						AND a.CREATE_TIME <![CDATA[ <= ]]> #{tAutoPaymentInfo.createTimeEnd}
					</if>
					<if test="tAutoPaymentInfo.updateTimeStart != null">
						AND a.UPDATE_TIME <![CDATA[ >= ]]> #{tAutoPaymentInfo.updateTimeStart}
					</if>
					<if test="tAutoPaymentInfo.updateTimeEnd != null">
						AND a.UPDATE_TIME <![CDATA[ <= ]]> #{tAutoPaymentInfo.updateTimeEnd}
					</if>
        </if>
    </sql>
    <!--tAutoPaymentInfo简单分页查询-->
    <select id="getTAutoPaymentInfoPage" resultMap="tAutoPaymentInfoMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_auto_payment_info a
        <where>
            1=1
            <include refid="tAutoPaymentInfo_where"/>
        </where>
    </select>
    <!--获取当前月的主表-->
    <select id="getThisMonthMainAuto" resultMap="tAutoPaymentInfoMap">
        SELECT
        	<include refid="Base_Column_List"/>
        FROM t_auto_payment_info a
        where a.CREATE_MONTH = DATE_FORMAT(now(),'%Y%m')
    </select>

    <!-- 重新办理，清空url -->
    <update id="setUrlToNullByRePayment" >
		update t_auto_payment_info a set a.ATTA_URL_ONE = null,a.ATTA_URL_TWO = null,a.ATTA_URL_THREE = null,a.ATTA_URL_FOUR = null where id = #{parentId}
    </update>

</mapper>
