ImLiveBroadcastRoomMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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.ym.mec.biz.dal.dao.ImLiveBroadcastRoomDao">
  4. <resultMap id="BaseResultMap" type="com.ym.mec.biz.dal.entity.ImLiveBroadcastRoom">
  5. <id column="id_" jdbcType="INTEGER" property="id"/>
  6. <result column="tenant_id_" jdbcType="INTEGER" property="tenantId"/>
  7. <result column="speaker_id_" jdbcType="INTEGER" property="speakerId"/>
  8. <result column="room_uid_" jdbcType="VARCHAR" property="roomUid"/>
  9. <result column="room_title_" jdbcType="VARCHAR" property="roomTitle"/>
  10. <result column="live_start_time_" jdbcType="TIMESTAMP" property="liveStartTime"/>
  11. <result column="live_end_time_" jdbcType="TIMESTAMP" property="liveEndTime"/>
  12. <result column="live_remark_" jdbcType="VARCHAR" property="liveRemark"/>
  13. <result column="pre_template_" jdbcType="VARCHAR" property="preTemplate"/>
  14. <result column="room_config_" jdbcType="VARCHAR" property="roomConfig"/>
  15. <result column="live_state_" jdbcType="INTEGER" property="liveState"/>
  16. <result column="room_state_" jdbcType="INTEGER" property="roomState"/>
  17. <result column="popularize_" jdbcType="INTEGER" property="popularize"/>
  18. <result column="popularize_type_" jdbcType="VARCHAR" property="popularizeType"/>
  19. <result column="popularize_org_ids_" jdbcType="VARCHAR" property="popularizeOrgIds"/>
  20. <result column="popularize_school_ids_" jdbcType="VARCHAR" property="popularizeSchoolIds"/>
  21. <result column="popularize_team_ids_" jdbcType="VARCHAR" property="popularizeTeamIds"/>
  22. <result column="created_by_" jdbcType="INTEGER" property="createdBy"/>
  23. <result column="created_time_" jdbcType="TIMESTAMP" property="createdTime"/>
  24. <result column="updated_by_" jdbcType="INTEGER" property="updatedBy"/>
  25. <result column="updated_time_" jdbcType="TIMESTAMP" property="updatedTime"/>
  26. </resultMap>
  27. <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
  28. parameterType="com.ym.mec.biz.dal.entity.ImLiveBroadcastRoom">
  29. insert into im_live_broadcast_room(tenant_id_, speaker_id_, room_uid_, room_title_, live_start_time_,
  30. live_end_time_, live_remark_, pre_template_, room_config_, live_state_, room_state_,
  31. popularize_, popularize_type_,popularize_org_ids_,popularize_school_ids_,popularize_team_ids_,
  32. created_by_, created_time_, updated_by_, updated_time_)
  33. values
  34. <foreach collection="entities" item="entity" separator=",">
  35. (#{entity.tenantId}, #{entity.speakerId}, #{entity.roomUid}, #{entity.roomTitle}, #{entity.liveStartTime},
  36. #{entity.liveEndTime}, #{entity.liveRemark}, #{entity.preTemplate}, #{entity.roomConfig},
  37. #{entity.liveState}, #{entity.roomState}, #{entity.popularize},
  38. #{entity.popularizeType},#{entity.popularizeOrgIds},#{entity.popularizeSchoolIds},#{entity.popularizeTeamIds},
  39. #{entity.createdBy}, #{entity.createdTime}, #{entity.updatedBy},#{entity.updatedTime})
  40. </foreach>
  41. </insert>
  42. <select id="queryPage" resultType="com.ym.mec.biz.dal.vo.ImLiveBroadcastRoomVo">
  43. select a.id_ AS id,
  44. a.tenant_id_ AS tenantId,
  45. t.name_ AS tenantName,
  46. t.logo_ AS tenantLogo,
  47. a.room_uid_ AS roomUid,
  48. a.room_title_ AS roomTitle,
  49. a.live_remark_ AS liveRemark,
  50. a.speaker_id_ AS speakerId,
  51. b.real_name_ AS speakerName,
  52. b.im_token_ as imToken,
  53. b.avatar_ AS speakerPic,
  54. a.live_start_time_ AS liveStartTime,
  55. a.live_state_ AS liveState,
  56. a.room_state_ AS roomState,
  57. c.real_name_ AS createdByName,
  58. a.pre_template_ AS preTemplate,
  59. a.room_config_ AS roomConfig,
  60. a.popularize_ AS popularize,
  61. a.popularize_type_ AS popularizeType,
  62. a.popularize_org_ids_ AS popularizeOrgIds,
  63. a.popularize_school_ids_ AS popularizeSchoolIds,
  64. a.popularize_team_ids_ AS popularizeTeamIds
  65. from (
  66. select *
  67. from im_live_broadcast_room
  68. <if test="param.allRoom == null">
  69. where popularize_type_ = 'ALL'
  70. </if>
  71. <if test="param.organIds != null">
  72. union all
  73. select *
  74. from im_live_broadcast_room as a
  75. where popularize_type_ in ( 'ORGAN', 'TEAM')
  76. and INTE_ARRAY(a.popularize_org_ids_, #{param.organIds}) = 1
  77. </if>
  78. <if test="param.schoolIds != null">
  79. union all
  80. select *
  81. from im_live_broadcast_room as a
  82. where popularize_type_ = 'SCHOOL'
  83. and INTE_ARRAY(a.popularize_school_ids_, #{param.schoolIds}) = 1
  84. </if>
  85. ) as a
  86. left join tenant_info AS t on a.tenant_id_ = t.id_
  87. left join sys_user AS b on a.speaker_id_ = b.id_
  88. left join sys_user AS c on a.created_by_ = c.id_
  89. <where>
  90. a.room_state_ in(0, 2)
  91. <if test="param.search != null ">
  92. AND (
  93. a.`id_` LIKE CONCAT('%', #{param.search},'%')
  94. OR a.`room_title_` LIKE CONCAT('%', #{param.search},'%')
  95. )
  96. </if>
  97. <if test="param.tenantId != null ">
  98. AND a.tenant_id_ = #{param.tenantId}
  99. </if>
  100. <if test="param.roomUid != null">
  101. and a.room_uid_ = #{param.roomUid}
  102. </if>
  103. <if test="param.liveState != null">
  104. and a.live_state_ = #{param.liveState}
  105. </if>
  106. <if test="param.startTime != null">
  107. <![CDATA[ AND a.live_start_time_ >= #{param.startTime} ]]>
  108. </if>
  109. <if test="param.endTime != null">
  110. <![CDATA[ AND a.live_start_time_ <= #{param.endTime} ]]>
  111. </if>
  112. <if test="param.popularize != null">
  113. and a.popularize_ = #{param.popularize}
  114. </if>
  115. </where>
  116. </select>
  117. <select id="queryUserPageByTenantId" resultType="map">
  118. SELECT id_, username_
  119. FROM sys_user
  120. WHERE tenant_id_ = 1
  121. and user_type_ = 'STUDENT'
  122. and lock_flag_ = 0
  123. and del_flag_ = 0
  124. and is_super_admin_ = 0
  125. and username_ is not null
  126. and username_ != ''
  127. </select>
  128. <select id="queryBaseUserInfo" resultType="com.ym.mec.biz.dal.vo.BaseRoomUserVo">
  129. select
  130. id_ AS userId,
  131. username_ AS userName
  132. from sys_user
  133. <where>
  134. id_ IN
  135. <foreach collection="list" item="id" open="(" separator="," close=")">
  136. #{id}
  137. </foreach>
  138. </where>
  139. </select>
  140. <resultMap id="LiveRoomGoodsOrderVo" type="com.ym.mec.biz.dal.vo.LiveRoomGoodsOrderVo">
  141. <result property="userId" column="user_id_"/>
  142. <result property="userName" column="username_"/>
  143. <result property="phone" column="phone_"/>
  144. <result property="goodsName" column="goods_name_"/>
  145. <result property="actualPrice" column="actual_amount_"/>
  146. <result property="expectPrice" column="expect_amount_"/>
  147. <result property="balance" column="balance_payment_amount_"/>
  148. <result property="couponRemitFee" column="coupon_remit_fee_"/>
  149. <result property="payTime" column="pay_time_"/>
  150. <result property="goodsName" column="goods_name_"/>
  151. </resultMap>
  152. <sql id="queryLiveRoomGoodsOrderSql">
  153. <where>
  154. spo.group_type_ = 'LIVE_BUY' AND spo.type_ = 'LIVE_BUY'
  155. AND spo.status_ = 'SUCCESS'
  156. <if test="search != null and search != ''">
  157. AND (su.id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  158. </if>
  159. <if test="roomUid != null and roomUid != ''">
  160. AND spo.music_group_id_ = #{roomUid}
  161. </if>
  162. <if test="startTime != null">
  163. AND DATE_FORMAT(spo.pay_time_, '%Y-%m-%d') >= #{startTime}
  164. </if>
  165. <if test="endTime != null">
  166. AND DATE_FORMAT(spo.pay_time_, '%Y-%m-%d') &lt;= #{endTime}
  167. </if>
  168. </where>
  169. </sql>
  170. <select id="queryLiveRoomGoodsOrderList" resultMap="LiveRoomGoodsOrderVo">
  171. SELECT su.id_ user_id_,su.username_,su.phone_,spo.actual_amount_,spo.expect_amount_,
  172. spo.balance_payment_amount_,spo.coupon_remit_fee_,spo.pay_time_,GROUP_CONCAT(lg.name_) goods_name_ FROM student_payment_order spo
  173. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  174. LEFT JOIN live_goods lg ON FIND_IN_SET(lg.id_,spod.goods_id_list_)
  175. LEFT JOIN sys_user su ON su.id_ = spo.user_id_
  176. <include refid="queryLiveRoomGoodsOrderSql"/>
  177. GROUP BY spo.id_
  178. ORDER BY spo.pay_time_ DESC
  179. <include refid="global.limit"/>
  180. </select>
  181. <select id="countLiveRoomGoodsOrderList" resultType="java.lang.Integer">
  182. SELECT COUNT(DISTINCT spo.id_) FROM student_payment_order spo
  183. LEFT JOIN sys_user su ON su.id_ = spo.user_id_
  184. <include refid="queryLiveRoomGoodsOrderSql"/>
  185. </select>
  186. <select id="sumLiveRoomGoodsOrderList" resultType="java.util.Map">
  187. SELECT COUNT(DISTINCT spo.user_id_) buyNum,SUM(spo.expect_amount_) totalAmount,
  188. SUM(spo.balance_payment_amount_) balance,SUM(spo.actual_amount_) actualAmount
  189. FROM student_payment_order spo
  190. LEFT JOIN sys_user su ON su.id_ = spo.user_id_
  191. <include refid="queryLiveRoomGoodsOrderSql"/>
  192. </select>
  193. <select id="queryRoomUser" resultType="com.ym.mec.biz.dal.vo.RoomReservationUserVo">
  194. select
  195. su.id_ as userId
  196. ,su.username_ as username
  197. ,su.phone_ as phone
  198. ,su.organ_id_ as organId
  199. ,o.name_ as organName
  200. ,(select group_concat(sub.name_) from subject sub
  201. where find_in_set(sub.id_,s.subject_id_list_) and sub.del_flag_ = 0 ) as subjectName
  202. from im_live_room_reservation ilrr
  203. left join sys_user su on su.id_ = ilrr.user_id_
  204. left join organization o on o.id_ = su.organ_id_
  205. left join student s on s.user_id_ = su.id_
  206. <where>
  207. ilrr.room_uid_ = #{query.roomUid}
  208. <if test="query.search != null and query.search != ''">
  209. and (su.id_ like concat('%',#{query.search},'%')
  210. or su.phone_ like concat('%',#{query.search},'%')
  211. or su.username_ like concat('%',#{query.search},'%'))
  212. </if>
  213. <if test="query.subjectId != null">
  214. and find_in_set(#{query.subjectId},s.subject_id_list_)
  215. </if>
  216. <if test="query.organId != null">
  217. and su.organ_id_ = #{query.organId}
  218. </if>
  219. </where>
  220. </select>
  221. <select id="querySchoolIds" resultType="string">
  222. select GROUP_CONCAT(id_) from cooperation_organ where find_in_set(organ_id_,#{organIds})
  223. </select>
  224. <select id="queryTeamIds" resultType="string">
  225. select group_concat(id_)
  226. from music_group where organ_id_ in (#{organIds}) group by organ_id_
  227. </select>
  228. </mapper>