101captain
2021-11-11 78d1c9ee9b0c49f77c29d0535cb93c6d62c42f3a
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<?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.ComActEasyPhotoDAO">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComActEasyPhotoDO">
        <id column="id" property="id" />
        <result column="sponsor_id" property="sponsorId" />
        <result column="happen_addr" property="happenAddr" />
        <result column="addr_remark" property="addrRemark" />
        <result column="status" property="status" />
        <result column="handler_id" property="handlerId" />
        <result column="create_at" property="createAt" />
        <result column="examine_at" property="examineAt" />
        <result column="detail" property="detail" />
        <result column="photo_path_list" property="photoPathList" />
        <result column="handle_result" property="handleResult" />
        <result column="handle_photo_list" property="handlePhotoList" />
        <result column="community_id" property="communityId" />
        <result column="is_hide" property="isHide" />
        <result column="is_need_feed_back" property="isNeedFeedBack" />
        <result column="feedback_at" property="feedbackAt" />
        <result column="reject_reason" property="rejectReason" />
        <result column="del_tag" property="delTag" />
        <result column="is_report" property="isReport" />
        <result column="is_publicity" property="isPublicity" />
        <result column="handle_status" property="handleStatus" />
        <result column="lng_lat" property="lngLat" />
        <result column="activity_type" property="activityType" />
        <result column="activity_amount" property="activityAmount" />
        <result column="activity_id" property="activityId" />
        <result column="img_width" property="imgWidth" />
        <result column="img_height" property="imgHeight" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, sponsor_id, happen_addr, addr_remark, status, handler_id, create_at, examine_at, detail, photo_path_list
        , handle_result, handle_photo_list, community_id, is_hide, is_need_feed_back, feedback_at, reject_reason
        , del_tag, is_report, is_publicity, handle_status, lng_lat, activity_type, activity_amount, activity_id
        , img_width, img_height
    </sql>
 
    <select id="pageEasyPhotoAdmin" parameterType="com.panzhihua.common.model.vos.community.ComActEasyPhotoVO"
            resultType="com.panzhihua.common.model.vos.community.ComActEasyPhotoVO">
        SELECT
            p.id,
            u.`name` sponsor_name,
            u.phone phone,
            count( pu.id ) giveThumbsUpNum,
            u.image_url,
            p.happen_addr,
            su.`name` handler_name,
            p.`status`,
            p.`detail`,
            p.`is_need_feed_back`,
            p.`photo_path_list`,
            p.create_at,
            p.feedback_at,
            p.is_report,
            p.is_publicity,
            p.activity_type,
            p.activity_amount,
            p.activity_id,
            p.is_report_urban,
            p.classify_id,
            ca.`name` as classifyName,
            p.examine_at,
            c.name  communityName,
            p.urban_status,
            p.transfer_reason
        FROM
            com_act_easy_photo p
            LEFT JOIN sys_user u ON p.sponsor_id = u.user_id
            LEFT JOIN com_act_easy_photo_user pu ON p.id = pu.easy_photo_id
            LEFT JOIN sys_user su ON p.handler_id = su.user_id
            left join com_act c on p.community_id =c.community_id
            left join com_act_easy_photo_classify ca on ca.id = p.classify_id
        WHERE
            p.del_tag = 0 and p.`status` != 3
        <if test='comActEasyPhotoVO.communityId != null and comActEasyPhotoVO.communityId != 0'>
          and p.community_id=#{comActEasyPhotoVO.communityId}
        </if>
        <if test='comActEasyPhotoVO.status != null and comActEasyPhotoVO.status!=0' >
          AND p.`status` = #{comActEasyPhotoVO.status}
        </if>
        <if test='comActEasyPhotoVO.isPublicity != null' >
            AND p.`is_publicity` = #{comActEasyPhotoVO.isPublicity}
        </if>
        <if test='comActEasyPhotoVO.isReportUrban != null' >
            AND p.`is_report_urban` = #{comActEasyPhotoVO.isReportUrban}
        </if>
        <if test='comActEasyPhotoVO.classifyId != null' >
            AND p.`classify_id` = #{comActEasyPhotoVO.classifyId}
        </if>
        <if test='comActEasyPhotoVO.urbanStatus != null' >
            AND p.`urban_status` = #{comActEasyPhotoVO.urbanStatus}
        </if>
        <if test='comActEasyPhotoVO.createBegin != null  '>
        AND p.create_at BETWEEN #{comActEasyPhotoVO.createBegin}
        AND #{comActEasyPhotoVO.createEnd}
        </if>
        <if test='comActEasyPhotoVO.activityType != null'>
            AND p.activity_type =#{comActEasyPhotoVO.activityType}
        </if>
 
        <if test='comActEasyPhotoVO.keyWord != null and comActEasyPhotoVO.keyWord != &quot;&quot;'>
            AND (u.`name` like concat(#{comActEasyPhotoVO.keyWord},'%') or
            p.happen_addr like concat(#{comActEasyPhotoVO.keyWord},'%') or
            su.`name` like concat(#{comActEasyPhotoVO.keyWord},'%') or
            p.detail like concat(#{comActEasyPhotoVO.keyWord},'%') or u.phone like concat(#{comActEasyPhotoVO.keyWord},'%')
            )
        </if>
        GROUP BY
            p.id
        ORDER BY
            p.create_at DESC
 
    </select>
 
    <select id="getEasyPhotoStatistics" resultType="com.panzhihua.common.model.vos.community.easyPhoto.ComActEasyPhotoStatisticsVO">
        SELECT
            count( id ) AS examineNum,
            ( SELECT count( id ) FROM com_act_easy_photo WHERE `status` = 2 AND community_id = #{communityId} AND del_tag = 0 ) AS verificationNum,
            ( SELECT count( id ) FROM com_act_easy_photo WHERE `status` in (1,2,4) AND `is_publicity` = 1 AND community_id = #{communityId} AND del_tag = 0 ) AS rejectNum,
            ( SELECT count( id ) FROM com_act_easy_photo WHERE `status` = 4 AND community_id = #{communityId} AND del_tag = 0 ) AS completeNum,
            (select count(id) from com_act_easy_photo where `status` in (2,4) AND community_id = #{communityId} and del_tag = 0 and activity_type = 1) as yzAllTotal,
            (select count(id) from com_act_easy_photo where `status` in (2,4) AND community_id = #{communityId} and del_tag = 0 and activity_type = 1 and examine_at between timestamp(date_add(curdate(), interval - 0 day)) and now()) as yzDayTotal,
            (select count(id) from com_act_easy_photo where `status` in (2,4) AND community_id = #{communityId} and del_tag = 0 and activity_type = 2) as jlAllTotal,
            (select count(id) from com_act_easy_photo where `status` in (2,4) AND community_id = #{communityId} and del_tag = 0 and activity_type = 2 and examine_at between timestamp(date_add(curdate(), interval - 0 day)) and now()) as jlDayTotal,
            (select count(id) from com_act_easy_photo where `status` in (2,4) AND community_id = #{communityId} and del_tag = 0 and activity_type = 3) as ptAllTotal,
            (select count(id) from com_act_easy_photo where `status` in (2,4) AND community_id = #{communityId} and del_tag = 0 and activity_type = 3 and examine_at between timestamp(date_add(curdate(), interval - 0 day)) and now()) as ptDayTotal,
            (select count(id) from com_act_easy_photo where `status` in (2,4) AND community_id = #{communityId} and del_tag = 0 and activity_type = 4) as ybAllTotal,
            (select count(id) from com_act_easy_photo where `status` in (2,4) AND community_id = #{communityId} and del_tag = 0 and activity_type = 4 and examine_at between timestamp(date_add(curdate(), interval - 0 day)) and now()) as ybDayTotal,
            (select IFNULL(sum(activity_amount),0) from com_act_easy_photo where `status` in (2,4) AND community_id = 2 and del_tag = 0) as allRewardAmount,
            (select IFNULL(sum(activity_amount),0)  from com_act_easy_photo where `status` in (2,4) AND community_id = 2 and del_tag = 0 and examine_at between timestamp(date_add(curdate(), interval - 0 day)) and now()) as dayRewardAmount
        FROM
            com_act_easy_photo
        WHERE
            `status` = 1
            AND community_id = #{communityId}
            AND del_tag = 0
    </select>
 
    <select id="easyPhotoCount" resultType="com.panzhihua.common.model.vos.community.easyPhoto.ComActEasyPhotoCountVO">
        select count(*) total,(select count(*) today from com_act_easy_photo where transfer_time BETWEEN DATE_FORMAT(CURDATE(),'%Y-%m-%d %H:%i:%s')  and DATE_ADD(CURRENT_DATE, INTERVAL 1 DAY)
       <if test="urbanStatus !=null">
        and urban_status=#{urbanStatus}
        </if>)
            today from com_act_easy_photo
        <where>
            1=1
            <if test="urbanStatus !=null">
                    and urban_status=#{urbanStatus}
            </if>
        </where>
    </select>
 
    <select id="export" resultType="com.panzhihua.common.model.vos.community.ComActEasyPhotoVO">
        SELECT
            p.id,
            u.`name` sponsor_name,
            u.phone phone,
            count( pu.id ) giveThumbsUpNum,
            u.image_url,
            p.happen_addr,
            su.`name` handler_name,
            p.`status`,
            p.`detail`,
            p.`is_need_feed_back`,
            p.`photo_path_list`,
            p.create_at,
            p.feedback_at,
            p.is_report,
            p.is_publicity,
            p.activity_type,
            p.activity_amount,
            p.activity_id,
            p.examine_at,
            c.name  communityName,
            p.is_report_urban,
            p.urban_status,
            ca.`name` as photoType
        FROM
            com_act_easy_photo p
                LEFT JOIN sys_user u ON p.sponsor_id = u.user_id
                LEFT JOIN com_act_easy_photo_user pu ON p.id = pu.easy_photo_id
                LEFT JOIN sys_user su ON p.handler_id = su.user_id
                left join com_act c on p.community_id =c.community_id
                left join com_act_easy_photo_classify ca on ca.id = p.classify_id
        WHERE
            p.del_tag = 0 and p.`is_report_urban` =1
        <if test='communityId != null and communityId != 0'>
            and p.community_id=#{communityId}
        </if>
        <if test='urbanStatus != null ' >
            AND p.`urban_status` = #{urbanStatus}
        </if>
        <if test='createBegin != null  '>
            AND p.create_at BETWEEN #{createBegin}
            AND #{createEnd}
        </if>
 
        <if test='keyWord != null and keyWord != &quot;&quot;'>
            AND (u.`name` like concat(#{keyWord},'%') or
            p.happen_addr like concat(#{keyWord},'%') or
            su.`name` like concat(#{keyWord},'%') or
            p.detail like concat(#{keyWord},'%') or u.phone like concat(#{comActEasyPhotoVO.keyWord},'%')
            )
        </if>
        GROUP BY
        p.id
        ORDER BY
        p.create_at DESC
    </select>
 
    <select id="exportByIds" resultType="com.panzhihua.common.model.vos.community.easyPhoto.ExportEasyPhotoVO">
        SELECT
        p.id,
        u.`name` sponsor_name,
        u.phone phone,
        count( pu.id ) giveThumbsUpNum,
        u.image_url,
        p.happen_addr,
        su.`name` handler_name,
        p.`status`,
        p.`detail`,
        p.`is_need_feed_back`,
        p.`photo_path_list`,
        p.create_at,
        p.feedback_at,
        p.is_report,
        p.is_publicity,
        p.activity_type,
        p.activity_amount,
        p.activity_id,
        p.examine_at,
        c.name  communityName,
        p.is_report_urban,
        p.urban_status,
        ca.`name` as photoType
        FROM
        com_act_easy_photo p
        LEFT JOIN sys_user u ON p.sponsor_id = u.user_id
        LEFT JOIN com_act_easy_photo_user pu ON p.id = pu.easy_photo_id
        LEFT JOIN sys_user su ON p.handler_id = su.user_id
        left join com_act c on p.community_id =c.community_id
        left join com_act_easy_photo_classify ca on ca.id = p.classify_id
        WHERE
        p.id in
        <foreach collection="list" item="ids" index="index"
                 open="(" close=")" separator=",">
        #{ids}
        </foreach>
        GROUP BY
        p.id
        ORDER BY
        p.create_at DESC
    </select>
 
    <select id="easyPhotoNoHandleIds" resultType="Long">
        select id from com_act_easy_photo where `status` = 1 and community_id = #{communityId} and del_tag = 0
    </select>
 
    <select id="banner" resultType="com.panzhihua.common.model.vos.community.easyPhoto.BannerVO">
        select id,cover,publish_at as show_time,1 as type,jump_url,jump_type  from com_act_dyn where status =1 and cover is not null and community_id =#{communityId}
        UNION ALL
        select id,cover,publish_at as show_time,2 as type,"" as   jump_url,"" as jump_type from com_act_activity  where status =3 and cover is not null and community_id =#{communityId}
        UNION ALL
        select id,cover,release_time as show_time,3 as type,"" as   jump_url,"" as jump_type from com_pb_activity  where status =3 and cover is not null and community_id =#{communityId}
        UNION ALL
        select id,"" as cover,publish_time as show_time,4 as type,"" as   jump_url,"" as jump_type from com_act_questnaire  where state =2   and community_id =#{communityId}
        UNION ALL
        select id,cover,publish_at as show_time,5 as type,jump_url,jump_type from com_pb_dyn  where status =2 and cover is not null and community_id =#{communityId}
        UNION ALL
        select id,img_url as cover,publish_time as show_time,6 as type,"" as   jump_url,"" as jump_type from com_act_reserve  where status =2 and community_id =#{communityId}
        UNION ALL
        select id,logo as cover,release_at as show_time,7 as type,"" as   jump_url,"" as jump_type from com_act_easy_photo_activity  where status =2  and community_id =#{communityId}
        order by show_time desc limit 30
    </select>
 
</mapper>