<?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.ssj.service.mapper.ZybStudentWorkMapper">
    <update id="updateStudentPushType">
        update zyb_student_push sp
        set sp.type = 4
        where sp.type = 0
          and exists(select 1
                     from scon_homework_picture hp
                     where to_days(hp.create_time) = to_days(sp.push_time)
                       and hp.vip_id = sp.vip_id
                       and hp.is_delete = 0)
    </update>

    <select id="findLearningDate" resultType="java.lang.String">
        select date(create_time)
        from scon_homework
        where vip_id = #{vipId}
          and work_type in (1,2,4)
          and create_time between #{beginDateTimeStr} and #{endDateTimeStr}
    </select>

    <select id="countHomeworkDaysAndUsedTime" resultType="java.util.Map">
        select subject course_name,
               count(*) coursecount,
               sum(ifnull(used_time, 0)) used_time
        from scon_homework
        where work_type in (1,2,4)
          and vip_id = #{vipId}
          and create_time between #{beginTime} and #{endTime}
        group by subject
    </select>
</mapper>