ImLiveBroadcastRoomMapper.xml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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.room_state_ AS roomState,
  54. c.real_name_ AS createdByName,
  55. a.pre_template_ AS preTemplate,
  56. a.room_config_ AS roomConfig,
  57. a.popularize_ AS popularize,
  58. a.popularize_type_ AS popularizeType
  59. from im_live_broadcast_room as a
  60. left join tenant_info AS t on a.tenant_id_ = t.id_
  61. left join sys_user AS b on a.speaker_id_ = b.id_
  62. left join sys_user AS c on a.created_by_ = c.id_
  63. <where>
  64. a.room_state_ in(0, 2)
  65. <if test="param.search != null ">
  66. AND (
  67. a.`id_` LIKE CONCAT('%', #{param.search},'%')
  68. OR a.`room_title_` LIKE CONCAT('%', #{param.search},'%')
  69. )
  70. </if>
  71. <if test="param.tenantId != null ">
  72. AND a.tenant_id_ = #{param.tenantId}
  73. </if>
  74. <if test="param.roomUid != null">
  75. and a.room_uid_ = #{param.roomUid}
  76. </if>
  77. <if test="param.liveState != null">
  78. and a.live_state_ = #{param.liveState}
  79. </if>
  80. <if test="param.startTime != null">
  81. <![CDATA[ AND a.live_start_time_ >= #{param.startTime} ]]>
  82. </if>
  83. <if test="param.endTime != null">
  84. <![CDATA[ AND a.live_start_time_ <= #{param.endTime} ]]>
  85. </if>
  86. <if test="param.popularize != null">
  87. and a.popularize_ = #{param.popularize}
  88. </if>
  89. <if test="param.speakerId != null">
  90. and a.speaker_id_ = #{param.speakerId}
  91. </if>
  92. </where>
  93. </select>
  94. <select id="queryBaseUserInfo" resultType="com.ym.mec.biz.dal.vo.BaseRoomUserVo">
  95. select
  96. id_ AS userId,
  97. username_ AS userName
  98. from sys_user
  99. <where>
  100. id_ IN
  101. <foreach collection="list" item="id" open="(" separator="," close=")">
  102. #{id}
  103. </foreach>
  104. </where>
  105. </select>
  106. <resultMap id="LiveRoomGoodsOrderVo" type="com.ym.mec.biz.dal.vo.LiveRoomGoodsOrderVo">
  107. <result property="userId" column="user_id_"/>
  108. <result property="userName" column="username_"/>
  109. <result property="phone" column="phone_"/>
  110. <result property="goodsName" column="goods_name_"/>
  111. <result property="actualPrice" column="actual_amount_"/>
  112. <result property="expectPrice" column="expect_amount_"/>
  113. <result property="balance" column="balance_payment_amount_"/>
  114. <result property="couponRemitFee" column="coupon_remit_fee_"/>
  115. <result property="payTime" column="pay_time_"/>
  116. <result property="goodsName" column="goods_name_"/>
  117. </resultMap>
  118. <sql id="queryLiveRoomGoodsOrderSql">
  119. <where>
  120. spo.group_type_ = 'LIVE_BUY' AND spo.type_ = 'LIVE_BUY'
  121. AND spo.status_ = 'SUCCESS'
  122. <if test="search != null and search != ''">
  123. AND (su.id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  124. </if>
  125. <if test="roomUid != null and roomUid != ''">
  126. AND spo.music_group_id_ = #{roomUid}
  127. </if>
  128. <if test="startTime != null">
  129. AND DATE_FORMAT(spo.pay_time_, '%Y-%m-%d') >= #{startTime}
  130. </if>
  131. <if test="endTime != null">
  132. AND DATE_FORMAT(spo.pay_time_, '%Y-%m-%d') &lt;= #{endTime}
  133. </if>
  134. </where>
  135. </sql>
  136. <select id="queryLiveRoomGoodsOrderList" resultMap="LiveRoomGoodsOrderVo">
  137. SELECT su.id_ user_id_,su.username_,su.phone_,spo.actual_amount_,spo.expect_amount_,
  138. spo.balance_payment_amount_,spo.coupon_remit_fee_,spo.pay_time_,GROUP_CONCAT(lg.name_) goods_name_ FROM student_payment_order spo
  139. LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
  140. LEFT JOIN live_goods lg ON FIND_IN_SET(lg.id_,spod.goods_id_list_)
  141. LEFT JOIN sys_user su ON su.id_ = spo.user_id_
  142. <include refid="queryLiveRoomGoodsOrderSql"/>
  143. GROUP BY spo.id_
  144. ORDER BY spo.pay_time_ DESC
  145. <include refid="global.limit"/>
  146. </select>
  147. <select id="countLiveRoomGoodsOrderList" resultType="java.lang.Integer">
  148. SELECT COUNT(DISTINCT spo.id_) FROM student_payment_order spo
  149. LEFT JOIN sys_user su ON su.id_ = spo.user_id_
  150. <include refid="queryLiveRoomGoodsOrderSql"/>
  151. </select>
  152. <select id="sumLiveRoomGoodsOrderList" resultType="java.util.Map">
  153. SELECT COUNT(DISTINCT spo.user_id_) buyNum,SUM(spo.expect_amount_) totalAmount,
  154. SUM(spo.balance_payment_amount_) balance,SUM(spo.actual_amount_) actualAmount
  155. FROM student_payment_order spo
  156. LEFT JOIN sys_user su ON su.id_ = spo.user_id_
  157. <include refid="queryLiveRoomGoodsOrderSql"/>
  158. </select>
  159. <select id="queryRoomUser" resultType="com.ym.mec.biz.dal.vo.RoomReservationUserVo">
  160. select
  161. su.id_ as userId
  162. ,su.username_ as username
  163. ,su.phone_ as phone
  164. ,su.organ_id_ as organId
  165. ,o.name_ as organName
  166. ,(select group_concat(sub.name_) from subject sub
  167. where find_in_set(sub.id_,s.subject_id_list_) and sub.del_flag_ = 0 ) as subjectName
  168. from im_live_room_reservation ilrr
  169. left join sys_user su on su.id_ = ilrr.user_id_
  170. left join organization o on o.id_ = su.organ_id_
  171. left join student s on s.user_id_ = su.id_
  172. <where>
  173. ilrr.room_uid_ = #{query.roomUid}
  174. <if test="query.search != null and query.search != ''">
  175. and (su.id_ like concat('%',#{query.search},'%')
  176. or su.phone_ like concat('%',#{query.search},'%')
  177. or su.username_ like concat('%',#{query.search},'%'))
  178. </if>
  179. <if test="query.subjectId != null">
  180. and find_in_set(#{query.subjectId},s.subject_id_list_)
  181. </if>
  182. <if test="query.organId != null">
  183. and su.organ_id_ = #{query.organId}
  184. </if>
  185. </where>
  186. </select>
  187. <select id="querySchoolIds" resultType="string">
  188. select GROUP_CONCAT(id_) from cooperation_organ where find_in_set(organ_id_,#{organIds})
  189. </select>
  190. <select id="queryTeamIds" resultType="string">
  191. select group_concat(id_)
  192. from music_group where organ_id_ in (#{organIds}) group by organ_id_
  193. </select>
  194. </mapper>