Blame view

MemberMapper.xml 16.5 KB
涂亚平 committed
1 2 3 4 5 6
<?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.subsidy.mapper.MemberMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.subsidy.model.MemberDO">
涂亚平 committed
7 8 9 10 11 12 13 14 15 16
        <id column="id" property="id"/>
        <result column="create_date" property="createDate"/>
        <result column="update_date" property="updateDate"/>
        <result column="delete_date" property="deleteDate"/>
        <result column="user_name" property="userName"/>
        <result column="telephone" property="telephone"/>
        <result column="password" property="password"/>
        <result column="gender" property="gender"/>
        <result column="image" property="image"/>
        <result column="id_card" property="idCard"/>
涂亚平 committed
17 18 19 20 21 22 23 24 25 26
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        create_date,
        update_date,
        delete_date,
        id, user_name, telephone, password, gender, image, id_card
    </sql>

涂亚平 committed
27 28
    <select id="passwordLogin" parameterType="com.subsidy.dto.member.PasswordLoginDTO"
            resultType="com.subsidy.vo.administer.UserRoleVO">
涂亚平 committed
29 30 31 32 33 34
        SELECT
            t.id,
            t.telephone,
            t.user_name,
            t.image,
            t.status,
涂亚平 committed
35 36
            t.first_login,
            t.password
涂亚平 committed
37 38
        FROM
            member t
39
            left join company_member_mapping t2 on t.id = t2.member_id
涂亚平 committed
40 41 42
        WHERE
            t.delete_date IS NULL
            AND t.account_name = #{accountName}
43
            AND t2.company_id =#{companyId}
涂亚平 committed
44 45
    </select>

涂亚平 committed
46 47 48 49 50
    <select id="studyPage" parameterType="com.subsidy.model.MemberDO" resultType="com.subsidy.vo.member.StudyPageVO">
        SELECT
            t3.id,
            t2.id as classId,
            t3.course_name,
涂亚平 committed
51 52
            t2.end_date,
            t2.class_name
涂亚平 committed
53 54 55 56 57 58 59
        FROM
            class_member_mapping t
            LEFT JOIN class_dict t2 ON t.class_id = t2.id
            left join course_dict t3 on t2.course_id = t3.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
涂亚平 committed
60
            and t3.delete_date is null
涂亚平 committed
61 62 63
            AND t.member_id = #{id}
    </select>

涂亚平 committed
64 65 66 67
    <select id="myCourses" parameterType="long" resultType="com.subsidy.vo.member.MyCoursesVO">
        SELECT
        t3.id AS courseId,
        t2.id AS classId,
涂亚平 committed
68
        t2.class_name,
涂亚平 committed
69
        t3.course_name,
涂亚平 committed
70
        t2.start_date,
涂亚平 committed
71
        t2.end_date,
涂亚平 committed
72
        t9.class_type,
涂亚平 committed
73 74 75
        t4.cnt AS totalCnt,
        t5.result AS studyCnt,
        t6.ttlMember,
涂亚平 committed
76 77
        t2.is_order,
        t2.is_fast_play,
涂亚平 committed
78
        t.email_status,
涂亚平 committed
79 80 81 82 83 84 85 86 87 88 89 90 91 92
        if(
        TIMESTAMPDIFF(
        DAY,
        DATE_FORMAT( NOW(), '%Y-%m-%d' ),
        t2.end_date)>0,TIMESTAMPDIFF(
        DAY,
        DATE_FORMAT( NOW(), '%Y-%m-%d' ),
        t2.end_date),0) AS diffDate
        FROM
        class_member_mapping t
        LEFT JOIN ( SELECT t.class_id, count( 1 ) ttlMember FROM class_member_mapping t WHERE t.delete_date IS NULL
        GROUP BY t.class_id ) t6 ON t.class_id = t6.class_id
        LEFT JOIN class_dict t2 ON t.class_id = t2.id
        LEFT JOIN course_dict t3 ON t2.course_id = t3.id
涂亚平 committed
93
        left join class_type_dict t9 on t2.class_type_id = t9.id
