| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048 | <?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.zhongzheng.modules.grade.mapper.ClassGradeMapper">    <resultMap type="com.zhongzheng.modules.grade.domain.ClassGrade" id="ClassGradeResult">        <result property="gradeId" column="grade_id"/>        <result property="classStatus" column="class_status"/>        <result property="officialName" column="official_name"/>        <result property="className" column="class_name"/>        <result property="studentUpper" column="student_upper"/>        <result property="learningTimeStart" column="learning_time_start"/>        <result property="learningStatus" column="learning_status"/>        <result property="status" column="status"/>        <result property="classStartTime" column="class_start_time"/>        <result property="classEndTime" column="class_end_time"/>        <result property="examineId" column="examine_id"/>        <result property="areasId" column="areas_id"/>        <result property="createTime" column="create_time"/>        <result property="updateTime" column="update_time"/>        <result property="sysUserId" column="sys_user_id"/>        <result property="interfacePushId" column="interface_push_id"/>        <result property="remark" column="remark"/>        <result property="interfaceAccountId" column="interface_account_id"/>        <result property="interfacePeriodId" column="interface_period_id"/>        <result property="officialLearningUrl" column="official_learning_url"/>    </resultMap>    <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeVo" id="ClassGradeVoResult">        <result property="gradeId" column="grade_id"/>        <result property="classStatus" column="class_status"/>        <result property="officialName" column="official_name"/>        <result property="className" column="class_name"/>        <result property="studentUpper" column="student_upper"/>        <result property="learningTimeStart" column="learning_time_start"/>        <result property="learningStatus" column="learning_status"/>        <result property="status" column="status"/>        <result property="classStartTime" column="class_start_time"/>        <result property="classEndTime" column="class_end_time"/>        <result property="examineId" column="examine_id"/>        <result property="areasId" column="areas_id"/>        <result property="sysUserId" column="sys_user_id"/>        <result property="interfacePushId" column="interface_push_id"/>        <result property="remark" column="remark"/>        <result property="interfaceAccountId" column="interface_account_id"/>        <result property="interfacePeriodId" column="interface_period_id"/>        <result property="interfaceAccountName" column="interface_account_name"/>        <result property="interfacePeriodName" column="interface_period_name"/>        <result property="interfacePushName" column="interface_push_name"/>        <result property="studentNum" column="student_num"/>        <result property="officialLearningUrl" column="official_learning_url"/>        <result property="officialStatusNum" column="official_status_num"/>        <result property="periodStatusNum" column="period_status_num"/>        <result property="periodPlushNum" column="period_plush_num"/>        <result property="periodPlushNum" column="period_plush_num"/>        <result property="subjectNames" column="subject_names"/>        <result property="subjectIds" column="subject_ids"/>        <result property="businessId" column="business_id"/>        <result property="projectId" column="project_id"/>        <result property="goodsId" column="goods_id"/>    </resultMap>    <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeUserListVo" id="ClassGradeUserListVo">        <result property="gradeId" column="grade_id"/>        <result property="classStatus" column="class_status"/>        <result property="officialName" column="official_name"/>        <result property="className" column="class_name"/>        <result property="studentUpper" column="student_upper"/>        <result property="learningTimeStart" column="learning_time_start"/>        <result property="learningStatus" column="learning_status"/>        <result property="status" column="status"/>        <result property="classStartTime" column="class_start_time"/>        <result property="classEndTime" column="class_end_time"/>        <result property="examineId" column="examine_id"/>        <result property="areasId" column="areas_id"/>        <result property="sysUserId" column="sys_user_id"/>        <result property="interfacePushId" column="interface_push_id"/>        <result property="remark" column="remark"/>        <result property="interfaceAccountId" column="interface_account_id"/>        <result property="interfacePeriodId" column="interface_period_id"/>        <result property="interfaceAccountName" column="interface_account_name"/>        <result property="interfacePeriodName" column="interface_period_name"/>        <result property="interfacePushName" column="interface_push_name"/>        <result property="studentNum" column="student_num"/>    </resultMap>    <resultMap type="com.zhongzheng.modules.goods.vo.GoodsVo" id="GoodsResultVo">        <result property="goodsId" column="goods_id"/>        <result property="year" column="year"/>        <result property="supplyId" column="supply_id"/>        <result property="goodsType" column="goods_type"/>        <result property="educationTypeId" column="education_type_id"/>        <result property="businessId" column="business_id"/>        <result property="schoolId" column="school_id"/>        <result property="majorId" column="major_id"/>        <result property="goodsName" column="goods_name"/>        <result property="standPrice" column="stand_price"/>        <result property="lowestPrice" column="lowest_price"/>        <result property="createTime" column="create_time"/>        <result property="updateTime" column="update_time"/>        <result property="status" column="status"/>        <result property="validityStartTime" column="validity_start_time"/>        <result property="validityEndTime" column="validity_end_time"/>        <result property="studyStartTime" column="study_start_time"/>        <result property="studyEndTime" column="study_end_time"/>        <result property="certificateIds" column="certificate_ids"/>        <result property="introduce" column="introduce"/>        <result property="suitableObject" column="suitable_object"/>        <result property="buyNote" column="buy_note"/>        <result property="pcDetailHtml" column="pc_detail_html"/>        <result property="mobileDetailHtml" column="mobile_detail_html"/>        <result property="goodsStatus" column="goods_status"/>        <result property="coverUrl" column="cover_url"/>        <result property="classHours" column="class_hours"/>        <result property="standPriceJson" column="stand_price_json"/>        <result property="code" column="code"/>        <result property="projectId" column="project_id"/>        <result property="goodsAuditionConfig" column="goods_audition_config"/>        <result property="goodsPhotographConfig" column="goods_photograph_config"/>        <result property="goodsPlayConfig" column="goods_play_config"/>        <result property="goodsExamConfig" column="goods_exam_config"/>        <result property="supplyName" column="supply_name"/>        <result property="educationName" column="education_name"/>        <result property="projectName" column="project_name"/>        <result property="businessName" column="business_name"/>        <result property="schoolName" column="school_name"/>        <result property="categoryName" column="category_name"/>        <result property="handoutsId" column="handouts_id"/>        <result property="templateType" column="template_type"/>    </resultMap>    <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeStudentVo" id="ClassGradeStudentVo">        <result property="userId" column="user_id"/>        <result property="id" column="id"/>        <result property="gradeId" column="grade_id"/>        <result property="studentCode" column="user_account"/>        <result property="realname" column="realname"/>        <result property="idCard" column="id_card" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>        <result property="telPhone" column="telphone"/>        <result property="userStatus" column="user_status"/>        <result property="status" column="status"/>        <result property="classHours" column="class_hours"/>        <result property="periodStatus" column="period_status"/>        <result property="finishStatus" column="finish_status"/>        <result property="officialStatus" column="official_status"/>        <result property="learnStatus" column="learn_status"/>        <result property="secAllNum" column="sec_all_num"/>        <result property="examNum" column="exam_num"/>        <result property="recordNum" column="record_num"/>        <result property="classStartTime" column="class_start_time"/>        <result property="classEndTime" column="class_end_time"/>        <result property="studyStartTime" column="study_start_time"/>        <result property="studyEndTime" column="study_end_time"/>        <result property="studyCount" column="study_count"/>        <result property="orderGoodsId" column="order_goods_id"/>        <result property="officialStatusNum" column="official_status_num"/>        <result property="officialStatusTime" column="official_status_time"/>        <result property="interfacePushId" column="interface_push_id"/>        <result property="periodPlush" column="period_plush"/>        <result property="rebuyOrderGoodsId" column="rebuy_order_goods_id"/>        <result property="serviceStartTime" column="service_start_time"/>        <result property="serviceEndTime" column="service_end_time"/>        <result property="goodsName" column="goods_name"/>        <result property="orderSn" column="order_sn"/>        <result property="categoryName" column="category_name"/>        <result property="reason" column="reason"/>        <result property="projectName" column="project_name"/>        <result property="businessName" column="business_name"/>        <result property="userBindWx" column="user_bind_wx"/>        <result property="userFollowWx" column="user_follow_wx"/>        <result property="useStudyCount" column="use_study_count"/>        <result property="examNumber" column="exam_number"/>        <result property="doNumber" column="do_number"/>        <result property="expendNumber" column="expend_number"/>        <result property="expendBefore" column="expend_before"/>    </resultMap>    <resultMap type="com.zhongzheng.modules.grade.vo.ClassGradeGoodsVo" id="ClassGradeGoodsVoResult">        <result property="goodsId" column="goods_id"/>        <collection property="gradeList" column="goods_id" select="findGradeList"/>    </resultMap>    <select id="findGradeList" resultMap="ClassGradeVoResult">        SELECT            g.*,            (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,            (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,            (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,            (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,            (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,            (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,            (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num,            (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1 and official_status =1) as official_status_num,            (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1 and period_status =1) as period_status_num,            (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1 and period_plush =1) as period_plush_num        FROM            class_grade_goods cgg LEFT JOIN            class_grade g on cgg.grade_id = g.grade_id            where cgg.goods_id = #{goods_id} and g.`status` = 1    </select>    <select id="queryList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeVoResult">        SELECT            g.*,            (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,            (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,            (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,            (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,            (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,            (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,            (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num,            (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1 and official_status =1) as official_status_num,            (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1 and period_status =1) as period_status_num,            (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1 and period_plush =1) as period_plush_num,            (SELECT GROUP_CONCAT(subject_name)  from course_subject where FIND_IN_SET(id,d.subject_ids)) subject_names        FROM            class_grade g        LEFT JOIN class_grade_goods cgg ON cgg.grade_id = g.grade_id        LEFT JOIN goods d ON cgg.goods_id = d.goods_id        LEFT JOIN course_business cb ON d.business_id = cb.id        <if test="userId != null and userId !=0 ">            LEFT JOIN class_grade_user gu on g.grade_id = gu.grade_id AND gu.status = 1        </if>        where g.status !=-1        <if test="status != null and status.size()!=0 ">            AND g.status in            <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">                #{item}            </foreach>        </if>        <if test="userId != null and userId !=0 ">            AND gu.user_id =  #{userId}        </if>        <if test="gradeId != null and gradeId !=0 ">            AND g.grade_id =  #{gradeId}        </if>        <if test="searchKey != null and searchKey !='' ">            AND ((g.class_name like concat('%', #{searchKey}, '%')) or (            SELECT            COUNT(*)            FROM            class_grade_user cgu            LEFT JOIN `user` u ON cgu.user_id = u.user_id            WHERE            g.grade_id = cgu.grade_id            AND u.realname  like concat('%', #{searchKey}, '%')            ) >0 or (            SELECT            COUNT(*)            FROM            class_grade_goods s            LEFT JOIN goods d ON s.goods_id = d.goods_id            WHERE            g.grade_id = s.grade_id            AND d.goods_name  like concat('%', #{searchKey}, '%')            ) >0)        </if>        <if test="classStatus != null  ">            AND g.class_status =  #{classStatus}        </if>        <if test="className != null and className !='' ">            AND g.class_name like concat('%', #{className}, '%')        </if>        <if test="atFull != null and atFull !='' ">            AND (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) < g.student_upper        </if>        <if test="classStartTime != null and classStartTime != ''  and classEndTime != null and classEndTime != ''">            AND (#{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time)        </if>        <if test="pastDue != null or pastDue != null ">            AND ((unix_timestamp(now())+10*24*3600) < g.class_end_time or g.class_start_time is null)        </if>        <if test="educationTypeId != null and educationTypeId !='' ">            AND (            SELECT            COUNT(*)            FROM            class_grade_goods s            LEFT JOIN goods d ON s.goods_id = d.goods_id            WHERE            1 = 1            AND g.grade_id = s.grade_id            AND d.education_type_id =#{educationTypeId}            ) >0        </if>        <if test="businessId != null and businessId !='' ">            AND cb.id = #{businessId}        </if>        <if test="schoolId != null and schoolId !='' ">            AND (            SELECT            COUNT(*)            FROM            class_grade_goods s            LEFT JOIN goods d ON s.goods_id = d.goods_id            WHERE            1 = 1            AND g.grade_id = s.grade_id            AND d.school_id =#{schoolId}            ) >0        </if>        <if test="majorId != null and majorId !='' ">            AND (            SELECT            COUNT(*)            FROM            class_grade_goods s            LEFT JOIN goods d ON s.goods_id = d.goods_id            WHERE            1 = 1            AND g.grade_id = s.grade_id            AND d.major_id =#{majorId}            ) >0        </if>        <if test="goodsId != null and goodsId !='' ">            AND (            SELECT            COUNT(*)            FROM            class_grade_goods s            WHERE            1 = 1            AND g.grade_id = s.grade_id            AND s.goods_id =#{goodsId}            ) >0        </if>        <if test="hasInterface != null and hasInterface == 0">            AND g.interface_account_id is null AND g.no_interface_account_id is null        </if>        <if test="hasInterface != null and hasInterface == 1">            AND g.interface_account_id is not null        </if>        <if test="hasInterface != null and hasInterface == 2">            AND g.no_interface_account_id is not null        </if>        <!-- 数据范围过滤 -->        ${params.dataScope}        order by g.create_time desc    </select>    <select id="queryGoodsList" parameterType="Long" resultMap="GoodsResultVo">        SELECT            g.*,            ps.supply_name,            cet.education_name,            cpt.project_name,            cb.business_name,            s.school_name,            m.category_name,            ot.type AS template_type        FROM            goods g                LEFT JOIN pay_supply ps ON g.supply_id = ps.supply_id                LEFT JOIN course_education_type cet ON g.education_type_id = cet.id                LEFT JOIN course_project_type cpt ON g.project_id = cpt.id                LEFT JOIN course_business cb ON g.business_id = cb.id                LEFT JOIN school s ON s.id = g.school_id                LEFT JOIN major m ON g.major_id = m.id                LEFT JOIN order_input_template ot ON cb.template_status = ot.id                LEFT JOIN class_grade_goods o ON o.goods_id = g.goods_id        WHERE            1 = 1          AND o.grade_id =#{gradeId}    </select>    <select id="listGrade"  parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">        SELECT        cgu.id,        cgu.official_status_time,        cgu.official_status_num,        u.user_account,        u.user_id,        cgu.`status`,        u.realname,        (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id) as goods_id,        u.id_card,        cgu.grade_id,        u.telphone,        (case WHEN (select COUNT(uu.id) FROM user_update uu where cgu.user_id = uu.user_id and uu.status = 2) >0 then 1 ELSE 0 end) as user_status,        (case WHEN cgu.official_status_time >  (select MAX(uu.create_time) FROM user_update uu where cgu.user_id = uu.user_id) then 0 ELSE 1 end) as user_info_status,        (select MAX(uu.create_time) FROM user_update uu where cgu.user_id = uu.user_id ) as update_info_time,        (SELECT g.class_hours FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where cg.grade_id = cgg.grade_id) as class_hours,        cgu.period_status,        cgu.finish_status,        cgu.period_plush,        (SELECT g.study_start_time FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where cg.grade_id = cgg.grade_id) as study_start_time,        (SELECT g.study_end_time FROM goods g LEFT JOIN class_grade_goods cgg on cgg.goods_id = g.goods_id where cg.grade_id = cgg.grade_id) as study_end_time,        cg.class_start_time,        cg.class_end_time,        cg.interface_push_id,        cgu.official_status,        cgu.learn_status,        (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id LEFT JOIN class_grade_goods cgg on cgg.goods_id = c.goods_id where cg.grade_id=cgg.grade_id and m.type  in (1,3) ) as exam_num,        (SELECT COUNT(DISTINCT ubr.module_id,ubr.chapter_id,ubr.exam_id) FROM user_bank_record ubr LEFT JOIN class_grade_goods cgg on cgg.goods_id = ubr.goods_id where ubr.`status`=1 and ubr.type  in (1,3) and  ubr.user_id = u.user_id and ubr.grade_id = cgu.grade_id and ubr.report_status=1 and ubr.current_status = 1) as record_num,        (og.study_count) as study_count,        og.order_goods_id,        og.rebuy_order_goods_id,        og.service_start_time,        og.service_end_time,        g.goods_name,        og.order_sn,        m.category_name,        g.major_id,        u.province,        cgu.reason,        cb.business_name,        cpt.project_name,        (case WHEN u.union_id is null then 0 ELSE 1 end) as user_bind_wx,        (case WHEN uwf.gzh_open_id is null then 0 ELSE 1 end) as user_follow_wx,        (SELECT IFNULL(SUM(usr.study_duration),0) from user_study_record usr where usr.user_id = cgu.user_id and usr.grade_id = cgu.grade_id) as user_study_duration,        (SELECT count(*) from class_grade_user cgu where cgu.order_goods_id = og.order_goods_id) as use_study_count,        ueg.exam_number,        ueg.do_number,        ueg.expend_number,        ueg.expend_before        FROM        class_grade_user cgu        LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id        LEFT JOIN `user` u ON u.user_id = cgu.user_id        LEFT JOIN order_goods og on cgu.order_goods_id = og.order_goods_id        LEFT JOIN goods g on og.goods_id = g.goods_id        LEFT JOIN major m ON g.major_id = m.id        LEFT JOIN course_business cb ON g.business_id = cb.id        LEFT JOIN course_project_type cpt ON g.project_id = cpt.id        LEFT JOIN user_wx_follow uwf ON u.union_id = uwf.union_id        LEFT JOIN user_exam_goods ueg ON ueg.order_goods_id = og.order_goods_id        where 1=1        <if test="gradeId != null and gradeId !='' ">          and cgu.grade_id = #{gradeId}        </if>        <if test="choice != null and choice == 1 ">            and (SELECT COUNT(cge.grade_id) FROM class_grade cge LEFT JOIN class_grade_user cgur on cge.grade_id = cgur.grade_id where cgu.user_id =cgur.user_id and (SELECT cgg.goods_id FROM class_grade_goods cgg where cge.grade_id=cgg.grade_id) = (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id)  AND (unix_timestamp(now()) < cge.class_end_time or cge.class_start_time is null) and cge.`status`=1 and cgur.`status` =1)= 0 and cgu.period_status=0            AND (SELECT COUNT(cgde.grade_id) FROM class_grade cgde where cgde.grade_id = cg.grade_id and (unix_timestamp(now()) < cgde.class_end_time or cgde.class_start_time is null)) =0        </if>        <if test="choice != null and choice == 2 ">            and (SELECT COUNT(cge.grade_id) FROM class_grade cge LEFT JOIN class_grade_user cgur on cge.grade_id = cgur.grade_id where cgu.user_id =cgur.user_id and (SELECT cgg.goods_id FROM class_grade_goods cgg            where cge.grade_id=cgg.grade_id) = (SELECT cgg.goods_id FROM class_grade_goods cgg where cg.grade_id=cgg.grade_id)  AND (unix_timestamp(now()) < cge.class_end_time or cge.class_start_time is null)            and cge.`status`=1 and cgur.`status` =1)> 0            AND (SELECT COUNT(cgde.grade_id) FROM class_grade cgde where cgde.grade_id = cg.grade_id and (unix_timestamp(now()) < cgde.class_end_time or cgde.class_start_time is null)) =0        </if>        <if test="studyCountMore != null and studyCountMore == 2 ">            AND og.study_count > 0 AND cgu.change_grade = 0        </if>        <if test="studyCountMore != null and studyCountMore == 1 ">            AND og.study_count > 0 AND cgu.change_grade = 1        </if>        <if test="studyCountMore != null and studyCountMore == 0 ">            AND og.study_count = 0        </if>        <if test="realname != null and realname != ''">            AND u.realname like concat('%', #{realname}, '%')        </if>        <if test="telphone != null and telphone != ''">            AND u.telphone like concat('%', #{telphone}, '%')        </if>        <if test="companyName != null and companyName != ''">            AND u.company_name like concat('%', #{companyName}, '%')        </if>        <if test="idCard != null and idCard != ''">            AND u.id_card like concat('%', #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')        </if>        <if test="idCards != null and idCards.size() != 0">            AND u.id_card IN            <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">            #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}            </foreach>        </if>        <if test="orderSn != null and orderSn != ''">            AND og.order_sn = #{orderSn}        </if>        <if test="goodsName != null and goodsName != ''">            AND g.goods_name like concat('%', #{goodsName}, '%')        </if>        <if test="searchStartTime != null and searchStartTime != ''">            AND cgu.create_time > #{searchStartTime}        </if>        <if test="searchEndTime != null and searchEndTime != ''">            AND cgu.create_time < #{searchEndTime}        </if>        <if test="finishStatus != null">            AND cgu.finish_status = #{finishStatus}        </if>        <if test="learnStatus != null">            AND cgu.learn_status = #{learnStatus}        </if>        <if test="projectId != null and projectId != ''">            AND g.project_id = #{projectId}        </if>        <if test="businessId != null and businessId != ''">            AND g.business_id = #{businessId}        </if>        <if test="educationTypeId != null and educationTypeId != ''">            AND g.education_type_id = #{educationTypeId}        </if>        <if test="majorId != null and majorId != ''">            AND m.id = #{majorId}        </if>        <if test="hasInterface != null and hasInterface == 0">            AND cg.interface_account_id is null AND cg.no_interface_account_id is null        </if>        <if test="hasInterface != null and hasInterface == 1">            AND cg.interface_account_id is not null        </if>        <if test="hasInterface != null and hasInterface == 2">            AND cg.no_interface_account_id is not null        </if>        <if test="hasBindWx != null and hasBindWx == 1 ">            AND u.union_id is not null        </if>        <if test="hasBindWx != null and hasBindWx == 0 ">            AND u.union_id is null        </if>        <if test="hasFollowWx != null and hasFollowWx == 1 ">            AND uwf.gzh_open_id is not null        </if>        <if test="hasFollowWx != null and hasFollowWx == 0 ">            AND uwf.gzh_open_id is null        </if>        order by user_info_status desc ,user_status desc ,cgu.id desc    </select>    <select id="listGradeInform" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeUserListVo">        SELECT        g.*,        (SELECT name FROM class_grade_interface i where g.interface_push_id = i.id) as interface_push_name,        (SELECT name FROM class_grade_interface i where g.interface_account_id = i.id) as interface_account_name,        (SELECT name FROM class_grade_interface i where g.interface_period_id = i.id) as interface_period_name,        (SELECT nick_name FROM sys_user u where g.sys_user_id = u.user_id) as nick_name,        (SELECT area_name FROM apply_areas a where a.area_id = g.areas_id) as area_name,        (SELECT area_name FROM apply_areas a where a.area_id = g.city_id) as city_name,        (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_num        FROM        class_grade g        where g.status !=-1        <if test="status != null and status.size()!=0 ">            AND g.status in            <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">                #{item}            </foreach>        </if>        <if test="gradeId != null and gradeId !=0 ">            AND g.grade_id =  #{gradeId}        </if>        <if test="className != null and className !='' ">            AND g.class_name like concat('%', #{className}, '%')        </if>        <if test="classStartTime != null and classStartTime !=0 ">            AND #{classStartTime} BETWEEN g.class_start_time and g.class_end_time or #{classEndTime} BETWEEN g.class_start_time and g.class_end_time        </if>        <if test="educationTypeId != null and educationTypeId !='' ">            AND (            SELECT            COUNT(*)            FROM            class_grade_goods s            LEFT JOIN goods d ON s.goods_id = d.goods_id            WHERE            1 = 1            AND g.grade_id = s.grade_id            AND d.education_type_id =#{educationTypeId}            ) >0        </if>        <if test="businessId != null and businessId !='' ">            AND (            SELECT            COUNT(*)            FROM            class_grade_goods s            LEFT JOIN goods d ON s.goods_id = d.goods_id            WHERE            1 = 1            AND g.grade_id = s.grade_id            AND d.business_id =#{businessId}            ) >0        </if>        <if test="schoolId != null and schoolId !='' ">            AND (            SELECT            COUNT(*)            FROM            class_grade_goods s            LEFT JOIN goods d ON s.goods_id = d.goods_id            WHERE            1 = 1            AND g.grade_id = s.grade_id            AND d.school_id =#{schoolId}            ) >0        </if>        <if test="majorId != null and majorId !='' ">            AND (            SELECT            COUNT(*)            FROM            class_grade_goods s            LEFT JOIN goods d ON s.goods_id = d.goods_id            WHERE            1 = 1            AND g.grade_id = s.grade_id            AND d.major_id =#{majorId}            ) >0        </if>        <if test="goodsId != null and goodsId !='' ">            AND (            SELECT            COUNT(*)            FROM            class_grade_goods s            WHERE            1 = 1            AND g.grade_id = s.grade_id            AND s.goods_id =#{goodsId}            ) >0        </if>        order by g.update_time desc    </select>    <select id="listGradeStudy"  parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">        SELECT            u.user_account,            u.user_id,            u.realname,            u.id_card        FROM            `user` u        WHERE            1 = 1                and u.realname is NOT NULL          and u.user_id not in (SELECT DISTINCT cgu.user_id from class_grade_user cgu )        <if test="status != null and status.size()!=0 ">            AND u.status in            <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">                #{item}            </foreach>        </if>    </select>    <select id="listGradeService"  parameterType="com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo" resultMap="ClassGradeStudentVo">        SELECT            DISTINCT u.*        FROM        `user` u        LEFT JOIN `order` o ON u.user_id = o.user_id        LEFT JOIN order_goods og ON o.order_sn = og.order_sn        LEFT JOIN goods g on g.goods_id=og.goods_id        WHERE        1 = 1        AND og.status=1        and u.status=1        and og.refund_status in(0,3)        and og.pay_status in (2,3,4)        and g.business_id =#{businessId}    </select>    <select id="querClassSMS"  parameterType="map" resultType="Long">        SELECT            COUNT(1)        FROM            class_grade_goods cgg                LEFT JOIN goods g ON g.business_id = cgg.goods_id        where 1=1          and cgg.grade_id=#{gradeId}          and g.business_id=#{businessId}    </select>    <select id="queryUser"  parameterType="Long" resultType="Long">        SELECT            user_id        FROM            class_grade_user        WHERE            grade_id = #{gradeId}          and `status` = 1    </select>    <select id="getConsoleGradeList" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultMap="ClassGradeVoResult">        SELECT        cg.grade_id,cg.class_status        FROM        class_grade cg LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id        LEFT JOIN goods g ON cgg.goods_id = g.goods_id        WHERE        1 = 1        and cg.`status` != -1        <if test="businessId != null">            AND g.business_id = #{businessId}        </if>        <if test="startTime != null">            AND cg.create_time >= #{startTime}        </if>        <if test="endTime != null">            AND #{endTime} >= cg.create_time        </if>    </select>    <select id="getConsoleGradeUserAccountNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">        SELECT        count(cgu.id)        FROM        class_grade_user cgu  LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id        LEFT JOIN goods g ON cgg.goods_id = g.goods_id        LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id        WHERE        cgu.`status` = 1        AND (cg.interface_account_id is not null or cg.no_interface_account_id is not null)        <if test="learnStatus != null">            AND cgu.learn_status = #{learnStatus}        </if>        <if test="finishStatus != null">            AND cgu.finish_status = #{finishStatus}        </if>        <if test="projectId != null">            AND g.project_id = #{projectId}        </if>        <if test="startTime != null">            AND cgu.create_time >= #{startTime}        </if>        <if test="endTime != null">            AND #{endTime} >= cgu.create_time        </if>    </select>    <select id="getConsoleGradeAccountNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">        SELECT        count(cg.grade_id)        FROM        class_grade cg  LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id        LEFT JOIN goods g ON cgg.goods_id = g.goods_id        WHERE        cg.status !=-1        <if test="interfaceAccountId != null and interfaceAccountId== 1">            AND cg.interface_account_id > 0        </if>        <if test="interfaceAccountId != null and interfaceAccountId== 0">            AND cg.interface_account_id is NULL        </if>        <if test="noInterfaceAccountId != null and noInterfaceAccountId== 1">            AND cg.no_interface_account_id > 0        </if>        <if test="noInterfaceAccountId != null and noInterfaceAccountId== 0">            AND cg.no_interface_account_id is NULL        </if>        <if test="interfacePeriodId != null and interfacePeriodId== 1">            AND cg.interface_period_id > 0        </if>        <if test="interfacePeriodId != null and interfacePeriodId== 0">            AND cg.interface_period_id is NULL        </if>        <if test="interfacePushId != null and interfacePushId== 1">            AND cg.interface_push_id > 0        </if>        <if test="interfacePushId != null and interfacePushId== 0">            AND cg.interface_push_id is NULL        </if>        <if test="businessId != null">            AND g.business_id = #{businessId}        </if>        <if test="startTime != null">            AND cg.create_time >= #{startTime}        </if>        <if test="endTime != null">            AND #{endTime} >= cg.create_time        </if>    </select>    <select id="getConsolePeriodNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">        SELECT        count(cgu.id)        FROM        class_grade_user cgu  LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id        LEFT JOIN goods g ON cgg.goods_id = g.goods_id        WHERE        1 = 1        <if test="periodStatus != null">            AND cgu.period_status = #{periodStatus}        </if>        <if test="businessId != null">            AND g.business_id = #{businessId}        </if>        <if test="startTime != null">            AND cgu.period_ing_time >= #{startTime}        </if>        <if test="endTime != null">            AND #{endTime} >= cgu.period_ing_time        </if>        <if test="waitStartTime != null">            AND cgu.period_wait_time >= #{waitStartTime}        </if>        <if test="waitEndTime != null">            AND #{waitEndTime} >= cgu.period_wait_time        </if>    </select>    <select id="getConsoleGradeUserPeriodNum" parameterType="com.zhongzheng.modules.base.bo.ConsoleQueryBo" resultType="Integer">        SELECT        count(cgu.id)        FROM        class_grade_user cgu  LEFT JOIN class_grade_goods cgg ON cgu.grade_id = cgg.grade_id        LEFT JOIN goods g ON cgg.goods_id = g.goods_id        LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id        WHERE        1 = 1        <if test="periodStatus != null">            AND cgu.period_status = 1        </if>        <if test="interfacePushId != null">            AND cg.interface_push_id > 0        </if>        <if test="officialStatus != null">            AND cgu.official_status = 1        </if>        <if test="periodPlush != null">            AND cgu.period_plush = 1        </if>        <if test="businessId != null">            AND g.business_id = #{businessId}        </if>    </select>    <select id="listGoodsBatch" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeGoodsVoResult">        SELECT        g.goods_id        FROM        goods g        WHERE        1=1        <if test="goodsIds != null and goodsIds.size()!=0 ">            AND g.goods_id in            <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">                #{item}            </foreach>        </if>    </select>    <select id="listGradeSubjects" resultMap="ClassGradeVoResult">        SELECT            cg.*,            g.subject_ids,            g.business_id,            g.project_id        FROM            class_grade cg        LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id        LEFT JOIN goods g ON cgg.goods_id = g.goods_id    </select>    <select id="queryCountList" parameterType="java.lang.Long" resultMap="ClassGradeVoResult">        SELECT            cg.*        FROM            class_grade cg        LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id        LEFT JOIN goods g ON cgg.goods_id = g.goods_id        WHERE            cg.`status` != -1          and cg.`status` in (0,1)          and g.business_id = #{businessId}    </select>        <select id="queryOfficialGradeCount" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultType="Integer">        SELECT            ((                 SELECT                     count(*)                 FROM                     class_grade_user_temp cgu                         LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id                 WHERE                     cg.official_name = #{officialName}                   AND cgu.`status` = 1             ) + (                 SELECT                     count(*)                 FROM                     class_grade_user cgu                         LEFT JOIN class_grade cg ON cgu.grade_id = cg.grade_id                 WHERE                     cg.official_name = #{officialName}                   AND cgu.`status` = 1             ))    </select>    <select id="queryGradeList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultMap="ClassGradeVoResult">        SELECT            cg.*,cgg.goods_id        FROM             class_grade cg LEFT JOIN class_grade_goods cgg on cg.grade_id = cgg.grade_id where            cg.class_end_time > #{startTime}            AND #{endTime} >= cg.class_end_time    </select>    <select id="getClassUserNumByTenant" parameterType="java.lang.Long" resultType="java.lang.Long">        SELECT            sum( a.num )        FROM            ( SELECT COUNT( user_id ) AS num FROM class_grade_user WHERE grade_id = #{gradeId} AND `status` = 1 AND change_grade = 0 GROUP BY user_id ) a    </select>    <select id="getGradeDetailByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassNpUserInfoBo" resultType="com.zhongzheng.modules.grade.vo.ClassNpUserInfoVo">        SELECT            CONCAT('',cg.tenant_id) as tenantId,            cg.official_name as classNo,            cb.alias_name as platformName,            cg.class_name as categoryName,            u.realname as `name`,            u.id_card as idNum,            u.telphone as mobile,            u.company_name as companyName,            og.create_time as orderTimeLong,            cg.class_start_time as createTimeLong,            cgu.official_status_time as doTimeLong,            cgu.official_status as reportStatu,            cgu.period_plush as studyQueueStatus,            u.user_id,            cg.grade_id,            g.subject_ids        FROM class_grade cg                 LEFT JOIN class_grade_user cgu ON cg.grade_id = cgu.grade_id                <if test="tenantId != null and tenantId !=''">                    AND cgu.tenant_id = #{tenantId}                </if>                 LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id                <if test="tenantId != null and tenantId !=''">                    AND cgg.tenant_id = #{tenantId}                </if>                 LEFT JOIN `user` u ON cgu.user_id = u.user_id                <if test="tenantId != null and tenantId !=''">                    AND u.tenant_id = #{tenantId}                </if>                 LEFT JOIN goods g ON cgg.goods_id = g.goods_id                <if test="tenantId != null and tenantId !=''">                    AND g.tenant_id = #{tenantId}                </if>                LEFT JOIN order_goods og ON cg.grade_id = og.grade_id                <if test="tenantId != null and tenantId !=''">                    AND og.tenant_id = #{tenantId}                </if>                 LEFT JOIN course_business cb ON g.business_id = cb.id                <if test="tenantId != null and tenantId !=''">                    AND cb.tenant_id = #{tenantId}                </if>        WHERE 1 = 1        <if test="officialName != null and officialName !=''">            AND cg.official_name = #{officialName}        </if>        <if test="tenantId != null and tenantId !=''">            AND cg.tenant_id = #{tenantId}        </if>        <if test="name != null and name !=''">            AND u.realname like concat('%', #{name}, '%')        </if>        <if test="idNum != null and idNum !=''">            AND u.id_card like concat('%', #{idNum}, '%')        </if>        <if test="mobile != null and mobile !=''">            AND u.telphone like concat('%', #{mobile}, '%')        </if>    </select>    <select id="getGradeListByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeListBo" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">        SELECT            cg.*        FROM            class_grade cg            LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id            LEFT JOIN goods g ON cgg.goods_id = g.goods_id            LEFT JOIN course_business cb ON g.business_id = cb.id        WHERE            cb.alias_name = #{aliasName} AND cg.class_status = 0 AND cg.`status` = 1        <if test="subIds != null and subIds.size()!=0 ">            AND (            <foreach collection="subIds" item="id" index="index">                <if test="index != subIds.size()-1">                    FIND_IN_SET(g.subject_ids,#{id}) OR                </if>                <if test="index == subIds.size()-1">                    FIND_IN_SET(g.subject_ids,#{id})                </if>            </foreach>                )        </if>    </select>    <select id="getGoodsIdByBoTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeListBo" resultType="java.lang.Long">        SELECT        g.goods_id        FROM            goods g            LEFT JOIN course_business cb ON g.business_id = cb.id AND cb.tenant_id = #{tenantId}        WHERE        cb.alias_name = #{aliasName} AND g.`status` = 1 AND g.tenant_id = #{tenantId}        <if test="subIds != null and subIds.size()!=0 ">            AND (            <foreach collection="subIds" item="id" index="index">                <if test="index != subIds.size()-1">                    FIND_IN_SET(g.subject_ids,#{id}) OR                </if>                <if test="index == subIds.size()-1">                    FIND_IN_SET(g.subject_ids,#{id})                </if>            </foreach>            )        </if>    </select>    <select id="queryListByNameTenantId" parameterType="map" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">        SELECT            *        FROM            class_grade        where class_name like concat('%', #{className}, '%') and tenant_id = #{tenantId}    </select>    <select id="getGradeListByCodeTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">        SELECT            *        FROM            class_grade        where register_code = #{registerCode}    </select>    <update id="UpGradeStatusByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeOpenUpBo" >        update class_grade set class_status = #{classStatus} , official_name = #{officialName} where 1 = 1        <if test="gradeIds != null and gradeIds.size()!=0 ">            AND grade_id in            <foreach collection="gradeIds" item="item" index="index" open="(" close=")" separator=",">                #{item}            </foreach>        </if>    </update>    <update id="UpGradeCodeByIdTenant" parameterType="java.lang.Long" >        update class_grade set register_code = official_name where 1 = 1        <if test="gradeIds != null and gradeIds.size()!=0 ">            AND grade_id in            <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">                #{item}            </foreach>        </if>    </update></mapper>
 |