TeacherMapper.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.yonge.cooleshow.biz.dal.dao.TeacherDao">
  4. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.Teacher">
  5. <result column="user_id_" property="userId"/>
  6. <result column="education_background_" property="educationBackground"/>
  7. <result column="graduate_school_" property="graduateSchool"/>
  8. <result column="technical_titles_" property="technicalTitles"/>
  9. <result column="work_unit_" property="workUnit"/>
  10. <result column="subject_id_" property="subjectId"/>
  11. <result column="default_subject_" property="defaultSubject"/>
  12. <result column="introduction_" property="introduction"/>
  13. <result column="subject_" property="subject"/>
  14. <result column="grad_certificate_" property="gradCertificate"/>
  15. <result column="degree_certificate_" property="degreeCertificate"/>
  16. <result column="teacher_certificate_" property="teacherCertificate"/>
  17. <result column="entry_flag_" property="entryFlag"/>
  18. <result column="entry_auth_date_" property="entryAuthDate"/>
  19. <result column="musician_flag_" property="musicianFlag"/>
  20. <result column="musician_date_" property="musicianDate"/>
  21. <result column="member_rank_setting_id_" property="memberRankSettingId"/>
  22. <result column="membership_start_time_" property="membershipStartTime"/>
  23. <result column="membership_end_time_" property="membershipEndTime"/>
  24. <result column="live_flag_" property="liveFlag"/>
  25. <result column="live_date_" property="liveDate"/>
  26. <result column="music_date_" property="musicDate"/>
  27. <result column="video_date_" property="videoDate"/>
  28. <result column="style_date_" property="styleDate"/>
  29. <result column="degree_date_" property="degreeDate"/>
  30. <result column="teacher_date_" property="teacherDate"/>
  31. <result column="degree_flag_" property="degreeFlag"/>
  32. <result column="teacher_flag_" property="teacherFlag"/>
  33. <result column="browse_" property="browse"/>
  34. <result column="memo_" property="memo"/>
  35. <result column="lock_flag_" property="lockFlag"/>
  36. <result column="is_settlement_" property="isSettlement"/>
  37. <result column="is_test_user_" property="isTestUser"/>
  38. <result column="tenant_id_" property="tenantId"/>
  39. <result column="settlement_from_" property="settlementFrom"/>
  40. <result column="create_time_" property="createTime"/>
  41. <result column="update_time_" property="updateTime"/>
  42. <result column="im_device_id_" property="imDeviceId"/>
  43. <result column="customer_service_" property="customerService"/>
  44. <result column="customer_id_" property="customerId"/>
  45. </resultMap>
  46. <resultMap id="HotTeacherVoMap" type="com.yonge.cooleshow.biz.dal.vo.HotTeacherVo">
  47. <result column="user_id_" property="userId"/>
  48. <result column="avatar_" property="avatar"/>
  49. <result column="graduate_school_" property="graduateSchool"/>
  50. <result column="username_" property="username"/>
  51. <result column="isLiving_" property="isLiving"/>
  52. </resultMap>
  53. <!-- 表字段 -->
  54. <sql id="baseColumns">
  55. t.user_id_ as "userId"
  56. , t.education_background_ as "educationBackground"
  57. , t.graduate_school_ as "graduateSchool"
  58. , t.technical_titles_ as "technicalTitles"
  59. , t.work_unit_ as "workUnit"
  60. , t.subject_id_ as "subjectId"
  61. , t.default_subject_ as defaultSubject
  62. , t.introduction_ as "introduction"
  63. , t.subject_ as "subject"
  64. , t.grad_certificate_ as "gradCertificate"
  65. , t.degree_certificate_ as "degreeCertificate"
  66. , t.teacher_certificate_ as "teacherCertificate"
  67. , t.entry_flag_ as "entryFlag"
  68. , t.entry_auth_date_ as "entryAuthDate"
  69. , t.musician_flag_ as "musicianFlag"
  70. , t.musician_date_ as "musicianDate"
  71. , t.live_flag_ as "liveFlag"
  72. , t.music_date_ as "musicDate"
  73. , t.video_date_ as "videoDate"
  74. , t.style_date_ as "styleDate"
  75. , t.degree_date_ as "degreeDate"
  76. , t.teacher_date_ as "teacherDate"
  77. , t.degree_flag_ as "degreeFlag"
  78. , t.teacher_flag_ as "teacherFlag"
  79. , t.member_rank_setting_id_ as "memberRankSettingId"
  80. <!-- , t.membership_start_time_ as "membershipStartTime"-->
  81. <!-- , t.membership_end_time_ as "membershipEndTime"-->
  82. , t.browse_ as "browse"
  83. , t.memo_ as "memo"
  84. , t.tag_ as "tag"
  85. , t.is_settlement_ as "isSettlement"
  86. , t.is_test_user_ as "isTestUser"
  87. , t.create_time_ as "createTime"
  88. , t.update_time_ as "updateTime"
  89. , t.train_time_ as trainTime
  90. , t.evaluate_time_ as evaluateTime
  91. , t.tenant_id_ as tenantId
  92. , t.settlement_from_ as settlementFrom
  93. , t.im_device_id_ as imDeviceId
  94. , t.customer_service_ as customerService
  95. , t.customer_id_ as customerId
  96. , t.im_customer_id_ AS imCustomerId
  97. </sql>
  98. <!-- 分页查询 -->
  99. <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherVo">
  100. SELECT
  101. <include refid="baseColumns"/>,
  102. if(u.lock_flag_ = 0 and t.lock_flag_ = 0,0,1) as lockFlag,
  103. u.username_ as username,
  104. u.phone_ as phone,
  105. u.real_name_ as realName,
  106. u.avatar_ as avatar,
  107. u.birthdate_ as birthdate,
  108. u.gender_ as gender,
  109. <!-- (case when t.membership_end_time_ &gt;= now() then 1 else 0 end) isVip,-->
  110. <!-- t.tag_ tag,-->
  111. u.del_flag_ as delFlag,
  112. ifnull(vcr2.vip_type_ ,'NORMAL') as vipType,
  113. max(if(vcr.vip_type_ = 'VIP', vcr.end_time_, null)) vipEndTime,
  114. max(if(vcr.vip_type_ = 'SVIP' and vcr.type_ = 'PERPETUAL', vcr.end_time_ , null)) perSvipEndTime,
  115. max(if(vcr.vip_type_ = 'SVIP', vcr.end_time_, null)) svipEndTime,
  116. max(vcr.end_time_) currentVipEndTime,
  117. (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal,
  118. (case when isnull(b.user_id_) then 0 else 1 end) as isBank,
  119. (case when t.tenant_id_ = -1 then '平台' else ti.name_ end) as tenantName
  120. FROM teacher t
  121. left join sys_user u on t.user_id_ = u.id_
  122. left join (
  123. select distinct user_id_ from user_bank_card where del_flag_ = 0
  124. ) b on t.user_id_ = b.user_id_
  125. left join tenant_info ti on t.tenant_id_ = ti.id_
  126. left join vip_card_record vcr on t.user_id_ = vcr.user_id_ and vcr.efficient_flag_ = 1 and vcr.client_type_='TEACHER'
  127. left join vip_card_record vcr2 on t.user_id_ = vcr2.user_id_ and vcr2.efficient_flag_ = 1 and vcr2.end_time_ > now() and now() >= vcr2.start_time_ and vcr2.client_type_='TEACHER'
  128. <where>
  129. <if test="null != param.search and '' != param.search">
  130. AND (
  131. t.user_id_ LIKE CONCAT('%', #{param.search}, '%') or
  132. u.username_ LIKE CONCAT('%', #{param.search}, '%') or
  133. u.real_name_ LIKE CONCAT('%', #{param.search}, '%') or
  134. u.phone_ LIKE CONCAT('%', #{param.search}, '%')
  135. )
  136. </if>
  137. <if test="null != param.teacherType and '' != param.teacherType">
  138. and (
  139. 1=0
  140. <if test='param.teacherType.contains("TOURIST")'>
  141. or (t.entry_flag_ = 0 and t.musician_flag_ = 0)
  142. </if>
  143. <if test='param.teacherType.contains("ENTRY")'>
  144. or t.entry_flag_ = 1
  145. </if>
  146. <if test='param.teacherType.contains("MUSICIAN")'>
  147. or t.musician_flag_ = 1
  148. </if>
  149. )
  150. </if>
  151. <if test="param.vipType != null">
  152. <if test="param.vipType.code == 'NORMAL'">
  153. and vcr2.id_ is null
  154. </if>
  155. <if test="param.vipType.code != 'NORMAL'">
  156. and vcr2.vip_type_ = #{param.vipType}
  157. </if>
  158. </if>
  159. <!-- <if test="param.isVip != null">-->
  160. <!-- <if test="param.isVip == 0">-->
  161. <!-- and (t.membership_end_time_ is null or t.membership_end_time_ &lt; now())-->
  162. <!-- </if>-->
  163. <!-- <if test="param.isVip == 1">-->
  164. <!-- and t.membership_end_time_ &gt;= now()-->
  165. <!-- </if>-->
  166. <!-- </if>-->
  167. <if test="param.tag != null">
  168. and find_in_set(#{param.tag},t.tag_)
  169. </if>
  170. <if test="null != param.lockFlag">
  171. and t.lock_flag_ = #{param.lockFlag}
  172. </if>
  173. <if test="null != param.delFlag">
  174. and u.del_flag_ = #{param.delFlag}
  175. </if>
  176. <if test="param.subjectId != null">
  177. and find_in_set(#{param.subjectId},t.subject_id_)
  178. </if>
  179. <if test="param.subjectIds != null and param.subjectIds.size() != 0">
  180. and (
  181. <foreach collection="param.subjectIds" item="subjectId" separator=" or " open="(" close=")">
  182. find_in_set(#{subjectId},t.subject_id_)
  183. </foreach>
  184. )
  185. </if>
  186. <if test="param.isSettlement != null">
  187. and t.is_settlement_ = #{param.isSettlement}
  188. </if>
  189. <if test="param.isTestUser != null">
  190. and t.is_test_user_ = #{param.isTestUser}
  191. </if>
  192. <if test="null != param.vipEndTime">
  193. and vcr.end_time_ &lt;= #{param.vipEndTime}
  194. </if>
  195. <if test="null != param.vipStartTime">
  196. and vcr.end_time_ &gt;= #{param.vipStartTime}
  197. </if>
  198. <if test="param.trainFlag != null">
  199. AND t.train_time_ > 0
  200. </if>
  201. <if test="param.evaluateFlag != null">
  202. AND t.evaluate_time_ > 0
  203. </if>
  204. <if test="param.tenantId != null">
  205. AND t.tenant_id_ = #{param.tenantId}
  206. </if>
  207. <if test="param.bindTenant != null and param.bindTenant == 0">
  208. and t.tenant_id_ = -1
  209. </if>
  210. <if test="param.bindTenant != null and param.bindTenant == 1">
  211. and t.tenant_id_ != -1
  212. </if>
  213. <if test="param.settlementFrom != null">
  214. AND t.settlement_from_ = #{param.settlementFrom}
  215. </if>
  216. <if test="param.tenantName != null and param.tenantName.trim() != ''">
  217. and ti.name_ like concat('%',#{param.tenantName},'%')
  218. </if>
  219. <if test="param.customerService != null">
  220. AND t.customer_service_ = #{param.customerService}
  221. </if>
  222. </where>
  223. group by t.user_id_
  224. <if test="param.vipStartTime != null and param.vipEndTime != null">
  225. <!-- having ((vipEndTime >= #{param.vipStartTime} and #{param.vipEndTime}> vipEndTime) or (svipEndTime >= #{param.vipStartTime} and #{param.vipEndTime}> svipEndTime))-->
  226. having currentVipEndTime >= #{param.vipStartTime} and #{param.vipEndTime}> currentVipEndTime
  227. </if>
  228. <choose>
  229. <when test="param.orderBy != null and param.orderBy.trim() != ''">
  230. order by ${param.orderBy}
  231. </when>
  232. <otherwise>
  233. order by t.create_time_ desc
  234. </otherwise>
  235. </choose>
  236. </select>
  237. <resultMap id="BasicUserInfo" type="com.yonge.cooleshow.biz.dal.dto.BasicUserInfo">
  238. <result property="userId" column="user_id_"/>
  239. <result property="username" column="username_"/>
  240. <result property="realName" column="real_name_"/>
  241. <result property="avatar" column="avatar_"/>
  242. <result property="phone" column="phone_"/>
  243. <result property="gender" column="gender_"/>
  244. <result property="birthdate" column="birthdate_"/>
  245. </resultMap>
  246. <select id="getBasicUserInfo" resultMap="BasicUserInfo">
  247. SELECT id_ user_id_, username_, real_name_, avatar_, phone_, gender_, birthdate_
  248. FROM sys_user
  249. WHERE del_flag_ = 0
  250. and id_ = #{userId}
  251. LIMIT 1
  252. </select>
  253. <select id="findBasicUserInfo" resultMap="BasicUserInfo">
  254. SELECT id_ user_id_,username_,real_name_,avatar_, phone_ FROM sys_user
  255. WHERE del_flag_ = 0 and id_ IN
  256. <foreach collection="studentIds" open="(" close=")" separator="," item="userId">
  257. #{userId}
  258. </foreach>
  259. </select>
  260. <select id="detail" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherVo">
  261. SELECT
  262. <include refid="baseColumns"/>,
  263. if(u.lock_flag_ = 0 and t.lock_flag_ = 0,0,1) as lockFlag,
  264. u.avatar_ as avatar,
  265. u.username_ as username,
  266. u.gender_ as `gender`,
  267. u.birthdate_ as birthdate,
  268. u.phone_ as phone,
  269. (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal,
  270. (!isnull(membership_end_time_) and membership_end_time_ > now()) as isVip,
  271. u.real_name_ as realName,
  272. u.id_card_no_ as idCardNo,
  273. if(vcr.type_ = 'PERMANENT',null,vcr.end_time_) as membershipEndTime,
  274. (case when isnull(b.user_id_) then 0 else 1 end) as isBank,
  275. (
  276. SELECT GROUP_CONCAT(name_ ORDER by locate(id_,t.subject_id_)) FROM subject WHERE FIND_IN_SET(id_,t.subject_id_)
  277. ) as subjectName,
  278. u.user_type_ as userType
  279. FROM teacher t
  280. left join sys_user u on t.user_id_ = u.id_
  281. left join (
  282. select distinct user_id_ from user_bank_card where del_flag_ = 0 and user_id_ = #{userId}
  283. ) b on t.user_id_ = b.user_id_
  284. left join vip_card_record vcr on t.user_id_ = vcr.user_id_ and vcr.client_type_ = 'TEACHER'
  285. and vcr.efficient_flag_ = 1 and vcr.end_time_ >= now() and now() > vcr.start_time_ and (vcr.vip_type_ = 'VIP' or vcr.vip_type_ = 'SVIP') and vcr.client_type_ = 'TEACHER'
  286. where t.user_id_ = #{userId}
  287. </select>
  288. <select id="querySubject" resultMap="com.yonge.cooleshow.biz.dal.dao.SubjectDao.Subject">
  289. SELECT s.*
  290. FROM `subject` s
  291. LEFT JOIN teacher t ON FIND_IN_SET(s.id_, t.subject_id_)
  292. WHERE t.user_id_ = #{userId}
  293. </select>
  294. <update id="setSubject">
  295. update teacher
  296. set subject_id_ = #{subjectIds},
  297. update_time_ = now()
  298. where user_id_ = #{id}
  299. </update>
  300. <update id="addHomeBrowse">
  301. update teacher
  302. set browse_ = browse_ + 1
  303. where user_id_ = #{userId}
  304. </update>
  305. <select id="querySubjectItem" resultType="com.yonge.cooleshow.biz.dal.entity.Subject">
  306. select t.* from subject t
  307. join (
  308. select a.subject_id_ from (
  309. <trim prefixOverrides="union all">
  310. <if test="type == null or type =='MUSIC'">
  311. union all
  312. (select music_subject_ as subject_id_ from music_sheet where user_id_ = #{userId} GROUP BY
  313. music_subject_)
  314. </if>
  315. <if test="type == null or type =='VIDEO'">
  316. union all
  317. (select lesson_subject_ as subject_id_ from video_lesson_group where teacher_id_ = #{userId} GROUP BY
  318. lesson_subject_)
  319. </if>
  320. <if test="type == null or type =='PIANO_ROOM'">
  321. union all
  322. (select subject_id_ as subject_id_ from course_group where type_ = 'PIANO_ROOM_CLASS' and teacher_id_ =
  323. #{userId} GROUP BY subject_id_)
  324. </if>
  325. <if test="type == null or type =='PRACTICE'">
  326. union all
  327. (select subject_id_ as subject_id_ from course_group where type_ = 'PRACTICE' and teacher_id_ =
  328. #{userId} GROUP BY subject_id_)
  329. </if>
  330. <if test="type == null or type =='LIVE'">
  331. union all
  332. (select subject_id_ as subject_id_ from course_group where type_ = 'LIVE' and teacher_id_ = #{userId}
  333. GROUP BY subject_id_)
  334. </if>
  335. </trim>
  336. ) a group by a.subject_id_
  337. ) a on t.id_ = a.subject_id_
  338. where t.parent_subject_id_ != 0
  339. and not exists(
  340. select 1 from teacher s where s.user_id_ = #{userId} and find_in_set(t.id_,s.subject_id_)
  341. )
  342. </select>
  343. <select id="queryMyFans" resultType="com.yonge.cooleshow.biz.dal.vo.MyFens">
  344. SELECT
  345. s.student_id_ AS userId,
  346. s.create_time_ AS starTime,
  347. u.avatar_ AS avatar,
  348. u.username_ AS userName,
  349. u.real_name_ AS realName,
  350. u.gender_ AS gender,
  351. u.phone_ AS phone,
  352. u.birthdate_ AS birthdate,
  353. (SELECT group_concat(name_) FROM `subject` WHERE find_in_set(id_,sr.subject_id_)) AS subjectName
  354. <!-- if(sr.membership_start_time_ &lt;= now() and sr.membership_end_time_ &gt;= now(),1,0) AS isVip-->
  355. FROM student_star s
  356. LEFT JOIN sys_user u ON s.student_id_ = u.id_
  357. LEFT JOIN student sr ON s.student_id_ = sr.user_id_
  358. <where>
  359. <!-- u.del_flag_ = 0-->
  360. <if test="record.teacherId != null">
  361. AND s.teacher_id_ =#{record.teacherId}
  362. </if>
  363. <if test="record.nickname != null">
  364. AND u.username_ LIKE '%${record.nickname}%'
  365. </if>
  366. <if test="record.userId != null">
  367. AND u.id_ = #{record.userId}
  368. </if>
  369. <if test="record.phone != null">
  370. AND u.phone_ = #{record.phone}
  371. </if>
  372. <if test="record.startTime != null and record.endTime != null">
  373. AND ( #{record.startTime} &lt;= s.create_time_ AND s.create_time_ &lt;= #{record.endTime})
  374. </if>
  375. </where>
  376. </select>
  377. <select id="queryHotTeacherList" resultMap="HotTeacherVoMap">
  378. select t.user_id_, t.graduate_school_, u.username_, u.avatar_, ifnull(a.speaker_id_, 0) isLiving_
  379. from teacher t
  380. left join sys_user u on t.user_id_ = u.id_
  381. left join teacher_total tt on tt.user_id_ = t.user_id_
  382. left join (SELECT lr.speaker_id_
  383. from live_room lr
  384. WHERE live_state_ = 1 and type_ = 'temp'
  385. group by lr.speaker_id_) a on a.speaker_id_ = t.user_id_
  386. where t.entry_flag_ = 1
  387. and t.is_test_user_ = 0
  388. and find_in_set(#{subjectId}, t.subject_id_)
  389. order by tt.fans_num_ desc
  390. limit 10
  391. </select>
  392. <!--老师学生人数统计-->
  393. <select id="selectTeacherStudentNumberStatInfo"
  394. resultType="com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper">
  395. SELECT t1.teacher_id_ AS id, COUNT(DISTINCT t1.id_) AS total FROM user_binding_teacher t1
  396. <where>
  397. <if test="teacherIds != null">
  398. AND t1.teacher_id_ IN (<foreach collection="teacherIds" separator="," item="item">
  399. #{item}
  400. </foreach>)
  401. </if>
  402. </where>
  403. GROUP BY t1.teacher_id_
  404. </select>
  405. <select id="countTeacherByTenantIds" resultType="com.yonge.cooleshow.biz.dal.wrapper.TenantInfoWrapper$UserCount">
  406. select tenant_id_ tenantId, count(tenant_id_) count
  407. from teacher
  408. <where>
  409. lock_flag_ = 0
  410. <if test="tenantIdList != null">
  411. AND tenant_id_ in
  412. <foreach collection="tenantIdList" item="item" separator="," open="(" close=")">
  413. #{item}
  414. </foreach>
  415. </if>
  416. </where>
  417. group by tenant_id_
  418. </select>
  419. <select id="queryTeacherCounts" resultType="java.lang.Integer">
  420. select count(tenant_id_)
  421. from teacher
  422. <where>
  423. lock_flag_ = 0
  424. <if test="id != null">
  425. and tenant_id_ = #{id}
  426. </if>
  427. </where>
  428. </select>
  429. <!--老师学生人数统计-->
  430. <select id="getCustomerServiceByFriendLeast" resultMap="BaseResultMap">
  431. select
  432. t.*
  433. from
  434. ( SELECT
  435. te.user_id_,
  436. count(iuf.friend_id_) friends
  437. from teacher te
  438. left join sys_user su on te.user_id_ = su.id_
  439. left join im_user_friend iuf on te.user_id_ = iuf.user_id_ and iuf.source_form_='CUSTOMER'
  440. where te.lock_flag_ = 0 and te.customer_service_ = 1 and su.del_flag_ = 0 and su.lock_flag_ = 0
  441. group by te.user_id_
  442. order by friends
  443. limit 1) m
  444. left join teacher t on m.user_id_ = t.user_id_
  445. </select>
  446. <select id="getCustomerServiceFriendNums" resultType="com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherWrapper$TeacherFriend">
  447. SELECT te.user_id_ teacherId,
  448. count(k.user_id_) friendNums
  449. from teacher te
  450. left join sys_user su on te.user_id_ = su.id_
  451. left join (select s.user_id_, s.customer_id_
  452. from student s
  453. where s.customer_id_ is not null
  454. union all
  455. select te.user_id_, te.customer_id_
  456. from teacher te
  457. where te.customer_service_ = 0 and te.customer_id_ is not null) k on te.user_id_ = k.customer_id_
  458. where te.lock_flag_ = 0
  459. and te.customer_service_ = 1
  460. and su.del_flag_ = 0
  461. and su.lock_flag_ = 0
  462. group by te.user_id_
  463. order by friendNums
  464. </select>
  465. <!--系统客服列表-->
  466. <select id="selectCustomerServiceV2" resultType="com.yonge.cooleshow.biz.dal.entity.Teacher">
  467. SELECT t.im_customer_id_ AS imCustomerId FROM (
  468. SELECT CONCAT(t1.user_id_, '_TEACHER') AS im_customer_id_ FROM teacher t1 LEFT JOIN sys_user t2 ON t1.user_id_ = t2.id_ WHERE t1.customer_service_ = 1 AND t1.lock_flag_ = 0 AND t2.lock_flag_ = 0
  469. UNION ALL
  470. SELECT CONCAT(t1.user_id_, '_SYSTEM') AS im_customer_id_ FROM employee t1 LEFT JOIN sys_user t2 ON t1.user_id_ = t2.id_ WHERE t1.customer_service_ = 1 AND t1.lock_flag_ = 0 AND t2.lock_flag_ = 0
  471. ) t
  472. </select>
  473. <!--系统客服好友统计-->
  474. <select id="countCustomerServiceMemberNum"
  475. resultType="com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper">
  476. SELECT t.im_customer_id_ AS gid, COUNT(t.user_id_) AS total FROM (
  477. SELECT t1.im_customer_id_, t1.user_id_ FROM teacher t1 WHERE t1.im_customer_id_ != '' AND t1.customer_service_ = 0
  478. UNION ALL
  479. SELECT t1.im_customer_id_, t1.user_id_ FROM student t1 WHERE t1.im_customer_id_ != ''
  480. ) t GROUP BY t.im_customer_id_
  481. </select>
  482. </mapper>