涂亚平 committed
94 95 96 97 98 99
        LEFT JOIN (
        SELECT
        t.course_id,
        count( 1 ) AS cnt
        FROM
        course_content t
涂亚平 committed
100
        LEFT JOIN content_vod_mapping t2 ON t.id = t2.content_id
涂亚平 committed
101 102 103
        WHERE
        t.delete_date IS NULL
        AND t2.delete_date IS NULL
涂亚平 committed
104
        and t2.id is not null
涂亚平 committed
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
        GROUP BY
        t.course_id
        ) t4 ON t3.id = t4.course_id
        LEFT JOIN (
        SELECT
        t1.member_id,
        t1.class_id,
        sum( result ) AS result
        FROM
        (
        SELECT
        t.member_id,
        t.vod_id,
        t.class_id,
        sum( t.play_length ) AS play_length,
        t2.vod_length,
        IF
        ( sum( t.play_length )>= t2.vod_length, 1, 0 ) AS result
        FROM
        vod_play_history t
        LEFT JOIN vod_dict t2 ON t.vod_id = t2.id
        WHERE
        t.member_id = #{memberId}
涂亚平 committed
128
        and t.delete_date IS NULL
涂亚平 committed
129 130 131 132 133 134 135 136 137 138 139 140 141 142
        GROUP BY
        t.member_id,
        t.vod_id,
        t.class_id
        ) t1
        GROUP BY
        t1.member_id,
        t1.class_id
        ) t5 ON t.class_id = t5.class_id
        AND t.member_id = t5.member_id
        WHERE
        t.delete_date IS NULL
        AND t2.delete_date IS NULL
        AND t3.delete_date IS NULL
涂亚平 committed
143
        and t2.class_type_id != 0
涂亚平 committed
144 145
        AND t.member_id = #{memberId}
        <if test="status ==1">
涂亚平 committed
146
            AND DATE_FORMAT(now(), '%Y-%m-%d') >= DATE_FORMAT(start_date, '%Y-%m-%d')
邓敏 committed
147
            AND DATE_FORMAT(now(), '%Y-%m-%d') &lt;= DATE_FORMAT(end_date, '%Y-%m-%d')
涂亚平 committed
148 149
        </if>
        <if test="status ==2">
涂亚平 committed
150
            AND DATE_FORMAT(now(), '%Y-%m-%d') &lt; DATE_FORMAT(start_date, '%Y-%m-%d')
涂亚平 committed
151 152
        </if>
        <if test="status ==3">
涂亚平 committed
153
            AND DATE_FORMAT(now(), '%Y-%m-%d') > DATE_FORMAT(end_date, '%Y-%m-%d')
涂亚平 committed
154
        </if>
涂亚平 committed
155
        order by t2.create_date desc
涂亚平 committed
156 157
    </select>

