<?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.staffing.custom.mapper.StEmployeeFundRecordMapper">
<resultMap type="StEmployeeFundRecord" id="StEmployeeFundRecordResult">
        <result property="id"    column="id"    />
        <result property="taskId"    column="task_id"    />
        <result property="taskName"    column="task_name"    />
        <result property="taskDate"    column="task_date"    />
        <result property="employeeId"    column="employee_id"    />
        <result property="employeeName"    column="employee_name"    />
        <result property="phone"    column="phone"    />
        <result property="idCard"    column="id_card"    />
        <result property="dayPrice"    column="day_price"    />
        <result property="shouldPrice"    column="should_price"    />
        <result property="realPrice"    column="real_price"    />
        <result property="payWay"    column="pay_way"    />
        <result property="payAccount"    column="pay_account"    />
        <result property="payTime"    column="pay_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="payStatus"    column="pay_status"    />
        <result property="transferNo"    column="transfer_no"    />
    </resultMap>

    <sql id="selectStEmployeeFundRecordVo">
        select id, task_id, task_name, task_date, employee_id, employee_name
        , phone, id_card, day_price, should_price, real_price, pay_way
        , pay_account, pay_time, update_time, pay_status, transfer_no from st_employee_fund_record
    </sql>

    <select id="selectStEmployeeFundRecordList" parameterType="StEmployeeFundRecord" resultMap="StEmployeeFundRecordResult">
        <include refid="selectStEmployeeFundRecordVo"/>
        <where>  
            <if test="taskName != null  and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
            <if test="taskDate != null "> and task_date = #{taskDate}</if>
            <if test="employeeName != null  and employeeName != ''"> and employee_name like concat('%', #{employeeName}, '%')</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="idCard != null  and idCard != ''"> and id_card = #{idCard}</if>
            <if test="payStatus != null "> and pay_status = #{payStatus}</if>
            <if test="taskId != null "> and task_id = #{taskId}</if>
            <if test="transferNo != null "> and transfer_no = #{transferNo}</if>
        </where>
    </select>
    
    <select id="selectStEmployeeFundRecordById" parameterType="Long" resultMap="StEmployeeFundRecordResult">
        <include refid="selectStEmployeeFundRecordVo"/>
        where id = #{id}
    </select>

    <select id="selectStEmployeeFundRecordBytransferNo" parameterType="Long" resultMap="StEmployeeFundRecordResult">
        <include refid="selectStEmployeeFundRecordVo"/>
        where transfer_no = #{transferNo}
    </select>

    <select id="selectStEmployeeFundRecordByUidAndTaskId" parameterType="Long" resultMap="StEmployeeFundRecordResult">
        <include refid="selectStEmployeeFundRecordVo"/>
        where task_id = #{taskId}
        and employee_id = #{employeeId}
    </select>

    <select id="selectStEmployeeFundRecordByTaskIds"  resultMap="StEmployeeFundRecordResult">
        <include refid="selectStEmployeeFundRecordVo"/>
        <where>
            <if test="taskIds != null ">
                and task_id in
                <foreach collection="taskIds" index="index" item="item" open="(" separator="," close=")">
                    (#{item})
                </foreach>
            </if>
        </where>
    </select>


    <insert id="insertStEmployeeFundRecord" parameterType="StEmployeeFundRecord" useGeneratedKeys="true" keyProperty="id">
        insert into st_employee_fund_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskId != null">task_id,</if>
            <if test="taskName != null">task_name,</if>
            <if test="taskDate != null">task_date,</if>
            <if test="employeeId != null">employee_id,</if>
            <if test="employeeName != null">employee_name,</if>
            <if test="phone != null">phone,</if>
            <if test="idCard != null">id_card,</if>
            <if test="dayPrice != null">day_price,</if>
            <if test="shouldPrice != null">should_price,</if>
            <if test="realPrice != null">real_price,</if>
            <if test="payWay != null">pay_way,</if>
            <if test="payAccount != null">pay_account,</if>
            <if test="payTime != null">pay_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="payStatus != null">pay_status,</if>
            <if test="transferNo != null">transfer_no,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskId != null">#{taskId},</if>
            <if test="taskName != null">#{taskName},</if>
            <if test="taskDate != null">#{taskDate},</if>
            <if test="employeeId != null">#{employeeId},</if>
            <if test="employeeName != null">#{employeeName},</if>
            <if test="phone != null">#{phone},</if>
            <if test="idCard != null">#{idCard},</if>
            <if test="dayPrice != null">#{dayPrice},</if>
            <if test="shouldPrice != null">#{shouldPrice},</if>
            <if test="realPrice != null">#{realPrice},</if>
            <if test="payWay != null">#{payWay},</if>
            <if test="payAccount != null">#{payAccount},</if>
            <if test="payTime != null">#{payTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="payStatus != null">#{payStatus},</if>
            <if test="transferNo != null">#{transferNo},</if>
         </trim>
    </insert>

    <update id="updateStEmployeeFundRecord" parameterType="StEmployeeFundRecord">
        update st_employee_fund_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskId != null">task_id = #{taskId},</if>
            <if test="taskName != null">task_name = #{taskName},</if>
            <if test="taskDate != null">task_date = #{taskDate},</if>
            <if test="employeeId != null">employee_id = #{employeeId},</if>
            <if test="employeeName != null">employee_name = #{employeeName},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="idCard != null">id_card = #{idCard},</if>
            <if test="dayPrice != null">day_price = #{dayPrice},</if>
            <if test="shouldPrice != null">should_price = #{shouldPrice},</if>
            <if test="realPrice != null">real_price = #{realPrice},</if>
            <if test="payWay != null">pay_way = #{payWay},</if>
            <if test="payAccount != null">pay_account = #{payAccount},</if>
            <if test="payTime != null">pay_time = #{payTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="payStatus != null">pay_status = #{payStatus},</if>
            <if test="transferNo != null">transfer_no = #{transferNo},</if>
        </trim>
        where id = #{id}

    </update>

    <update id="updateStEmployeeFundRecordByEmId" parameterType="StEmployeeFundRecord">
        update st_employee_fund_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskId != null">task_id = #{taskId},</if>
            <if test="taskName != null">task_name = #{taskName},</if>
            <if test="taskDate != null">task_date = #{taskDate},</if>
            <if test="employeeId != null">employee_id = #{employeeId},</if>
            <if test="employeeName != null">employee_name = #{employeeName},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="idCard != null">id_card = #{idCard},</if>
            <if test="dayPrice != null">day_price = #{dayPrice},</if>
            <if test="shouldPrice != null">should_price = #{shouldPrice},</if>
            <if test="realPrice != null">real_price = #{realPrice},</if>
            <if test="payWay != null">pay_way = #{payWay},</if>
            <if test="payAccount != null">pay_account = #{payAccount},</if>
            <if test="payTime != null">pay_time = #{payTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="payStatus != null">pay_status = #{payStatus},</if>
            <if test="transferNo != null">transfer_no = #{transferNo},</if>
        </trim>
        where  employee_id = #{employeeId}
    </update>
    <update id="updateStEmployeeFundRecordByTaskAndUid" parameterType="StEmployeeFundRecord">
        update st_employee_fund_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskId != null">task_id = #{taskId},</if>
            <if test="taskName != null">task_name = #{taskName},</if>
            <if test="taskDate != null">task_date = #{taskDate},</if>
            <if test="employeeId != null">employee_id = #{employeeId},</if>
            <if test="employeeName != null">employee_name = #{employeeName},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="idCard != null">id_card = #{idCard},</if>
            <if test="dayPrice != null">day_price = #{dayPrice},</if>
            <if test="shouldPrice != null">should_price = #{shouldPrice},</if>
            <if test="realPrice != null">real_price = #{realPrice},</if>
            <if test="payWay != null">pay_way = #{payWay},</if>
            <if test="payAccount != null">pay_account = #{payAccount},</if>
            <if test="payTime != null">pay_time = #{payTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="payStatus != null">pay_status = #{payStatus},</if>
            <if test="transferNo != null">transfer_no = #{transferNo},</if>
        </trim>
        where task_id = #{taskId}
        and employee_id = #{employeeId}
    </update>
    <update id="updateStEmployeeFundRecordByTask" parameterType="StEmployeeFundRecord">
        update st_employee_fund_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskId != null">task_id = #{taskId},</if>
            <if test="taskName != null">task_name = #{taskName},</if>
            <if test="taskDate != null">task_date = #{taskDate},</if>
            <if test="employeeId != null">employee_id = #{employeeId},</if>
            <if test="employeeName != null">employee_name = #{employeeName},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="idCard != null">id_card = #{idCard},</if>
            <if test="dayPrice != null">day_price = #{dayPrice},</if>
            <if test="shouldPrice != null">should_price = #{shouldPrice},</if>
            <if test="realPrice != null">real_price = #{realPrice},</if>
            <if test="payWay != null">pay_way = #{payWay},</if>
            <if test="payAccount != null">pay_account = #{payAccount},</if>
            <if test="payTime != null">pay_time = #{payTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="payStatus != null">pay_status = #{payStatus},</if>
            <if test="transferNo != null">transfer_no = #{transferNo},</if>
        </trim>
        where task_id = #{taskId}
    </update>
    <delete id="deleteStEmployeeFundRecordById" parameterType="Long">
        delete from st_employee_fund_record where id = #{id}
    </delete>

    <delete id="deleteStEmployeeFundRecordByIds" parameterType="String">
        delete from st_employee_fund_record where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deleteStEmployeeFundRecordByUidAndTaskId">
        delete from st_employee_fund_record
        where task_id = #{taskId}
        and employee_id = #{employeeId}
    </delete>

</mapper>