| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="platform.modules.sys.dao.ActivityDetailDao">
- <select id="findAvtivityList" resultType="platform.modules.sys.entity.ActivityDetail"
- parameterType="java.lang.String">
- SELECT
- detail.id,
- detail.activity_type,
- detail.activity_title,
- detail.activity_location,
- detail.is_review,
- detail.is_qrcode_show,
- detail.reading_number,
- detail.activity_publishtime,
- detail.activity_starttime,
- detail.activity_endtime,
- detail.activity_state,
- (
- IF (
- detail.activity_state = 0,
- 0,
- IF (
- detail.activity_state = 2,
- 2,
- IF (
- NOW() <![CDATA[<]]> detail.activity_starttime,
- 1,
- IF (
- NOW() <![CDATA[>]]> detail.activity_endtime,
- 4,
- 3
- )
- )
- )
- )
- ) state_code,
- (
- SELECT
- count(id)
- FROM
- ac_activity_registration
- WHERE
- del_flag = 0
- and activity_id = detail.id
- and review_state in ('0','1')
- ) registration_number,
- (
- SELECT
- count(id)
- FROM
- ac_activity_registration
- WHERE
- del_flag = 0
- and activity_id = detail.id
- and review_state = 1
- ) registration_pass_number,
- (
- SELECT
- count(id)
- FROM
- ac_activity_feedback
- WHERE
- del_flag = 0
- and activity_id = detail.id
- ) feedback_number,
- (
- SELECT
- count(id)
- FROM
- ac_activity_registration
- WHERE
- del_flag = 0
- AND activity_id = detail.id
- AND sign_state = 0
- AND review_state != 3
- ) sgin_number
- FROM
- ac_activity_detail detail
- WHERE
- 1=1
- AND detail.del_flag = 0
- <if test="activity.title != null and activity.title != '' ">
- AND detail.activity_title LIKE CONCAT('%',#{activity.title},'%')
- </if>
- <if test="activity.type != null and activity.type != '' ">
- AND detail.activity_type = #{activity.type}
- </if>
- <if test="activity.review != null and activity.review != '' ">
- AND detail.is_review = #{activity.review}
- </if>
- <if test="activity.state != '' and activity.state != null ">
- <if test="activity.state == 0">
- AND detail.activity_state = #{activity.state}
- </if>
- <if test="activity.state == 2">
- AND detail.activity_state = #{activity.state}
- </if>
- <!-- 发布 -->
- <if test="activity.state == 1">
- AND detail.activity_state = 1
- AND detail.activity_starttime <![CDATA[>]]> NOW()
- </if>
- <!-- 进行 -->
- <if test="activity.state == 3">
- AND detail.activity_state = 1
- AND detail.activity_starttime <![CDATA[<=]]> NOW()
- AND detail.activity_endtime <![CDATA[>=]]> NOW()
- </if>
- <!-- 结束 -->
- <if test="activity.state == 4">
- AND detail.activity_state = 1
- AND detail.activity_endtime <![CDATA[<]]> NOW()
- </if>
- </if>
- <if test="activity.review != null and activity.review != '' ">
- AND detail.is_review = #{activity.review}
- </if>
- <if test="activity.review != null and activity.review != '' ">
- AND detail.is_review = #{activity.review}
- </if>
- <if test="activity.startTime != null and activity.startTime != ''">
- AND detail.activity_endtime <![CDATA[>]]> #{activity.startTime}
- </if>
- <if test="activity.endTime != null and activity.endTime != ''">
- AND detail.activity_starttime <![CDATA[<]]> #{activity.endTime}
- </if>
- ORDER BY
- detail.activity_publishtime DESC
- ,detail.create_time DESC
- </select>
- <select id="findOne" resultMap="ActivityDeatilResultMap" parameterType="java.lang.String">
- SELECT
- detail.id id,
- detail.activity_type activity_type,
- detail.activity_title activity_title,
- detail.activity_location activity_location,
- detail.lat_lng lat_lng,
- detail.activity_starttime activity_starttime,
- detail.activity_endtime activity_endtime,
- detail.activity_state activity_state,
- detail.activity_poster activity_poster,
- detail.activity_quota activity_quota,
- detail.activity_deadline activity_deadline,
- detail.activity_publishtime activity_publishtime,
- detail.is_review is_review,
- detail.is_qrcode_show is_qrcode_show,
- detail.is_public is_public,
- detail.push_level push_level,
- detail.content content,
- detail.reading_number reading_number,
- push.user_id user_id,
- push.user_type user_type,
- users.name user_name
- FROM
- ac_activity_detail detail
- LEFT JOIN ac_activity_push push ON detail.id = push.activity_id
- LEFT JOIN (
- SELECT
- s.id id,
- s.name name,
- '4' type
- FROM
- s_street s
- UNION
- SELECT
- y.id id,
- y.name name,
- '1' type
- FROM
- y_info y
- UNION
- SELECT
- c.id id,
- c.company_name name,
- '3' type
- FROM
- y_company c
- ) users ON push.user_id = users.id
- AND push.user_type = users.type
- WHERE
- detail.id = #{id}
- </select>
- <resultMap id="ActivityDeatilResultMap" type="platform.modules.sys.entity.ActivityDetail">
- <id column="id" property="id"/>
- <result column="activity_type" property="activity_type"/>
- <result column="activity_title" property="activity_title"/>
- <result column="activity_location" property="activity_location"/>
- <result column="lat_lng" property="lat_lng"/>
- <result column="activity_starttime" property="activity_starttime"/>
- <result column="activity_endtime" property="activity_endtime"/>
- <result column="activity_state" property="activity_state"/>
- <result column="activity_poster" property="activity_poster"/>
- <result column="activity_quota" property="activity_quota"/>
- <result column="activity_deadline" property="activity_deadline"/>
- <result column="activity_publishtime" property="activity_publishtime"/>
- <result column="is_review" property="is_review"/>
- <result column="is_qrcode_show" property="is_qrcode_show"/>
- <result column="is_public" property="is_public"/>
- <result column="push_level" property="push_level"/>
- <result column="content" property="content"/>
- <result column="reading_number" property="reading_number"/>
- <collection property="pushList" ofType="platform.modules.sys.entity.ActivityPush">
- <id column="user_id" property="user_id"/>
- <result column="user_type" property="user_type"/>
- <result column="user_name" property="user_name"/>
- </collection>
- </resultMap>
- <select id="findAvtivityPage" resultType="platform.modules.sys.entity.ActivityDetail"
- parameterType="platform.modules.sys.entity.ActivityDetail">
- SELECT
- id,
- activity_type,
- activity_title,
- content,
- activity_location,
- activity_starttime,
- activity_endtime,
- left(activity_starttime,4) start_year,
- (
- IF (
- activity_state = 0,
- 0,
- IF (
- activity_state = 2,
- 2,
- IF (
- NOW() <![CDATA[<]]> activity_starttime,
- 1,
- IF (
- NOW() <![CDATA[>]]> activity_endtime,
- 4,
- 3
- )
- )
- )
- )
- ) state_code,
- <!-- 20200612 新需求 活动报名进行的在前 正序 活动结束的在后 倒序 ======start====== -->
- <!-- 使用时间戳及活动状态来改变排序 -->
- (
- IF
- (
- activity_state = 0,
- 0,
- IF
- (
- activity_state = 2,
- 3000000000 - unix_timestamp ( activity_starttime ),
- IF
- (
- NOW( ) <![CDATA[<]]> activity_starttime, unix_timestamp( activity_starttime ) - 3000000000, IF ( NOW( )
- <![CDATA[>]]> activity_endtime,
- 3000000000 - unix_timestamp ( activity_starttime ),
- unix_timestamp( activity_starttime ) - 3000000000
- )
- )
- )
- )
- ) custom_sort1,
- <!-- 20200612 新需求 活动报名进行的在前 正序 活动结束的在后 倒序 ======end====== -->
- activity_poster,
- push_level,
- reg_num,
- activity_deadline,
- activity_publishtime,
- if(str_to_date(activity_endtime, '%Y-%m-%d %T')>NOW(),1,0) can_sign_up
- <if test="activity.is_pushed == '0' ">
- ,push_level
- </if>
- FROM
- (
- SELECT
- detail.id id,
- detail.activity_type activity_type,
- detail.activity_title activity_title,
- detail.activity_state activity_state,
- detail.content content,
- detail.activity_location activity_location,
- detail.activity_starttime activity_starttime,
- detail.activity_endtime activity_endtime,
- detail.activity_publishtime activity_publishtime,
- detail.activity_poster activity_poster,
- detail.create_time create_time,
- detail.activity_deadline activity_deadline,
- detail.push_level push_level,
- (
- SELECT
- count(id)
- FROM
- ac_activity_registration
- WHERE
- activity_id = detail.id
- AND review_state = 1
- ) reg_num,
- (
- (
- SELECT
- count(id)
- FROM
- ac_activity_registration
- WHERE
- activity_id = detail.id
- ) + detail.reading_number / 100
- ) heat,
- 0 AS sort
- <if test="activity.is_pushed == '0' ">
- ,detail.push_level detail.push_level
- </if>
- FROM
- ac_activity_detail detail
- WHERE
- detail.del_flag = 0
- and detail.is_public = 0
- and detail.activity_state = 1
- <if test="activity.is_favourited == '1' and activity.is_pushed == '1'">
- AND detail.is_public = 0
- </if>
- <if test="activity.activity_title != null and activity.activity_title != '' ">
- AND detail.activity_title LIKE CONCAT('%',#{activity.activity_title},'%')
- </if>
- <if test="activity.activity_type != null and activity.activity_type != '' ">
- AND detail.activity_type = #{activity.activity_type}
- </if>
- <if test="activity.sort_criteria == 0 ">
- AND detail.activity_starttime <![CDATA[<=]]> NOW()
- AND detail.activity_endtime <![CDATA[>=]]> NOW()
- </if>
- <if test="activity.is_expired == 1 ">
- AND detail.activity_endtime <![CDATA[>]]> NOW()
- </if>
- <if test="activity.is_pushed == '0' ">
- AND push.user_id = #{activity.user_id}
- </if>
- <if test="activity.is_favourited == '0' ">
- AND fav.user_id = #{activity.user_id}
- </if>
- <if test="activity.sort_criteria == 0">
- UNION ALL
- SELECT
- detail.id id,
- detail.activity_type activity_type,
- detail.activity_title activity_title,
- detail.activity_state activity_state,
- detail.content content,
- detail.activity_location activity_location,
- detail.activity_starttime activity_starttime,
- detail.activity_endtime activity_endtime,
- detail.activity_publishtime activity_publishtime,
- detail.activity_poster activity_poster,
- detail.create_time create_time,
- detail.activity_deadline activity_deadline,
- detail.push_level push_level,
- (
- SELECT
- count(id)
- FROM
- ac_activity_registration
- WHERE
- activity_id = detail.id
- ) reg_num,
- (
- (
- SELECT
- count(id)
- FROM
- ac_activity_registration
- WHERE
- activity_id = detail.id
- ) + detail.reading_number / 100
- ) heat,
- 1 AS sort
- FROM
- ac_activity_detail detail
- WHERE
- detail.del_flag = 0
- and detail.is_public = 0
- and detail.activity_state = 1
- <if test="activity.is_favourited == '1' and activity.is_pushed == '1'">
- AND detail.is_public = 0
- </if>
- <if test="activity.activity_title != null and activity.activity_title != '' ">
- AND detail.activity_title LIKE CONCAT('%',#{activity.activity_title},'%')
- </if>
- <if test="activity.activity_type != null and activity.activity_type != '' ">
- AND detail.activity_type = #{activity.activity_type}
- </if>
- <if test="activity.sort_criteria == 0 ">
- AND (detail.activity_starttime <![CDATA[>=]]> NOW()
- OR detail.activity_endtime <![CDATA[<=]]> NOW())
- </if>
- <if test="activity.is_expired == 1 ">
- AND detail.activity_endtime <![CDATA[>]]> NOW()
- </if>
- <if test="activity.is_pushed == '0' ">
- AND push.user_id = #{activity.user_id}
- </if>
- <if test="activity.is_favourited == '0' ">
- AND fav.user_id = #{activity.user_id}
- </if>
- </if>
- ) t
- ORDER BY
- <if test="activity.sort_criteria == 1 ">
- activity_starttime DESC,
- create_time DESC
- </if>
- <if test="activity.sort_criteria == 2 ">
- can_sign_up DESC,
- reg_num DESC,
- activity_starttime DESC
- </if>
- <!-- 20200623 3为首页热门 优先按年度排 2为正常的热门排序 -->
- <if test="activity.sort_criteria == 3 ">
- start_year DESC,
- can_sign_up DESC,
- reg_num DESC,
- activity_starttime DESC
- </if>
- <if test="activity.sort_criteria == 0 ">
- <!-- 20200612 新需求 活动报名进行的在前 正序 活动结束的在后 倒序 ======start====== -->
- custom_sort1,
- <!-- 20200612 新需求 活动报名进行的在前 正序 活动结束的在后 倒序 ======end====== -->
- can_sign_up DESC,
- heat DESC
- </if>
- </select>
- <select id="findStreetBuildCompanyByName" resultType="platform.modules.government.dto.StreetsBuildingsCompanies"
- parameterType="java.lang.String">
- select id,company_name name,'3' type from y_company where company_name like CONCAT('%',#{name},'%')
- UNION all
- select id,name name,'4' type from s_street where name like CONCAT('%',#{name},'%')
- UNION all
- select id,name name,'1' type from y_info where name like CONCAT('%',#{name},'%')
- </select>
- <select id="findFavouriteList" resultType="platform.modules.sys.entity.ActivityDetail"
- parameterType="java.lang.String">
- SELECT
- detail.id activity_id,
- fav.id favourite_id,
- detail.activity_poster activity_poster,
- detail.activity_title activity_title,
- detail.activity_poster activity_poster,
- detail.activity_starttime activity_starttime,
- detail.activity_endtime activity_endtime,
- if(str_to_date(detail.activity_deadline, '%Y-%m-%d %T')>NOW(),0,1) activity_deadline,
- detail.activity_location activity_location,
- IF( detail.activity_deadline >= now( ), TRUE, FALSE ) as can_sign_up
- FROM
- ac_activity_detail detail
- JOIN ac_activity_favourite fav ON fav.activity_id = detail.id
- WHERE
- fav.user_id = #{user_id}
- <if test="title != null and title != '' ">
- AND detail.activity_title LIKE CONCAT('%',#{title},'%')
- </if>
- ORDER BY
- fav.create_time DESC
- </select>
- <select id="findPushList" resultType="platform.modules.sys.entity.ActivityDetail"
- parameterType="platform.modules.sys.entity.ActivityDetail">
- SELECT
- detail.id id,
- detail.activity_poster activity_poster,
- detail.activity_title activity_title,
- detail.activity_poster activity_poster,
- detail.activity_starttime activity_starttime,
- detail.activity_endtime activity_endtime,
- detail.activity_location activity_location,
- detail.push_level push_level,
- detail.activity_publishtime activity_publishtime,
- if(str_to_date(detail.activity_deadline, '%Y-%m-%d %T')>NOW(),0,1) activity_deadline
- FROM
- ac_activity_detail detail
- LEFT JOIN ac_activity_push push ON push.activity_id = detail.id
- LEFT JOIN z_user zuser ON zuser.user_type = push.user_type
- AND (
- push.user_id = zuser.street_id
- OR push.user_id = zuser.build_id
- OR push.user_id = zuser.company_id
- )
- WHERE
- zuser.id = #{activity.user_id}
- AND detail.activity_state != 0
- <if test="activity.push_level != null and activity.push_level != '' ">
- AND detail.push_level = #{activity.push_level}
- </if>
- <if test="activity.activity_title != null and activity.activity_title != '' ">
- AND detail.activity_title LIKE CONCAT('%',#{activity.activity_title},'%')
- </if>
- <if test="activity.activity_state == '2' ">
- AND (
- detail.activity_state = 2
- OR str_to_date(
- detail.activity_deadline,
- '%Y-%m-%d %T'
- ) <![CDATA[>]]> NOW()
- )
- </if>
- <if test="activity.activity_state == '1' ">
- AND
- detail.activity_state != 2
- AND str_to_date(
- detail.activity_deadline,
- '%Y-%m-%d %T'
- ) <![CDATA[<]]> NOW()
- </if>
- </select>
- <select id="getTypes" resultType="java.lang.String">
- SELECT
- d.activity_type
- FROM
- ac_activity_detail d
- JOIN ac_activity_favourite f ON d.id = f.activity_id
- WHERE
- f.user_id = #{id}
- </select>
- <select id="getActivityByType" parameterType="java.util.Set"
- resultType="platform.modules.sys.entity.ActivityDetail">
- SELECT
- id,
- activity_title,
- activity_poster,
- (
- SELECT
- count(id)
- FROM
- ac_activity_registration r
- WHERE
- r.activity_id = d.id
- ) counts
- FROM
- ac_activity_detail d
- WHERE
- 1 = 1
- <if test="types.size() > 0">
- and activity_type in
- <foreach item="item" index="index" collection="types" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- ORDER BY
- counts DESC
- LIMIT 6
- </select>
- <update id="updateReadingnumberById">
- update ac_activity_detail set reading_number = #{count}
- where id=#{id}
- </update>
- <update id="updateQuotaById" parameterType="java.lang.String">
- update ac_activity_detail set activity_quota = #{quota}
- where id=#{id}
- </update>
- <select id="getAllEventsDate" resultType="java.lang.String">
- select activity_starttime from ac_activity_detail where activity_state = '1'
- <if test="type!=null and type !=''">
- and type = #{type}
- </if>
- order by create_time desc
- </select>
- <select id="getEventList" resultType="platform.modules.sys.entity.ActivityDetail">
- select
- ad.id,
- ad.activity_title,
- ad.activity_starttime,
- ad.activity_endtime,
- IF
- (
- ad.activity_starttime > now( ),
- IF
- (
- ad.activity_deadline > NOW( ),
- IF
- ( ( SELECT COUNT( ar.id ) FROM ac_activity_registration ar WHERE ar.activity_id = ad.id AND ar.user_id =
- #{userId} ) IS NULL, '可报名', '待参加' ),
- IF
- ( ( SELECT COUNT( ar.id ) FROM ac_activity_registration ar WHERE ar.activity_id = ad.id AND ar.user_id =
- #{userId} ) IS NULL, '未开始', '待参加' )
- ),
- IF( ad.activity_endtime >= now(),
- IF
- ( ( SELECT COUNT( ar.id ) FROM ac_activity_registration ar WHERE ar.activity_id = ad.id AND ar.user_id =
- #{userId} ) IS NULL, '活动中', '待参加' ),
- '已结束')
- ) AS activity_status_str
- from ac_activity_detail ad where activity_state = '1'
- <if test="type!=null and type !=''">
- and type = #{type}
- </if>
- <if test="start!=null and start !=''">
- and activity_starttime <![CDATA[>=]]> #{start}
- </if>
- <if test="end!=null and end !=''">
- and activity_starttime <![CDATA[<=]]> #{end}
- </if>
- order by create_time desc
- </select>
- <select id="getAllActivityCount" resultType="integer">
- select
- count(id)
- from ac_activity_detail
- where activity_state = '1'
- </select>
- <select id="getJoinedActivityCount" resultType="integer">
- select
- count(id)
- from ac_activity_registration ac
- where review_state = '1'
- <if test="condition.user_type!=null">
- and user_type = #{condition.user_type}
- </if>
- <if test="condition.street_id != null and condition.street_id !=''">
- and user_id = #{condition.street_id}
- </if>
- </select>
- <select id="getHotActivity" resultType="platform.modules.sys.entity.ActivityDetail">
- SELECT
- ad.activity_title,
- COUNT( ar.activity_id ) AS acticityCount
- FROM
- ac_activity_detail ad
- LEFT JOIN ac_activity_registration ar ON ar.activity_id = ad.id
- WHERE
- ar.del_flag = 0
- GROUP BY
- ar.activity_id
- ORDER BY acticityCount DESC
- LIMIT 0,10
- </select>
- <select id="findOverList" resultType="platform.modules.sys.entity.ActivityDetail">
- select * from ac_activity_detail
- where activity_endtime <![CDATA[ < ]]> now()
- <if test="condition.activity_type != null and condition.activity_type !='' ">
- and activity_type = #{condition.activity_type}
- </if>
- <if test="condition.title != null and condition.title !='' ">
- and activity_title LIKE CONCAT('%', #{condition.title}, '%')
- </if>
- </select>
- <select id="findMyActivityPage" resultType="platform.modules.sys.entity.ActivityDetail">
- SELECT
- ad.id,
- ad.activity_title,
- ad.activity_starttime,
- (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 =
- #{condition.user_id} ) AS registration_number,
- (SELECT COUNT(ar.id) FROM ac_activity_registration ar WHERE ar.del_flag = 0 and ar.activity_id = ad.id AND ar.user_id =
- #{condition.user_id} AND review_state = 1) AS registration_success_number,
- IF(ad.activity_starttime > now() , 1,
- IF(ad.activity_endtime <![CDATA[ >= ]]> now() ,2,
- IF( ( SELECT count(af.id) FROM ac_activity_feedback af WHERE user_id = #{condition.user_id} AND af.activity_id =
- ad.id ) IS NULL, 4, 3) )) AS activity_status
- FROM
- ac_activity_detail ad
- WHERE
- ad.id IN ( SELECT DISTINCT activity_id FROM ac_activity_registration WHERE user_id = #{condition.user_id} )
- <if test="condition.activity_title != null and condition.activity_title !=''">
- AND ad.activity_title like CONCAT('%',#{condition.activity_title},'%')
- </if>
- </select>
- <select id="findByActivityId" resultType="platform.modules.sys.entity.ActivityDetail">
- SELECT
- ad.id,
- ad.activity_title,
- ad.activity_location,
- ad.activity_starttime,
- ad.activity_endtime,
- IF(ad.activity_starttime > now() , '未开始', IF(ad.activity_endtime <![CDATA[ >= ]]> now() , '活动中', '已结束' )) AS activity_status_str
- FROM
- ac_activity_detail ad
- WHERE
- ad.id = #{id}
- </select>
- <select id="findHighlyRecommended" resultType="platform.modules.sys.entity.ActivityDetail">
- select id, activity_title from ac_activity_detail where push_level = 1 AND del_flag = 0
- </select>
- </mapper>
|