涂亚平 committed
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
    <select id="myCertCourses" parameterType="long" resultType="com.subsidy.vo.member.MyCoursesVO">
        SELECT
        t3.id AS courseId,
        t2.id AS classId,
        t2.class_name,
        t3.course_name,
        t2.start_date,
        t2.end_date,
        t4.cnt AS totalCnt,
        t5.result AS studyCnt,
        t6.ttlMember,
        t2.is_order,
        t2.is_fast_play,
        t.email_status,
        if(
        TIMESTAMPDIFF(
        DAY,
        DATE_FORMAT( NOW(), '%Y-%m-%d' ),
        t2.end_date)>0,TIMESTAMPDIFF(
        DAY,
        DATE_FORMAT( NOW(), '%Y-%m-%d' ),
        t2.end_date),0) AS diffDate
        FROM
        class_member_mapping t
        LEFT JOIN ( SELECT t.class_id, count( 1 ) ttlMember FROM class_member_mapping t WHERE t.delete_date IS NULL
        GROUP BY t.class_id ) t6 ON t.class_id = t6.class_id
        LEFT JOIN class_dict t2 ON t.class_id = t2.id
        LEFT JOIN course_dict t3 ON t2.course_id = t3.id
        LEFT JOIN (
        SELECT
        t.course_id,
        count( 1 ) AS cnt
        FROM
        course_content t
        LEFT JOIN content_vod_mapping t2 ON t.id = t2.content_id
        WHERE
        t.delete_date IS NULL
        AND t2.delete_date IS NULL
        and t2.id is not null
        GROUP BY
        t.course_id
        ) t4 ON t3.id = t4.course_id
        LEFT JOIN (
        SELECT
        t1.member_id,
        t1.class_id,
        sum( result ) AS result
        FROM
        (
        SELECT
        t.member_id,
        t.vod_id,
        t.class_id,
        sum( t.play_length ) AS play_length,
        t2.vod_length,
        IF
        ( sum( t.play_length )>= t2.vod_length, 1, 0 ) AS result
        FROM
        vod_play_history t
        LEFT JOIN vod_dict t2 ON t.vod_id = t2.id
        WHERE
        t.member_id = #{memberId}
        GROUP BY
        t.member_id,
        t.vod_id,
        t.class_id
        ) t1
        GROUP BY
        t1.member_id,
        t1.class_id
        ) t5 ON t.class_id = t5.class_id
        AND t.member_id = t5.member_id
        WHERE
        t.delete_date IS NULL
        AND t2.delete_date IS NULL
        AND t3.delete_date IS NULL
        and t2.class_type_id = 0
        AND t.member_id = #{memberId}
        <if test="status ==1">
            AND DATE_FORMAT(now(), '%Y-%m-%d') >= DATE_FORMAT(start_date, '%Y-%m-%d')
            AND DATE_FORMAT(now(), '%Y-%m-%d') &lt;= DATE_FORMAT(end_date, '%Y-%m-%d')
        </if>
        <if test="status ==2">
            AND DATE_FORMAT(now(), '%Y-%m-%d') &lt; DATE_FORMAT(start_date, '%Y-%m-%d')
        </if>
        <if test="status ==3">
            AND DATE_FORMAT(now(), '%Y-%m-%d') > DATE_FORMAT(end_date, '%Y-%m-%d')
        </if>
        order by t2.create_date desc
    </select>
涂亚平 committed
248 249 250 251 252 253 254 255 256 257 258 259

    <select id="getDepartments" parameterType="long" resultType="com.subsidy.model.DepartmentDictDO">
        SELECT
            t2.id,
            t2.department_name,
            t2.parent_id
        FROM
            member_department_mapping t
            LEFT JOIN department_dict t2 ON t.department_id = t2.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
260
            and t.member_status = 1
涂亚平 committed
261 262 263 264 265
            AND t.member_id = #{memberId}
    </select>

    <select id="getMembers" resultType="com.subsidy.vo.member.GetAllVO">
        SELECT
涂亚平 committed
266 267 268
        t2.id,
        t2.user_name,
        t2.account_name,
邓敏 committed
269
        t2.account_name_en,
涂亚平 committed
270 271 272
        t2.telephone,
        t2.gender,
        t2.id_card,
涂亚平 committed
273 274 275 276
        t2.status,
        t2.email,
        t2.work_no,
        t2.induction_date
涂亚平 committed
277 278 279 280 281 282
        FROM
        member_department_mapping t
        LEFT JOIN member t2 ON t.member_id = t2.id
        WHERE
        t.delete_date IS NULL
        AND t2.delete_date IS NULL
283
        and t.member_status = 1
涂亚平 committed
284
        and t.department_id = #{departmentId}
涂亚平 committed
285
        <if test="userName != null and userName !=''">
