ImLiveBroadcastRoomMapper.xml 10 KB

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