<?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="jnpf.attendance.mapper.EnableBalanceMapper">

    <select id="getOvertimeSalary" resultType="jnpf.model.attendance.vo.attendance.OvertimeSalaryHoursVo">
        SELECT
        F_UserId userId,
        SUM(CASE WHEN F_OvertimeType = 1 THEN F_Balance ELSE 0 END) AS weekdayOvertimeSalaryDays,
        SUM(CASE WHEN F_OvertimeType = 3 THEN F_Balance ELSE 0 END) AS holidaysOvertimeSalaryDays,
        SUM(CASE WHEN F_OvertimeType = 2 THEN F_Balance ELSE 0 END) AS publicHolidaysOvertimeSalaryDays
        FROM ftb_attendance_enable_balance
        WHERE F_UserId IN
        <foreach item="item" collection="userIds" separator="," open="(" close=")" index="">
            #{item}
        </foreach>
        <if test="startDate != null and endDate != null ">
            and F_Day between #{startDate} and #{endDate}
        </if>
        GROUP BY F_UserId
    </select>
    <select id="getOvertimeSalaryJson" resultType="jnpf.model.attendance.vo.attendance.OvertimeSalaryHoursJsonVo">
        SELECT
        F_UserId userId,
        F_Balance AS holidaysOvertimeSalaryDays,
        F_FestivalStr festivalStr
        FROM ftb_attendance_enable_balance
        WHERE
        F_OvertimeType = 3
        and F_FestivalStr is not null
        and F_UserId IN
        <foreach item="item" collection="userIds" separator="," open="(" close=")" index="">
            #{item}
        </foreach>
        <if test="startDate != null and endDate != null ">
            and F_Day between #{startDate} and #{endDate}
        </if>
    </select>
</mapper>
