ImLiveBroadcastRoomMapper.xml 10 KB

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