<?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.sqx.modules.userSign.dao.UserSignRecordDao">

    <select id="getNoRecordTask" resultType="Long">
        SELECT
            sign.id
        FROM
            user_sign_record sign
                LEFT JOIN task_center_record cenRecord ON sign.id = cenRecord.source_id
        WHERE
            sign.`DAY` = 7
          AND sign.user_id = #{userId}
          and sign.create_time &gt; #{time}
          AND cenRecord.id IS NULL
        order by sign.create_time asc
    </select>

    <select id="getTaskWCount" resultType="com.sqx.modules.userSign.entity.UserSignRecord">
        SELECT
            sign.id as id,
            #{wCount} - COUNT(CASE WHEN spRecord.source_id IS NOT NULL THEN 1 END) AS `day`
        FROM
            user_sign_record sign
                LEFT JOIN disc_spinning_record spRecord ON sign.id = spRecord.source_id
        WHERE
                sign.`DAY` = 7
            AND sign.user_id = #{userId}
            AND sign.create_time &gt; #{time}
            <if test="ids!= null and ids.size() > 0">
                AND sign.id in
                <foreach collection="ids" item="id" open="(" close=")" separator=",">
                    #{id}
                </foreach>
            </if>
        GROUP BY sign.id
        order by sign.create_time asc
    </select>

    <select id="getWSignCount" resultType="Integer">
        SELECT `day`
        FROM user_sign_record
        WHERE user_id = #{userId}
          and create_time &gt; #{time}
        ORDER BY create_time desc
            LIMIT 1
    </select>

</mapper>