罗元桥
2021-09-28 a5e8dc52dbf29b0ea4b39c00bfe8f88efb6aa76c
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?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.ComActReserveMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActReserveDO">
        <id column="id" property="id"/>
        <result column="community_id" property="communityId"/>
        <result column="type" property="type"/>
        <result column="title" property="title"/>
        <result column="view_num" property="viewNum"/>
        <result column="join_all_count" property="joinAllCount"/>
        <result column="join_count" property="joinCount"/>
        <result column="img_type" property="imgType"/>
        <result column="img_url" property="imgUrl"/>
        <result column="status" property="status"/>
        <result column="publish_time" property="publishTime"/>
        <result column="is_repeat" property="isRepeat"/>
        <result column="remark" property="remark"/>
        <result column="json_object" property="jsonObject"/>
        <result column="adver_position_top" property="adverPositionTop"/>
        <result column="adver_position_application" property="adverPositionApplication"/>
        <result column="create_at" property="createAt"/>
        <result column="create_by" property="createBy"/>
        <result column="update_at" property="updateAt"/>
        <result column="update_by" property="updateBy"/>
        <result column="end_time" property="endTime"/>
        <result column="is_del" property="isDel"/>
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, community_id, type, title, view_num, join_all_count, join_count, img_type, img_url, status, publish_time, is_repeat, remark, json_object, adver_position_top, adver_position_application, create_at, create_by, update_at, update_by, end_time, is_del
    </sql>
 
    <select id="indexBanner" resultType="com.panzhihua.common.model.vos.community.ComActReserveIndexVo">
        select id,title,type,img_type, img_url,adver_position_top, adver_position_application from com_act_reserve
        where
            status = 2 and adver_position_top = 1
            <if test="communityId !=null">
                and community_id =#{communityId}
            </if>
 
    </select>
 
    <select id="indexApplication" resultType="com.panzhihua.common.model.vos.community.ComActReserveIndexVo">
        select id,title,type,img_type, img_url,adver_position_top, adver_position_application from com_act_reserve
        <where>
            status = 2 and adver_position_application = 1
            <if test="communityId !=null">
                and community_id =#{communityId}
            </if>
        </where>
    </select>
 
 
 
    <select id="pageReserveAdmin" parameterType="com.panzhihua.common.model.dtos.community.reserve.PageReserveAdminDTO"
            resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveListAdminVO">
        SELECT
            id,
            community_id,
            `type`,
            title,
            view_num,
            join_all_count,
            join_count,
            `status`,
            publish_time,
            create_at,
            end_time,
            adver_position_top,
            adver_position_application
        FROM
            com_act_reserve
            <where>
                and is_del = 2
                <if test="pageReserveDTO.communityId != null">
                    and community_id = #{pageReserveDTO.communityId}
                </if>
                <if test="pageReserveDTO.type != null and pageReserveDTO.type.size > 0">
                    and `type` in
                    <foreach collection='pageReserveDTO.type' item='id' index='index' open='(' close=')' separator=',' >
                        #{id}
                    </foreach>
                </if>
                <if test="pageReserveDTO.status != null">
                    and status = #{pageReserveDTO.status}
                </if>
                <if test="pageReserveDTO.advertType != null and pageReserveDTO.advertType == 1">
                    and adver_position_top = 2 and adver_position_application = 2
                </if>
                <if test="pageReserveDTO.advertType != null and pageReserveDTO.advertType == 2">
                    and adver_position_top = 1
                </if>
                <if test="pageReserveDTO.advertType != null and pageReserveDTO.advertType == 3">
                    and adver_position_application = 1
                </if>
                <if test="pageReserveDTO.keyWord != null and pageReserveDTO.keyWord != &quot;&quot;">
                    and title like concat (#{pageReserveDTO.keyWord},'%')
                </if>
                <if test="pageReserveDTO.startTime != null and pageReserveDTO.startTime != &quot;&quot;">
                    AND DATE_FORMAT(create_at,'%Y-%m-%d %H:%i:%s') <![CDATA[ >= ]]> #{pageReserveDTO.startTime}
                </if>
                <if test="pageReserveDTO.endTime != null and pageReserveDTO.endTime != &quot;&quot;">
                    AND DATE_FORMAT(create_at,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{pageReserveDTO.endTime}
                </if>
            </where>
            order by create_at desc
    </select>
 
    <delete id="deleteReserveSubAll">
        delete from com_act_reserve_sub where reserve_id = #{reserveId};
        delete from com_act_reserve_sub_selection where reserve_id = #{reserveId};
    </delete>
 
    <select id="getReserveMakeLeftStatistics" resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveMakeLeftStatisticsAdminVO">
        SELECT
            date_format( reserve_time, '%Y-%m-%d' ) AS reserveTime,
            count( id ) AS count
        FROM
            com_act_reserve_record
        WHERE
            `status` = 2
            AND type = 1
            AND community_id = #{communityId}
 
            group by reserveTime
    </select>
 
    <select id="getReserveMakeRightStatistics" parameterType="com.panzhihua.common.model.dtos.community.reserve.ComActReserveMakeStatisticsDTO"
            resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveMakeRightStatisticsAdminVO">
        SELECT
            date_format( carr.reserve_time, '%Y-%m-%d' ) AS reserveTime,
            car.title AS title,
            count( carr.id ) AS count
        FROM
            com_act_reserve_record AS carr
            LEFT JOIN com_act_reserve AS car ON car.id = carr.reserve_id
        WHERE
            carr.`status` = 2
            AND carr.type = 1
            AND carr.community_id = #{makeStatisticsDTO.communityId}
            <if test="makeStatisticsDTO.startTime != null and makeStatisticsDTO.startTime != &quot;&quot;">
                AND carr.reserve_time <![CDATA[ >= ]]> #{makeStatisticsDTO.startTime}
            </if>
            <if test="makeStatisticsDTO.endTime != null and makeStatisticsDTO.endTime != &quot;&quot;">
                AND carr.reserve_time <![CDATA[ <= ]]> #{makeStatisticsDTO.endTime}
            </if>
        GROUP BY
            reserveTime,
            car.id
    </select>
 
    <select id="getReserveRecordCount" resultType="integer">
        select count(id) from com_act_reserve_record
        where `status` = 2 and `type` = 1 and community_id = #{communityId}
        and reserve_time <![CDATA[ >= ]]> #{startTime}
        and reserve_time <![CDATA[ <= ]]> #{endTime}
    </select>
 
    <select id="listReserveAdmin"  parameterType="com.panzhihua.common.model.dtos.community.reserve.PageReserveAdminDTO"
            resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveListAdminVO">
        SELECT
            id,
            community_id,
            `type`,
            title,
            view_num,
            join_all_count,
            join_count,
            `status`,
            publish_time,
            create_at,
            end_time,
            adver_position_top,
            adver_position_application
        FROM
            com_act_reserve
            where is_del = 2 and `type` = 1 and community_id = #{communityId}
    </select>
 
    <update id="addReserveCountById">
        update com_act_reserve set join_count = join_count - 1 where id = #{reserveId}
    </update>
 
    <select id="getReserveIndexList" resultType="com.panzhihua.common.model.vos.community.ComActReserveIndexVo">
        select id,title,type,img_type,img_url,adver_position_top,adver_position_application from com_act_reserve where `status` = 2 and is_del = 2
        and community_id = #{communityId}
    </select>
</mapper>