涂亚平 committed
286 287 288 289 290
            and t2.user_name like concat('%',#{userName} ,'%')
        </if>
        <if test="status != null and status !=''">
            and t2.status = #{status}
        </if>
涂亚平 committed
291 292 293 294 295 296
        <if test="startDate != null and startEndDate !=''">
            and DATE_FORMAT(t2.induction_date ,'%Y-%m-%d')>=DATE_FORMAT(#{startDate}, '%Y-%m-%d')
        </if>
        <if test="endDate != null and endDate !=''">
            and DATE_FORMAT(t2.induction_date ,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
        </if>
涂亚平 committed
297 298
    </select>

涂亚平 committed
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
    <select id="getMemberWithoutPage" resultType="com.subsidy.model.MemberDO">
        SELECT
        t2.id,
        t2.user_name,
        t2.account_name,
        t2.account_name_en,
        t2.telephone,
        t2.gender,
        t2.id_card,
        t2.status,
        t2.email,
        t2.work_no,
        t2.induction_date
        FROM
        member_department_mapping t
        LEFT JOIN member t2 ON t.member_id = t2.id
        WHERE
        t.delete_date IS NULL
        AND t2.delete_date IS NULL
涂亚平 committed
318
        AND t2.id IS NOT NULL
涂亚平 committed
319
        and t.department_id = #{departmentId}
320
        and t.member_status = 1
涂亚平 committed
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
        <if test="userName != null and userName !=''">
            and t2.user_name like concat('%',#{userName} ,'%')
        </if>
        <if test="status != null and status !=''">
            and t2.status = #{status}
        </if>
        <if test="startDate != null and startEndDate !=''">
            and DATE_FORMAT(t2.induction_date ,'%Y-%m-%d')>=DATE_FORMAT(#{startDate}, '%Y-%m-%d')
        </if>
        <if test="endDate != null and endDate !=''">
            and DATE_FORMAT(t2.induction_date ,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
        </if>
    </select>

    <select id="getCompanyMember" resultType="com.subsidy.vo.member.GetAllVO">
        SELECT
        t2.id,
        t2.user_name,
        t2.account_name,
        t2.account_name_en,
        t2.telephone,
        t2.gender,
        t2.id_card,
        t2.status,
        t2.email,
        t2.work_no,
        t2.induction_date
        FROM
        member t2
350
        left join company_member_mapping t5 on t5.member_id = t2.id and t5.member_status = 1
涂亚平 committed
351 352
        WHERE
         t2.delete_date IS NULL
353
        and t5.company_id = #{companyId}
涂亚平 committed
354 355 356 357 358 359 360 361 362 363 364 365 366
        <if test="userName != null and userName !=''">
            and t2.user_name like concat('%',#{userName} ,'%')
        </if>
        <if test="status != null and status !=''">
            and t2.status = #{status}
        </if>
        <if test="startDate != null and startEndDate !=''">
            and DATE_FORMAT(t2.induction_date ,'%Y-%m-%d')>=DATE_FORMAT(#{startDate}, '%Y-%m-%d')
        </if>
        <if test="endDate != null and endDate !=''">
            and DATE_FORMAT(t2.induction_date ,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
        </if>
    </select>
367

涂亚平 committed
368 369 370 371 372 373 374
    <select id="manageMember" parameterType="string" resultType="com.subsidy.vo.administer.ManageMemberVO">
        SELECT
            t.id,
            t.user_name,
            t.telephone,
            t.id_card,
            t.account_name,
涂亚平 committed
375 376 377 378
            t2.company_name,
            t.check_image,
            t.check_time,
            t.first_login
涂亚平 committed
379 380
        FROM
            member t
381 382
        left join company_member_mapping t5 on t5.member_id = t.id and t5.member_status = 1
        LEFT JOIN company_dict t2 ON t5.company_id = t2.id
涂亚平 committed
383 384 385 386 387 388 389
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            <if test="userName != null and userName != ''">
                AND t.user_name LIKE concat('%',#{userName} ,'%')
            </if>
            <if test="companyId != null and companyId != ''">
390
                and t5.company_id = #{companyId}
涂亚平 committed
391 392 393
            </if>
    </select>

邓敏 committed
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
    <select id="getMemberList" resultType="com.subsidy.model.MemberDO">
        select
            m.*
        from member m
        left join class_member_mapping cmm on cmm.member_id = m.id
        where cmm.class_id = #{classId}
        and m.delete_date is null
        and cmm.delete_date is null
    </select>

    <select id="getMemberListBySignInRecord" resultType="com.subsidy.model.MemberDO">
        SELECT
            m.*
        FROM
            member m
            LEFT JOIN class_member_mapping cmm ON cmm.member_id = m.id
            LEFT JOIN ( SELECT member_id, count( id ) AS signInCount FROM sign_in_record WHERE class_id = #{classId} AND delete_date IS NULL GROUP BY member_id ) s ON s.member_id = m.id
        WHERE
            cmm.class_id = #{classId}
          AND m.delete_date IS NULL
          AND cmm.delete_date IS NULL
涂亚平 committed
415
          AND s.signInCount is null
邓敏 committed
416 417 418 419 420 421 422 423 424
        GROUP BY
            m.id
    </select>

    <select id="getUnfinishedMemberList" resultType="com.subsidy.model.MemberDO">
        SELECT
            m.*
        FROM
            member m
涂亚平 committed
425
            LEFT JOIN class_member_mapping cm ON cm.member_id = m.id
426
            LEFT JOIN ( SELECT member_id, count( 1 ) AS ts, class_id FROM exercise_done_result WHERE score >= 60 GROUP BY class_id,member_id ) AS r ON r.member_id = m.id AND r.class_id = cm.class_id
邓敏 committed
427
        WHERE
涂亚平 committed
428 429 430
            cm.class_id = #{classId}
            AND r.ts is NULL
            and m.delete_date is null
邓敏 committed
431
    </select>
涂亚平 committed
432 433

    <update id="removeCheckImage"  parameterType="long">
涂亚平 committed
434
        update member set check_image = null,check_time = null where id = #{id}
涂亚平 committed
435
    </update>
涂亚平 committed
436 437 438

    <select id="companySettings" parameterType="long" resultType="com.subsidy.vo.classdict.SystemSettings">
            SELECT
涂亚平 committed
439
                t2.id,
涂亚平 committed
440 441 442 443 444
                t2.time_limit,
                t2.ip_address_record,
                t2.device_no_record
            FROM
                member t
445 446
                left join company_member_mapping t5 on t5.member_id = t.id and t5.member_status = 1
                LEFT JOIN company_dict t2 ON t5.company_id = t2.id
涂亚平 committed
447 448 449 450 451
            WHERE
                t.delete_date IS NULL
                AND t2.delete_date IS NULL
                AND t.id = #{memberId}
    </select>
涂亚平 committed
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473

    <select id="memberLives" parameterType="long" resultType="com.subsidy.vo.live.MemberLivesVO">
        SELECT
           distinct t2.live_id,
            t3.live_name,
            t3.live_url,
            t3.start_time,
            t3.live_status,
            t3.channel,
            t3.play_start_date,
            t3.play_end_date
        FROM
            class_member_mapping t
            LEFT JOIN live_classes t2 ON t.class_id = t2.class_id
            LEFT JOIN live_dict t3 ON t2.live_id = t3.id
        WHERE
            t.delete_date IS NULL
            AND t2.delete_date IS NULL
            AND t3.delete_date IS NULL
            and t2.live_id IS not NULL
            AND t.member_id = #{memberId}
    </select>
涂亚平 committed
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507

    <select id="checkClassVodPlayStatus" resultType="integer">
        SELECT
        IF
            ( t.play_length > t2.vod_length, 1, 0 ) AS result
        FROM
            (
            SELECT
                t.vod_id,
                sum( t.play_length ) AS play_length
            FROM
                vod_play_history t
            WHERE
                t.delete_date IS NULL
                AND t.class_id = #{classId}
                AND t.member_id = #{memberId}
                AND t.vod_id = #{vodId}
            ) t
            LEFT JOIN vod_dict t2 ON t.vod_id = t2.id
    </select>

    <select id="checkClassPaperPassStatus" resultType="integer">
        SELECT
            IF
                ( count( 1 )> 0, 1, 0 ) AS result
            FROM
                exercise_done_result t
            WHERE
                t.delete_date IS NULL
                AND t.class_id = #{classId}
                AND t.member_id = #{memberId}
                AND t.paper_id = #{paperId}
                AND t.result = '合格'
    </select>
涂亚平 committed
508
</mapper>