ImLiveBroadcastRoomMapper.xml 10 KB

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