ActivityPlanMapper.xml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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.yonge.cooleshow.biz.dal.dao.ActivityPlanDao">
  4. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.ActivityPlan">
  5. <result column="id_" property="id" />
  6. <result column="activity_type_" property="activityType" />
  7. <result column="activity_client_" property="activityClient" />
  8. <result column="activity_name_" property="activityName" />
  9. <result column="describe_" property="describe" />
  10. <result column="rule_describe_" property="ruleDescribe" />
  11. <result column="subject_url_" property="subjectUrl" />
  12. <result column="background_url_" property="backgroundUrl" />
  13. <result column="activity_url_" property="activityUrl" />
  14. <result column="share_url_" property="shareUrl" />
  15. <result column="activity_start_" property="activityStart" />
  16. <result column="activity_end_" property="activityEnd" />
  17. <result column="registration_method_" property="registrationMethod" />
  18. <result column="registration_price_" property="registrationPrice" />
  19. <result column="share_rate_" property="shareRate" />
  20. <result column="share_type_" property="shareType" />
  21. <result column="ranking_" property="ranking" />
  22. <result column="ranking_rule_" property="rankingRule" />
  23. <result column="ranking_method_" property="rankingMethod" />
  24. <result column="ranking_score_" property="rankingScore" />
  25. <result column="draft_flag_" property="draftFlag" />
  26. <result column="activity_state_" property="activityState" />
  27. <result column="create_time_" property="createTime" />
  28. <result column="create_by_" property="createBy" />
  29. <result column="update_time_" property="updateTime" />
  30. <result column="update_by_" property="updateBy" />
  31. </resultMap>
  32. <!-- 表字段 -->
  33. <sql id="baseColumns">
  34. t.id_ as id
  35. , t.activity_type_ as activityType
  36. , t.activity_client_ as activityClient
  37. , t.activity_name_ as activityName
  38. , t.describe_ as `describe`
  39. , t.rule_describe_ as ruleDescribe
  40. , t.subject_url_ as subjectUrl
  41. , t.background_url_ as backgroundUrl
  42. , t.share_url_ as shareUrl
  43. , t.activity_url_ as activityUrl
  44. , t.activity_start_ as activityStart
  45. , t.activity_end_ as activityEnd
  46. , t.registration_method_ as registrationMethod
  47. , t.registration_price_ as registrationPrice
  48. , t.share_rate_ as shareRate
  49. , t.share_type_ as shareType
  50. , t.ranking_ as ranking
  51. , t.ranking_rule_ as rankingRule
  52. , t.ranking_method_ as rankingMethod
  53. , t.ranking_score_ as rankingScore
  54. , t.draft_flag_ as draftFlag
  55. , if(t.activity_state_ = 1, 1, 0) as activityState
  56. , t.create_time_ as createTime
  57. , t.create_by_ as createBy
  58. , t.update_time_ as updateTime
  59. , t.update_by_ as updateBy
  60. </sql>
  61. <select id="detail" resultType="com.yonge.cooleshow.biz.dal.vo.ActivityPlanVo">
  62. SELECT
  63. <include refid="baseColumns"/>
  64. FROM activity_plan t
  65. where t.id_ = #{id}
  66. </select>
  67. <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.ActivityPlanVo">
  68. SELECT
  69. <include refid="baseColumns" />
  70. , u.username_ as updateByName
  71. /*, (select count(1) from activity_registration r where t.id_ = r.activity_id_) as registrationNum*/
  72. /*, (select count(distinct r.user_id_) from activity_user_reward r where t.id_ = r.activity_id_) as rewardNum*/
  73. FROM activity_plan t
  74. LEFT JOIN sys_user u on t.update_by_ = u.id_
  75. <where>
  76. <if test="param.activityName != null and param.activityName != ''">
  77. and (t.activity_name_ like concat('%',#{param.activityName},'%') <if test="param.activityId != null"> OR t.id_ = #{param.activityId}</if> )
  78. </if>
  79. <if test="param.draftFlag != null">
  80. and t.draft_flag_ = #{param.draftFlag}
  81. </if>
  82. <choose>
  83. <when test="param.activityState != null">
  84. <if test="param.activityState == 0">
  85. and (t.activity_state_ = 0 or t.activity_state_ = 2)
  86. </if>
  87. <if test="param.activityState == 1">
  88. and t.activity_state_ = 1
  89. </if>
  90. </when>
  91. <otherwise> AND t.activity_start_ &gt;= -1 </otherwise>
  92. </choose>
  93. <if test="param.startTime !=null">
  94. and t.activity_start_ &gt;= #{param.startTime}
  95. </if>
  96. <if test="param.endTime !=null">
  97. and t.activity_end_ &lt;= #{param.endTime}
  98. </if>
  99. <if test="param.activityClient != null">
  100. and t.activity_client_ = #{param.activityClient}
  101. </if>
  102. <if test="param.activityType != null">
  103. and t.activity_type_ = #{param.activityType}
  104. </if>
  105. </where>
  106. order by t.id_ desc
  107. </select>
  108. <select id="selectActivityPlanEvaluation" resultType="java.lang.String">
  109. select evaluation_difficulty_
  110. from activity_plan_evaluation
  111. where id_ = #{activityPlanId}
  112. </select>
  113. <select id="activityState" resultType="com.yonge.cooleshow.biz.dal.entity.ActivityPlan">
  114. select <include refid="baseColumns"/>
  115. from activity_plan t where draft_flag_ = 0
  116. and (
  117. (t.activity_start_ &lt;= now() and t.activity_end_ &gt; now() and activity_state_ = 0)
  118. or (t.activity_end_ &lt;= now() and activity_state_ = 1)
  119. )
  120. </select>
  121. <select id="selectActivityShare" resultType="com.yonge.cooleshow.biz.dal.vo.ActivityPlanVo">
  122. select
  123. <include refid="baseColumns"/>
  124. from activity_plan t
  125. left join activity_evaluation ae on t.id_ = ae.activity_id_
  126. <where>
  127. activity_state_ = 1 and activity_start_ &lt;= now() and activity_end_ &gt;= now() and activity_type_ = 'SHARE'
  128. <if test="type != null and type != ''">
  129. and #{type} = t.share_type_
  130. </if>
  131. <if test="userId != null">
  132. and ae.music_sheet_id_ = #{userId}
  133. and ae.resource_type_ = 'TEACHER'
  134. </if>
  135. </where>
  136. </select>
  137. <!--活动参与人数、获奖人数统计-->
  138. <select id="selectActivityParticipateStatInfo"
  139. resultType="com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper">
  140. SELECT t1.activity_id_ AS id, COUNT(DISTINCT t1.id_) AS total FROM activity_registration t1
  141. <where>
  142. <if test="activityIds != null">
  143. AND t1.activity_id_ IN (<foreach collection="activityIds" separator="," item="item">#{item}</foreach>)
  144. </if>
  145. </where>
  146. GROUP BY t1.activity_id_
  147. </select>
  148. <select id="selectActivityWinnerStatInfo"
  149. resultType="com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper">
  150. SELECT t1.activity_id_ AS id, COUNT(DISTINCT t1.user_id_) AS total FROM activity_user_reward t1
  151. <where>
  152. <if test="activityIds != null">
  153. AND t1.activity_id_ IN (<foreach collection="activityIds" separator="," item="item">#{item}</foreach>)
  154. </if>
  155. </where>
  156. GROUP BY t1.activity_id_
  157. </select>
  158. <!--活动参与人数、获奖人数统计-->
  159. <!--活动总分用户排名-->
  160. <select id="selectActivityHighestScoreRankingInfo"
  161. resultType="com.yonge.cooleshow.biz.dal.vo.ActivityRankingVo">
  162. SELECT
  163. t1.score_, t1.user_id_, t2.avatar_ AS userAvatar, t2.username_ AS username
  164. FROM
  165. activity_evaluation_record t1 LEFT JOIN sys_user t2 ON t1.user_id_ = t2.id_
  166. WHERE
  167. t1.activity_id_ = #{activityId} AND t1.resource_id_ = #{subjectId} AND t1.ranking_method_ = 'TOTAL_SCORE' AND t1.score_ > #{rankingScore}
  168. ORDER BY
  169. t1.score_ DESC,
  170. t1.registration_time_ ASC
  171. LIMIT #{limit}
  172. </select>
  173. <!--活动总分用户排名-->
  174. </mapper>