huanghongfa
2021-01-14 f48fa183ae990a28217b1045b9d0a8eaf95cc9cf
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
package com.panzhihua.service_community.dao;
 
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.model.vos.community.ComActMicroWishVO;
import com.panzhihua.common.model.vos.community.TodoEventsVO;
import com.panzhihua.service_community.model.dos.ComActMicroWishDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
 
import java.util.List;
 
/**
 * @program: springcloud_k8s_panzhihuazhihuishequ
 * @description: 微心愿
 * @author: huang.hongfa weixin hhf9596 qq 959656820
 * @create: 2020-12-07 14:27
 **/
@Mapper
public interface ComActMicroWishDAO extends BaseMapper<ComActMicroWishDO> {
 
    @Select("<script> " +
            "select * from ( "+
            "SELECT\n" +
            "w.id,\n" +
            "u.name sponsor_name,\n" +
            "u.image_url ,\n" +
            "w.sponsor_phone,\n" +
            "w.wish_name,\n" +
            "w.`status`,\n" +
            "w.`feedback_at`,\n" +
            "w.`examine_at`,\n" +
            "w.`distribution_at`,\n" +
            "w.`evaluate_at`,\n" +
            "w.`photo_path_list`,\n" +
            "count(wu.id)star_num,\n" +
            "w.`detail`,\n" +
            "w.form,\n" +
            "w.reject_reason,\n" +
            "su.`name` responsible_name,\n" +
            "w.score,\n" +
            "w.create_at \n" +
            "FROM\n" +
            "com_act_micro_wish w\n" +
            "left join com_act_micro_wish_user wu on w.id=wu.micro_wish_id "+
            "JOIN sys_user u ON w.sponsor_id = u.user_id \n" +
            "<if test='comActMicroWishVO.sponsorName != null and comActMicroWishVO.sponsorName.trim() != &quot;&quot;'>" +
            "AND u.name = #{comActMicroWishVO.sponsorName} \n" +
            " </if> " +
            "LEFT JOIN sys_user su ON w.responsible_id = su.user_id \n" +
            "<if test='comActMicroWishVO.responsibleName != null and comActMicroWishVO.responsibleName.trim() != &quot;&quot;'>" +
            "AND su.`name` = #{comActMicroWishVO.responsibleName} \n" +
            " </if> " +
            "where w.status!=3 " +
            "<if test='comActMicroWishVO.communityId != null and comActMicroWishVO.communityId != 0'>" +
            " and w.community_id=#{comActMicroWishVO.communityId} \n" +
            " </if> " +
            "<if test='comActMicroWishVO.sponsorPhone != null and comActMicroWishVO.sponsorPhone.trim() != &quot;&quot;'>" +
            "AND w.sponsor_phone = #{comActMicroWishVO.sponsorPhone} \n" +
            " </if> " +
            "<if test='comActMicroWishVO.status != null and comActMicroWishVO.status!=0 '>" +
            "AND w.`status` = #{comActMicroWishVO.status} \n" +
            " </if> " +
            "<if test='comActMicroWishVO.createBegin != null '>" +
            "AND w.create_at BETWEEN #{comActMicroWishVO.createBegin} \n" +
            "AND #{comActMicroWishVO.createEnd}" +
            " </if> " +
            "<if test='comActMicroWishVO.isApplets != null and comActMicroWishVO.isApplets != 0'>" +
            "AND w.status  in (3,6) \n" +
            " </if> " +
            "<if test='comActMicroWishVO.userId != null and comActMicroWishVO.userId != 0'>" +
            "AND w.sponsor_id  =#{comActMicroWishVO.userId} \n" +
            " </if> " +
            " group by w.id  \n"+
 
 
            "union all "+
 
            "SELECT\n" +
            "w.id,\n" +
            "u.name sponsor_name,\n" +
            "u.image_url ,\n" +
            "w.sponsor_phone,\n" +
            "w.wish_name,\n" +
            "w.`status`,\n" +
            "w.`feedback_at`,\n" +
            "w.`examine_at`,\n" +
            "w.`distribution_at`,\n" +
            "w.`evaluate_at`,\n" +
            "w.`photo_path_list`,\n" +
            "count(wu.id)star_num,\n" +
            "w.`detail`,\n" +
            "w.form,\n" +
            "w.reject_reason,\n" +
            "su.`name` responsible_name,\n" +
            "w.score,\n" +
            "w.create_at \n" +
            "FROM\n" +
            "com_act_micro_wish w\n" +
            "left join com_act_micro_wish_user wu on w.id=wu.micro_wish_id "+
            "JOIN sys_user u ON w.sponsor_id = u.user_id \n" +
            "<if test='comActMicroWishVO.sponsorName != null and comActMicroWishVO.sponsorName.trim() != &quot;&quot;'>" +
            "AND u.name = #{comActMicroWishVO.sponsorName} \n" +
            " </if> " +
            "LEFT JOIN sys_user su ON w.responsible_id = su.user_id \n" +
            "<if test='comActMicroWishVO.responsibleName != null and comActMicroWishVO.responsibleName.trim() != &quot;&quot;'>" +
            "AND su.`name` = #{comActMicroWishVO.responsibleName} \n" +
            " </if> " +
            "where w.status=3 and w.form=1 \n" +
            "<if test='comActMicroWishVO.backUserId != null and comActMicroWishVO.backUserId != 0'>" +
            "and w.responsible_id=#{comActMicroWishVO.backUserId} \n"+
            " </if> " +
            "<if test='comActMicroWishVO.communityId != null and comActMicroWishVO.communityId != 0'>" +
            " and w.community_id=#{comActMicroWishVO.communityId} \n" +
            " </if> " +
            "<if test='comActMicroWishVO.sponsorPhone != null and comActMicroWishVO.sponsorPhone.trim() != &quot;&quot;'>" +
            "AND w.sponsor_phone = #{comActMicroWishVO.sponsorPhone} \n" +
            " </if> " +
            "<if test='comActMicroWishVO.status != null and comActMicroWishVO.status!=0 '>" +
            "AND w.`status` = #{comActMicroWishVO.status} \n" +
            " </if> " +
            "<if test='comActMicroWishVO.createBegin != null '>" +
            "AND w.create_at BETWEEN #{comActMicroWishVO.createBegin} \n" +
            "AND #{comActMicroWishVO.createEnd}" +
            " </if> " +
            "<if test='comActMicroWishVO.isApplets != null and comActMicroWishVO.isApplets != 0'>" +
            "AND w.status  in (3,6) \n" +
            " </if> " +
            "<if test='comActMicroWishVO.userId != null and comActMicroWishVO.userId != 0'>" +
            "AND w.sponsor_id  =#{comActMicroWishVO.userId} \n" +
            " </if> " +
            " group by w.id  )t\n"+
            "ORDER BY t.`status`, t.create_at "+
            "</script>")
    IPage<ComActMicroWishVO> pageMicroWish(Page page, @Param("comActMicroWishVO") ComActMicroWishVO comActMicroWishVO);
    @Select("SELECT\n" +
            "w.id,\n" +
            "u.name sponsor_name,\n" +
            "w.create_at,\n" +
            "u.image_url,\n" +
            "w.sponsor_phone,\n" +
            "w.`status`,\n" +
            "w.wish_name,\n" +
            "count(wu.id)starNum,\n" +
            "w.detail,\n" +
            "w.photo_path_list,\n" +
            "su.`name` responsible_name,\n" +
            "w.form,\n" +
            "w.reject_reason,\n" +
            "w.examine_at,\n" +
            "w.finish,\n" +
            "w.finish_photo_path_list,\n" +
            "w.finish_at,\n" +
            "w.score,\n" +
            "w.feedback,\n" +
            "w.feedback_at,\n" +
            "w.feedback_photo_path_list,\n" +
            "w.distribution_at,\n" +
            "w.evaluate_at,\n" +
            "w.evaluate \n" +
            "FROM\n" +
            "com_act_micro_wish w\n" +
            "JOIN sys_user u ON w.sponsor_id = u.user_id\n" +
            "LEFT JOIN sys_user su ON w.responsible_id = su.user_id \n" +
            "LEFT JOIN com_act_micro_wish_user wu ON w.id = wu.micro_wish_id \n" +
            "WHERE\n" +
            "w.id =#{id}"+
            " group by w.id "
    )
    ComActMicroWishVO detailMicroWish(Long id);
    @Select("SELECT\n" +
            "'微心愿' FUNCTION,\n" +
            "'待审核' behavior,\n" +
            "'新增微心愿动态待审核' words \n" +
            "FROM\n" +
            "com_act_micro_wish w \n" +
            "WHERE\n" +
            "w.community_id = #{communityId} \n" +
            "AND w.`status` = 1\n" +
            "\n" +
            "union all \n" +
            "\n" +
            "SELECT\n" +
            "\t'微心愿' FUNCTION,\n" +
            "\t'需要进行反馈' behavior,\n" +
            "\t'微心愿有待反馈动态' words \n" +
            "FROM\n" +
            "\tcom_act_micro_wish w \n" +
            "WHERE\n" +
            "\tw.community_id = #{communityId} \n" +
            "\tAND w.`status` = 3 \n" +
            "\tAND w.form = 1 \n" +
            "\tAND w.responsible_id = #{userId} \n" +
            "GROUP BY\n" +
            "\tw.community_id\n")
    List<TodoEventsVO> selectNeedToDo(@Param("communityId") Long communityId, @Param("userId") Long userId);
}