12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583 |
- <?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.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"/>
- <result property="sevenCode" column="seven_code"/>
- </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" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
- <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="educationName" column="education_name"/>
- <result property="sevenYear" column="seven_year"/>
- <result property="orgId" column="org_id"/>
- <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"/>
- <result property="periodPlushMsg" column="official_status_msg"/>
- <result property="officialStatusMsg" column="period_plush_msg"/>
- <result property="companyName" column="company_name"/>
- <result property="gradeName" column="class_name"/>
- <result property="endTime" column="end_time"/>
- <result property="profileStatus" column="profile_status"/>
- <result property="classStatus" column="class_status"/>
- </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>
- <resultMap type="com.zhongzheng.modules.grade.vo.ClassNpUserInfoVo" id="ClassNpUserInfoVoResult">
- <result property="gradeId" column="grade_id"/>
- <result property="tenantId" column="tenantId"/>
- <result property="classNo" column="classNo"/>
- <result property="platformName" column="platformName"/>
- <result property="categoryName" column="categoryName"/>
- <result property="name" column="name"/>
- <result property="idNum" column="idNum" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
- <result property="mobile" column="mobile" typeHandler="com.zhongzheng.common.type.EncryptHandler"/>
- <result property="companyName" column="companyName"/>
- <result property="orderTimeLong" column="orderTimeLong"/>
- <result property="createTimeLong" column="createTimeLong"/>
- <result property="doTimeLong" column="doTimeLong"/>
- <result property="reportStatu" column="reportStatu"/>
- <result property="finishStatus" column="finishStatus"/>
- <result property="studyQueueStatus" column="studyQueueStatus"/>
- <result property="finishStatus" column="finishStatus"/>
- <result property="applyTimeLong" column="applyTimeLong"/>
- <result property="userId" column="user_id"/>
- <result property="subjectIds" column="subject_ids"/>
- </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.*,
- d.goods_id,
- (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())+6*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 d.goods_id = #{goodsId}
- </if>
- <if test="goodsIds != null and goodsIds.size()!=0 ">
- AND d.goods_id in
- <foreach collection="goodsIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </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,
- og.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,
- g.class_hours,
- cgu.period_status,
- cgu.finish_status,
- cgu.period_plush,
- g.study_start_time,
- g.study_end_time,
- cg.class_start_time,
- cg.class_end_time,
- cg.interface_push_id,
- cgu.official_status,
- cgu.official_status_msg,
- cgu.period_plush_msg,
- cgu.learn_status,
- (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id where c.goods_id=og.goods_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 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.order_goods_id = cgu.order_goods_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,
- og.seven_year,
- m.category_name,
- g.major_id,
- u.province,
- cgu.reason,
- cgu.tenant_id as org_id,
- 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,
- cet.education_name
- 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 course_education_type cet ON g.education_type_id = cet.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 and cgu.`status` = 1
- <if test="sevenCode != null and sevenCode !='' ">
- AND cg.seven_code = #{sevenCode}
- </if>
- <if test="gradeId != null and gradeId !='' and (sevenCode == null or sevenCode =='')">
- 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 cgur.order_goods_id = cgu.order_goods_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 cgur.order_goods_id = cgu.order_goods_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="officialStatus != null and officialStatus == 1 ">
- AND cgu.official_status = 1
- </if>
- <if test="officialStatus != null and officialStatus == 0 ">
- AND (cgu.official_status is NULL or cgu.official_status=0)
- </if>
- <if test="periodPlush != null and periodPlush == 1 ">
- AND cgu.period_plush = 1
- </if>
- <if test="periodPlush != null and periodPlush == 0 ">
- AND (cgu.period_plush is NULL or cgu.period_plush=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,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
- </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="searchKey != null and searchKey != ''">
- AND (cg.class_name like concat('%', #{searchKey}, '%') or u.realname like concat('%', #{searchKey}, '%') or u.company_name like concat('%', #{searchKey}, '%'))
- </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="listGradeAll" 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,
- u.company_name,
- cgu.`status`,
- u.realname,
- og.goods_id,
- u.id_card,
- cgu.grade_id,
- u.telphone,
- g.class_hours,
- cgu.period_status,
- cgu.finish_status,
- cgu.period_plush,
- g.study_start_time,
- g.study_end_time,
- cg.class_start_time,
- cg.class_end_time,
- cg.class_status,
- cg.interface_push_id,
- cgu.official_status,
- cgu.official_status_msg,
- cgu.period_plush_msg,
- cgu.learn_status,
- cgu.period_wait_time as end_time,
- (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,
- (SELECT COUNT(m.id) FROM course_menu_exam m LEFT JOIN goods_course c on m.course_id=c.course_id where c.goods_id=og.goods_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 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.order_goods_id = cgu.order_goods_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,
- og.seven_year,
- m.category_name,
- g.major_id,
- u.province,
- cg.class_name,
- cgu.reason,
- cgu.tenant_id as org_id,
- cb.business_name,
- cpt.project_name,
- (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,
- up.`status` as profile_status,
- cet.education_name
- 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 course_education_type cet ON g.education_type_id = cet.id
- LEFT JOIN user_exam_goods ueg ON ueg.order_goods_id = og.order_goods_id
- LEFT JOIN user_profile up on cgu.order_goods_id = up.order_goods_id and up.type_status=1 and up.current_status = 1
- where 1=1 and cgu.`status` = 1
- <if test="sevenCode != null and sevenCode !='' ">
- AND cg.seven_code = #{sevenCode}
- </if>
- <if test="gradeId != null and gradeId !='' and (sevenCode == null or sevenCode =='')">
- 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 cgur.order_goods_id = cgu.order_goods_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 cgur.order_goods_id = cgu.order_goods_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 AND (cg.status = 0 or unix_timestamp(now()) > cg.class_end_time)
- </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="officialStatus != null and officialStatus == 1 ">
- AND cgu.official_status = 1
- </if>
- <if test="officialStatus != null and officialStatus == 0 ">
- AND (cgu.official_status is NULL or cgu.official_status=0)
- </if>
- <if test="periodPlush != null and periodPlush == 1 ">
- AND cgu.period_plush = 1
- </if>
- <if test="periodPlush != null and periodPlush == 0 ">
- AND (cgu.period_plush is NULL or cgu.period_plush=0)
- </if>
- <if test="searchKey != null and searchKey != ''">
- AND (cg.class_name like concat('%', #{searchKey}, '%') or u.realname like concat('%', #{searchKey}, '%') or u.company_name like concat('%', #{searchKey}, '%'))
- </if>
- <if test="telphone != null and telphone != ''">
- AND (u.telphone like concat('%', #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
- </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>
- </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 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 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 order_goods og ON cgu.order_goods_id = og.order_goods_id
- LEFT JOIN goods g ON og.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 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 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
- <if test="classSign != null">
- AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cgu.tenant_id AND sog.share_class = #{classSign}) > 0
- </if>
- ) + (
- 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
- <if test="classSign != null">
- AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cgu.tenant_id AND sog.share_class = #{classSign}) > 0
- </if>
- ))
- </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
- IFNULL(sum( a.num ),0)
- 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" resultMap="ClassNpUserInfoVoResult" >
- 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,
- (SELECT og.create_time FROM order_goods og LEFT JOIN `order` o ON og.order_sn = o.order_sn WHERE og.goods_id = g.goods_id AND o.user_id = u.user_id AND og.pay_status in (2, 3, 4)
- AND og.refund_status !=2
- ORDER BY og.create_time DESC LIMIT 1) AS orderTimeLong,
- cg.class_start_time as createTimeLong,
- cgu.official_status_time as doTimeLong,
- cgu.official_status as reportStatu,
- cgu.finish_status as finishStatus,
- cgu.period_plush as studyQueueStatus,
- cgu.period_wait_time as applyTimeLong,
- cgu.finish_status as finishStatus,
- u.user_id,
- cg.grade_id,
- g.subject_ids
- FROM class_grade cg
- INNER JOIN class_grade_user cgu ON cg.grade_id = cgu.grade_id
- <if test="tenantId != null">
- AND cgu.tenant_id = #{tenantId}
- </if>
- INNER JOIN order_goods og ON cgu.order_goods_id = og.order_goods_id
- <if test="tenantId != null">
- AND og.tenant_id = #{tenantId}
- </if>
- LEFT JOIN `user` u ON cgu.user_id = u.user_id
- <if test="tenantId != null">
- AND u.tenant_id = #{tenantId}
- </if>
- LEFT JOIN goods g ON og.goods_id = g.goods_id
- <if test="tenantId != null">
- AND g.tenant_id = #{tenantId}
- </if>
- LEFT JOIN course_business cb ON g.business_id = cb.id
- <if test="tenantId != null">
- AND cb.tenant_id = #{tenantId}
- </if>
- WHERE 1 = 1
- AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
- <if test="officialName != null and officialName !=''">
- AND cg.official_name = #{officialName}
- </if>
- <if test="tenantId != null">
- 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,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
- </if>
- <if test="mobile != null and mobile !=''">
- AND u.telphone like concat('%', #{mobile,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
- </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 AND g.goods_status = 1 AND cb.`status` = 1 AND g.`status` = 1
- AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = cg.tenant_id AND sog.share_class = 1) > 0
- <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(#{id},g.subject_ids) OR
- </if>
- <if test="index == subIds.size()-1">
- FIND_IN_SET(#{id},g.subject_ids)
- </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}
- LEFT JOIN course_project_type cpt ON cb.project_id = cpt.id AND cpt.tenant_id = #{tenantId}
- LEFT JOIN course_education_type cet ON cpt.education_id = cet.id AND cet.tenant_id = #{tenantId}
- WHERE
- cb.alias_name = #{aliasName} AND g.`status` = 1 AND g.tenant_id = #{tenantId} AND g.goods_status = 1 AND cet.education_name = #{educationName}
- AND (SELECT COUNT(*) FROM sys_old_org sog WHERE sog.tenant_id = g.tenant_id AND sog.share_class = 1) > 0
- <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(#{id},g.subject_ids) OR
- </if>
- <if test="index == subIds.size()-1">
- FIND_IN_SET(#{id},g.subject_ids)
- </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
- cg.*
- FROM
- class_grade cg
- where cg.official_name = #{officialName}
- AND (SELECT COUNT(*) FROM sys_tenant s WHERE s.tenant_id = cg.tenant_id AND s.share_class = 1) > 0
- </select>
- <update id="UpGradeStatusByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeOpenUpBo" >
- update class_grade set class_status = #{classStatus},official_name = #{officialName},class_name = #{className},
- class_start_time = #{classStartTime},class_end_time = #{classEndTime},learning_status = #{learningStatus},learning_time_start = #{learningTimeStart}
- 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="ids != null and ids.size()!=0 ">
- AND grade_id in
- <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </update>
- <update id="UpGradeInterfaceByTenant" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeOpenUpBo" >
- update class_grade set interface_push_id = #{interfacePushId} where grade_id = #{gradeId}
- </update>
- <select id="getSevenGrade" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.grade.domain.ClassGrade">
- SELECT *
- FROM class_grade cg
- WHERE cg.`status` = 1 AND (
- (SELECT COUNT(DISTINCT cgu.user_id) FROM class_grade_user cgu WHERE cg.grade_id = cgu.grade_id AND cgu.`status` = 1 AND cgu.change_grade = 0) +
- (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cg.grade_id = cgut.grade_id AND cgut.`status` = 1 )
- ) <![CDATA[ < ]]> cg.student_upper AND cg.grade_id IN
- <foreach collection="gradeIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- LIMIT 1
- </select>
- <select id="getStudeCountByCode" resultType="java.lang.Long" parameterType="java.lang.String">
- SELECT SUM(
- (SELECT COUNT(DISTINCT cgu.user_id) FROM class_grade_user cgu WHERE cgu.grade_id = cg.grade_id AND cgu.`status` = 1 AND cgu.change_grade = 0) +
- (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
- ) as num FROM class_grade cg
- WHERE cg.`status` = 1 AND cg.seven_code = #{sevenCode}
- </select>
- <select id="searchGradeList" parameterType="com.zhongzheng.modules.grade.bo.ClassGradeQueryBo" resultType="com.zhongzheng.modules.grade.vo.ClassGradeVo">
- SELECT
- *
- FROM
- (
- SELECT DISTINCT
- g.grade_id,
- g.class_name,
- g.create_time,
- g.class_status,
- d.goods_name,
- g.official_name,
- g.seven_code,
- g.student_upper,
- g.class_start_time,
- g.class_end_time,
- g.learning_status,
- g.remark,
- g.status,
- (SELECT COUNT(a.id) FROM class_grade_user a where a.grade_id = g.grade_id and a.status =1) as student_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 (SELECT grade_id,any_value(goods_id) goods_id from class_grade_goods GROUP BY grade_id)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
- WHERE
- g.seven_code IS NULL
- <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="searchKey != null and searchKey !='' ">
- AND ((g.class_name like concat('%', #{searchKey}, '%')) 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="userName != null and userName !='' ">
- AND (
- 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('%', #{userName}, '%')
- ) >0
- </if>
- AND g.status != -1
- <if test="classStatus != null and classStatus==0">
- AND (g.class_status = #{classStatus} or g.class_status is null )
- </if>
- <if test="classStatus != null and classStatus==1">
- AND g.class_status = 1 and g.class_end_time >= unix_timestamp(now())
- </if>
- <if test="classStatus != null and classStatus == 2 ">
- AND g.class_status = 1 and unix_timestamp(now()) > g.class_end_time
- </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 g.class_start_time >=#{classStartTime}
- </if>
- <if test="classEndTime != null and classEndTime != '' ">
- AND #{classEndTime} >= 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 d.education_type_id = #{educationTypeId}
- </if>
- <if test="businessId != null and businessId !='' ">
- AND cb.id = #{businessId}
- </if>
- <if test="majorId != null and majorId !='' ">
- AND d.major_id = #{majorId}
- </if>
- UNION ALL
- SELECT DISTINCT
- g.grade_id,
- g.class_name,
- g.create_time,
- g.class_status,
- d.goods_name,
- g.official_name,
- g.seven_code,
- g.student_upper,
- g.class_start_time,
- g.class_end_time,
- g.learning_status,
- g.remark,
- g.status,
- (SELECT COUNT(c.id) FROM class_grade_user c where a.grade_id = c.grade_id and c.status =1) as student_num,
- (
- SELECT
- GROUP_CONCAT( subject_name )
- FROM
- course_subject
- WHERE
- FIND_IN_SET( id, d.subject_ids )) subject_names
- FROM
- ( SELECT any_value ( g.grade_id ) AS grade_id FROM class_grade g WHERE g.`status` != - 1 AND g.seven_code IS NOT NULL
- <if test="userName != null and userName !='' ">
- AND (
- 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('%', #{userName}, '%')
- ) >0
- </if>
- GROUP BY seven_code ) a
- LEFT JOIN class_grade g ON a.grade_id = g.grade_id
- 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
- WHERE
- 1 = 1
- AND 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="searchKey != null and searchKey !='' ">
- AND ((g.class_name like concat('%', #{searchKey}, '%')) 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 classStatus==0">
- AND (g.class_status = #{classStatus} or g.class_status is null )
- </if>
- <if test="classStatus != null and classStatus==1">
- AND g.class_status = 1 and g.class_end_time >= unix_timestamp(now())
- </if>
- <if test="classStatus != null and classStatus == 2 ">
- AND g.class_status = 1 and unix_timestamp(now()) > g.class_end_time
- </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 g.class_start_time >=#{classStartTime}
- </if>
- <if test="classEndTime != null and classEndTime != '' ">
- AND #{classEndTime} >= 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 d.education_type_id = #{educationTypeId}
- </if>
- <if test="businessId != null and businessId !='' ">
- AND cb.id = #{businessId}
- </if>
- <if test="majorId != null and majorId !='' ">
- AND d.major_id = #{majorId}
- </if>
- ) b
- WHERE
- 1 = 1
- ORDER BY
- b.create_time DESC
- </select>
- <select id="getSevenYearByCode" resultType="java.lang.String" parameterType="java.lang.String">
- SELECT DISTINCT
- g.seven_year
- 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.seven_code = #{sevenCode}
- </select>
- <select id="listByIdsNoTenant" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="java.lang.Long">
- SELECT
- cg.*
- FROM
- class_grade cg
- WHERE
- cg.`status` != - 1
- AND cg.grade_id in
- <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </select>
- <select id="getListNoTenant" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="map">
- SELECT
- *
- FROM
- class_grade
- WHERE
- `status` = 1
- AND seven_code = #{sevenCode}
- AND grade_id != #{gradeId}
- </select>
- <update id="updateByIdNoTenant" parameterType="com.zhongzheng.modules.grade.domain.ClassGrade">
- UPDATE class_grade
- SET class_status = #{classStatus},
- official_name = #{officialName},
- class_name = #{className},
- student_upper = #{studentUpper},
- learning_time_start = #{learningTimeStart},
- learning_status = #{learningStatus},
- `status` = #{status},
- class_start_time = #{classStartTime},
- class_end_time = #{classEndTime},
- examine_id = #{examineId},
- areas_id = #{areasId}
- WHERE
- grade_id = #{gradeId}
- </update>
- <select id="getCodeNoTenant" resultType="com.zhongzheng.modules.grade.domain.ClassGrade" parameterType="map">
- SELECT
- *
- FROM
- class_grade
- WHERE
- `status` = 1
- AND official_name = #{officialName}
- AND tenant_id = #{tenantId}
- LIMIT 1
- </select>
- <select id="getGradeCount" resultType="java.lang.Long" parameterType="java.lang.String">
- SELECT
- COUNT( DISTINCT cgu.user_id )
- FROM
- class_grade_user cgu
- WHERE
- cgu.`status` = 1
- AND cgu.grade_id IN ( SELECT grade_id FROM class_grade WHERE seven_code = #{sevenCode} )
- </select>
- <select id="getStudeCountByCodeNoTenant" resultType="java.lang.Integer" parameterType="java.lang.String">
- SELECT SUM(
- (SELECT COUNT(DISTINCT cgu.user_id) FROM class_grade_user cgu WHERE cgu.grade_id = cg.grade_id AND cgu.`status` = 1 AND cgu.change_grade = 0) +
- (SELECT COUNT(DISTINCT cgut.user_id) FROM class_grade_user_temp cgut WHERE cgut.grade_id = cg.grade_id AND cgut.`status` = 1 )
- ) as num FROM class_grade cg
- WHERE cg.`status` = 1 AND cg.seven_code = #{sevenCode}
- </select>
- </mapper>
|