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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?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.ComActRaffleRecordDao">
 
    <resultMap type="com.panzhihua.service_community.entity.ComActRaffleRecord" id="ComActRaffleRecordBaseResultMap">
        <result property="id" column="id"/>
        <result property="userId" column="user_id"/>
        <result property="createTime" column="create_time"/>
        <result property="prizeId" column="prize_id"/>
        <result property="staffId" column="staff_id"/>
        <result property="staffTime" column="staff_time"/>
        <result property="status" column="status"/>
    </resultMap>
 
    <select id="selectByUserId" resultType="com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordVO">
        select t.*, t1.image, t1.name as prizeName, t2.nick_name, t2.phone, t2.`name` as username, t3.name as staffName
        from com_act_raffle_record t
        left join com_act_raffle_prize t1 on t.prize_id = t1.id
        left join sys_user t2 on t.user_id = t2.user_id
        left join sys_user t3 on t.staff_id = t3.user_id
        where 1=1 <if test="userId !=null and userId !=0"> and t.user_id = #{userId} </if>
          and t.raffle_id = #{raffleId}
    </select>
 
    <select id="pageList" resultType="com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordVO">
        select t.*, t1.image, t1.name as prizeName, t2.nick_name, t2.phone, t2.`name` as username, t3.name as staffName,t4.raffle_start_time as raffleStartTime,t4.raffle_stop_time as raffleStopTime
        from com_act_raffle_record t
        left join com_act_raffle_prize t1 on t.prize_id = t1.id
        left join sys_user t2 on t.user_id = t2.user_id
        left join sys_user t3 on t.staff_id = t3.user_id
        left join com_act_raffle t4 on t.raffle_id = t4.id
        <where>
                t.status >0
            <if test="commonPage.status!=null">
                and t.status = #{commonPage.status}
            </if>
            <if test="commonPage.keyword!=null and commonPage.keyword!=''">
                and (t2.name like concat('%',#{commonPage.keyword},'%') or t2.phone like
                concat('%',#{commonPage.keyword},'%') or t1.name like concat('%',#{commonPage.keyword},'%') )
            </if>
            <if test="commonPage.paramId !=null">
                and t.raffle_id = #{commonPage.paramId}
            </if>
            <if test="commonPage.userId !=null">
                and t.user_id = #{commonPage.userId}
            </if>
            <if test="commonPage.paramId2 !=null">
                and t.staff_id = #{commonPage.paramId2}
            </if>
        </where>
        order by t.create_time desc
    </select>
 
    <select id="export" resultType="com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordExcelVO">
        select t.*, t1.image as imageUrl, t1.name as prizeName, t2.nick_name, t2.phone, t2.`name` as username, t3.name as staffName
        from com_act_raffle_record t
        left join com_act_raffle_prize t1 on t.prize_id = t1.id
        left join sys_user t2 on t.user_id = t2.user_id
        left join sys_user t3 on t.staff_id = t3.user_id
        <where>
            <if test="commonPage.status!=null">
                and t.status = #{commonPage.status}
            </if>
            <if test="commonPage.keyword!=null and commonPage.keyword!=''">
                and (t2.name like concat('%',#{commonPage.keyword},'%') or t2.phone like
                concat('%',#{commonPage.keyword},'%') or t1.name like concat('%',#{commonPage.keyword},'%') )
            </if>
            <if test="commonPage.paramId !=null">
                and t.raffle_id = #{commonPage.paramId}
            </if>
            <if test="commonPage.userId !=null">
                and t.user_id = #{commonPage.userId}
            </if>
        </where>
        order by t.create_time desc
    </select>
 
    <select id="selectOneById" resultType="com.panzhihua.common.model.vos.community.raffle.ComActRaffleRecordVO">
        select t.*, t1.`name` as prizeName, t1.image,t2.phone, t2.`name` as username, t3.name as staffName
        from com_act_raffle_record t
        LEFT JOIN com_act_raffle_prize t1 on t.prize_id = t1.id
        left join sys_user t2 on t.user_id = t2.user_id
        left join sys_user t3 on t.staff_id = t3.user_id
        where t.id=#{id}
    </select>
 
    <update id="updateStatusByRaffleId">
        update com_act_raffle_record set status = 3 where raffle_id = #{id} and status = 1
    </update>
</mapper>