| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046 |
- <?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"/>
- </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="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,
- (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) AS orderTimeLong,
- cg.class_start_time as createTimeLong,
- cgu.official_status_time as doTimeLong,
- cgu.official_status as reportStatu,
- cgu.period_plush as studyQueueStatus,
- cgu.period_wait_time as applyTimeLong,
- 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 cgu.tenant_id = #{tenantId}
- </if>
- LEFT JOIN class_grade_goods cgg ON cg.grade_id = cgg.grade_id
- <if test="tenantId != null">
- AND cgg.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 cgg.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
- <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}, '%')
- </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},class_name = #{className},class_start_time = #{classStartTime},class_end_time = #{classEndTime}
- 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>
|