ActivityDetailDao.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="platform.modules.sys.dao.ActivityDetailDao">
  6. <select id="findAvtivityList" resultType="platform.modules.sys.entity.ActivityDetail"
  7. parameterType="java.lang.String">
  8. SELECT
  9. detail.id,
  10. detail.activity_type,
  11. detail.activity_title,
  12. detail.activity_location,
  13. detail.is_review,
  14. detail.is_qrcode_show,
  15. detail.reading_number,
  16. detail.activity_publishtime,
  17. detail.activity_starttime,
  18. detail.activity_endtime,
  19. detail.activity_state,
  20. (
  21. IF (
  22. detail.activity_state = 0,
  23. 0,
  24. IF (
  25. detail.activity_state = 2,
  26. 2,
  27. IF (
  28. NOW() <![CDATA[<]]> detail.activity_starttime,
  29. 1,
  30. IF (
  31. NOW() <![CDATA[>]]> detail.activity_endtime,
  32. 4,
  33. 3
  34. )
  35. )
  36. )
  37. )
  38. ) state_code,
  39. (
  40. SELECT
  41. count(id)
  42. FROM
  43. ac_activity_registration
  44. WHERE
  45. del_flag = 0
  46. and activity_id = detail.id
  47. and review_state in ('0','1')
  48. ) registration_number,
  49. (
  50. SELECT
  51. count(id)
  52. FROM
  53. ac_activity_registration
  54. WHERE
  55. del_flag = 0
  56. and activity_id = detail.id
  57. and review_state = 1
  58. ) registration_pass_number,
  59. (
  60. SELECT
  61. count(id)
  62. FROM
  63. ac_activity_feedback
  64. WHERE
  65. del_flag = 0
  66. and activity_id = detail.id
  67. ) feedback_number,
  68. (
  69. SELECT
  70. count(id)
  71. FROM
  72. ac_activity_registration
  73. WHERE
  74. del_flag = 0
  75. AND activity_id = detail.id
  76. AND sign_state = 0
  77. AND review_state != 3
  78. ) sgin_number
  79. FROM
  80. ac_activity_detail detail
  81. WHERE
  82. 1=1
  83. AND detail.del_flag = 0
  84. <if test="activity.title != null and activity.title != '' ">
  85. AND detail.activity_title LIKE CONCAT('%',#{activity.title},'%')
  86. </if>
  87. <if test="activity.type != null and activity.type != '' ">
  88. AND detail.activity_type = #{activity.type}
  89. </if>
  90. <if test="activity.review != null and activity.review != '' ">
  91. AND detail.is_review = #{activity.review}
  92. </if>
  93. <if test="activity.state != '' and activity.state != null ">
  94. <if test="activity.state == 0">
  95. AND detail.activity_state = #{activity.state}
  96. </if>
  97. <if test="activity.state == 2">
  98. AND detail.activity_state = #{activity.state}
  99. </if>
  100. <!-- 发布 -->
  101. <if test="activity.state == 1">
  102. AND detail.activity_state = 1
  103. AND detail.activity_starttime <![CDATA[>]]> NOW()
  104. </if>
  105. <!-- 进行 -->
  106. <if test="activity.state == 3">
  107. AND detail.activity_state = 1
  108. AND detail.activity_starttime <![CDATA[<=]]> NOW()
  109. AND detail.activity_endtime <![CDATA[>=]]> NOW()
  110. </if>
  111. <!-- 结束 -->
  112. <if test="activity.state == 4">
  113. AND detail.activity_state = 1
  114. AND detail.activity_endtime <![CDATA[<]]> NOW()
  115. </if>
  116. </if>
  117. <if test="activity.review != null and activity.review != '' ">
  118. AND detail.is_review = #{activity.review}
  119. </if>
  120. <if test="activity.review != null and activity.review != '' ">
  121. AND detail.is_review = #{activity.review}
  122. </if>
  123. <if test="activity.startTime != null and activity.startTime != ''">
  124. AND detail.activity_endtime <![CDATA[>]]> #{activity.startTime}
  125. </if>
  126. <if test="activity.endTime != null and activity.endTime != ''">
  127. AND detail.activity_starttime <![CDATA[<]]> #{activity.endTime}
  128. </if>
  129. ORDER BY
  130. detail.activity_publishtime DESC
  131. ,detail.create_time DESC
  132. </select>
  133. <select id="findOne" resultMap="ActivityDeatilResultMap" parameterType="java.lang.String">
  134. SELECT
  135. detail.id id,
  136. detail.activity_type activity_type,
  137. detail.activity_title activity_title,
  138. detail.activity_location activity_location,
  139. detail.lat_lng lat_lng,
  140. detail.activity_starttime activity_starttime,
  141. detail.activity_endtime activity_endtime,
  142. detail.activity_state activity_state,
  143. detail.activity_poster activity_poster,
  144. detail.activity_quota activity_quota,
  145. detail.activity_deadline activity_deadline,
  146. detail.activity_publishtime activity_publishtime,
  147. detail.is_review is_review,
  148. detail.is_qrcode_show is_qrcode_show,
  149. detail.is_public is_public,
  150. detail.push_level push_level,
  151. detail.content content,
  152. detail.reading_number reading_number,
  153. push.user_id user_id,
  154. push.user_type user_type,
  155. users.name user_name
  156. FROM
  157. ac_activity_detail detail
  158. LEFT JOIN ac_activity_push push ON detail.id = push.activity_id
  159. LEFT JOIN (
  160. SELECT
  161. s.id id,
  162. s.name name,
  163. '4' type
  164. FROM
  165. s_street s
  166. UNION
  167. SELECT
  168. y.id id,
  169. y.name name,
  170. '1' type
  171. FROM
  172. y_info y
  173. UNION
  174. SELECT
  175. c.id id,
  176. c.company_name name,
  177. '3' type
  178. FROM
  179. y_company c
  180. ) users ON push.user_id = users.id
  181. AND push.user_type = users.type
  182. WHERE
  183. detail.id = #{id}
  184. </select>
  185. <resultMap id="ActivityDeatilResultMap" type="platform.modules.sys.entity.ActivityDetail">
  186. <id column="id" property="id"/>
  187. <result column="activity_type" property="activity_type"/>
  188. <result column="activity_title" property="activity_title"/>
  189. <result column="activity_location" property="activity_location"/>
  190. <result column="lat_lng" property="lat_lng"/>
  191. <result column="activity_starttime" property="activity_starttime"/>
  192. <result column="activity_endtime" property="activity_endtime"/>
  193. <result column="activity_state" property="activity_state"/>
  194. <result column="activity_poster" property="activity_poster"/>
  195. <result column="activity_quota" property="activity_quota"/>
  196. <result column="activity_deadline" property="activity_deadline"/>
  197. <result column="activity_publishtime" property="activity_publishtime"/>
  198. <result column="is_review" property="is_review"/>
  199. <result column="is_qrcode_show" property="is_qrcode_show"/>
  200. <result column="is_public" property="is_public"/>
  201. <result column="push_level" property="push_level"/>
  202. <result column="content" property="content"/>
  203. <result column="reading_number" property="reading_number"/>
  204. <collection property="pushList" ofType="platform.modules.sys.entity.ActivityPush">
  205. <id column="user_id" property="user_id"/>
  206. <result column="user_type" property="user_type"/>
  207. <result column="user_name" property="user_name"/>
  208. </collection>
  209. </resultMap>
  210. <select id="findAvtivityPage" resultType="platform.modules.sys.entity.ActivityDetail"
  211. parameterType="platform.modules.sys.entity.ActivityDetail">
  212. SELECT
  213. id,
  214. activity_type,
  215. activity_title,
  216. content,
  217. activity_location,
  218. activity_starttime,
  219. activity_endtime,
  220. left(activity_starttime,4) start_year,
  221. (
  222. IF (
  223. activity_state = 0,
  224. 0,
  225. IF (
  226. activity_state = 2,
  227. 2,
  228. IF (
  229. NOW() <![CDATA[<]]> activity_starttime,
  230. 1,
  231. IF (
  232. NOW() <![CDATA[>]]> activity_endtime,
  233. 4,
  234. 3
  235. )
  236. )
  237. )
  238. )
  239. ) state_code,
  240. <!-- 20200612 新需求 活动报名进行的在前 正序 活动结束的在后 倒序 ======start====== -->
  241. <!-- 使用时间戳及活动状态来改变排序 -->
  242. (
  243. IF
  244. (
  245. activity_state = 0,
  246. 0,
  247. IF
  248. (
  249. activity_state = 2,
  250. 3000000000 - unix_timestamp ( activity_starttime ),
  251. IF
  252. (
  253. NOW( ) <![CDATA[<]]> activity_starttime, unix_timestamp( activity_starttime ) - 3000000000, IF ( NOW( )
  254. <![CDATA[>]]> activity_endtime,
  255. 3000000000 - unix_timestamp ( activity_starttime ),
  256. unix_timestamp( activity_starttime ) - 3000000000
  257. )
  258. )
  259. )
  260. )
  261. ) custom_sort1,
  262. <!-- 20200612 新需求 活动报名进行的在前 正序 活动结束的在后 倒序 ======end====== -->
  263. activity_poster,
  264. push_level,
  265. reg_num,
  266. activity_deadline,
  267. activity_publishtime,
  268. if(str_to_date(activity_endtime, '%Y-%m-%d %T')>NOW(),1,0) can_sign_up
  269. <if test="activity.is_pushed == '0' ">
  270. ,push_level
  271. </if>
  272. FROM
  273. (
  274. SELECT
  275. detail.id id,
  276. detail.activity_type activity_type,
  277. detail.activity_title activity_title,
  278. detail.activity_state activity_state,
  279. detail.content content,
  280. detail.activity_location activity_location,
  281. detail.activity_starttime activity_starttime,
  282. detail.activity_endtime activity_endtime,
  283. detail.activity_publishtime activity_publishtime,
  284. detail.activity_poster activity_poster,
  285. detail.create_time create_time,
  286. detail.activity_deadline activity_deadline,
  287. detail.push_level push_level,
  288. (
  289. SELECT
  290. count(id)
  291. FROM
  292. ac_activity_registration
  293. WHERE
  294. activity_id = detail.id
  295. AND review_state = 1
  296. ) reg_num,
  297. (
  298. (
  299. SELECT
  300. count(id)
  301. FROM
  302. ac_activity_registration
  303. WHERE
  304. activity_id = detail.id
  305. ) + detail.reading_number / 100
  306. ) heat,
  307. 0 AS sort
  308. <if test="activity.is_pushed == '0' ">
  309. ,detail.push_level detail.push_level
  310. </if>
  311. FROM
  312. ac_activity_detail detail
  313. WHERE
  314. detail.del_flag = 0
  315. and detail.is_public = 0
  316. and detail.activity_state = 1
  317. <if test="activity.is_favourited == '1' and activity.is_pushed == '1'">
  318. AND detail.is_public = 0
  319. </if>
  320. <if test="activity.activity_title != null and activity.activity_title != '' ">
  321. AND detail.activity_title LIKE CONCAT('%',#{activity.activity_title},'%')
  322. </if>
  323. <if test="activity.activity_type != null and activity.activity_type != '' ">
  324. AND detail.activity_type = #{activity.activity_type}
  325. </if>
  326. <if test="activity.sort_criteria == 0 ">
  327. AND detail.activity_starttime <![CDATA[<=]]> NOW()
  328. AND detail.activity_endtime <![CDATA[>=]]> NOW()
  329. </if>
  330. <if test="activity.is_expired == 1 ">
  331. AND detail.activity_endtime <![CDATA[>]]> NOW()
  332. </if>
  333. <if test="activity.is_pushed == '0' ">
  334. AND push.user_id = #{activity.user_id}
  335. </if>
  336. <if test="activity.is_favourited == '0' ">
  337. AND fav.user_id = #{activity.user_id}
  338. </if>
  339. <if test="activity.sort_criteria == 0">
  340. UNION ALL
  341. SELECT
  342. detail.id id,
  343. detail.activity_type activity_type,
  344. detail.activity_title activity_title,
  345. detail.activity_state activity_state,
  346. detail.content content,
  347. detail.activity_location activity_location,
  348. detail.activity_starttime activity_starttime,
  349. detail.activity_endtime activity_endtime,
  350. detail.activity_publishtime activity_publishtime,
  351. detail.activity_poster activity_poster,
  352. detail.create_time create_time,
  353. detail.activity_deadline activity_deadline,
  354. detail.push_level push_level,
  355. (
  356. SELECT
  357. count(id)
  358. FROM
  359. ac_activity_registration
  360. WHERE
  361. activity_id = detail.id
  362. ) reg_num,
  363. (
  364. (
  365. SELECT
  366. count(id)
  367. FROM
  368. ac_activity_registration
  369. WHERE
  370. activity_id = detail.id
  371. ) + detail.reading_number / 100
  372. ) heat,
  373. 1 AS sort
  374. FROM
  375. ac_activity_detail detail
  376. WHERE
  377. detail.del_flag = 0
  378. and detail.is_public = 0
  379. and detail.activity_state = 1
  380. <if test="activity.is_favourited == '1' and activity.is_pushed == '1'">
  381. AND detail.is_public = 0
  382. </if>
  383. <if test="activity.activity_title != null and activity.activity_title != '' ">
  384. AND detail.activity_title LIKE CONCAT('%',#{activity.activity_title},'%')
  385. </if>
  386. <if test="activity.activity_type != null and activity.activity_type != '' ">
  387. AND detail.activity_type = #{activity.activity_type}
  388. </if>
  389. <if test="activity.sort_criteria == 0 ">
  390. AND (detail.activity_starttime <![CDATA[>=]]> NOW()
  391. OR detail.activity_endtime <![CDATA[<=]]> NOW())
  392. </if>
  393. <if test="activity.is_expired == 1 ">
  394. AND detail.activity_endtime <![CDATA[>]]> NOW()
  395. </if>
  396. <if test="activity.is_pushed == '0' ">
  397. AND push.user_id = #{activity.user_id}
  398. </if>
  399. <if test="activity.is_favourited == '0' ">
  400. AND fav.user_id = #{activity.user_id}
  401. </if>
  402. </if>
  403. ) t
  404. ORDER BY
  405. <if test="activity.sort_criteria == 1 ">
  406. activity_starttime DESC,
  407. create_time DESC
  408. </if>
  409. <if test="activity.sort_criteria == 2 ">
  410. can_sign_up DESC,
  411. reg_num DESC,
  412. activity_starttime DESC
  413. </if>
  414. <!-- 20200623 3为首页热门 优先按年度排 2为正常的热门排序 -->
  415. <if test="activity.sort_criteria == 3 ">
  416. start_year DESC,
  417. can_sign_up DESC,
  418. reg_num DESC,
  419. activity_starttime DESC
  420. </if>
  421. <if test="activity.sort_criteria == 0 ">
  422. <!-- 20200612 新需求 活动报名进行的在前 正序 活动结束的在后 倒序 ======start====== -->
  423. custom_sort1,
  424. <!-- 20200612 新需求 活动报名进行的在前 正序 活动结束的在后 倒序 ======end====== -->
  425. can_sign_up DESC,
  426. heat DESC
  427. </if>
  428. </select>
  429. <select id="findStreetBuildCompanyByName" resultType="platform.modules.government.dto.StreetsBuildingsCompanies"
  430. parameterType="java.lang.String">
  431. select id,company_name name,'3' type from y_company where company_name like CONCAT('%',#{name},'%')
  432. UNION all
  433. select id,name name,'4' type from s_street where name like CONCAT('%',#{name},'%')
  434. UNION all
  435. select id,name name,'1' type from y_info where name like CONCAT('%',#{name},'%')
  436. </select>
  437. <select id="findFavouriteList" resultType="platform.modules.sys.entity.ActivityDetail"
  438. parameterType="java.lang.String">
  439. SELECT
  440. detail.id activity_id,
  441. fav.id favourite_id,
  442. detail.activity_poster activity_poster,
  443. detail.activity_title activity_title,
  444. detail.activity_poster activity_poster,
  445. detail.activity_starttime activity_starttime,
  446. detail.activity_endtime activity_endtime,
  447. if(str_to_date(detail.activity_deadline, '%Y-%m-%d %T')>NOW(),0,1) activity_deadline,
  448. detail.activity_location activity_location,
  449. IF( detail.activity_deadline >= now( ), TRUE, FALSE ) as can_sign_up
  450. FROM
  451. ac_activity_detail detail
  452. JOIN ac_activity_favourite fav ON fav.activity_id = detail.id
  453. WHERE
  454. fav.user_id = #{user_id}
  455. <if test="title != null and title != '' ">
  456. AND detail.activity_title LIKE CONCAT('%',#{title},'%')
  457. </if>
  458. ORDER BY
  459. fav.create_time DESC
  460. </select>
  461. <select id="findPushList" resultType="platform.modules.sys.entity.ActivityDetail"
  462. parameterType="platform.modules.sys.entity.ActivityDetail">
  463. SELECT
  464. detail.id id,
  465. detail.activity_poster activity_poster,
  466. detail.activity_title activity_title,
  467. detail.activity_poster activity_poster,
  468. detail.activity_starttime activity_starttime,
  469. detail.activity_endtime activity_endtime,
  470. detail.activity_location activity_location,
  471. detail.push_level push_level,
  472. detail.activity_publishtime activity_publishtime,
  473. if(str_to_date(detail.activity_deadline, '%Y-%m-%d %T')>NOW(),0,1) activity_deadline
  474. FROM
  475. ac_activity_detail detail
  476. LEFT JOIN ac_activity_push push ON push.activity_id = detail.id
  477. LEFT JOIN z_user zuser ON zuser.user_type = push.user_type
  478. AND (
  479. push.user_id = zuser.street_id
  480. OR push.user_id = zuser.build_id
  481. OR push.user_id = zuser.company_id
  482. )
  483. WHERE
  484. zuser.id = #{activity.user_id}
  485. AND detail.activity_state != 0
  486. <if test="activity.push_level != null and activity.push_level != '' ">
  487. AND detail.push_level = #{activity.push_level}
  488. </if>
  489. <if test="activity.activity_title != null and activity.activity_title != '' ">
  490. AND detail.activity_title LIKE CONCAT('%',#{activity.activity_title},'%')
  491. </if>
  492. <if test="activity.activity_state == '2' ">
  493. AND (
  494. detail.activity_state = 2
  495. OR str_to_date(
  496. detail.activity_deadline,
  497. '%Y-%m-%d %T'
  498. ) <![CDATA[>]]> NOW()
  499. )
  500. </if>
  501. <if test="activity.activity_state == '1' ">
  502. AND
  503. detail.activity_state != 2
  504. AND str_to_date(
  505. detail.activity_deadline,
  506. '%Y-%m-%d %T'
  507. ) <![CDATA[<]]> NOW()
  508. </if>
  509. </select>
  510. <select id="getTypes" resultType="java.lang.String">
  511. SELECT
  512. d.activity_type
  513. FROM
  514. ac_activity_detail d
  515. JOIN ac_activity_favourite f ON d.id = f.activity_id
  516. WHERE
  517. f.user_id = #{id}
  518. </select>
  519. <select id="getActivityByType" parameterType="java.util.Set"
  520. resultType="platform.modules.sys.entity.ActivityDetail">
  521. SELECT
  522. id,
  523. activity_title,
  524. activity_poster,
  525. (
  526. SELECT
  527. count(id)
  528. FROM
  529. ac_activity_registration r
  530. WHERE
  531. r.activity_id = d.id
  532. ) counts
  533. FROM
  534. ac_activity_detail d
  535. WHERE
  536. 1 = 1
  537. <if test="types.size() > 0">
  538. and activity_type in
  539. <foreach item="item" index="index" collection="types" open="(" separator="," close=")">
  540. #{item}
  541. </foreach>
  542. </if>
  543. ORDER BY
  544. counts DESC
  545. LIMIT 6
  546. </select>
  547. <update id="updateReadingnumberById">
  548. update ac_activity_detail set reading_number = #{count}
  549. where id=#{id}
  550. </update>
  551. <update id="updateQuotaById" parameterType="java.lang.String">
  552. update ac_activity_detail set activity_quota = #{quota}
  553. where id=#{id}
  554. </update>
  555. <select id="getAllEventsDate" resultType="java.lang.String">
  556. select activity_starttime from ac_activity_detail where activity_state = '1'
  557. <if test="type!=null and type !=''">
  558. and type = #{type}
  559. </if>
  560. order by create_time desc
  561. </select>
  562. <select id="getEventList" resultType="platform.modules.sys.entity.ActivityDetail">
  563. select
  564. ad.id,
  565. ad.activity_title,
  566. ad.activity_starttime,
  567. ad.activity_endtime,
  568. IF
  569. (
  570. ad.activity_starttime > now( ),
  571. IF
  572. (
  573. ad.activity_deadline > NOW( ),
  574. IF
  575. ( ( SELECT COUNT( ar.id ) FROM ac_activity_registration ar WHERE ar.activity_id = ad.id AND ar.user_id =
  576. #{userId} ) IS NULL, '可报名', '待参加' ),
  577. IF
  578. ( ( SELECT COUNT( ar.id ) FROM ac_activity_registration ar WHERE ar.activity_id = ad.id AND ar.user_id =
  579. #{userId} ) IS NULL, '未开始', '待参加' )
  580. ),
  581. IF( ad.activity_endtime >= now(),
  582. IF
  583. ( ( SELECT COUNT( ar.id ) FROM ac_activity_registration ar WHERE ar.activity_id = ad.id AND ar.user_id =
  584. #{userId} ) IS NULL, '活动中', '待参加' ),
  585. '已结束')
  586. ) AS activity_status_str
  587. from ac_activity_detail ad where activity_state = '1'
  588. <if test="type!=null and type !=''">
  589. and type = #{type}
  590. </if>
  591. <if test="start!=null and start !=''">
  592. and activity_starttime <![CDATA[>=]]> #{start}
  593. </if>
  594. <if test="end!=null and end !=''">
  595. and activity_starttime <![CDATA[<=]]> #{end}
  596. </if>
  597. order by create_time desc
  598. </select>
  599. <select id="getAllActivityCount" resultType="integer">
  600. select
  601. count(id)
  602. from ac_activity_detail
  603. where activity_state = '1'
  604. </select>
  605. <select id="getJoinedActivityCount" resultType="integer">
  606. select
  607. count(id)
  608. from ac_activity_registration ac
  609. where review_state = '1'
  610. <if test="condition.user_type!=null">
  611. and user_type = #{condition.user_type}
  612. </if>
  613. <if test="condition.street_id != null and condition.street_id !=''">
  614. and user_id = #{condition.street_id}
  615. </if>
  616. </select>
  617. <select id="getHotActivity" resultType="platform.modules.sys.entity.ActivityDetail">
  618. SELECT
  619. ad.activity_title,
  620. COUNT( ar.activity_id ) AS acticityCount
  621. FROM
  622. ac_activity_detail ad
  623. LEFT JOIN ac_activity_registration ar ON ar.activity_id = ad.id
  624. WHERE
  625. ar.del_flag = 0
  626. GROUP BY
  627. ar.activity_id
  628. ORDER BY acticityCount DESC
  629. LIMIT 0,10
  630. </select>
  631. <select id="findOverList" resultType="platform.modules.sys.entity.ActivityDetail">
  632. select * from ac_activity_detail
  633. where activity_endtime <![CDATA[ < ]]> now()
  634. <if test="condition.activity_type != null and condition.activity_type !='' ">
  635. and activity_type = #{condition.activity_type}
  636. </if>
  637. <if test="condition.title != null and condition.title !='' ">
  638. and activity_title LIKE CONCAT('%', #{condition.title}, '%')
  639. </if>
  640. </select>
  641. <select id="findMyActivityPage" resultType="platform.modules.sys.entity.ActivityDetail">
  642. SELECT
  643. ad.id,
  644. ad.activity_title,
  645. ad.activity_starttime,
  646. (SELECT COUNT(ar.id) FROM ac_activity_registration ar WHERE ar.del_flag = 0 and review_state != '3' and ar.activity_id = ad.id AND ar.user_id =
  647. #{condition.user_id} ) AS registration_number,
  648. (SELECT COUNT(ar.id) FROM ac_activity_registration ar WHERE ar.del_flag = 0 and ar.activity_id = ad.id AND ar.user_id =
  649. #{condition.user_id} AND review_state = 1) AS registration_success_number,
  650. IF(ad.activity_starttime > now() , 1,
  651. IF(ad.activity_endtime <![CDATA[ >= ]]> now() ,2,
  652. IF( ( SELECT count(af.id) FROM ac_activity_feedback af WHERE user_id = #{condition.user_id} AND af.activity_id =
  653. ad.id ) IS NULL, 4, 3) )) AS activity_status
  654. FROM
  655. ac_activity_detail ad
  656. WHERE
  657. ad.id IN ( SELECT DISTINCT activity_id FROM ac_activity_registration WHERE user_id = #{condition.user_id} )
  658. <if test="condition.activity_title != null and condition.activity_title !=''">
  659. AND ad.activity_title like CONCAT('%',#{condition.activity_title},'%')
  660. </if>
  661. </select>
  662. <select id="findByActivityId" resultType="platform.modules.sys.entity.ActivityDetail">
  663. SELECT
  664. ad.id,
  665. ad.activity_title,
  666. ad.activity_location,
  667. ad.activity_starttime,
  668. ad.activity_endtime,
  669. IF(ad.activity_starttime > now() , '未开始', IF(ad.activity_endtime <![CDATA[ >= ]]> now() , '活动中', '已结束' )) AS activity_status_str
  670. FROM
  671. ac_activity_detail ad
  672. WHERE
  673. ad.id = #{id}
  674. </select>
  675. <select id="findHighlyRecommended" resultType="platform.modules.sys.entity.ActivityDetail">
  676. select id, activity_title from ac_activity_detail where push_level = 1 AND del_flag = 0
  677. </select>
  678. </mapper>