mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?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>