<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gic.haoban.manage.service.dao.mapper.fee.TabHaobanQywxFeeAccountInterceptLogMapper">

    <resultMap type="com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeAccountInterceptLog"
               id="TabHaobanQywxFeeAccountInterceptLogMap">
        <result property="feeAccountInterceptId" column="fee_account_intercept_id" jdbcType="INTEGER"/>
        <result property="corpId" column="corp_id" jdbcType="VARCHAR"/>
        <result property="wxEnterpriseId" column="wx_enterprise_id" jdbcType="VARCHAR"/>
        <result property="wxUserId" column="wx_user_id" jdbcType="VARCHAR"/>
        <result property="staffId" column="staff_id" jdbcType="VARCHAR"/>
        <result property="qwCreateTime" column="qw_create_time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        fee_account_intercept_id
        , corp_id, wx_enterprise_id, wx_user_id, staff_id, qw_create_time
    </sql>


    <!--查询指定行数据-->
    <select id="queryAllByLimit" resultMap="TabHaobanQywxFeeAccountInterceptLogMap">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_qywx_fee_account_intercept_log
        <where>
            <if test="feeAccountInterceptId != null">
                and fee_account_intercept_id = #{feeAccountInterceptId}
            </if>
            <if test="corpId != null and corpId != ''">
                and corp_id = #{corpId}
            </if>
            <if test="wxEnterpriseId != null and wxEnterpriseId != ''">
                and wx_enterprise_id = #{wxEnterpriseId}
            </if>
            <if test="wxUserId != null and wxUserId != ''">
                and wx_user_id = #{wxUserId}
            </if>
            <if test="staffId != null and staffId != ''">
                and staff_id = #{staffId}
            </if>
            <if test="qwCreateTime != null">
                and qw_create_time = #{qwCreateTime}
            </if>
        </where>
        limit #{pageable.offset}, #{pageable.pageSize}
    </select>

    <!--新增所有列-->
    <insert id="insert" keyProperty="feeAccountId" useGeneratedKeys="true">
        insert into tab_haoban_qywx_fee_account_intercept_log(fee_account_intercept_id, corp_id, wx_enterprise_id, wx_user_id,
                                                              staff_id, qw_create_time)
        values (#{feeAccountInterceptId}, #{corpId}, #{wxEnterpriseId}, #{wxUserId}, #{staffId}, #{qwCreateTime})
    </insert>

    <insert id="insertBatch" keyProperty="feeAccountId" useGeneratedKeys="true">
        insert into tab_haoban_qywx_fee_account_intercept_log(fee_account_intercept_id, corp_id, wx_enterprise_id, wx_user_id,
        staff_id, qw_create_time)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.feeAccountInterceptId}, #{entity.corpId}, #{entity.wxEnterpriseId}, #{entity.wxUserId}, #{entity.staffId},
            #{entity.qwCreateTime})
        </foreach>
    </insert>


    <!--通过主键删除-->
    <delete id="deleteById">
        delete
        from tab_haoban_qywx_fee_account_intercept_log
        where fee_account_intercept_id = #{feeAccountInterceptId}
    </delete>


    <select id="queryByWxEnterpriseId" resultMap="TabHaobanQywxFeeAccountInterceptLogMap">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_qywx_fee_account_intercept_log
        where wx_enterprise_id = #{wxEnterpriseId}
        and DATE_SUB(CURDATE(), INTERVAL 1 DAY) <![CDATA[ <= ]]> date(qw_create_time)
    </select>

</mapper>

