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
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?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>
        order by create_at desc
    </select>
 
 
 
    <select id="pageReserveAdmin" parameterType="com.panzhihua.common.model.dtos.community.reserve.PageReserveAdminDTO"
            resultType="com.panzhihua.common.model.vos.community.reserve.ComActReserveListAdminVO">
            SELECT
            t.id,
            t.community_id,
            t.`type`,
            t.title,
            view_num,
            join_all_count,
            join_count,
            t.`status`,
            publish_time,
            t.create_at,
            end_time,
            adver_position_top,
            adver_position_application,
            t1.`name` as community_name
            FROM
            com_act_reserve t left join com_act t1 on t.community_id = t1.community_id
            <where>
                and t.is_del = 2
                <if test="pageReserveDTO.communityId != null and pageReserveDTO.communityId !=0">
                    and t.community_id = ${pageReserveDTO.communityId}
                </if>
                <if test="pageReserveDTO.areaCode !=null">
                    and t1.area_code = #{pageReserveDTO.areaCode}
                </if>
                <if test="pageReserveDTO.type != null and pageReserveDTO.type.size > 0">
                    and t.`type` in
                    <foreach collection='pageReserveDTO.type' item='id' index='index' open='(' close=')' separator=',' >
                        #{id}
                    </foreach>
                </if>
                <if test="pageReserveDTO.status != null">
                    and t.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(t.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(t.create_at,'%Y-%m-%d %H:%i:%s') <![CDATA[ <= ]]> #{pageReserveDTO.endTime}
                </if>
                <if test="pageReserveDTO.isWjw !=null">
                    AND (title like '%返攀%' or title like '%居家%')
                </if>
            </where>
            order by t.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}
        order by create_at desc
    </select>
 
    <select id="indexBackReserve" resultType="Integer">
        select count(*) from com_act_reserve t  LEFT JOIN com_act_reserve_record t3 on t.id=t3.reserve_id where t.community_id = ${communityId} and ( t.title like '%返攀登记%' or t.title like '%来攀登记%')
    </select>
 
    <select id="indexHomeQuarantine" resultType="Integer">
        select count(*) from com_act_reserve t  LEFT JOIN com_act_reserve_record t3 on t.id=t3.reserve_id where t.community_id = ${communityId} and t.title like '%居家隔离%'
    </select>
 
    <select id="indexBackReserveSub" resultType="com.panzhihua.common.model.vos.community.bigscreen.IndexReserveSub">
        select a.*,IFNULL(b.num,0) num from (select count(t2.id) as allCount,t1.key from com_act_reserve t
                                                                                             LEFT JOIN com_act_reserve_sub t1 on t.id = t1.reserve_id
                                                                                             LEFT JOIN com_act_reserve_answer_content t2 on t1.id = t2.reserve_sub_id
                                             where t.community_id = ${communityId} and ( t.title like '%返攀登记%' or t.title like '%来攀登记%') and t1.`key` in (1,2,3,17,19,26) group by t1.key) a LEFT JOIN
                                            (select count(t2.id) as num,t1.key from com_act_reserve t
                                                                                        LEFT JOIN com_act_reserve_sub t1 on t.id = t1.reserve_id
                                                                                        LEFT JOIN com_act_reserve_answer_content t2 on t1.id = t2.reserve_sub_id
                                             where t.community_id = ${communityId} and ( t.title like '%返攀登记%' or t.title like '%来攀登记%') and t1.`key` in (1,2,3,17,19,26) and t2.answer_content = '是' group by t1.key) b on a.key = b.key
    </select>
 
    <select id="IndexHomeQuarantineSub" resultType="com.panzhihua.common.model.vos.community.bigscreen.IndexReserveSub">
        select a.*,IFNULL(b.num,0) num from (select count(t2.id) as allCount,t1.key from com_act_reserve t
                                                                                             LEFT JOIN com_act_reserve_sub t1 on t.id = t1.reserve_id
                                                                                             LEFT JOIN com_act_reserve_answer_content t2 on t1.id = t2.reserve_sub_id
                                             where t.community_id = ${communityId} and t.title like '%居家隔离%' and t1.`key` in (12,14,16) group by t1.key) a LEFT JOIN
                                            (select count(t2.id) as num,t1.key from com_act_reserve t
                                                                                        LEFT JOIN com_act_reserve_sub t1 on t.id = t1.reserve_id
                                                                                        LEFT JOIN com_act_reserve_answer_content t2 on t1.id = t2.reserve_sub_id
                                             where t.community_id = ${communityId} and t.title like '%居家隔离%' and t1.`key` in (12,14,16) and t2.answer_content = '是' group by t1.key) b on a.key = b.key
    </select>
 
    <select id="selectCommunityPhoneByReserveId" resultType="string">
        select contacts_phone from com_act_reserve t left join com_act t1 on t.community_id = t1.community_id where t.id = #{reserveId}
    </select>
</mapper>