<?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="com.panzhihua.service_community.dao.ComActActivityDAO">
|
|
<!-- 通用查询映射结果 -->
|
<resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActActivityDO">
|
<id column="id" property="id" />
|
<result column="activity_name" property="activityName" />
|
<result column="sponsor_id" property="sponsorId" />
|
<result column="activity_addr" property="activityAddr" />
|
<result column="lat" property="lat" />
|
<result column="lng" property="lng" />
|
<result column="status" property="status" />
|
<result column="publish_at" property="publishAt" />
|
<result column="end_at" property="endAt" />
|
<result column="begin_at" property="beginAt" />
|
<result column="sign_up_begin" property="signUpBegin" />
|
<result column="sign_up_end" property="signUpEnd" />
|
<result column="aattend_people" property="aattendPeople" />
|
<result column="volunteer_min" property="volunteerMin" />
|
<result column="volunteer_max" property="volunteerMax" />
|
<result column="participant_min" property="participantMin" />
|
<result column="participant_max" property="participantMax" />
|
<result column="cover" property="cover" />
|
<result column="has_prize" property="hasPrize" />
|
<result column="is_qr_code" property="isQrCode" />
|
<result column="contact_name" property="contactName" />
|
<result column="contact_phone" property="contactPhone" />
|
<result column="is_regist" property="isRegist" />
|
<result column="is_top" property="isTop" />
|
<result column="prize_remark" property="prizeRemark" />
|
<result column="reward_desc" property="rewardDesc" />
|
<result column="content" property="content" />
|
<result column="community_id" property="communityId" />
|
<result column="create_at" property="createAt" />
|
<result column="cancel_reason" property="cancelReason" />
|
<result column="range" property="range" />
|
<result column="have_integral_reward" property="haveIntegralReward" />
|
<result column="reward_way" property="rewardWay" />
|
<result column="reward_integral" property="rewardIntegral" />
|
<result column="limit" property="limit" />
|
<result column="can_cancel" property="canCancel" />
|
<result column="cancel_deduct" property="cancelDeduct" />
|
<result column="activity_type" property="activityType" />
|
</resultMap>
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
id, activity_name, sponsor_id, activity_addr, lat, lng, status, publish_at, end_at, begin_at, sign_up_begin, sign_up_end, aattend_people, volunteer_min, volunteer_max, participant_min, participant_max, cover, has_prize, is_qr_code, contact_name, contact_phone, is_regist, is_top, prize_remark, reward_desc, content, community_id, create_at, cancel_reason
|
</sql>
|
<insert id="addActivityType">
|
INSERT INTO com_act_activity_type (`name`, `type`, community_id)
|
VALUES (#{comActActivityTypeVO.name}, #{comActActivityTypeVO.type}, #{comActActivityTypeVO.communityId})
|
</insert>
|
|
<select id="activityStatistics" resultType="com.panzhihua.common.model.vos.community.ComActActivityStatisticsVO">
|
SELECT IFNULL(volunteer_max,0) + IFNULL(participant_max,0) as signTotal
|
,(SELECT count(id) FROM com_act_act_sign WHERE activity_id = #{activityId} AND `status` = 1) as reallySignTotal
|
,(SELECT count(id) FROM com_act_act_sign WHERE activity_id = #{activityId} AND `status` = 1) as registTotal
|
,(SELECT count(id) FROM com_act_act_regist WHERE activity_id = #{activityId}) as reallyRegistTotal
|
,((SELECT count(id) FROM com_act_act_sign WHERE activity_id = #{activityId} AND `status` = 1) - (SELECT count(id) FROM com_act_act_regist WHERE activity_id = #{activityId})) as noRegistTotal
|
,(SELECT count(id) FROM com_act_act_sign WHERE activity_id = #{activityId} AND `status` = 1) as evaluateTotal
|
,(SELECT count(id) FROM com_act_act_evaluate WHERE activity_id = #{activityId}) as reallyEvaluateTotal
|
,((SELECT count(id) FROM com_act_act_sign WHERE activity_id = #{activityId} AND `status` = 1) - (SELECT count(id) FROM com_act_act_evaluate WHERE activity_id = #{activityId})) as noEvaluateTotal
|
FROM com_act_activity where id = #{activityId}
|
</select>
|
<select id="getIndexTopActivityList" resultMap="BaseResultMap">
|
SELECT * FROM `com_act_activity`
|
WHERE community_id = #{communityId} and is_top = 1 and sign_up_end >= now()
|
</select>
|
<select id="pageActivityCommunityBack"
|
resultType="com.panzhihua.common.model.vos.community.ComActActivityVO">
|
SELECT t.* FROM (
|
SELECT a.id, a.activity_name, u.`name` sponsorName, a.activity_addr, a.participant_max, a.contact_name,
|
COUNT(if(s.is_volunteer=1,NULL,s.id))participant_now, a.volunteer_max,
|
COUNT(if(s.is_volunteer=1,s.id,NULL))volunteer_now, a.`status`, a.publish_at, a.is_qr_code,
|
a.begin_at, a.end_at, a.sign_up_begin, a.sign_up_end, a.reward_way, a.activity_type, a.have_integral_reward , a.cover <if test='comActActivityVO.type != null and comActActivityVO.type == 4'>,so.socialCount</if>
|
FROM com_act_activity a
|
LEFT JOIN sys_user u ON a.sponsor_id=u.user_id
|
LEFT JOIN (SELECT * FROM com_act_act_sign WHERE `status` = 1) s ON a.id=s.activity_id
|
<if test='comActActivityVO.type != null and comActActivityVO.type == 4'>
|
left join (select count(t.id) as socialCount,activity_id from com_act_act_regist t LEFT JOIN sys_user t1 on t.user_id = t1.user_id LEFT JOIN com_act_social_worker t2 on t1.phone = t2.telephone where t2.id is not null GROUP BY t.activity_id) so on a.id = so.activity_id
|
</if>
|
WHERE a.`status` = 1 AND a.community_id=#{comActActivityVO.communityId}
|
<if test='comActActivityVO.type != null and comActActivityVO.type == 1'>
|
AND a.volunteer_max != 0
|
</if>
|
<if test='comActActivityVO.type != null and comActActivityVO.type == 2'>
|
AND a.volunteer_max = 0
|
</if>
|
<if test='comActActivityVO.type != null and comActActivityVO.type == 4'>
|
AND a.is_project = 1
|
</if>
|
<if test='comActActivityVO.rewardWay != null and comActActivityVO.rewardWay != 0'>
|
AND a.reward_way = #{comActActivityVO.rewardWay}
|
</if>
|
<if test='comActActivityVO.activityType != null and comActActivityVO.activityType !=""'>
|
AND a.activity_type = #{comActActivityVO.activityType}
|
</if>
|
<if test='comActActivityVO.activityName != null and comActActivityVO.activityName !=""'>
|
AND a.activity_name LIKE concat( #{comActActivityVO.activityName}, '%' )
|
</if>
|
<if test='comActActivityVO.status != null and comActActivityVO.status !=0 and comActActivityVO.status !=1'>
|
AND a.`status` = 99
|
</if>
|
<if test='comActActivityVO.beginAt != null '>
|
AND a.begin_at <![CDATA[ >= ]]> #{comActActivityVO.beginAt} AND a.end_at <![CDATA[ <= ]]> #{comActActivityVO.endAt}
|
</if>
|
GROUP BY a.id
|
UNION ALL SELECT t1.* FROM (
|
SELECT a.id, a.activity_name, u.`name` sponsorName, a.activity_addr, a.participant_max, a.contact_name,
|
COUNT(if(s.is_volunteer=1,NULL,s.id))participant_now, a.volunteer_max,
|
COUNT(if(s.is_volunteer=1,s.id,NULL))volunteer_now, a.`status`, a.publish_at,
|
a.is_qr_code, a.begin_at, a.end_at, a.sign_up_begin, a.sign_up_end, a.reward_way, a.activity_type, a.have_integral_reward ,a.cover<if test='comActActivityVO.type != null and comActActivityVO.type == 4'>,so.socialCount</if>
|
FROM com_act_activity a
|
LEFT JOIN sys_user u ON a.sponsor_id=u.user_id
|
LEFT JOIN (SELECT * FROM com_act_act_sign WHERE `status` = 1) s ON a.id=s.activity_id
|
<if test='comActActivityVO.type != null and comActActivityVO.type == 4'>
|
left join (select count(t.id) as socialCount,activity_id from com_act_act_regist t LEFT JOIN sys_user t1 on t.user_id = t1.user_id LEFT JOIN com_act_social_worker t2 on t1.phone = t2.telephone where t2.id is not null GROUP BY t.activity_id) so on a.id = so.activity_id
|
</if>
|
WHERE a.`status` != 1 AND a.community_id=#{comActActivityVO.communityId}
|
<if test='comActActivityVO.type != null and comActActivityVO.type == 1'>
|
AND a.volunteer_max != 0
|
</if>
|
<if test='comActActivityVO.type != null and comActActivityVO.type == 2'>
|
AND a.volunteer_max = 0
|
</if>
|
<if test='comActActivityVO.type != null and comActActivityVO.type == 4'>
|
AND a.is_project = 1
|
</if>
|
<if test='comActActivityVO.rewardWay != null and comActActivityVO.rewardWay != 0'>
|
AND a.reward_way = #{comActActivityVO.rewardWay}
|
</if>
|
<if test='comActActivityVO.activityType != null and comActActivityVO.activityType !=""'>
|
AND a.activity_type = #{comActActivityVO.activityType}
|
</if>
|
<if test='comActActivityVO.activityName != null and comActActivityVO.activityName !=""'>
|
AND a.activity_name LIKE concat( #{comActActivityVO.activityName}, '%' )
|
</if>
|
<if test='comActActivityVO.status != null and comActActivityVO.status !=0 '>
|
AND a.`status` = #{comActActivityVO.status}
|
</if>
|
<if test='comActActivityVO.beginAt != null '>
|
AND a.begin_at <![CDATA[ >= ]]> #{comActActivityVO.beginAt} AND a.end_at <![CDATA[ <= ]]> #{comActActivityVO.endAt}
|
</if>
|
GROUP BY a.id ORDER BY a.publish_at DESC
|
)t1
|
)t
|
</select>
|
<select id="inforActivity" resultType="com.panzhihua.common.model.vos.community.ComActActivityVO">
|
SELECT u.name sponsorName, ca.name communityName,
|
count(if(s.is_volunteer=1,s.id,null))volunteer_now, count(if(s.is_volunteer=0,s.id,null))participant_now, a.*,t1.name as projectName
|
FROM com_act_activity a
|
left join sys_user u on a.sponsor_id=u.user_id
|
left join (select * from com_act_act_sign where `status` = 1) s on a.id=s.activity_id
|
left join com_act ca on a.community_id=ca.community_id left join com_act_social_project t1 on a.project_id = t1.id where a.id = #{id} group by a.id
|
|
</select>
|
<select id="listActivityType" resultType="com.panzhihua.common.model.vos.community.ComActActivityTypeVO">
|
SELECT * FROM com_act_activity_type WHERE `type` = #{type} AND community_id = #{communityId} ORDER BY id ASC
|
</select>
|
|
<select id="selectProjectActivity" resultType="com.panzhihua.common.model.vos.community.ComActActivityVO">
|
SELECT a.id, a.activity_name, u.`name` sponsorName, a.activity_addr, a.participant_max, a.contact_name,
|
COUNT(if(s.is_volunteer=1,NULL,s.id))participant_now, a.volunteer_max,
|
COUNT(if(s.is_volunteer=1,s.id,NULL))volunteer_now, a.`status`, a.publish_at, a.is_qr_code,
|
a.begin_at, a.end_at, a.sign_up_begin, a.sign_up_end, a.reward_way, a.activity_type, a.have_integral_reward , a.cover , t1.evaluateLevel
|
FROM com_act_activity a
|
LEFT JOIN sys_user u ON a.sponsor_id=u.user_id
|
LEFT JOIN (SELECT * FROM com_act_act_sign WHERE `status` = 1) s ON a.id=s.activity_id
|
LEFT JOIN (select AVG(star_level) as evaluateLevel,activity_id from com_act_act_evaluate GROUP BY activity_id) t1 on a.id = t1.activity_id
|
WHERE is_project=1 order by t1.evaluateLevel desc
|
</select>
|
|
<select id="selectActivityBySocialWorker" resultType="com.panzhihua.common.model.vos.community.ComActActivityVO">
|
select t.* from com_act_activity t left join com_act_act_regist t1 on t.id=t1.activity_id where t1.user_id =
|
(select t1.user_id from com_act_social_worker t LEFT JOIN sys_user t1 on t.telephone = t1.phone where t.id = #{id})
|
</select>
|
</mapper>
|