<?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.ComActRaffleDao">
|
|
<resultMap type="com.panzhihua.service_community.entity.ComActRaffle" id="ComActRaffleBaseResultMap">
|
<result property="id" column="id"/>
|
<result property="name" column="name"/>
|
<result property="startTime" column="start_time"/>
|
<result property="stopTime" column="stop_time"/>
|
<result property="lotteryTime" column="lottery_time"/>
|
<result property="raffleStartTime" column="raffle_start_time"/>
|
<result property="raffleStopTime" column="raffle_stop_time"/>
|
<result property="workTime" column="work_time"/>
|
<result property="address" column="address"/>
|
<result property="longitude" column="longitude"/>
|
<result property="latitude" column="latitude"/>
|
<result property="phone" column="phone"/>
|
<result property="cover" column="cover"/>
|
<result property="createTime" column="create_time"/>
|
<result property="status" column="status"/>
|
<result property="createBy" column="create_by"/>
|
<result property="communityId" column="community_id"/>
|
</resultMap>
|
|
<select id="pageList" resultType="com.panzhihua.common.model.vos.community.raffle.ComActRaffleVO">
|
select t.*,t2.waitRaffleCount,t3.joinCount,t4.name as createName,t5.raffleCount,t6.prizeCount,ISNULL(t7.isJoin) as isJoin from com_act_raffle t
|
LEFT JOIN (select count(*) waitRaffleCount,raffle_id from com_act_raffle_record where status = 1 group by raffle_id) t2 on t.id = t2.raffle_id
|
LEFT JOIN (select count(*) as joinCount,raffle_id from com_act_raffle_record GROUP BY raffle_id) t3 on t.id = t3.raffle_id
|
LEFT JOIN sys_user t4 on t.create_by = t4.user_id
|
LEFT JOIN (select count(*) as raffleCount,raffle_id from com_act_raffle_record where status >0 GROUP BY raffle_id) t5 on t.id = t5.raffle_id
|
LEFT JOIN (select sum(total) as prizeCount,raffle_id from com_act_raffle_prize GROUP BY raffle_id) t6 on t.id = t6.raffle_id
|
LEFT JOIN (select count(*) as isJoin,raffle_id from com_act_raffle_record <if test="commonPage.userId !=null"> where user_id = ${commonPage.userId} </if> group by raffle_id) t7 on t.id = t7.raffle_id
|
|
<where>
|
<if test="commonPage.communityId!=null">
|
and t.community_id = #{commonPage.communityId}
|
</if>
|
<if test="commonPage.status !=null">
|
and t.status =#{commonPage.status}
|
</if>
|
<if test="commonPage.keyword !=null">
|
and t.name like concat('%',#{commonPage.keyword},'%')
|
</if>
|
<if test="commonPage.type!=null">
|
and t.status > 0
|
</if>
|
</where>
|
order by t.create_time desc
|
</select>
|
|
<select id="selectById" resultType="com.panzhihua.common.model.vos.community.raffle.ComActRaffleVO">
|
select t.*,t2.waitRaffleCount,t3.joinCount,t4.name as createName,t5.raffleCount from com_act_raffle t
|
LEFT JOIN (select sum(surplus) as waitRaffleCount,raffle_id from com_act_raffle_prize GROUP BY raffle_id) t2 on t.id = t2.raffle_id
|
LEFT JOIN (select count(*) as joinCount,raffle_id from com_act_raffle_record GROUP BY raffle_id) t3 on t.id = t3.raffle_id
|
LEFT JOIN sys_user t4 on t.create_by = t4.user_id
|
LEFT JOIN (select count(*) as raffleCount,raffle_id from com_act_raffle_record where status >0 GROUP BY raffle_id) t5 on t.id = t5.raffle_id
|
where t.id=#{id}
|
</select>
|
</mapper>
|