正在显示
5 个修改的文件
包含
2557 行增加
和
2312 行删除
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: Administrator | ||
5 | - * Date: 2018/12/31 | ||
6 | - * Time: 11:30 | ||
7 | - */ | ||
8 | -namespace api\index\controller; | ||
9 | - | ||
10 | -use api\index\model\ActivityModel; | ||
11 | -use api\index\model\ActivityNewsModel; | ||
12 | -use api\index\model\ActivityType; | ||
13 | -use api\index\model\ActivityTypeModel; | ||
14 | -use api\index\model\JoinModel; | ||
15 | -use api\index\model\PositionProvinceModel; | ||
16 | -use api\index\model\SlideItemModel; | ||
17 | -use api\index\model\UserModel; | ||
18 | -use api\index\model\VolunteerModel; | ||
19 | -use cmf\controller\RestBaseController; | ||
20 | -use Dompdf\Frame\Factory; | ||
21 | -use EasyWeChatComposer\EasyWeChat; | ||
22 | -use Hooklife\ThinkphpWechat\Wechat; | ||
23 | -use Magicfier\Image; | ||
24 | -use think\Url; | ||
25 | -use traits\think\Instance; | ||
26 | -use wxapp\Code; | ||
27 | - | ||
28 | -/** | ||
29 | - * @title 首页 | ||
30 | - * @description 首页 | ||
31 | - */ | ||
32 | -class IndexController extends RestBaseController | ||
33 | -{ | ||
34 | - public function _initialize() | ||
35 | - { | ||
36 | - $user_id = $this->getUserId(); | ||
37 | - $userModel = new UserModel(); | ||
38 | - $user = $userModel->where(array('id'=>$user_id))->find(); | ||
39 | - if($user['user_status'] == 0){ | ||
40 | - $this->error(['code'=>40005,'msg'=>'您已被列入黑名单,请联系管理员!']); | ||
41 | - } | ||
42 | - } | ||
43 | - | ||
44 | - /** | ||
45 | - * @title 首页 | ||
46 | - * @description 首页 | ||
47 | - * @author Xiaogang Wang | ||
48 | - * @url /index/index/index | ||
49 | - * @method GET | ||
50 | - * | ||
51 | - * @header name:XX-Token require:1 default: desc:token | ||
52 | - * | ||
53 | - * @param name:volunteer_page type:int require:0 other: desc:志愿者当前页(0为第一页)(默认0) | ||
54 | - * @param name:volunteer_pageNum type:int require:0 other: desc:活动显示数量(默认3) | ||
55 | - * @param name:activity_page type:int require:0 other: desc:活动当前页(0为第一页)(默认0) | ||
56 | - * @param name:activity_pageNum type:int require:0 other: desc:活动显示数量(默认4) | ||
57 | - * | ||
58 | - * @return volunteer:志愿者@ | ||
59 | - * @volunteer id:id name:姓名 sex:性别 level:星级 birthday:生日 nation:民族 politics:政治面貌 education:学历 unit:工作单位 duty:职务 addr:通讯地址 postcode:邮编 school:毕业院校 card_number:身份证号 fixed_phone:固定电话 move_phone:移动电话 email:email urgency_phone:紧急联系电话 qq:qq province:省 city:市 county:区/县 address:详细地址 type:志愿者类型(0医院志愿者,2社会志愿者,3办事处志愿者) record:个人履历@ front_card:身份证正面照 reverse_card:身份证背面照 photo:照片 status:状态(1审核中,2审核成功,3审核失败) user_id:用户id | ||
60 | - * @record record_start_time:开始时间 record_end_time:结束时间 record_unit:单位 record_duty:职务 record_name:证明人 record_phone:证明人电话 | ||
61 | - * @return activity:活动@ | ||
62 | - * @activity id:id activity_name:活动名称 abstract:摘要 thumbnail:缩略图 time:时间 content:内容 province_name:省市地区 | ||
63 | - * @return news:活动新闻@ | ||
64 | - * @news id:id activity_name:活动名称 abstract:摘要 thumbnail:缩略图 time:时间 content:内容 province_name:省市地区 | ||
65 | - * @return volunteer_page:志愿者下一页 | ||
66 | - * @return activity_page:活动下一页 | ||
67 | - */ | ||
68 | - public function index(){ | ||
69 | - $param = $this->request->param(); | ||
70 | - $volunteer_page = $param['volunteer_page'] ? $param['volunteer_page'] : 0;//当前页数下标 | ||
71 | - $volunteer_pageNum = $param['volunteer_pageNum'] ? $param['volunteer_pageNum'] : 3;//每页显示几条数据 | ||
72 | - $activity_page = $param['activity_page'] ? $param['activity_page'] : 0;//当前页数下标 | ||
73 | - $activity_pageNum = $param['activity_pageNum'] ? $param['activity_pageNum'] : 4;//每页显示几条数据 | ||
74 | - //获取志愿者 | ||
75 | - $volunteerModel = new VolunteerModel(); | ||
76 | - $volunteer = $volunteerModel->selectData($volunteer_page,$volunteer_pageNum,array('status'=>2)); | ||
77 | - //活动 | ||
78 | - $activityModel = new ActivityModel(); | ||
79 | - $activity = $activityModel->selectData(0,2); | ||
80 | - // $beginAtOnce = $activityModel->beginAtOnce($activity_page,$activity_pageNum); | ||
81 | - | ||
82 | - //新闻 | ||
83 | - $activityNewsModel = new ActivityNewsModel(); | ||
84 | - $news = $activityNewsModel->selectData($activity_page,$activity_pageNum); | ||
85 | - | ||
86 | - //幻灯片 | ||
87 | - $slideItemModel = new SlideItemModel(); | ||
88 | - $slide = $slideItemModel->selectData(array('slide_id'=>1)); | ||
89 | - $data['slide'] = $slide; | ||
90 | - $data['volunteer'] = $volunteer; | ||
91 | - $data['activity'] = $activity; | ||
92 | - $data['news'] = $news; | ||
93 | - $data['volunteer_page'] = $volunteer_page+1; | ||
94 | - $data['activity_page'] = $activity_page+1; | ||
95 | - $this->success('获取成功!',$data); | ||
96 | - } | ||
97 | - /** | ||
98 | - * @title 更多志愿者 | ||
99 | - * @description 更多志愿者 | ||
100 | - * @author Xiaogang Wang | ||
101 | - * @url /index/index/volunteer | ||
102 | - * @method GET | ||
103 | - * | ||
104 | - * @header name:XX-Token require:1 default: desc:token | ||
105 | - * | ||
106 | - * @param name:page type:int require:0 other: desc:志愿者当前页(0为第一页)(默认0) | ||
107 | - * @param name:pageNum type:int require:0 other: desc:活动显示数量(默认10) | ||
108 | - * | ||
109 | - * @return volunteer:志愿者@ | ||
110 | - * @volunteer id:id name:姓名 sex:性别 level:星级 birthday:生日 nation:民族 politics:政治面貌 education:学历 unit:工作单位 duty:职务 addr:通讯地址 postcode:邮编 school:毕业院校 card_number:身份证号 fixed_phone:固定电话 move_phone:移动电话 email:email urgency_phone:紧急联系电话 qq:qq province:省 city:市 county:区/县 address:详细地址 type:志愿者类型(0医院志愿者,2社会志愿者,3办事处志愿者) record:个人履历@ front_card:身份证正面照 reverse_card:身份证背面照 photo:照片 status:状态(1审核中,2审核成功,3审核失败) user_id:用户id | ||
111 | - * @record record_start_time:开始时间 record_end_time:结束时间 record_unit:单位 record_duty:职务 record_name:证明人 record_phone:证明人电话 | ||
112 | - * @return page:志愿者下一页 | ||
113 | - * @return page:活动下一页 | ||
114 | - */ | ||
115 | - public function volunteer(){ | ||
116 | - $param = $this->request->param(); | ||
117 | - $page = $param['page'] ? $param['page'] : 0;//当前页数下标 | ||
118 | - $pageNum = $param['pageNum'] ? $param['pageNum'] : 10;//每页显示几条数据 | ||
119 | - //获取志愿者 | ||
120 | - $volunteerModel = new VolunteerModel(); | ||
121 | - $volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>2)); | ||
122 | - $data['volunteer'] = $volunteer; | ||
123 | - $data['page'] = $page+1; | ||
124 | - $this->success('获取成功!',$data); | ||
125 | - } | ||
126 | - | ||
127 | - /** | ||
128 | - * @title 获取更多即将开始的活动 | ||
129 | - * @description | ||
130 | - * @author Xiaogang Wang | ||
131 | - * @url /index/index/activityAtOnce | ||
132 | - * @method GET | ||
133 | - * | ||
134 | - * @header name:XX-Token require:1 default: desc:token | ||
135 | - * | ||
136 | - * @param name:page type:int require:0 other: desc:当前页(0为第一页)(默认0) | ||
137 | - * @param name:pageNum type:int require:0 other: desc:活动显示数量(默认10) | ||
138 | - * | ||
139 | - * @return activity:活动@ | ||
140 | - * @activity id:id activity_name:活动名称 abstract:摘要 thumbnail:缩略图 time:时间 content:内容 province_name:省市地区 | ||
141 | - * @return page:活动下一页 | ||
142 | - */ | ||
143 | - public function activityAtOnce(){ | ||
144 | - $param = $this->request->param(); | ||
145 | - $page = $param['page'] ? $param['page'] : 0;//当前页数下标 | ||
146 | - $pageNum = $param['pageNum'] ? $param['pageNum'] : 10;//每页显示几条数据 | ||
147 | - | ||
148 | - $Activity=new ActivityModel(); | ||
149 | - $activity=$Activity->beginAtOnce($page,$pageNum); | ||
150 | - $data['activity'] = $activity; | ||
151 | - $data['page'] =$page+1; | ||
152 | - $this->success('获取成功!',$data); | ||
153 | - } | ||
154 | - | ||
155 | - | ||
156 | - | ||
157 | - | ||
158 | - | ||
159 | - | ||
160 | - /** | ||
161 | - * @title 志愿者详情 | ||
162 | - * @description 志愿者详情 | ||
163 | - * @author Xiaogang Wang | ||
164 | - * @url /index/index/volunteer_info | ||
165 | - * @method GET | ||
166 | - * | ||
167 | - * @param name:id type:int require:1 other: desc:志愿者id | ||
168 | - * | ||
169 | - * @return id:id | ||
170 | - * @return name:姓名 | ||
171 | - * @return sex:性别 | ||
172 | - * @return birthday:生日 | ||
173 | - * @return nation:民族 | ||
174 | - * @return politics:政治面貌 | ||
175 | - * @return education:学历 | ||
176 | - * @return unit:工作单位 | ||
177 | - * @return duty:职务 | ||
178 | - * @return addr:通讯地址 | ||
179 | - * @return postcode:邮编 | ||
180 | - * @return school:毕业院校 | ||
181 | - * @return card_number:身份证号 | ||
182 | - * @return fixed_phone:固定电话 | ||
183 | - * @return move_phone:移动电话 | ||
184 | - * @return email:email | ||
185 | - * @return urgency_phone:紧急联系电话 | ||
186 | - * @return qq:qq | ||
187 | - * @return province:省 | ||
188 | - * @return city:市 | ||
189 | - * @return county:区/县 | ||
190 | - * @return address:详细地址 | ||
191 | - * @return type:志愿者类型(0医院志愿者,2社会志愿者,3办事处志愿者) | ||
192 | - * @return record:个人履历@ | ||
193 | - * @record record_start_time:开始时间 record_end_time:结束时间 record_unit:单位 record_duty:职务 record_name:证明人 record_phone:证明人电话 | ||
194 | - * @return front_card:身份证正面照 | ||
195 | - * @return reverse_card:身份证背面照 | ||
196 | - * @return photo:照片 | ||
197 | - * @return status:状态(1审核中,2审核成功,3审核失败) | ||
198 | - * @return user_id:用户id | ||
199 | - */ | ||
200 | - public function volunteer_info(){ | ||
201 | - $id = $this->request->param('id'); | ||
202 | - //获取志愿者 | ||
203 | - $volunteerModel = new VolunteerModel(); | ||
204 | - $volunteer = $volunteerModel->findData(array('id'=>$id)); | ||
205 | - $this->success('获取成功!',$volunteer); | ||
206 | - } | ||
207 | - /** | ||
208 | - * @title 活动详情 | ||
209 | - * @description 活动详情 | ||
210 | - * @author Xiaogang Wang | ||
211 | - * @url /index/index/activity_info | ||
212 | - * @method GET | ||
213 | - * | ||
214 | - * @header name:XX-Token require:1 default: desc:token | ||
215 | - * | ||
216 | - * @param name:id type:int require:1 other: desc:活动id | ||
217 | - * | ||
218 | - * @return id:id | ||
219 | - * @return activity_name:活动名称 | ||
220 | - * @return abstract:摘要 | ||
221 | - * @return thumbnail:缩略图 | ||
222 | - * @return time:时间 | ||
223 | - * @return content:内容 | ||
224 | - * @return admin:是否为管理员1是管理员 | ||
225 | - * @return button_title:按钮标题 | ||
226 | - * @return join:参加用户@ | ||
227 | - * @join photo:照片 name:名称 level:星级 duty:岗位 | ||
228 | - * @return button_status:按钮状态7.用户被拒绝重新申请客户6.用户是志愿者,但是未报名参加活动5.已结束(活动过期)4.已提交工作汇报(用户是志愿者,已报名活动,已通过审核,已签到)3.提交工作汇报(用户是志愿者,已报名活动,选择线下或线上+线下,已通过审核,按钮变为签到但不可点击,活动有效时间内,变为可点击状态)2.待审核(用户是志愿者,已报名活动,但是未通过审核)1.报名 (用户是志愿者,但是未报名参加活动) | ||
229 | - */ | ||
230 | - public function activity_info(){ | ||
231 | - $id = $this->request->param('id'); | ||
232 | - //活动 | ||
233 | - $activityModel = new ActivityModel(); | ||
234 | - $userId=$this->getUserId(); | ||
235 | - $activity = $activityModel->findData(array('id'=>$id)); | ||
236 | - /*获取状态*/ | ||
237 | - $userModel = new UserModel(); | ||
238 | - $user = $userModel->findData(array('id'=>$userId)); | ||
239 | - | ||
240 | - | ||
241 | - /*是否为志愿者*/ | ||
242 | - $Volunteer=new VolunteerModel(); | ||
243 | - $volunteerMap['user_id']=$userId; | ||
244 | - $volunteerMap['status']=2; | ||
245 | - $volunteerMap['delete_time']=0; | ||
246 | - $volunteer=$Volunteer->findData($volunteerMap); | ||
247 | - | ||
248 | - if (empty($volunteer)){ | ||
249 | - $is_volunteer=0; | ||
250 | - }else{ | ||
251 | - $is_volunteer=1; | ||
252 | - } | ||
253 | - /*是否活动结束*/ | ||
254 | - $Activity=new ActivityModel(); | ||
255 | - $activityMap['id']=$id; | ||
256 | - $activity=$Activity->findData($activityMap); | ||
257 | - if($activity['end_time']<time()){ | ||
258 | - $is_end=1; | ||
259 | - }else{ | ||
260 | - $is_end=0; | ||
261 | - } | ||
262 | - | ||
263 | - if($user['type'] == 2){ | ||
264 | - $activity['admin']=1; | ||
265 | - }else{ | ||
266 | - $activity['admin']=0; | ||
267 | - } | ||
268 | - /*是否报名活动*/ | ||
269 | - $Join=new JoinModel(); | ||
270 | - $where['activity_id']=$id; | ||
271 | - $where['user_id']=$userId; | ||
272 | - $where['delete_time']=0; | ||
273 | - | ||
274 | - $join=$Join->findData($where); | ||
275 | - if (empty($join)){ | ||
276 | - $is_join=0; | ||
277 | - }else{ | ||
278 | - $is_join=1; | ||
279 | - } | ||
280 | - | ||
281 | - /*是否报名通过*/ | ||
282 | - if (empty($join['status']) || $join['status']==2){ | ||
283 | - $is_pass=0; | ||
284 | - $is_book=0; | ||
285 | - }elseif($join['status']=='3'){ | ||
286 | - $is_book=1; | ||
287 | - $is_pass=1; | ||
288 | - }elseif($join['status']=='1'){ | ||
289 | - $is_book=0; | ||
290 | - $is_pass=1; | ||
291 | - }elseif($join['status']==0){ | ||
292 | - $is_book=1; | ||
293 | - $is_pass=0; | ||
294 | - | ||
295 | - } | ||
296 | - | ||
297 | - $check=0; | ||
298 | - | ||
299 | - if ($is_volunteer==1 && $check==0 && $is_join==1 && $is_pass==1 && $is_book==0){ | ||
300 | - $status=3; | ||
301 | - $title='工作汇报'; | ||
302 | - $check=1; | ||
303 | - } | ||
304 | - | ||
305 | - if ($is_volunteer==0 && $check==0) { | ||
306 | - $status=6; | ||
307 | - $check=1; | ||
308 | - $title='成为志愿者'; | ||
309 | - } | ||
310 | - | ||
311 | - if ($is_end==1 && $check==0){ | ||
312 | - $status=5; | ||
313 | - $title='已结束'; | ||
314 | - $check=1; | ||
315 | - } | ||
316 | - | ||
317 | - if ($is_volunteer==1 && $check==0 && $is_pass==1 && $is_book==1){ | ||
318 | - $status=4; | ||
319 | - $title='已签到'; | ||
320 | - $check=1; | ||
321 | - } | ||
322 | - | ||
323 | - if ($is_volunteer==1 && $check==0 && $is_join==1 && $is_pass==1 && $is_book==0){ | ||
324 | - $status=3; | ||
325 | - $title='工作汇报'; | ||
326 | - $check=1; | ||
327 | - } | ||
328 | - if ($is_volunteer==1 && $check==0 && $is_join==1 && $join['status']=='2'){ | ||
329 | - $status=7; | ||
330 | - $title='报名'; | ||
331 | - $check=1; | ||
332 | - } | ||
333 | - if ($is_volunteer==1 && $check==0 && $is_join==1 && $is_pass==0){ | ||
334 | - $status=2; | ||
335 | - $title='待审核'; | ||
336 | - $check=0; | ||
337 | - } | ||
338 | - | ||
339 | - if ($is_volunteer==1 && $check==0 && $is_join==0){ | ||
340 | - $status=1; | ||
341 | - $title='报名'; | ||
342 | - $check=0; | ||
343 | - } | ||
344 | - $activity['button_title']=$title; | ||
345 | - $activity['button_status']=$status; | ||
346 | - $people=$Join->getJoinData($id); | ||
347 | - $join1=[]; | ||
348 | - foreach ($people as $k=>$v){ | ||
349 | - $join1[$k]['photo']=$v['photo']; | ||
350 | - $join1[$k]['name']=$v['name']; | ||
351 | - $join1[$k]['level']=$v['level']; | ||
352 | - $join1[$k]['duty']=$v['duty']; | ||
353 | - } | ||
354 | - $activity['join']=$join1; | ||
355 | - $this->success('获取成功!',$activity); | ||
356 | - } | ||
357 | - /** | ||
358 | - * @title 新闻详情 | ||
359 | - * @description 新闻详情 | ||
360 | - * @author Xiaogang Wang | ||
361 | - * @url /index/index/news_info | ||
362 | - * @method GET | ||
363 | - * | ||
364 | - * @header name:XX-Token require:1 default: desc:token | ||
365 | - * | ||
366 | - * @param name:id type:int require:1 other: desc:活动id | ||
367 | - * | ||
368 | - * @return id:id | ||
369 | - * @return activity_name:活动名称 | ||
370 | - * @return abstract:摘要 | ||
371 | - * @return thumbnail:缩略图 | ||
372 | - * @return time:时间 | ||
373 | - * @return content:内容 | ||
374 | - * @return button_title:按钮标题 | ||
375 | - * @return join:参加用户@ | ||
376 | - * @join photo:照片 name:名称 level:星级 | ||
377 | - * @return button_status:按钮状态6.用户是志愿者,但是未报名参加活动5.已结束(活动过期)4.已提交工作汇报(用户是志愿者,已报名活动,已通过审核,已签到)3.提交工作汇报(用户是志愿者,已报名活动,选择线下或线上+线下,已通过审核,按钮变为签到但不可点击,活动有效时间内,变为可点击状态)2.待审核(用户是志愿者,已报名活动,但是未通过审核)1.报名 (用户是志愿者,但是未报名参加活动) | ||
378 | - */ | ||
379 | - public function news_info(){ | ||
380 | - $id = $this->request->param('id'); | ||
381 | - //活动 | ||
382 | - $activityModel = new ActivityNewsModel(); | ||
383 | - $userId=$this->getUserId(); | ||
384 | - $activity = $activityModel->findData(array('id'=>$id)); | ||
385 | - /*获取状态*/ | ||
386 | - | ||
387 | - /*是否为志愿者*/ | ||
388 | - $Volunteer=new VolunteerModel(); | ||
389 | - $volunteerMap['user_id']=$userId; | ||
390 | - $volunteerMap['status']=2; | ||
391 | - $volunteerMap['delete_time']=0; | ||
392 | - $volunteer=$Volunteer->findData($volunteerMap); | ||
393 | - | ||
394 | - if (empty($volunteer)){ | ||
395 | - $is_volunteer=0; | ||
396 | - }else{ | ||
397 | - $is_volunteer=1; | ||
398 | - } | ||
399 | - /*是否活动结束*/ | ||
400 | - $Activity=new ActivityModel(); | ||
401 | - $activityMap['id']=$id; | ||
402 | - $activity_news=$Activity->findData($activityMap); | ||
403 | - if($activity_news['end_time']>time()){ | ||
404 | - $is_end=1; | ||
405 | - }else{ | ||
406 | - $is_end=0; | ||
407 | - } | ||
408 | - | ||
409 | - /*是否报名活动*/ | ||
410 | - $Join=new JoinModel(); | ||
411 | - $where['activity_id']=$id; | ||
412 | - $where['user_id']=$userId; | ||
413 | - $where['delete_time']=0; | ||
414 | - $join=$Join->findData($where); | ||
415 | - if (empty($join)){ | ||
416 | - $is_join=0; | ||
417 | - }else{ | ||
418 | - $is_join=1; | ||
419 | - } | ||
420 | - /*是否报名通过*/ | ||
421 | - if (empty($join['status']) || $join['status']==2){ | ||
422 | - $is_pass=0; | ||
423 | - $is_book=0; | ||
424 | - }elseif($join['status']=='3'){ | ||
425 | - $is_book=1; | ||
426 | - $is_pass=1; | ||
427 | - }elseif($join['status']=='1'){ | ||
428 | - $is_book=0; | ||
429 | - $is_pass=1; | ||
430 | - } | ||
431 | - $check=0; | ||
432 | - if ($is_volunteer==0 && $check==0) { | ||
433 | - $status=6; | ||
434 | - $check=1; | ||
435 | - $title='成为志愿者'; | ||
436 | - } | ||
437 | - | ||
438 | - if ($is_end==1 && $check==0){ | ||
439 | - $status=5; | ||
440 | - $title='已结束'; | ||
441 | - $check=1; | ||
442 | - } | ||
443 | - | ||
444 | - if ($is_volunteer==1 && $check==0 && $is_pass==1 && $is_book==1){ | ||
445 | - $status=4; | ||
446 | - $title='已提交工作汇报'; | ||
447 | - $check=1; | ||
448 | - } | ||
449 | - | ||
450 | - if ($is_volunteer==1 && $check==0 && $is_join==1 && $is_pass==1 && $is_book==0){ | ||
451 | - $status=3; | ||
452 | - $title='提交工作汇报'; | ||
453 | - $check=1; | ||
454 | - } | ||
455 | - | ||
456 | - if ($is_volunteer==1 && $check==0 && $is_join==1 && $is_pass==0){ | ||
457 | - $status=2; | ||
458 | - $title='待审核'; | ||
459 | - $check=0; | ||
460 | - } | ||
461 | - | ||
462 | - if ($is_volunteer==1 && $check==0 && $is_join==0){ | ||
463 | - $status=1; | ||
464 | - $title='报名'; | ||
465 | - $check=0; | ||
466 | - } | ||
467 | - $activity['button_title']=$title; | ||
468 | - $activity['button_status']=$status; | ||
469 | - $people=$Join->getJoinData($id); | ||
470 | - $join1=[]; | ||
471 | - foreach ($people as $k=>$v){ | ||
472 | - $join1[$k]['photo']=$v['photo']; | ||
473 | - $join1[$k]['name']=$v['name']; | ||
474 | - $join1[$k]['level']=$v['level']; | ||
475 | - } | ||
476 | - $activity['join']=$join1; | ||
477 | - $this->success('获取成功!',$activity); | ||
478 | - } | ||
479 | - | ||
480 | - /** | ||
481 | - * @title 签到(提交工作汇报)(new) | ||
482 | - * @description 活动签到 | ||
483 | - * @author Xiaogang Wang | ||
484 | - * @url /index/index/sginIn | ||
485 | - * @method GET | ||
486 | - * | ||
487 | - * @header name:XX-Token require:1 default: desc:token | ||
488 | - * | ||
489 | - * @param name:id type:int require:1 other: desc:活动id | ||
490 | - * @param name:work_report type:int require:1 other: desc:感想汇报 | ||
491 | - * @param name:work_pic type:int require:1 other: desc:图片 | ||
492 | - * | ||
493 | - */ | ||
494 | - public function sginIn(){ | ||
495 | - $userId=$this->getUserId(); | ||
496 | - $activity_id=input('id'); | ||
497 | - $Join=new JoinModel(); | ||
498 | - $where['user_id']=$userId; | ||
499 | - $where['activity_id']=$activity_id; | ||
500 | - $where['delete_time']=0; | ||
501 | - $join=$Join->findData($where); | ||
502 | - if (empty($join)){ | ||
503 | - $this->error('您还未报名此活动'); | ||
504 | - } | ||
505 | - if ($join['status']==3){ | ||
506 | - $this->error('您已经提交过了'); | ||
507 | - } | ||
508 | - if ($join['status']==2||$join['status']==0){ | ||
509 | - $this->error('还没有通过审核'); | ||
510 | - } | ||
511 | - if ($join['status']==1){ | ||
512 | - $data['sgin_time']=time(); | ||
513 | - $data['status']=3; | ||
514 | - $data['work_report']=input('work_report'); | ||
515 | - $data['work_pic']=html_entity_decode(htmlspecialchars_decode(input('work_pic'))); | ||
516 | - $result=db('join')->where($where)->update($data); | ||
517 | - if ($result==0){ | ||
518 | - $this->error('提交失败'); | ||
519 | - } | ||
520 | - } | ||
521 | - $this->success('提交成功!'); | ||
522 | - } | ||
523 | - | ||
524 | - | ||
525 | - /** | ||
526 | - * @title 申请活动(new) | ||
527 | - * @description 活动申请 | ||
528 | - * @author Xiaogang Wang | ||
529 | - * @url /index/index/applyJoin | ||
530 | - * @method GET | ||
531 | - * | ||
532 | - * @header name:XX-Token require:1 default: desc:token | ||
533 | - * | ||
534 | - * @param name:id type:int require:1 other: desc:活动id | ||
535 | - * @param name:form_id type:int require:1 other: desc:表单id | ||
536 | - * @param name:type type:int require:1 other: desc:活动类型1:线上2:线下3:线上+线下 | ||
537 | - * @param name:start_time type:int require:1 other: desc:开始时间 | ||
538 | - * @param name:end_time type:int require:1 other: desc:结束时间 | ||
539 | - * @param name:work_content type:int require:1 other: desc:工作内容 | ||
540 | - * @param name:select_time type:int require:1 other: desc:选择日期[{"date":"2018-01-02","time":"18:01"},{"date":"2018-01-02","time":"18:01"}] | ||
541 | - * @param name:apply_stay type:int require:1 other: desc:申请入住[{"date":"2018-01-02","idcard":"123456"},{"date":"2018-01-02","idcard":"123456"}] | ||
542 | - * @param name:apply_food type:int require:1 other: desc:申请用餐[{"date":"2018-01-02","time":"18:01"},{"date":"2018-01-02","time":"18:01"}] | ||
543 | - * | ||
544 | - */ | ||
545 | - public function applyJoin(){ | ||
546 | - $userId=$this->getUserId(); | ||
547 | - $type=input('type'); | ||
548 | - $start_time=strtotime(input('start_time')); | ||
549 | - $end_time=strtotime(input('end_time')); | ||
550 | - $activity_id=input('id'); | ||
551 | - $form_id=input('form_id'); | ||
552 | - $this->saveFormId($userId,$form_id); | ||
553 | - | ||
554 | - /*三期增加字段*/ | ||
555 | - $work_content=input('work_content'); | ||
556 | - $select_time=html_entity_decode(htmlspecialchars_decode(input('select_time'))); | ||
557 | - $apply_stay=html_entity_decode(htmlspecialchars_decode(input('apply_stay'))); | ||
558 | - $apply_food=html_entity_decode(htmlspecialchars_decode(input('apply_food'))); | ||
559 | - | ||
560 | - /*判断是否未志愿者*/ | ||
561 | - $Volunteer=new VolunteerModel(); | ||
562 | - $where['user_id']=$userId; | ||
563 | - $volunter=$Volunteer->findData($where); | ||
564 | - if (empty($volunter)){ | ||
565 | - $this->error('请先成为志愿者!'); | ||
566 | - } | ||
567 | - /*判断是否参加了活动*/ | ||
568 | - $Join=new JoinModel(); | ||
569 | - $map['user_id']=$userId; | ||
570 | - $map['activity_id']=$activity_id; | ||
571 | - $map['delete_time']=0; | ||
572 | - $join=$Join->findData($map); | ||
573 | - if ($join){ | ||
574 | - // $this->error('已经报名参加过该活动!'); | ||
575 | - } | ||
576 | - $data['user_id']=$userId; | ||
577 | - $data['activity_id']=$activity_id; | ||
578 | - $data['type']=$type; | ||
579 | - $data['start_time']=$start_time; | ||
580 | - $data['end_time']=$end_time; | ||
581 | - $data['add_time']=time(); | ||
582 | - /*三期功能字段*/ | ||
583 | - $data['work_content']=$work_content; | ||
584 | - $data['select_time']=html_entity_decode(htmlspecialchars_decode(input('select_time'))); | ||
585 | - $data['apply_stay']=html_entity_decode(htmlspecialchars_decode(input('apply_stay'))); | ||
586 | - $data['apply_food']=html_entity_decode(htmlspecialchars_decode(input('apply_food'))); | ||
587 | - | ||
588 | - $result=$Join->insert($data); | ||
589 | - if ($result>0){ | ||
590 | - $this->success('报名成功,请等待审核!'); | ||
591 | - } | ||
592 | - $this->error('报名失败'); | ||
593 | - } | ||
594 | - /** | ||
595 | - * @title 编辑参加活动信息(new) | ||
596 | - * @description 活动申请 | ||
597 | - * @author Xiaogang Wang | ||
598 | - * @url /index/index/editApply | ||
599 | - * @method GET | ||
600 | - * | ||
601 | - * @header name:XX-Token require:1 default: desc:token | ||
602 | - * | ||
603 | - * @param name:id type:int require:1 other: desc:活动id | ||
604 | - * @param name:form_id type:int require:1 other: desc:表单id | ||
605 | - * @param name:type type:int require:1 other: desc:活动类型1:线上2:线下3:线上+线下 | ||
606 | - * @param name:start_time type:int require:1 other: desc:开始时间 | ||
607 | - * @param name:end_time type:int require:1 other: desc:结束时间 | ||
608 | - * @param name:work_content type:int require:1 other: desc:工作内容 | ||
609 | - * @param name:select_time type:int require:1 other: desc:选择日期[{"date":"2018-01-02","time":"18:01"},{"date":"2018-01-02","time":"18:01"}] | ||
610 | - * @param name:apply_stay type:int require:1 other: desc:申请入住[{"date":"2018-01-02","idcard":"123456"},{"date":"2018-01-02","idcard":"123456"}] | ||
611 | - * @param name:apply_food type:int require:1 other: desc:申请用餐[{"date":"2018-01-02","time":"18:01"},{"date":"2018-01-02","time":"18:01"}] | ||
612 | - * | ||
613 | - */ | ||
614 | - public function editApply(){ | ||
615 | - $userId=$this->getUserId(); | ||
616 | - $activity_id=input('id'); | ||
617 | - $map['activity_id']=$activity_id; | ||
618 | - $map['user_id']=$userId; | ||
619 | - $map['delete_time']=0; | ||
620 | - $form_id=input('form_id'); | ||
621 | - $this->saveFormId($userId,$form_id); | ||
622 | - $join=db('join')->where($map)->find(); | ||
623 | - if (empty($join)){ | ||
624 | - $this->error('不存在相关信息'); | ||
625 | - } | ||
626 | - $type=input('type'); | ||
627 | - $start_time=strtotime(input('start_time')); | ||
628 | - $end_time=strtotime(input('end_time')); | ||
629 | - /*三期增加字段*/ | ||
630 | - $work_content=input('work_content'); | ||
631 | - | ||
632 | - $select_time=html_entity_decode(htmlspecialchars_decode(input('select_time'))); | ||
633 | - $apply_stay=html_entity_decode(htmlspecialchars_decode(input('apply_stay'))); | ||
634 | - $apply_food=html_entity_decode(htmlspecialchars_decode(input('apply_food'))); | ||
635 | - | ||
636 | - | ||
637 | - $data['user_id']=$userId; | ||
638 | - $data['activity_id']=$activity_id; | ||
639 | - $data['type']=$type; | ||
640 | - $data['start_time']=$start_time; | ||
641 | - $data['end_time']=$end_time; | ||
642 | - /*三期功能字段*/ | ||
643 | - $data['work_content']=$work_content; | ||
644 | - $data['select_time']=$select_time; | ||
645 | - $data['apply_stay']=$apply_stay; | ||
646 | - $data['apply_food']=$apply_food; | ||
647 | - $Join=new JoinModel(); | ||
648 | - $result=$Join->where($map)->Update($data); | ||
649 | - /*echo $Join->getLastSql(); | ||
650 | - dump($result); | ||
651 | - exit();*/ | ||
652 | - | ||
653 | - if ($result>0){ | ||
654 | - $this->success('修改成功,请等待审核!'); | ||
655 | - } | ||
656 | - $this->error('修改失败'); | ||
657 | - } | ||
658 | - /** | ||
659 | - * @title 获取申请活动填写信息(new) | ||
660 | - * @description 活动申请 | ||
661 | - * @author Xiaogang Wang | ||
662 | - * @url /index/index/getApplyInfo | ||
663 | - * @method GET | ||
664 | - * | ||
665 | - * @header name:XX-Token require:1 default: desc:token | ||
666 | - * | ||
667 | - * @param name:id type:int require:1 other: desc:活动id | ||
668 | - * @param name:user_id type:int require:1 other: desc:用户id | ||
669 | - * | ||
670 | - * @return name:姓名 | ||
671 | - * @return birthday:生日 | ||
672 | - * @return sex:性别 | ||
673 | - * @return tel:手机号 | ||
674 | - * @return work_type:工作类型 | ||
675 | - * @return work_content:工作内容 | ||
676 | - * @return select_time:选择日期 | ||
677 | - * @return apply_stay:申请入住 | ||
678 | - * @return apply_food:申请用餐 | ||
679 | - * | ||
680 | - */ | ||
681 | - public function getApplyInfo(){ | ||
682 | - $userId=$this->getUserId(); | ||
683 | - $activity_id=input('id'); | ||
684 | - $user_id=input('user_id'); | ||
685 | - if (!empty($user_id)){ | ||
686 | - $userModel = new UserModel(); | ||
687 | - $user = $userModel->findData(array('id'=>$userId)); | ||
688 | - if($user['type'] != 2){ | ||
689 | - $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
690 | - } | ||
691 | - $userId=$user_id; | ||
692 | - } | ||
693 | - $map['user_id']=$userId; | ||
694 | - $map['activity_id']=$activity_id; | ||
695 | - $map['delete_time']=0; | ||
696 | - /*获取*/ | ||
697 | - $activity=db('activity')->field('start_time,end_time')->where('id',$activity_id)->order('id','desc')->find(); | ||
698 | - $time=$activity['end_time']; | ||
699 | - $now=time(); | ||
700 | - while ($time>$now){ | ||
701 | - $return['time'][]=date('Y-m-d',$time); | ||
702 | - $time=$time-60*60*24; | ||
703 | - } | ||
704 | - | ||
705 | - if (!empty($return['time'])){ | ||
706 | - $return['time']= array_reverse($return['time']); | ||
707 | - } | ||
708 | - | ||
709 | - $info=db('join')->field('sgin_time,id,type,user_id,activity_id,select_time,apply_stay,apply_food,work_content')->where($map)->find(); | ||
710 | - $user=db('volunteer')->field('sex,name,birthday,move_phone')->where('user_id',$userId)->find(); | ||
711 | - if (!empty($user)){ | ||
712 | - $return['name']=$user['name']; | ||
713 | - $return['birthday']=$user['birthday']; | ||
714 | - $return['sex']=$user['sex']==1?'男':'女'; | ||
715 | - $return['tel']=$user['move_phone']; | ||
716 | - } | ||
717 | - if (!empty($info)){ | ||
718 | - $return['work_content']=db('work')->where('id',$info['work_content'])->value('name'); | ||
719 | - $return['work_content']=$info['work_content']; | ||
720 | - $return['select_time']=json_decode($info['select_time'],true); | ||
721 | - $return['apply_stay']=json_decode($info['apply_stay'],true); | ||
722 | - $return['apply_food']=json_decode($info['apply_food'],true); | ||
723 | - $return['id']=$info['id']; | ||
724 | - $return['work_type']=$info['type']; | ||
725 | - $return['is_complete']=$info['sgin_time']==0?'0':'1'; | ||
726 | - /* switch ($info['type']){ | ||
727 | - case 1: | ||
728 | - $return['work_type']='线上'; | ||
729 | - break; | ||
730 | - case 2: | ||
731 | - $return['work_type']='线下'; | ||
732 | - break; | ||
733 | - case 3: | ||
734 | - $return['work_type']='线上及线下'; | ||
735 | - break; | ||
736 | - | ||
737 | - }*/ | ||
738 | - } | ||
739 | - | ||
740 | - $this->success('',$return); | ||
741 | - } | ||
742 | - | ||
743 | - | ||
744 | - | ||
745 | - /** | ||
746 | - * @title 退出活动(new) | ||
747 | - * @description 活动申请 | ||
748 | - * @author Xiaogang Wang | ||
749 | - * @url /index/index/quitActivity | ||
750 | - * @method GET | ||
751 | - * | ||
752 | - * @header name:XX-Token require:1 default: desc:token | ||
753 | - * | ||
754 | - * @param name:id type:int require:1 other: desc:活动id | ||
755 | - * | ||
756 | - */ | ||
757 | - public function quitActivity(){ | ||
758 | - $userId=$this->getUserId(); | ||
759 | - $activity_id=input('id'); | ||
760 | - $map['user_id']=$userId; | ||
761 | - $map['activity_id']=$activity_id; | ||
762 | - $data['delete_time']=time(); | ||
763 | - $result=db('join')->where($map)->update($data); | ||
764 | - if ($result>0){ | ||
765 | - $this->success('退出成功!'); | ||
766 | - }else{ | ||
767 | - $this->error('退出失败!'); | ||
768 | - } | ||
769 | - } | ||
770 | - | ||
771 | - /** | ||
772 | - * @title 工作汇报表信息(new) | ||
773 | - * @description 获取工作汇报表信息 | ||
774 | - * @author Xiaogang Wang | ||
775 | - * @url /index/index/workReportInfo | ||
776 | - * @method GET | ||
777 | - * | ||
778 | - * @header name:XX-Token require:1 default: desc:token | ||
779 | - * | ||
780 | - * @param name:id type:int require:1 other: desc:活动id | ||
781 | - * @param name:user_id type:int require:1 other: desc:用户id | ||
782 | - * | ||
783 | - * @return work_content:工作内容 | ||
784 | - * @return date:参加日期 | ||
785 | - * @return time:参加时间 | ||
786 | - * @return name:姓名 | ||
787 | - */ | ||
788 | - public function workReportInfo(){ | ||
789 | - $userId=$this->getUserId(); | ||
790 | - $activity_id=input('id'); | ||
791 | - if (!empty($user_id)){ | ||
792 | - $userModel = new UserModel(); | ||
793 | - $user = $userModel->findData(array('id'=>$userId)); | ||
794 | - if($user['type'] != 2){ | ||
795 | - $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
796 | - } | ||
797 | - $userId=$user_id; | ||
798 | - } | ||
799 | - $map['user_id']=input('user_id'); | ||
800 | - $map['activity_id']=$activity_id; | ||
801 | - $map['status']=['in','1,3']; | ||
802 | - $map['delete_time']=0; | ||
803 | - $result=db('join')->where($map)->find(); | ||
804 | - // echo db('join')->getLastSql(); | ||
805 | - if (empty($result)){ | ||
806 | - $this->error('没有相关信息'); | ||
807 | - } | ||
808 | - $return['work_content']=db('work')->where('id',$result['work_content'])->value('name'); | ||
809 | - /* $return['date']=date('Y-m-d',$result['add_time']); | ||
810 | - $return['time']=date('H:i:s',$result['add_time']);*/ | ||
811 | - $return['time']=json_decode($result['select_time'],true); | ||
812 | - $return['name']=db('volunteer')->where('user_id',$result['user_id'])->value('name'); | ||
813 | - $return['pic']=json_decode($result['work_pic'],true); | ||
814 | - | ||
815 | - $this->success('',$return); | ||
816 | - } | ||
817 | - | ||
818 | - | ||
819 | - /** | ||
820 | - * @title 获取城市列表 | ||
821 | - * @description 活动申请 | ||
822 | - * @author Xiaogang Wang | ||
823 | - * @url /index/index/cityList | ||
824 | - * @method GET | ||
825 | - * | ||
826 | - * @header name:XX-Token require:1 default: desc:token | ||
827 | - * | ||
828 | - * @param name:id type:int require:1 other: desc:城市id | ||
829 | - * @param name:province_name type:int require:1 other: desc:城市名称 | ||
830 | - * | ||
831 | - */ | ||
832 | - public function cityList(){ | ||
833 | - $Pro=new PositionProvinceModel(); | ||
834 | - $pro=$Pro->selectData(); | ||
835 | - foreach ($pro as $k=>$v){ | ||
836 | - $return['city'][$k]=$v['province_name']; | ||
837 | - $return['id'][$k]=$v['id']; | ||
838 | - } | ||
839 | - $this->success('',$return); | ||
840 | - } | ||
841 | - /** | ||
842 | - * @title 通过城市获取活动 | ||
843 | - * @description 活动类型 | ||
844 | - * @author Xiaogang Wang | ||
845 | - * @url /index/index/cityGetActivity | ||
846 | - * @method GET | ||
847 | - * | ||
848 | - * @header name:XX-Token require:1 default: desc:token | ||
849 | - * | ||
850 | - * @param name:city_id type:int require:1 other: desc:城市id | ||
851 | - * @return activity:活动@ | ||
852 | - * @activity id:id activity_name:活动名称 abstract:摘要 thumbnail:缩略图 time:时间 content:内容 province_name:省市地区 | ||
853 | - | ||
854 | - */ | ||
855 | - public function cityGetActivity(){ | ||
856 | - $city_id=input('city_id'); | ||
857 | - $Activity=new ActivityModel(); | ||
858 | - $activity=$Activity->selectCityData($city_id); | ||
859 | - $this->success('',$activity); | ||
860 | - } | ||
861 | - | ||
862 | - | ||
863 | - | ||
864 | - /** | ||
865 | - * @title 获取活动类型列表 | ||
866 | - * @description 活动类型 | ||
867 | - * @author Xiaogang Wang | ||
868 | - * @url /index/index/activityType | ||
869 | - * @method GET | ||
870 | - * | ||
871 | - * @header name:XX-Token require:1 default: desc:token | ||
872 | - * | ||
873 | - * @param name:id type:int require:1 other: desc:id | ||
874 | - * @param name:type_name type:int require:1 other: desc:活动类型 | ||
875 | - * | ||
876 | - */ | ||
877 | - public function activityType(){ | ||
878 | - $Type=new ActivityTypeModel(); | ||
879 | - $type=$Type->selectData(); | ||
880 | - foreach ($type as $k=>$v){ | ||
881 | - $return['type_name'][$k]=$v['type_name']; | ||
882 | - $return['id'][$k]=$v['id']; | ||
883 | - } | ||
884 | - $this->success('',$return); | ||
885 | - } | ||
886 | - /** | ||
887 | - * @title 通过类型获取活动 | ||
888 | - * @description 活动类型 | ||
889 | - * @author Xiaogang Wang | ||
890 | - * @url /index/index/typeGetActivity | ||
891 | - * @method GET | ||
892 | - * | ||
893 | - * @header name:XX-Token require:1 default: desc:token | ||
894 | - * | ||
895 | - * @param name:type n_id type:int require:1 other: desc:类型id | ||
896 | - * @return activity:活动@ | ||
897 | - * @activity id:id activity_name:活动名称 abstract:摘要 thumbnail:缩略图 time:时间 content:内容 province_name:省市地区 | ||
898 | - | ||
899 | - */ | ||
900 | - public function typeGetActivity(){ | ||
901 | - $type_id=input('type'); | ||
902 | - $Activity=new ActivityModel(); | ||
903 | - $activity=$Activity->selectTypeData($type_id); | ||
904 | - $this->success('',$activity); | ||
905 | - } | ||
906 | - | ||
907 | - /** | ||
908 | - * @title 生成分享图片地址(new); | ||
909 | - * @description 活动类型 | ||
910 | - * @author Xiaogang Wang | ||
911 | - * @url /index/index/makePic | ||
912 | - * @method GET | ||
913 | - * | ||
914 | - * @header name:XX-Token require:1 default: desc:token | ||
915 | - * | ||
916 | - * @param name:id n_id type:int require:1 other: desc:活动id | ||
917 | - */ | ||
918 | - public function makePic(){ | ||
919 | - $id=input('id'); | ||
920 | - $activity=db('activity')->where('id',$id)->find(); | ||
921 | - $text=$activity['activity_name']; | ||
922 | - $headimg='../upload/'.$activity['thumbnail']; | ||
923 | - | ||
924 | - $scene=$id; | ||
925 | - $name='1-'.$id; | ||
926 | - | ||
927 | - $Code=new Code(); | ||
928 | - $path='../upload/qrcode/'; | ||
929 | - $name1=$Code->code($scene,'pages/img_txt/img_txt',280,$name); | ||
930 | - | ||
931 | - $Image = new Image($path.$name1); | ||
932 | - $circle=$Image->circle(); | ||
933 | - | ||
934 | - $Image->save('../upload/qrcode/1-'.$id.'.png','png',5); | ||
935 | - /*生成图片*/ | ||
936 | - $image1=\think\Image::open($headimg); | ||
937 | - $image1->thumb(595,545,\think\Image::THUMB_CENTER)->save('../upload/qrcode/2-'.$id.'.png'); | ||
938 | - $image = \think\Image::open('../static/images/background.png'); | ||
939 | - // $text='这个是一个活动名称啊啊啊'; | ||
940 | - $num=mb_strlen($text); | ||
941 | - $cha=$num-8; | ||
942 | - $locate[]=188-$cha*13; | ||
943 | - $locate[]=680; | ||
944 | - $font='../static/font-awesome/fonts/PingFang Medium.ttf'; | ||
945 | - $result=$image->water('../upload/qrcode/2-'.$id.'.png',\think\Image::WATER_NORTHWEST)->water('../static/images/bottom.png',9) | ||
946 | - ->water('../upload/qrcode/1-'.$id.'.png',5)->text($text,$font,20,'#000000',$locate)->save($path.$id.'.png'); | ||
947 | - /*清除产生的图片*/ | ||
948 | - unlink($path.'1-'.$id.'.jpg'); | ||
949 | - unlink($path.'1-'.$id.'.png'); | ||
950 | - unlink($path.'2-'.$id.'.png'); | ||
951 | - $return['url']=cmf_get_image_url('/upload/qrcode/'.$id.'.png'); | ||
952 | - $this->success('',$return); | ||
953 | - | ||
954 | -/* | ||
955 | - $Head=new Image('../static/images/qr.jpg'); | ||
956 | - $Head->thumb('595'); | ||
957 | - $Head->save('../upload/qrcode/2-'.$id.'.jpg'); | ||
958 | - $path2='../upload/qrcode/2-'.$id.'.jpg'; | ||
959 | - $background =new Image('../static/images/background.png'); | ||
960 | - $background->mergeImage($path2,'jpg',595,'400',0,0); | ||
961 | - echo 111; | ||
962 | - //$background->mergeImage('../static/images/bottom.png','jpg',595,536,'425',0); | ||
963 | - $background->save('../upload/qrcode/3-'.$id.'.png'); | ||
964 | - echo 222; | ||
965 | - $last=new Image('../upload/qrcode/3-'.$id.'.png'); | ||
966 | - $last->mergeImage('../static/images/bottom.png','png',595,536,425,0); | ||
967 | - $last->mergeImage('../upload/qrcode/1-'.$id.'.png','png',595,536,477,160); | ||
968 | - $last->save('../upload/qrcode/4-'.$id.'.png'); | ||
969 | - | ||
970 | - | ||
971 | - dump($circle); | ||
972 | - dump($Image->get());*/ | ||
973 | - | ||
974 | - } | ||
975 | - | ||
976 | - /** | ||
977 | - * 添加formid | ||
978 | - * @param $userId | ||
979 | - * @param $formId | ||
980 | - */ | ||
981 | - protected function saveFormId($userId,$formId){ | ||
982 | - | ||
983 | - if ($formId=='undefined'){ | ||
984 | - return; | ||
985 | - } | ||
986 | - $data['user_id']=$userId; | ||
987 | - $data['add_time']=time(); | ||
988 | - $data['value']=$formId; | ||
989 | - $data['expire_time']=time()+604800; | ||
990 | - db('form_id')->insert($data); | ||
991 | - } | ||
992 | - | ||
993 | - | ||
994 | - public function test(){ | ||
995 | - | ||
996 | - $config = [ | ||
997 | - 'app_id' => 'wx3cf0f39249eb0exx', | ||
998 | - 'secret' => 'f1c242f4f28f735d4687abb469072axx', | ||
999 | - // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名 | ||
1000 | - 'response_type' => 'array' | ||
1001 | - ]; | ||
1002 | - $app = Factory::officialAccount($config); | ||
1003 | - | ||
1004 | - } | 1 | +<?php |
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: Administrator | ||
5 | + * Date: 2018/12/31 | ||
6 | + * Time: 11:30 | ||
7 | + */ | ||
8 | +namespace api\index\controller; | ||
9 | + | ||
10 | +use api\index\model\ActivityModel; | ||
11 | +use api\index\model\ActivityNewsModel; | ||
12 | +use api\index\model\ActivityType; | ||
13 | +use api\index\model\ActivityTypeModel; | ||
14 | +use api\index\model\JoinModel; | ||
15 | +use api\index\model\PositionProvinceModel; | ||
16 | +use api\index\model\SlideItemModel; | ||
17 | +use api\index\model\UserModel; | ||
18 | +use api\index\model\VolunteerModel; | ||
19 | +use cmf\controller\RestBaseController; | ||
20 | +use Dompdf\Frame\Factory; | ||
21 | +use EasyWeChatComposer\EasyWeChat; | ||
22 | +use Hooklife\ThinkphpWechat\Wechat; | ||
23 | +use Magicfier\Image; | ||
24 | +use think\Url; | ||
25 | +use traits\think\Instance; | ||
26 | +use wxapp\Code; | ||
27 | + | ||
28 | +/** | ||
29 | + * @title 首页 | ||
30 | + * @description 首页 | ||
31 | + */ | ||
32 | +class IndexController extends RestBaseController | ||
33 | +{ | ||
34 | + public function _initialize() | ||
35 | + { | ||
36 | + $user_id = $this->getUserId(); | ||
37 | + $userModel = new UserModel(); | ||
38 | + $user = $userModel->where(array('id'=>$user_id))->find(); | ||
39 | + if($user['user_status'] == 0){ | ||
40 | + $this->error(['code'=>40005,'msg'=>'您已被列入黑名单,请联系管理员!']); | ||
41 | + } | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * @title 首页 | ||
46 | + * @description 首页 | ||
47 | + * @author Xiaogang Wang | ||
48 | + * @url /index/index/index | ||
49 | + * @method GET | ||
50 | + * | ||
51 | + * @header name:XX-Token require:1 default: desc:token | ||
52 | + * | ||
53 | + * @param name:volunteer_page type:int require:0 other: desc:志愿者当前页(0为第一页)(默认0) | ||
54 | + * @param name:volunteer_pageNum type:int require:0 other: desc:活动显示数量(默认3) | ||
55 | + * @param name:activity_page type:int require:0 other: desc:活动当前页(0为第一页)(默认0) | ||
56 | + * @param name:activity_pageNum type:int require:0 other: desc:活动显示数量(默认4) | ||
57 | + * | ||
58 | + * @return volunteer:志愿者@ | ||
59 | + * @volunteer id:id name:姓名 sex:性别 level:星级 birthday:生日 nation:民族 politics:政治面貌 education:学历 unit:工作单位 duty:职务 addr:通讯地址 postcode:邮编 school:毕业院校 card_number:身份证号 fixed_phone:固定电话 move_phone:移动电话 email:email urgency_phone:紧急联系电话 qq:qq province:省 city:市 county:区/县 address:详细地址 type:志愿者类型(0医院志愿者,2社会志愿者,3办事处志愿者) record:个人履历@ front_card:身份证正面照 reverse_card:身份证背面照 photo:照片 status:状态(1审核中,2审核成功,3审核失败) user_id:用户id | ||
60 | + * @record record_start_time:开始时间 record_end_time:结束时间 record_unit:单位 record_duty:职务 record_name:证明人 record_phone:证明人电话 | ||
61 | + * @return activity:活动@ | ||
62 | + * @activity id:id activity_name:活动名称 abstract:摘要 thumbnail:缩略图 time:时间 content:内容 province_name:省市地区 | ||
63 | + * @return news:活动新闻@ | ||
64 | + * @news id:id activity_name:活动名称 abstract:摘要 thumbnail:缩略图 time:时间 content:内容 province_name:省市地区 | ||
65 | + * @return volunteer_page:志愿者下一页 | ||
66 | + * @return activity_page:活动下一页 | ||
67 | + */ | ||
68 | + public function index(){ | ||
69 | + $param = $this->request->param(); | ||
70 | + $volunteer_page = $param['volunteer_page'] ? $param['volunteer_page'] : 0;//当前页数下标 | ||
71 | + $volunteer_pageNum = $param['volunteer_pageNum'] ? $param['volunteer_pageNum'] : 3;//每页显示几条数据 | ||
72 | + $activity_page = $param['activity_page'] ? $param['activity_page'] : 0;//当前页数下标 | ||
73 | + $activity_pageNum = $param['activity_pageNum'] ? $param['activity_pageNum'] : 4;//每页显示几条数据 | ||
74 | + //获取志愿者 | ||
75 | + $volunteerModel = new VolunteerModel(); | ||
76 | + $volunteer = $volunteerModel->selectData($volunteer_page,$volunteer_pageNum,array('status'=>2)); | ||
77 | + //活动 | ||
78 | + $activityModel = new ActivityModel(); | ||
79 | + $activity = $activityModel->selectDataByTime(0,2); | ||
80 | + foreach ($activity as $k=>$v){ | ||
81 | + $activity[$k]['start_time']=date('Y-m-d',$v['start_time']); | ||
82 | + } | ||
83 | + // $beginAtOnce = $activityModel->beginAtOnce($activity_page,$activity_pageNum); | ||
84 | + | ||
85 | + //新闻 | ||
86 | + $activityNewsModel = new ActivityNewsModel(); | ||
87 | + $news = $activityModel->selectDataByTime($activity_page,$activity_pageNum,1); | ||
88 | + | ||
89 | + //幻灯片 | ||
90 | + $slideItemModel = new SlideItemModel(); | ||
91 | + $slide = $slideItemModel->selectData(array('slide_id'=>1)); | ||
92 | + $data['slide'] = $slide; | ||
93 | + $data['volunteer'] = $volunteer; | ||
94 | + $data['activity'] = $activity; | ||
95 | + $data['news'] = $news; | ||
96 | + $data['volunteer_page'] = $volunteer_page+1; | ||
97 | + $data['activity_page'] = $activity_page+1; | ||
98 | + $this->success('获取成功!',$data); | ||
99 | + } | ||
100 | + /** | ||
101 | + * @title 更多志愿者 | ||
102 | + * @description 更多志愿者 | ||
103 | + * @author Xiaogang Wang | ||
104 | + * @url /index/index/volunteer | ||
105 | + * @method GET | ||
106 | + * | ||
107 | + * @header name:XX-Token require:1 default: desc:token | ||
108 | + * | ||
109 | + * @param name:page type:int require:0 other: desc:志愿者当前页(0为第一页)(默认0) | ||
110 | + * @param name:pageNum type:int require:0 other: desc:活动显示数量(默认10) | ||
111 | + * | ||
112 | + * @return volunteer:志愿者@ | ||
113 | + * @volunteer id:id name:姓名 sex:性别 level:星级 birthday:生日 nation:民族 politics:政治面貌 education:学历 unit:工作单位 duty:职务 addr:通讯地址 postcode:邮编 school:毕业院校 card_number:身份证号 fixed_phone:固定电话 move_phone:移动电话 email:email urgency_phone:紧急联系电话 qq:qq province:省 city:市 county:区/县 address:详细地址 type:志愿者类型(0医院志愿者,2社会志愿者,3办事处志愿者) record:个人履历@ front_card:身份证正面照 reverse_card:身份证背面照 photo:照片 status:状态(1审核中,2审核成功,3审核失败) user_id:用户id | ||
114 | + * @record record_start_time:开始时间 record_end_time:结束时间 record_unit:单位 record_duty:职务 record_name:证明人 record_phone:证明人电话 | ||
115 | + * @return page:志愿者下一页 | ||
116 | + * @return page:活动下一页 | ||
117 | + */ | ||
118 | + public function volunteer(){ | ||
119 | + $param = $this->request->param(); | ||
120 | + $page = $param['page'] ? $param['page'] : 0;//当前页数下标 | ||
121 | + $pageNum = $param['pageNum'] ? $param['pageNum'] : 10;//每页显示几条数据 | ||
122 | + //获取志愿者 | ||
123 | + $volunteerModel = new VolunteerModel(); | ||
124 | + $volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>2)); | ||
125 | + $data['volunteer'] = $volunteer; | ||
126 | + $data['page'] = $page+1; | ||
127 | + $this->success('获取成功!',$data); | ||
128 | + } | ||
129 | + | ||
130 | + /** | ||
131 | + * @title 获取更多即将开始的活动 | ||
132 | + * @description | ||
133 | + * @author Xiaogang Wang | ||
134 | + * @url /index/index/activityAtOnce | ||
135 | + * @method GET | ||
136 | + * | ||
137 | + * @header name:XX-Token require:1 default: desc:token | ||
138 | + * | ||
139 | + * @param name:page type:int require:0 other: desc:当前页(0为第一页)(默认0) | ||
140 | + * @param name:pageNum type:int require:0 other: desc:活动显示数量(默认10) | ||
141 | + * | ||
142 | + * @return activity:活动@ | ||
143 | + * @activity id:id activity_name:活动名称 abstract:摘要 thumbnail:缩略图 time:时间 content:内容 province_name:省市地区 | ||
144 | + * @return page:活动下一页 | ||
145 | + */ | ||
146 | + public function activityAtOnce(){ | ||
147 | + $param = $this->request->param(); | ||
148 | + $page = $param['page'] ? $param['page'] : 0;//当前页数下标 | ||
149 | + $pageNum = $param['pageNum'] ? $param['pageNum'] : 10;//每页显示几条数据 | ||
150 | + | ||
151 | + $Activity=new ActivityModel(); | ||
152 | + $activity=$Activity->beginAtOnce($page,$pageNum); | ||
153 | + $data['activity'] = $activity; | ||
154 | + $data['page'] =$page+1; | ||
155 | + $this->success('获取成功!',$data); | ||
156 | + } | ||
157 | + | ||
158 | + | ||
159 | + | ||
160 | + | ||
161 | + | ||
162 | + | ||
163 | + /** | ||
164 | + * @title 志愿者详情 | ||
165 | + * @description 志愿者详情 | ||
166 | + * @author Xiaogang Wang | ||
167 | + * @url /index/index/volunteer_info | ||
168 | + * @method GET | ||
169 | + * | ||
170 | + * @param name:id type:int require:1 other: desc:志愿者id | ||
171 | + * | ||
172 | + * @return id:id | ||
173 | + * @return name:姓名 | ||
174 | + * @return sex:性别 | ||
175 | + * @return birthday:生日 | ||
176 | + * @return nation:民族 | ||
177 | + * @return politics:政治面貌 | ||
178 | + * @return education:学历 | ||
179 | + * @return unit:工作单位 | ||
180 | + * @return duty:职务 | ||
181 | + * @return addr:通讯地址 | ||
182 | + * @return postcode:邮编 | ||
183 | + * @return school:毕业院校 | ||
184 | + * @return card_number:身份证号 | ||
185 | + * @return fixed_phone:固定电话 | ||
186 | + * @return move_phone:移动电话 | ||
187 | + * @return email:email | ||
188 | + * @return urgency_phone:紧急联系电话 | ||
189 | + * @return qq:qq | ||
190 | + * @return province:省 | ||
191 | + * @return city:市 | ||
192 | + * @return county:区/县 | ||
193 | + * @return address:详细地址 | ||
194 | + * @return type:志愿者类型(0医院志愿者,2社会志愿者,3办事处志愿者) | ||
195 | + * @return record:个人履历@ | ||
196 | + * @record record_start_time:开始时间 record_end_time:结束时间 record_unit:单位 record_duty:职务 record_name:证明人 record_phone:证明人电话 | ||
197 | + * @return front_card:身份证正面照 | ||
198 | + * @return reverse_card:身份证背面照 | ||
199 | + * @return photo:照片 | ||
200 | + * @return status:状态(1审核中,2审核成功,3审核失败) | ||
201 | + * @return user_id:用户id | ||
202 | + */ | ||
203 | + public function volunteer_info(){ | ||
204 | + $id = $this->request->param('id'); | ||
205 | + //获取志愿者 | ||
206 | + $volunteerModel = new VolunteerModel(); | ||
207 | + $volunteer = $volunteerModel->findData(array('id'=>$id)); | ||
208 | + $this->success('获取成功!',$volunteer); | ||
209 | + } | ||
210 | + /** | ||
211 | + * @title 活动详情 | ||
212 | + * @description 活动详情 | ||
213 | + * @author Xiaogang Wang | ||
214 | + * @url /index/index/activity_info | ||
215 | + * @method GET | ||
216 | + * | ||
217 | + * @header name:XX-Token require:1 default: desc:token | ||
218 | + * | ||
219 | + * @param name:id type:int require:1 other: desc:活动id | ||
220 | + * | ||
221 | + * @return id:id | ||
222 | + * @return activity_name:活动名称 | ||
223 | + * @return abstract:摘要 | ||
224 | + * @return thumbnail:缩略图 | ||
225 | + * @return time:时间 | ||
226 | + * @return content:内容 | ||
227 | + * @return admin:是否为管理员1是管理员 | ||
228 | + * @return button_title:按钮标题 | ||
229 | + * @return join:参加用户@ | ||
230 | + * @join photo:照片 name:名称 level:星级 duty:岗位 | ||
231 | + * @return button_status:按钮状态8.报名通过活动未结束,不能填写报告7.用户被拒绝重新申请客户6.用户是志愿者,但是未报名参加活动5.已结束(活动过期)4.已提交工作汇报(用户是志愿者,已报名活动,已通过审核,已签到)3.提交工作汇报(用户是志愿者,已报名活动,选择线下或线上+线下,已通过审核,按钮变为签到但不可点击,活动有效时间内,变为可点击状态)2.待审核(用户是志愿者,已报名活动,但是未通过审核)1.报名 (用户是志愿者,但是未报名参加活动) | ||
232 | + * @return activity_stage:0.未开始1.进行中2.已结束 | ||
233 | + * @return status:0.未审核1.已通过2.已拒绝3.已提交工作汇报 | ||
234 | + * @return is_join:0.未参加1.已参加 | ||
235 | + */ | ||
236 | + public function activity_info(){ | ||
237 | + $id = $this->request->param('id'); | ||
238 | + //活动 | ||
239 | + $activityModel = new ActivityModel(); | ||
240 | + $userId=$this->getUserId(); | ||
241 | + $activity = $activityModel->findData(array('id'=>$id)); | ||
242 | + /*获取状态*/ | ||
243 | + $userModel = new UserModel(); | ||
244 | + $user = $userModel->findData(array('id'=>$userId)); | ||
245 | + /*是否为志愿者*/ | ||
246 | + $Volunteer=new VolunteerModel(); | ||
247 | + $volunteerMap['user_id']=$userId; | ||
248 | + $volunteerMap['status']=2; | ||
249 | + $volunteerMap['delete_time']=0; | ||
250 | + $volunteer=$Volunteer->findData($volunteerMap); | ||
251 | + | ||
252 | + if (empty($volunteer)){ | ||
253 | + $is_volunteer=0; | ||
254 | + }else{ | ||
255 | + $is_volunteer=1; | ||
256 | + } | ||
257 | + /*是否活动结束*/ | ||
258 | + $Activity=new ActivityModel(); | ||
259 | + $activityMap['id']=$id; | ||
260 | + $activity=$Activity->findData($activityMap); | ||
261 | + if($activity['end_time']<time()){ | ||
262 | + $is_end=1; | ||
263 | + }else{ | ||
264 | + $is_end=0; | ||
265 | + } | ||
266 | + | ||
267 | + if ($is_end==0){ | ||
268 | + if ($activity['start_time']>time()){ | ||
269 | + $activity['activity_stage']=0; | ||
270 | + }else{ | ||
271 | + $activity['activity_stage']=1; | ||
272 | + } | ||
273 | + }else{ | ||
274 | + $activity['activity_stage']=2; | ||
275 | + } | ||
276 | + | ||
277 | + | ||
278 | + if($user['type'] == 2){ | ||
279 | + $activity['admin']=1; | ||
280 | + }else{ | ||
281 | + $activity['admin']=0; | ||
282 | + } | ||
283 | + /*是否报名活动*/ | ||
284 | + $Join=new JoinModel(); | ||
285 | + $where['activity_id']=$id; | ||
286 | + $where['user_id']=$userId; | ||
287 | + $where['delete_time']=0; | ||
288 | + | ||
289 | + $join=$Join->findData($where); | ||
290 | + if (empty($join)){ | ||
291 | + $is_join=0; | ||
292 | + }else{ | ||
293 | + $is_join=1; | ||
294 | + } | ||
295 | + | ||
296 | + /*是否报名通过*/ | ||
297 | + if (empty($join['status']) || $join['status']==2){ | ||
298 | + $is_pass=0; | ||
299 | + $is_book=0; | ||
300 | + }elseif($join['status']=='3'){ | ||
301 | + $is_book=1; | ||
302 | + $is_pass=1; | ||
303 | + }elseif($join['status']=='1'){ | ||
304 | + $is_book=0; | ||
305 | + $is_pass=1; | ||
306 | + }elseif($join['status']==0){ | ||
307 | + $is_book=1; | ||
308 | + $is_pass=0; | ||
309 | + } | ||
310 | + | ||
311 | + $check=0; | ||
312 | + | ||
313 | + /*添加状态 活动没有开始时不能提交报告*/ | ||
314 | + if ($is_volunteer==1 && $check==0 && $is_pass==1 && $is_end==0){ | ||
315 | + $status=8; | ||
316 | + $title='暂不能提交工作汇报'; | ||
317 | + $check=1; | ||
318 | + } | ||
319 | + | ||
320 | + if ($is_volunteer==1 && $check==0 && $is_join==1 && $is_pass==1 && $is_book==0){ | ||
321 | + $status=3; | ||
322 | + $title='工作汇报'; | ||
323 | + $check=1; | ||
324 | + } | ||
325 | + | ||
326 | + if ($is_end==1 && $check==0){ | ||
327 | + $status=5; | ||
328 | + $title='已结束'; | ||
329 | + $check=1; | ||
330 | + } | ||
331 | + | ||
332 | + | ||
333 | + if ($is_volunteer==0 && $check==0) { | ||
334 | + $status=6; | ||
335 | + $check=1; | ||
336 | + $title='成为志愿者'; | ||
337 | + } | ||
338 | + | ||
339 | + if ($is_volunteer==1 && $check==0 && $is_pass==1 && $is_book==1){ | ||
340 | + $status=4; | ||
341 | + $title='已签到'; | ||
342 | + $check=1; | ||
343 | + } | ||
344 | + | ||
345 | + if ($is_volunteer==1 && $check==0 && $is_join==1 && $is_pass==1 && $is_book==0){ | ||
346 | + $status=3; | ||
347 | + $title='工作汇报'; | ||
348 | + $check=1; | ||
349 | + } | ||
350 | + if ($is_volunteer==1 && $check==0 && $is_join==1 && $join['status']=='2'){ | ||
351 | + $status=7; | ||
352 | + $title='报名'; | ||
353 | + $check=1; | ||
354 | + } | ||
355 | + if ($is_volunteer==1 && $check==0 && $is_join==1 && $is_pass==0){ | ||
356 | + $status=2; | ||
357 | + $title='待审核'; | ||
358 | + $check=0; | ||
359 | + } | ||
360 | + | ||
361 | + if ($is_volunteer==1 && $check==0 && $is_join==0){ | ||
362 | + $status=1; | ||
363 | + $title='报名'; | ||
364 | + $check=0; | ||
365 | + } | ||
366 | + $activity['button_title']=$title; | ||
367 | + $activity['button_status']=$status; | ||
368 | + /*活动参与状态*/ | ||
369 | + $activity['is_join']=$is_join; | ||
370 | + | ||
371 | + $people=$Join->getJoinData($id); | ||
372 | + $map1=[]; | ||
373 | + $sub_map['j.activity_id']=$id; | ||
374 | + $sub_map['j.status']=['in','1,3']; | ||
375 | + $sub_map['j.delete_time']=0; | ||
376 | + | ||
377 | + $subQuery = db('join')->alias('j') | ||
378 | + ->field('max(j.id)') | ||
379 | + ->join('volunteer v','v.user_id=j.user_id') | ||
380 | + ->where($sub_map) | ||
381 | + ->group('j.user_id') | ||
382 | + ->select() | ||
383 | + ->toArray(); | ||
384 | + | ||
385 | + if (!empty($subQuery)){ | ||
386 | + foreach ($subQuery as $k=>$v){ | ||
387 | + $new_map[]=$v["max(j.id)"]; | ||
388 | + } | ||
389 | + $map1['j.id']=['in',implode(',',$new_map)]; | ||
390 | + } | ||
391 | + | ||
392 | + $map1['j.activity_id']=$id; | ||
393 | + $map1['j.status']=['in','1,3']; | ||
394 | + $map1['j.delete_time']=0; | ||
395 | + | ||
396 | + $people=db('join')->alias('j') | ||
397 | + ->group('j.user_id') | ||
398 | + ->field('v.name,v.photo,v.level,j.work_content') | ||
399 | + ->join('volunteer v','v.user_id=j.user_id') | ||
400 | + ->where($map1) | ||
401 | + ->order('j.id','asc') | ||
402 | + ->select() | ||
403 | + ->toArray(); | ||
404 | + | ||
405 | + $join1=[]; | ||
406 | + $work_content=db('work')->column('name'); | ||
407 | + // dump($people); | ||
408 | + foreach ($people as $k=>$v){ | ||
409 | + $join1[$k]['photo']=$v['photo']; | ||
410 | + $join1[$k]['name']=$v['name']; | ||
411 | + $join1[$k]['level']=$v['level']; | ||
412 | + $join1[$k]['duty']=$work_content[$v['work_content']-1]??''; | ||
413 | + } | ||
414 | + $activity['join']=$join1; | ||
415 | + $this->success('获取成功!',$activity); | ||
416 | + } | ||
417 | + /** | ||
418 | + * @title 新闻详情 | ||
419 | + * @description 新闻详情 | ||
420 | + * @author Xiaogang Wang | ||
421 | + * @url /index/index/news_info | ||
422 | + * @method GET | ||
423 | + * | ||
424 | + * @header name:XX-Token require:1 default: desc:token | ||
425 | + * | ||
426 | + * @param name:id type:int require:1 other: desc:活动id | ||
427 | + * | ||
428 | + * @return id:id | ||
429 | + * @return activity_name:活动名称 | ||
430 | + * @return abstract:摘要 | ||
431 | + * @return thumbnail:缩略图 | ||
432 | + * @return time:时间 | ||
433 | + * @return content:内容 | ||
434 | + * @return button_title:按钮标题 | ||
435 | + * @return join:参加用户@ | ||
436 | + * @join photo:照片 name:名称 level:星级 | ||
437 | + * @return button_status:按钮状态6.用户是志愿者,但是未报名参加活动5.已结束(活动过期)4.已提交工作汇报(用户是志愿者,已报名活动,已通过审核,已签到)3.提交工作汇报(用户是志愿者,已报名活动,选择线下或线上+线下,已通过审核,按钮变为签到但不可点击,活动有效时间内,变为可点击状态)2.待审核(用户是志愿者,已报名活动,但是未通过审核)1.报名 (用户是志愿者,但是未报名参加活动) | ||
438 | + */ | ||
439 | + public function news_info(){ | ||
440 | + $id = $this->request->param('id'); | ||
441 | + //活动 | ||
442 | + $activityModel = new ActivityNewsModel(); | ||
443 | + $userId=$this->getUserId(); | ||
444 | + $activity = $activityModel->findData(array('id'=>$id)); | ||
445 | + /*获取状态*/ | ||
446 | + | ||
447 | + /*是否为志愿者*/ | ||
448 | + $Volunteer=new VolunteerModel(); | ||
449 | + $volunteerMap['user_id']=$userId; | ||
450 | + $volunteerMap['status']=2; | ||
451 | + $volunteerMap['delete_time']=0; | ||
452 | + $volunteer=$Volunteer->findData($volunteerMap); | ||
453 | + | ||
454 | + if (empty($volunteer)){ | ||
455 | + $is_volunteer=0; | ||
456 | + }else{ | ||
457 | + $is_volunteer=1; | ||
458 | + } | ||
459 | + /*是否活动结束*/ | ||
460 | + $Activity=new ActivityModel(); | ||
461 | + $activityMap['id']=$id; | ||
462 | + $activity_news=$Activity->findData($activityMap); | ||
463 | + if($activity_news['end_time']>time()){ | ||
464 | + $is_end=1; | ||
465 | + }else{ | ||
466 | + $is_end=0; | ||
467 | + } | ||
468 | + | ||
469 | + /*是否报名活动*/ | ||
470 | + $Join=new JoinModel(); | ||
471 | + $where['activity_id']=$id; | ||
472 | + $where['user_id']=$userId; | ||
473 | + $where['delete_time']=0; | ||
474 | + $join=$Join->findData($where); | ||
475 | + if (empty($join)){ | ||
476 | + $is_join=0; | ||
477 | + }else{ | ||
478 | + $is_join=1; | ||
479 | + } | ||
480 | + /*是否报名通过*/ | ||
481 | + if (empty($join['status']) || $join['status']==2){ | ||
482 | + $is_pass=0; | ||
483 | + $is_book=0; | ||
484 | + }elseif($join['status']=='3'){ | ||
485 | + $is_book=1; | ||
486 | + $is_pass=1; | ||
487 | + }elseif($join['status']=='1'){ | ||
488 | + $is_book=0; | ||
489 | + $is_pass=1; | ||
490 | + } | ||
491 | + $check=0; | ||
492 | + | ||
493 | + | ||
494 | + if ($is_volunteer==0 && $check==0) { | ||
495 | + $status=6; | ||
496 | + $check=1; | ||
497 | + $title='成为志愿者'; | ||
498 | + } | ||
499 | + | ||
500 | + if ($is_end==1 && $check==0){ | ||
501 | + $status=5; | ||
502 | + $title='已结束'; | ||
503 | + $check=1; | ||
504 | + } | ||
505 | + | ||
506 | + if ($is_volunteer==1 && $check==0 && $is_pass==1 && $is_book==1){ | ||
507 | + $status=4; | ||
508 | + $title='已提交工作汇报'; | ||
509 | + $check=1; | ||
510 | + } | ||
511 | + | ||
512 | + if ($is_volunteer==1 && $check==0 && $is_join==1 && $is_pass==1 && $is_book==0){ | ||
513 | + $status=3; | ||
514 | + $title='提交工作汇报'; | ||
515 | + $check=1; | ||
516 | + } | ||
517 | + | ||
518 | + if ($is_volunteer==1 && $check==0 && $is_join==1 && $is_pass==0){ | ||
519 | + $status=2; | ||
520 | + $title='待审核'; | ||
521 | + $check=0; | ||
522 | + } | ||
523 | + | ||
524 | + if ($is_volunteer==1 && $check==0 && $is_join==0){ | ||
525 | + $status=1; | ||
526 | + $title='报名'; | ||
527 | + $check=0; | ||
528 | + } | ||
529 | + $activity['button_title']=$title; | ||
530 | + $activity['button_status']=$status; | ||
531 | + $people=$Join->getJoinData($id); | ||
532 | + $join1=[]; | ||
533 | + foreach ($people as $k=>$v){ | ||
534 | + $join1[$k]['photo']=$v['photo']; | ||
535 | + $join1[$k]['name']=$v['name']; | ||
536 | + $join1[$k]['level']=$v['level']; | ||
537 | + } | ||
538 | + $activity['join']=$join1; | ||
539 | + $this->success('获取成功!',$activity); | ||
540 | + } | ||
541 | + | ||
542 | + /** | ||
543 | + * @title 签到(提交工作汇报)(new) | ||
544 | + * @description 活动签到 | ||
545 | + * @author Xiaogang Wang | ||
546 | + * @url /index/index/sginIn | ||
547 | + * @method GET | ||
548 | + * | ||
549 | + * @header name:XX-Token require:1 default: desc:token | ||
550 | + * | ||
551 | + * @param name:id type:int require:1 other: desc:活动id | ||
552 | + * @param name:work_report type:int require:1 other: desc:感想汇报 | ||
553 | + * @param name:work_pic type:int require:1 other: desc:图片 | ||
554 | + * | ||
555 | + */ | ||
556 | + public function sginIn(){ | ||
557 | + $userId=$this->getUserId(); | ||
558 | + $activity_id=input('id'); | ||
559 | + $Join=new JoinModel(); | ||
560 | + $where['user_id']=$userId; | ||
561 | + $where['activity_id']=$activity_id; | ||
562 | + $where['status']=1; | ||
563 | + $where['delete_time']=0; | ||
564 | + $join=$Join->findData($where); | ||
565 | + if (empty($join)){ | ||
566 | + $this->error('您还未报名此活动'); | ||
567 | + } | ||
568 | + if ($join['status']==3){ | ||
569 | + $this->error('您已经提交过了'); | ||
570 | + } | ||
571 | + if ($join['status']==2||$join['status']==0){ | ||
572 | + $this->error('还没有通过审核'); | ||
573 | + } | ||
574 | + if ($join['status']==1){ | ||
575 | + $data['sgin_time']=time(); | ||
576 | + $data['status']=3; | ||
577 | + $data['work_report']=input('work_report'); | ||
578 | + $data['work_pic']=html_entity_decode(htmlspecialchars_decode(input('work_pic'))); | ||
579 | + $result=db('join')->where($where)->update($data); | ||
580 | + if ($result==0){ | ||
581 | + $this->error('提交失败'); | ||
582 | + } | ||
583 | + } | ||
584 | + $this->success('提交成功!'); | ||
585 | + } | ||
586 | + | ||
587 | + | ||
588 | + /** | ||
589 | + * @title 申请活动(new) | ||
590 | + * @description 活动申请 | ||
591 | + * @author Xiaogang Wang | ||
592 | + * @url /index/index/applyJoin | ||
593 | + * @method GET | ||
594 | + * | ||
595 | + * @header name:XX-Token require:1 default: desc:token | ||
596 | + * | ||
597 | + * @param name:id type:int require:1 other: desc:活动id | ||
598 | + * @param name:form_id type:int require:1 other: desc:表单id | ||
599 | + * @param name:card_number type:int require:1 other: desc:身份证号 | ||
600 | + * @param name:type type:int require:1 other: desc:活动类型1:线上2:线下3:线上+线下 | ||
601 | + * @param name:start_time type:int require:1 other: desc:开始时间 | ||
602 | + * @param name:end_time type:int require:1 other: desc:结束时间 | ||
603 | + * @param name:work_content type:int require:1 other: desc:工作内容 | ||
604 | + * @param name:select_time type:int require:1 other: desc:选择日期[{"date":"2018-01-02","time":"18:01"},{"date":"2018-01-02","time":"18:01"}] | ||
605 | + * @param name:apply_stay type:int require:1 other: desc:申请入住[{"date":"2018-01-02","idcard":"123456"},{"date":"2018-01-02","idcard":"123456"}] | ||
606 | + * @param name:apply_food type:int require:1 other: desc:申请用餐[{"date":"2018-01-02","time":"18:01"},{"date":"2018-01-02","time":"18:01"}] | ||
607 | + * | ||
608 | + */ | ||
609 | + public function applyJoin(){ | ||
610 | + $userId=$this->getUserId(); | ||
611 | + $type=input('type'); | ||
612 | + $start_time=strtotime(input('start_time')); | ||
613 | + $end_time=strtotime(input('end_time')); | ||
614 | + $activity_id=input('id'); | ||
615 | + $form_id=input('form_id'); | ||
616 | + $card_number=input('card_number'); | ||
617 | + $this->saveFormId($userId,$form_id); | ||
618 | + | ||
619 | + /*三期增加字段*/ | ||
620 | + $work_content=input('work_content'); | ||
621 | + $select_time=html_entity_decode(htmlspecialchars_decode(input('select_time'))); | ||
622 | + $apply_stay=html_entity_decode(htmlspecialchars_decode(input('apply_stay'))); | ||
623 | + $apply_food=html_entity_decode(htmlspecialchars_decode(input('apply_food'))); | ||
624 | + | ||
625 | + /*判断是否未志愿者*/ | ||
626 | + $Volunteer=new VolunteerModel(); | ||
627 | + $where['user_id']=$userId; | ||
628 | + $volunter=$Volunteer->findData($where); | ||
629 | + if (empty($volunter)){ | ||
630 | + $this->error('请先成为志愿者!'); | ||
631 | + } | ||
632 | + /*判断是否参加了活动*/ | ||
633 | + $Join=new JoinModel(); | ||
634 | + $map['user_id']=$userId; | ||
635 | + $map['activity_id']=$activity_id; | ||
636 | + $map['delete_time']=0; | ||
637 | + $map['status']=0; | ||
638 | + | ||
639 | + $join=$Join->findData($map); | ||
640 | + if ($join){ | ||
641 | + $this->error('已经报名参加过该活动!'); | ||
642 | + } | ||
643 | + $data['user_id']=$userId; | ||
644 | + $data['card_number']=$card_number; | ||
645 | + $data['activity_id']=$activity_id; | ||
646 | + $data['type']=$type; | ||
647 | + $data['start_time']=$start_time; | ||
648 | + $data['end_time']=$end_time; | ||
649 | + $data['add_time']=time(); | ||
650 | + /*三期功能字段*/ | ||
651 | + $data['work_content']=$work_content; | ||
652 | + $data['select_time']=html_entity_decode(htmlspecialchars_decode(input('select_time'))); | ||
653 | + $data['apply_stay']=html_entity_decode(htmlspecialchars_decode(input('apply_stay'))); | ||
654 | + $data['apply_food']=html_entity_decode(htmlspecialchars_decode(input('apply_food'))); | ||
655 | + | ||
656 | + $result=$Join->insert($data); | ||
657 | + if ($result>0){ | ||
658 | + $this->success('报名成功,请等待审核!'); | ||
659 | + } | ||
660 | + $this->error('报名失败'); | ||
661 | + } | ||
662 | + /** | ||
663 | + * @title 编辑参加活动信息(new) | ||
664 | + * @description 活动申请 | ||
665 | + * @author Xiaogang Wang | ||
666 | + * @url /index/index/editApply | ||
667 | + * @method GET | ||
668 | + * | ||
669 | + * @header name:XX-Token require:1 default: desc:token | ||
670 | + * | ||
671 | + * @param name:id type:int require:1 other: desc:活动id | ||
672 | + * @param name:form_id type:int require:1 other: desc:表单id | ||
673 | + * @param name:type type:int require:1 other: desc:活动类型1:线上2:线下3:线上+线下 | ||
674 | + * @param name:start_time type:int require:1 other: desc:开始时间 | ||
675 | + * @param name:end_time type:int require:1 other: desc:结束时间 | ||
676 | + * @param name:work_content type:int require:1 other: desc:工作内容 | ||
677 | + * @param name:select_time type:int require:1 other: desc:选择日期[{"date":"2018-01-02","time":"18:01"},{"date":"2018-01-02","time":"18:01"}] | ||
678 | + * @param name:apply_stay type:int require:1 other: desc:申请入住[{"date":"2018-01-02","idcard":"123456"},{"date":"2018-01-02","idcard":"123456"}] | ||
679 | + * @param name:apply_food type:int require:1 other: desc:申请用餐[{"date":"2018-01-02","time":"18:01"},{"date":"2018-01-02","time":"18:01"}] | ||
680 | + * | ||
681 | + */ | ||
682 | + public function editApply(){ | ||
683 | + $userId=$this->getUserId(); | ||
684 | + $activity_id=input('id'); | ||
685 | + $map['activity_id']=$activity_id; | ||
686 | + $map['user_id']=$userId; | ||
687 | + $map['delete_time']=0; | ||
688 | + $form_id=input('form_id'); | ||
689 | + $this->saveFormId($userId,$form_id); | ||
690 | + $join=db('join')->where($map)->find(); | ||
691 | + if (empty($join)){ | ||
692 | + $this->error('不存在相关信息'); | ||
693 | + } | ||
694 | + $type=input('type'); | ||
695 | + $start_time=strtotime(input('start_time')); | ||
696 | + $end_time=strtotime(input('end_time')); | ||
697 | + /*三期增加字段*/ | ||
698 | + $work_content=input('work_content'); | ||
699 | + | ||
700 | + $select_time=html_entity_decode(htmlspecialchars_decode(input('select_time'))); | ||
701 | + $apply_stay=html_entity_decode(htmlspecialchars_decode(input('apply_stay'))); | ||
702 | + $apply_food=html_entity_decode(htmlspecialchars_decode(input('apply_food'))); | ||
703 | + | ||
704 | + | ||
705 | + $data['user_id']=$userId; | ||
706 | + $data['activity_id']=$activity_id; | ||
707 | + $data['type']=$type; | ||
708 | + $data['start_time']=$start_time; | ||
709 | + $data['end_time']=$end_time; | ||
710 | + /*三期功能字段*/ | ||
711 | + $data['work_content']=$work_content; | ||
712 | + $data['select_time']=$select_time; | ||
713 | + $data['apply_stay']=$apply_stay; | ||
714 | + $data['apply_food']=$apply_food; | ||
715 | + $data['card_number']=input('card_number'); | ||
716 | + $data['status']=0;//需要重新进行审核 | ||
717 | + $Join=new JoinModel(); | ||
718 | + $result=$Join->where($map)->Update($data); | ||
719 | + /*echo $Join->getLastSql(); | ||
720 | + dump($result); | ||
721 | + exit();*/ | ||
722 | + if ($result>0){ | ||
723 | + $this->success('修改成功,请等待审核!'); | ||
724 | + } | ||
725 | + $this->error('修改失败'); | ||
726 | + } | ||
727 | + /** | ||
728 | + * @title 获取申请活动填写信息(new) | ||
729 | + * @description 活动申请 | ||
730 | + * @author Xiaogang Wang | ||
731 | + * @url /index/index/getApplyInfo | ||
732 | + * @method GET | ||
733 | + * | ||
734 | + * @header name:XX-Token require:1 default: desc:token | ||
735 | + * | ||
736 | + * @param name:id type:int require:1 other: desc:活动id | ||
737 | + * @param name:user_id type:int require:1 other: desc:用户id | ||
738 | + * | ||
739 | + * @return name:姓名 | ||
740 | + * @return birthday:生日 | ||
741 | + * @return sex:性别 | ||
742 | + * @return tel:手机号 | ||
743 | + * @return card_number:身份证号 | ||
744 | + * @return work_type:工作类型 | ||
745 | + * @return work_content:工作内容 | ||
746 | + * @return select_time:选择日期 | ||
747 | + * @return apply_stay:申请入住 | ||
748 | + * @return apply_food:申请用餐 | ||
749 | + * | ||
750 | + * | ||
751 | + */ | ||
752 | + public function getApplyInfo(){ | ||
753 | + $userId=$this->getUserId(); | ||
754 | + $activity_id=input('id'); | ||
755 | + $user_id=input('user_id'); | ||
756 | + if (!empty($user_id)){ | ||
757 | + $userModel = new UserModel(); | ||
758 | + $user = $userModel->findData(array('id'=>$userId)); | ||
759 | + if($user['type'] != 2){ | ||
760 | + $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
761 | + } | ||
762 | + $userId=$user_id; | ||
763 | + } | ||
764 | + $map['user_id']=$userId; | ||
765 | + $map['activity_id']=$activity_id; | ||
766 | + $map['delete_time']=0; | ||
767 | + /*获取*/ | ||
768 | + $activity=db('activity')->field('start_time,end_time')->where('id',$activity_id)->order('id','desc')->find(); | ||
769 | + $time=$activity['end_time']; | ||
770 | + $now=time(); | ||
771 | + while ($time>$now){ | ||
772 | + $return['time'][]=date('Y-m-d',$time); | ||
773 | + $time=$time-60*60*24; | ||
774 | + } | ||
775 | + | ||
776 | + if (!empty($return['time'])){ | ||
777 | + $return['time']= array_reverse($return['time']); | ||
778 | + } | ||
779 | + | ||
780 | + $info=db('join')->field('sgin_time,id,type,user_id,activity_id,select_time,apply_stay,apply_food,work_content')->where($map)->find(); | ||
781 | + $user=db('volunteer')->field('card_number,sex,name,birthday,move_phone')->where('user_id',$userId)->find(); | ||
782 | + if (!empty($user)){ | ||
783 | + $return['name']=$user['name']; | ||
784 | + $return['birthday']=$user['birthday']; | ||
785 | + $return['sex']=$user['sex']==1?'男':'女'; | ||
786 | + $return['tel']=$user['move_phone']; | ||
787 | + $return['card_number']=$user['card_number']; | ||
788 | + } | ||
789 | + if (!empty($info)){ | ||
790 | + $return['work_content']=db('work')->where('id',$info['work_content'])->value('name'); | ||
791 | + $return['work_content']=$info['work_content']; | ||
792 | + $return['select_time']=json_decode($info['select_time'],true); | ||
793 | + $return['apply_stay']=json_decode($info['apply_stay'],true); | ||
794 | + $return['apply_food']=json_decode($info['apply_food'],true); | ||
795 | + $return['id']=$info['id']; | ||
796 | + $return['work_type']=$info['type']; | ||
797 | + $return['is_complete']=$info['sgin_time']==0?'0':'1'; | ||
798 | + /* switch ($info['type']){ | ||
799 | + case 1: | ||
800 | + $return['work_type']='线上'; | ||
801 | + break; | ||
802 | + case 2: | ||
803 | + $return['work_type']='线下'; | ||
804 | + break; | ||
805 | + case 3: | ||
806 | + $return['work_type']='线上及线下'; | ||
807 | + break; | ||
808 | + | ||
809 | + }*/ | ||
810 | + } | ||
811 | + | ||
812 | + $this->success('',$return); | ||
813 | + } | ||
814 | + | ||
815 | + | ||
816 | + | ||
817 | + /** | ||
818 | + * @title 退出活动(new) | ||
819 | + * @description 活动申请 | ||
820 | + * @author Xiaogang Wang | ||
821 | + * @url /index/index/quitActivity | ||
822 | + * @method GET | ||
823 | + * | ||
824 | + * @header name:XX-Token require:1 default: desc:token | ||
825 | + * | ||
826 | + * @param name:id type:int require:1 other: desc:活动id | ||
827 | + * | ||
828 | + */ | ||
829 | + public function quitActivity(){ | ||
830 | + $userId=$this->getUserId(); | ||
831 | + $activity_id=input('id'); | ||
832 | + $map['user_id']=$userId; | ||
833 | + $map['activity_id']=$activity_id; | ||
834 | + $data['delete_time']=time(); | ||
835 | + $result=db('join')->where($map)->update($data); | ||
836 | + if ($result>0){ | ||
837 | + $this->success('退出成功!'); | ||
838 | + }else{ | ||
839 | + $this->error('退出失败!'); | ||
840 | + } | ||
841 | + } | ||
842 | + | ||
843 | + /** | ||
844 | + * @title 工作汇报表信息(new) | ||
845 | + * @description 获取工作汇报表信息 | ||
846 | + * @author Xiaogang Wang | ||
847 | + * @url /index/index/workReportInfo | ||
848 | + * @method GET | ||
849 | + * | ||
850 | + * @header name:XX-Token require:1 default: desc:token | ||
851 | + * | ||
852 | + * @param name:id type:int require:1 other: desc:活动id | ||
853 | + * @param name:user_id type:int require:1 other: desc:用户id | ||
854 | + * | ||
855 | + * @return work_content:工作内容 | ||
856 | + * @return date:参加日期 | ||
857 | + * @return time:参加时间 | ||
858 | + * @return name:姓名 | ||
859 | + */ | ||
860 | + public function workReportInfo(){ | ||
861 | + $userId=$this->getUserId(); | ||
862 | + $activity_id=input('id'); | ||
863 | + if (!empty($user_id)){ | ||
864 | + $userModel = new UserModel(); | ||
865 | + $user = $userModel->findData(array('id'=>$userId)); | ||
866 | + if($user['type'] != 2){ | ||
867 | + $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
868 | + } | ||
869 | + $userId=$user_id; | ||
870 | + } | ||
871 | + $map['user_id']=input('user_id'); | ||
872 | + if (empty($map['user_id'])){ | ||
873 | + $map['user_id']=$userId; | ||
874 | + } | ||
875 | + $map['activity_id']=$activity_id; | ||
876 | + $map['status']=['in','1,3']; | ||
877 | + $map['delete_time']=0; | ||
878 | + $result=db('join')->where($map)->order('id','desc')->find(); | ||
879 | + if (empty($result)){ | ||
880 | + $this->error('没有相关信息'); | ||
881 | + } | ||
882 | + $return['work_content']=db('work')->where('id',$result['work_content'])->value('name'); | ||
883 | + $return['work_report']=$result['work_report']; | ||
884 | + /* $return['date']=date('Y-m-d',$result['add_time']); | ||
885 | + $return['time']=date('H:i:s',$result['add_time']);*/ | ||
886 | + $return['time']=json_decode($result['select_time'],true); | ||
887 | + $return['name']=db('volunteer')->where('user_id',$result['user_id'])->value('name'); | ||
888 | + $return['pic']=json_decode($result['work_pic'],true); | ||
889 | + | ||
890 | + $this->success('',$return); | ||
891 | + } | ||
892 | + | ||
893 | + | ||
894 | + /** | ||
895 | + * @title 获取城市列表 | ||
896 | + * @description 活动申请 | ||
897 | + * @author Xiaogang Wang | ||
898 | + * @url /index/index/cityList | ||
899 | + * @method GET | ||
900 | + * | ||
901 | + * @header name:XX-Token require:1 default: desc:token | ||
902 | + * | ||
903 | + * @param name:id type:int require:1 other: desc:城市id | ||
904 | + * @param name:province_name type:int require:1 other: desc:城市名称 | ||
905 | + * | ||
906 | + */ | ||
907 | + public function cityList(){ | ||
908 | + $Pro=new PositionProvinceModel(); | ||
909 | + $pro=$Pro->selectData(); | ||
910 | + foreach ($pro as $k=>$v){ | ||
911 | + $return['city'][$k]=$v['province_name']; | ||
912 | + $return['id'][$k]=$v['id']; | ||
913 | + } | ||
914 | + $this->success('',$return); | ||
915 | + } | ||
916 | + /** | ||
917 | + * @title 通过城市获取活动 | ||
918 | + * @description 活动类型 | ||
919 | + * @author Xiaogang Wang | ||
920 | + * @url /index/index/cityGetActivity | ||
921 | + * @method GET | ||
922 | + * | ||
923 | + * @header name:XX-Token require:1 default: desc:token | ||
924 | + * | ||
925 | + * @param name:city_id type:int require:1 other: desc:城市id | ||
926 | + * @param name:end type:int require:1 other: desc:0,未结束1,已结束 | ||
927 | + * @return activity:活动@ | ||
928 | + * @activity id:id activity_name:活动名称 abstract:摘要 thumbnail:缩略图 time:时间 content:内容 province_name:省市地区 | ||
929 | + | ||
930 | + */ | ||
931 | + public function cityGetActivity(){ | ||
932 | + $city_id=input('city_id'); | ||
933 | + $end=input('end'); | ||
934 | + if (empty($end)||$end==0){ | ||
935 | + $type='>='; | ||
936 | + }else{ | ||
937 | + $type='<'; | ||
938 | + } | ||
939 | + $Activity=new ActivityModel(); | ||
940 | + $activity=$Activity->selectCityData($city_id,$type); | ||
941 | + $this->success('',$activity); | ||
942 | + } | ||
943 | + | ||
944 | + | ||
945 | + | ||
946 | + /** | ||
947 | + * @title 获取活动类型列表 | ||
948 | + * @description 活动类型 | ||
949 | + * @author Xiaogang Wang | ||
950 | + * @url /index/index/activityType | ||
951 | + * @method GET | ||
952 | + * | ||
953 | + * @header name:XX-Token require:1 default: desc:token | ||
954 | + * | ||
955 | + * @param name:id type:int require:1 other: desc:id | ||
956 | + * @param name:type_name type:int require:1 other: desc:活动类型 | ||
957 | + * | ||
958 | + */ | ||
959 | + public function activityType(){ | ||
960 | + $Type=new ActivityTypeModel(); | ||
961 | + $type=$Type->selectData(); | ||
962 | + foreach ($type as $k=>$v){ | ||
963 | + $return['type_name'][$k]=$v['type_name']; | ||
964 | + $return['id'][$k]=$v['id']; | ||
965 | + } | ||
966 | + $this->success('',$return); | ||
967 | + } | ||
968 | + /** | ||
969 | + * @title 通过类型获取活动 | ||
970 | + * @description 活动类型 | ||
971 | + * @author Xiaogang Wang | ||
972 | + * @url /index/index/typeGetActivity | ||
973 | + * @method GET | ||
974 | + * | ||
975 | + * @header name:XX-Token require:1 default: desc:token | ||
976 | + * | ||
977 | + * @param name:type n_id type:int require:1 other: desc:类型id | ||
978 | + * @param name:end type:int require:1 other: desc:0,未结束1,已结束 | ||
979 | + * @return activity:活动@ | ||
980 | + * @activity id:id activity_name:活动名称 abstract:摘要 thumbnail:缩略图 time:时间 content:内容 province_name:省市地区 | ||
981 | + | ||
982 | + */ | ||
983 | + public function typeGetActivity(){ | ||
984 | + $type_id=input('type'); | ||
985 | + $end=input('end'); | ||
986 | + if (empty($end)||$end==0){ | ||
987 | + $type='>='; | ||
988 | + }else{ | ||
989 | + $type='<'; | ||
990 | + } | ||
991 | + $Activity=new ActivityModel(); | ||
992 | + $activity=$Activity->selectTypeData($type_id,$type); | ||
993 | + $this->success('',$activity); | ||
994 | + } | ||
995 | + | ||
996 | + /** | ||
997 | + * @title 生成分享图片地址(new); | ||
998 | + * @description 活动类型 | ||
999 | + * @author Xiaogang Wang | ||
1000 | + * @url /index/index/makePic | ||
1001 | + * @method GET | ||
1002 | + * | ||
1003 | + * @header name:XX-Token require:1 default: desc:token | ||
1004 | + * | ||
1005 | + * @param name:id n_id type:int require:1 other: desc:活动id | ||
1006 | + */ | ||
1007 | + public function makePic(){ | ||
1008 | + $id=input('id'); | ||
1009 | + $activity=db('activity')->where('id',$id)->find(); | ||
1010 | + $text=$activity['activity_name']; | ||
1011 | + $headimg='../upload/'.$activity['thumbnail']; | ||
1012 | + | ||
1013 | + $scene=$id; | ||
1014 | + $name='1-'.$id; | ||
1015 | + | ||
1016 | + $Code=new Code(); | ||
1017 | + $path='../upload/qrcode/'; | ||
1018 | + $name1=$Code->code($scene,'pages/img_txt/img_txt',280,$name); | ||
1019 | + | ||
1020 | + $Image = new Image($path.$name1); | ||
1021 | + $circle=$Image->circle(); | ||
1022 | + | ||
1023 | + $Image->save('../upload/qrcode/1-'.$id.'.png','png',5); | ||
1024 | + /*生成图片*/ | ||
1025 | + $image1=\think\Image::open($headimg); | ||
1026 | + $image1->thumb(595,545,\think\Image::THUMB_CENTER)->save('../upload/qrcode/2-'.$id.'.png'); | ||
1027 | + $image = \think\Image::open('../static/images/background.png'); | ||
1028 | + // $text='这个是一个活动名称啊啊啊'; | ||
1029 | + $num=mb_strlen($text); | ||
1030 | + $cha=$num-8; | ||
1031 | + $locate[]=188-$cha*13; | ||
1032 | + $locate[]=680; | ||
1033 | + $font='../static/font-awesome/fonts/PingFang Medium.ttf'; | ||
1034 | + $result=$image->water('../upload/qrcode/2-'.$id.'.png',\think\Image::WATER_NORTHWEST)->water('../static/images/bottom.png',9) | ||
1035 | + ->water('../upload/qrcode/1-'.$id.'.png',5)->text($text,$font,20,'#000000',$locate)->save($path.$id.'.png'); | ||
1036 | + /*清除产生的图片*/ | ||
1037 | + unlink($path.'1-'.$id.'.jpg'); | ||
1038 | + unlink($path.'1-'.$id.'.png'); | ||
1039 | + unlink($path.'2-'.$id.'.png'); | ||
1040 | + $return['url']=cmf_get_image_url('/upload/qrcode/'.$id.'.png'); | ||
1041 | + $this->success('',$return); | ||
1042 | + | ||
1043 | +/* | ||
1044 | + $Head=new Image('../static/images/qr.jpg'); | ||
1045 | + $Head->thumb('595'); | ||
1046 | + $Head->save('../upload/qrcode/2-'.$id.'.jpg'); | ||
1047 | + $path2='../upload/qrcode/2-'.$id.'.jpg'; | ||
1048 | + $background =new Image('../static/images/background.png'); | ||
1049 | + $background->mergeImage($path2,'jpg',595,'400',0,0); | ||
1050 | + echo 111; | ||
1051 | + //$background->mergeImage('../static/images/bottom.png','jpg',595,536,'425',0); | ||
1052 | + $background->save('../upload/qrcode/3-'.$id.'.png'); | ||
1053 | + echo 222; | ||
1054 | + $last=new Image('../upload/qrcode/3-'.$id.'.png'); | ||
1055 | + $last->mergeImage('../static/images/bottom.png','png',595,536,425,0); | ||
1056 | + $last->mergeImage('../upload/qrcode/1-'.$id.'.png','png',595,536,477,160); | ||
1057 | + $last->save('../upload/qrcode/4-'.$id.'.png'); | ||
1058 | + dump($circle); | ||
1059 | + dump($Image->get());*/ | ||
1060 | + | ||
1061 | + } | ||
1062 | + | ||
1063 | + /** | ||
1064 | + * 添加formid | ||
1065 | + * @param $userId | ||
1066 | + * @param $formId | ||
1067 | + */ | ||
1068 | + protected function saveFormId($userId,$formId){ | ||
1069 | + | ||
1070 | + if ($formId=='undefined'){ | ||
1071 | + return; | ||
1072 | + } | ||
1073 | + $data['user_id']=$userId; | ||
1074 | + $data['add_time']=time(); | ||
1075 | + $data['value']=$formId; | ||
1076 | + $data['expire_time']=time()+604800; | ||
1077 | + db('form_id')->insert($data); | ||
1078 | + } | ||
1079 | + | ||
1080 | + | ||
1081 | + public function test(){ | ||
1082 | + | ||
1083 | + $config = [ | ||
1084 | + 'app_id' => 'wx3cf0f39249eb0exx', | ||
1085 | + 'secret' => 'f1c242f4f28f735d4687abb469072axx', | ||
1086 | + // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名 | ||
1087 | + 'response_type' => 'array' | ||
1088 | + ]; | ||
1089 | + $app = Factory::officialAccount($config); | ||
1090 | + | ||
1091 | + } | ||
1092 | + | ||
1093 | + | ||
1094 | + | ||
1005 | } | 1095 | } |
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: Administrator | ||
5 | - * Date: 2018/12/31 | ||
6 | - * Time: 15:35 | ||
7 | - */ | ||
8 | - | ||
9 | -namespace api\index\controller; | ||
10 | - | ||
11 | - | ||
12 | -use api\index\model\AboutModel; | ||
13 | -use api\index\model\ContactModel; | ||
14 | -use api\index\model\JoinModel; | ||
15 | -use api\index\model\VolunteerModel; | ||
16 | -use api\index\model\UserModel; | ||
17 | -use cmf\controller\RestBaseController; | ||
18 | -use EasyWeChat\Foundation\Application; | ||
19 | -use think\Validate; | ||
20 | - | ||
21 | -/** | ||
22 | - * @title 个人中心 | ||
23 | - * @description 个人中心 | ||
24 | - */ | ||
25 | -class MemberCenterController extends RestBaseController | ||
26 | -{ | ||
27 | - public function _initialize() | ||
28 | - { | ||
29 | - $user_id = $this->getUserId(); | ||
30 | - $userModel = new UserModel(); | ||
31 | - $user = $userModel->where(array('id'=>$user_id))->find(); | ||
32 | - if($user['user_status'] == 0){ | ||
33 | - $this->error(['code'=>40005,'msg'=>'您已被列入黑名单,请联系管理员!']); | ||
34 | - } | ||
35 | - } | ||
36 | - /** | ||
37 | - * @title 个人中心 | ||
38 | - * @description 个人中心 | ||
39 | - * @author XiaoGang Wang | ||
40 | - * @url /index/member_center/index | ||
41 | - * @method GET | ||
42 | - * | ||
43 | - * @header name:XX-Token require:1 default: desc:token | ||
44 | - * | ||
45 | - * @return id:id | ||
46 | - * @return user_nickname:用户昵称 | ||
47 | - * @return level:用户星级 | ||
48 | - * @return work_time:工作时长 | ||
49 | - * @return avatar:头像 | ||
50 | - * @return type:类型(1为普通,2为管理员) | ||
51 | - * @return is_submit:0为未提交过,1为已提交过 | ||
52 | - */ | ||
53 | - public function index(){ | ||
54 | - $user_id = $this->getUserId(); | ||
55 | - //判断当前用户是否提交过 | ||
56 | - $volunteerModel = new VolunteerModel(); | ||
57 | - $result = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0)); | ||
58 | - $userModel = new UserModel(); | ||
59 | - $user = $userModel->findData(array('id'=>$user_id)); | ||
60 | - if(empty($result)){ | ||
61 | - $is_submit = 0; | ||
62 | - }else { | ||
63 | - | ||
64 | - $is_submit = 1; | ||
65 | - } | ||
66 | - | ||
67 | - if (empty($result['level'])){ | ||
68 | - $result['level']=0; | ||
69 | - } | ||
70 | - if (empty($result['work_time'])){ | ||
71 | - $result['work_time']=0; | ||
72 | - } | ||
73 | - $user['level']=$result['level']; | ||
74 | - $user['work_time']=$result['work_time']; | ||
75 | - $user['is_submit'] = $is_submit; | ||
76 | - $this->success('获取成功!',$user); | ||
77 | - } | ||
78 | - /** | ||
79 | - * @title 判断是否为管理员是否提交过申请 | ||
80 | - * @description 判断是否为管理员是否提交过申请 | ||
81 | - * @author XiaoGang Wang | ||
82 | - * @url /index/member_center/is_submit_admin | ||
83 | - * @method GET | ||
84 | - * | ||
85 | - * @header name:XX-Token require:1 default: desc:token | ||
86 | - * | ||
87 | - * @return id:id | ||
88 | - * @return user_nickname:用户昵称 | ||
89 | - * @return avatar:头像 | ||
90 | - * @return type:类型(1为普通,2为管理员) | ||
91 | - * @return is_submit:0为未提交过,1为已提交过 | ||
92 | - */ | ||
93 | - public function is_submit_admin(){ | ||
94 | - $user_id = $this->getUserId(); | ||
95 | - //判断当前用户是否提交过 | ||
96 | - $volunteerModel = new VolunteerModel(); | ||
97 | - $result = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0)); | ||
98 | - if(empty($result)){ | ||
99 | - $is_submit = 0; | ||
100 | - }else{ | ||
101 | - $is_submit = 1; | ||
102 | - } | ||
103 | - //判断这个用户是不是管理员 | ||
104 | - $userModel = new UserModel(); | ||
105 | - $user = $userModel->findData(array('id'=>$user_id)); | ||
106 | - if($user['type'] != 2){ | ||
107 | - $is_admin = 0; | ||
108 | - }else{ | ||
109 | - $is_admin = 1; | ||
110 | - } | ||
111 | - $data['is_submit'] = $is_submit; | ||
112 | - $data['is_admin'] = $is_admin; | ||
113 | - $this->success('获取成功!',$data); | ||
114 | - } | ||
115 | - /** | ||
116 | - * @title 提交审核 | ||
117 | - * @description 提交审核 | ||
118 | - * @author XiaoGang Wang | ||
119 | - * @url /index/member_center/submit_form | ||
120 | - * @method GET | ||
121 | - * | ||
122 | - * @header name:XX-Token require:1 default: desc:token | ||
123 | - * | ||
124 | - * @param name:form_id type:str require:1 other: desc:表单id | ||
125 | - * @param name:name type:str require:1 other: desc:姓名 | ||
126 | - * @param name:sex type:str require:1 other: desc:性别(1男,2女) | ||
127 | - * @param name:birthday type:str require:1 other: desc:生日 | ||
128 | - * @param name:nation type:str require:1 other: desc:民族 | ||
129 | - * @param name:politics type:str require:1 other: desc:政治面貌 | ||
130 | - * @param name:education type:str require:1 other: desc:学历 | ||
131 | - * @param name:unit type:str require:1 other: desc:工作单位 | ||
132 | - * @param name:duty type:str require:1 other: desc:职务 | ||
133 | - * @param name:addr type:str require:1 other: desc:通讯地址 | ||
134 | - * @param name:postcode type:str require:1 other: desc:邮编 | ||
135 | - * @param name:school type:str require:1 other: desc:毕业院校 | ||
136 | - * @param name:card_number type:str require:1 other: desc:身份证号码 | ||
137 | - * @param name:fixed_phone type:str require:1 other: desc:固定电话 | ||
138 | - * @param name:move_phone type:str require:1 other: desc:移动电话 | ||
139 | - * @param name:email type:str require:1 other: desc:email | ||
140 | - * @param name:urgency_phone type:str require:1 other: desc:紧急联系人电话 | ||
141 | - * @param name:qq type:str require:1 other: desc:qq | ||
142 | - * @param name:province type:str require:1 other: desc:省 | ||
143 | - * @param name:city type:str require:1 other: desc:市 | ||
144 | - * @param name:county type:str require:1 other: desc:区/县 | ||
145 | - * @param name:address type:str require:1 other: desc:详细地址 | ||
146 | - * @param name:type type:int require:1 other: desc:1医院志愿者,2社会志愿者,3办事处志愿者 | ||
147 | - * @param name:record_start_time type:str require:1 other: desc:开始时间 | ||
148 | - * @param name:record_end_time type:str require:1 other: desc:结束时间 | ||
149 | - * @param name:record_unit type:str require:1 other: desc:单位 | ||
150 | - * @param name:record_duty type:str require:1 other: desc:职务 | ||
151 | - * @param name:record_name type:str require:1 other: desc:证明人 | ||
152 | - * @param name:record_phone type:str require:1 other: desc:证明人电话 | ||
153 | - * @param name:front_card type:str require:1 other: desc:身份证正面照 | ||
154 | - * @param name:reverse_card type:str require:1 other: desc:身份证背面照 | ||
155 | - * @param name:photo type:str require:1 other: desc:照片 | ||
156 | - */ | ||
157 | - public function submit_form(){ | ||
158 | - $user_id = $this->getUserId(); | ||
159 | - $param = $this->request->param(); | ||
160 | - $validate = new Validate([ | ||
161 | - 'name' => 'require', | ||
162 | - 'sex' => 'require', | ||
163 | - 'birthday' => 'require', | ||
164 | - 'nation' => 'require', | ||
165 | - 'politics' => 'require', | ||
166 | - 'education' => 'require', | ||
167 | - 'unit' => 'require', | ||
168 | - 'duty' => 'require', | ||
169 | - 'addr' => 'require', | ||
170 | - 'postcode' => 'require', | ||
171 | - 'school' => 'require', | ||
172 | - 'card_number' => 'require', | ||
173 | -// 'fixed_phone' => 'require', | ||
174 | - 'move_phone' => 'require', | ||
175 | - 'email' => 'require', | ||
176 | - 'urgency_phone' => 'require', | ||
177 | - 'qq' => 'require', | ||
178 | - 'province' => 'require', | ||
179 | - 'city' => 'require', | ||
180 | -// 'county' => 'require', | ||
181 | - 'address' => 'require', | ||
182 | - 'record_start_time' => 'require', | ||
183 | - 'record_end_time' => 'require', | ||
184 | - 'record_unit' => 'require', | ||
185 | - 'record_duty' => 'require', | ||
186 | - 'record_name' => 'require', | ||
187 | - 'record_phone' => 'require', | ||
188 | - 'front_card' => 'require', | ||
189 | - 'reverse_card' => 'require', | ||
190 | - 'photo' => 'require', | ||
191 | - ]); | ||
192 | - $validate->message([ | ||
193 | - 'name' => '缺少参数name', | ||
194 | - 'sex' => '缺少参数sex', | ||
195 | - 'birthday' => '缺少参数birthday', | ||
196 | - 'nation' => '缺少参数nation', | ||
197 | - 'politics' => '缺少参数politics', | ||
198 | - 'education' => '缺少参数education', | ||
199 | - 'unit' => '缺少参数unit', | ||
200 | - 'duty' => '缺少参数duty', | ||
201 | - 'addr' => '缺少参数addr', | ||
202 | - 'postcode' => '缺少参数postcode', | ||
203 | - 'school' => '缺少参数school', | ||
204 | - 'card_number' => '缺少参数card_number', | ||
205 | -// 'fixed_phone' => '缺少参数fixed_phone', | ||
206 | - 'move_phone' => '缺少参数move_phone', | ||
207 | - 'email' => '缺少参数email', | ||
208 | - 'urgency_phone' => '缺少参数urgency_phone', | ||
209 | - 'qq' => '缺少参数qq', | ||
210 | - 'province' => '缺少参数province', | ||
211 | - 'city' => '缺少参数city', | ||
212 | -// 'county' => '缺少参数county', | ||
213 | - 'address' => '缺少参数address', | ||
214 | - 'record_start_time' => '缺少参数record_start_time', | ||
215 | - 'record_end_time' => '缺少参数record_end_time', | ||
216 | - 'record_unit' => '缺少参数record_unit', | ||
217 | - 'record_duty' => '缺少参数record_duty', | ||
218 | - 'record_name' => '缺少参数record_name', | ||
219 | - 'record_phone' => '缺少参数record_phone', | ||
220 | - 'front_card' => '缺少参数front_card', | ||
221 | - 'reverse_card' => '缺少参数reverse_card', | ||
222 | - 'photo' => '缺少参数photo', | ||
223 | - ]); | ||
224 | - if (!$validate->check($param)) { | ||
225 | - $this->error($validate->getError()); | ||
226 | - } | ||
227 | - $record_start_time = explode(',',$param['record_start_time']); | ||
228 | - $record_end_time = explode(',',$param['record_end_time']); | ||
229 | - $record_unit = explode(',',$param['record_unit']); | ||
230 | - $record_duty = explode(',',$param['record_duty']); | ||
231 | - $record_name = explode(',',$param['record_name']); | ||
232 | - $record_phone = explode(',',$param['record_phone']); | ||
233 | - $record = []; | ||
234 | - foreach($record_start_time as $key => $r_s_t){ | ||
235 | - $record[$key]['record_start_time'] = !empty($r_s_t) ? $r_s_t : ''; | ||
236 | - $record[$key]['record_end_time'] = !empty($record_end_time[$key]) ? $record_end_time[$key] : ''; | ||
237 | - $record[$key]['record_unit'] = !empty($record_unit[$key]) ? $record_unit[$key] :''; | ||
238 | - $record[$key]['record_duty'] = !empty($record_duty[$key]) ? $record_duty[$key] :''; | ||
239 | - $record[$key]['record_name'] = !empty($record_name[$key]) ? $record_name[$key] :''; | ||
240 | - $record[$key]['record_phone'] = !empty($record_phone[$key]) ? $record_phone[$key] :''; | ||
241 | - } | ||
242 | - if(!empty($record)){ | ||
243 | - $record = json_encode($record); | ||
244 | - }else{ | ||
245 | - $record = null; | ||
246 | - } | ||
247 | - $data = [ | ||
248 | - 'name' => $param['name'], | ||
249 | - 'sex' => $param['sex'], | ||
250 | - 'birthday' => $param['birthday'], | ||
251 | - 'nation' => $param['nation'], | ||
252 | - 'politics' => $param['politics'], | ||
253 | - 'education' => $param['education'], | ||
254 | - 'unit' => $param['unit'], | ||
255 | - 'duty' => $param['duty'], | ||
256 | - 'addr' => $param['addr'], | ||
257 | - 'postcode' => $param['postcode'], | ||
258 | - 'school' => $param['school'], | ||
259 | - 'card_number' => $param['card_number'], | ||
260 | - 'fixed_phone' => $param['fixed_phone'], | ||
261 | - 'move_phone' => $param['move_phone'], | ||
262 | - 'email' => $param['email'], | ||
263 | - 'urgency_phone' => $param['urgency_phone'], | ||
264 | - 'qq' => $param['qq'], | ||
265 | - 'province' => $param['province'], | ||
266 | - 'city' => $param['city'], | ||
267 | - 'county' => !empty($param['county'])?$param['county']:null, | ||
268 | - 'address' => $param['address'], | ||
269 | - /* 'type' => $param['type'],*/ | ||
270 | - 'record' => $record, | ||
271 | - 'front_card' => $param['front_card'], | ||
272 | - 'reverse_card' => $param['reverse_card'], | ||
273 | - 'photo' => $param['photo'], | ||
274 | - 'status' => 1, | ||
275 | - 'user_id' => $user_id, | ||
276 | - ]; | ||
277 | - $form_id=input('form_id'); | ||
278 | - if (empty($form_id)){ | ||
279 | - $this->saveFormId($user_id,$form_id); | ||
280 | - } | ||
281 | - $volunteerModel = new VolunteerModel(); | ||
282 | - $result1 = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0)); | ||
283 | - //判断该用户是否提交过 | ||
284 | - if(!empty($result1)){ | ||
285 | - $data['update_time'] = time(); | ||
286 | - $volunteerModel->updateData(array('id'=>$result1['id']),$data); | ||
287 | - }else{ | ||
288 | - $data['create_time'] = time(); | ||
289 | - $volunteerModel->insertData($data); | ||
290 | - } | ||
291 | - $this->success('提交成功!'); | ||
292 | - } | ||
293 | - /** | ||
294 | - * @title 进入修改页面 | ||
295 | - * @description 进入修改页面 | ||
296 | - * @author XiaoGang Wang | ||
297 | - * @url /index/member_center/edit | ||
298 | - * @method GET | ||
299 | - * | ||
300 | - * @header name:XX-Token require:1 default: desc:token | ||
301 | - * | ||
302 | - * @return name:姓名 | ||
303 | - * @return sex:性别(1男,2女) | ||
304 | - * @return birthday:生日 | ||
305 | - * @return nation:民族 | ||
306 | - * @return politics:政治面貌 | ||
307 | - * @return education:学历 | ||
308 | - * @return unit:工作单位 | ||
309 | - * @return duty:职务 | ||
310 | - * @return addr:通讯地址 | ||
311 | - * @return postcode:邮编 | ||
312 | - * @return school: desc:毕业院校 | ||
313 | - * @return card_number :身份证号码 | ||
314 | - * @return fixed_phone:固定电话 | ||
315 | - * @return move_phone:移动电话 | ||
316 | - * @return email:email | ||
317 | - * @return urgency_phone:紧急联系人电话 | ||
318 | - * @return qq:qq | ||
319 | - * @return province:省 | ||
320 | - * @return city:市 | ||
321 | - * @return county:区/县 | ||
322 | - * @return address:详细地址 | ||
323 | - * @return type:1医院志愿者,2社会志愿者,3办事处志愿者 | ||
324 | - * @return record_start_time:开始时间 | ||
325 | - * @return record_end_time:结束时间 | ||
326 | - * @return record_unit:单位 | ||
327 | - * @return record_duty:职务 | ||
328 | - * @return record_name:证明人 | ||
329 | - * @return record_phone:证明人电话 | ||
330 | - * @return front_card type:str require:1 other: desc:身份证正面照 | ||
331 | - * @return reverse_card:身份证背面照 | ||
332 | - * @return photo:照片 | ||
333 | - */ | ||
334 | - public function edit(){ | ||
335 | -// $user_id = $this->getUserId(); | ||
336 | - $user_id = $this->request->param('id'); | ||
337 | - //判断当前用户是否提交过 | ||
338 | - $volunteerModel = new VolunteerModel(); | ||
339 | - $result = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0)); | ||
340 | - $this->success('获取成功!',$result); | ||
341 | - } | ||
342 | - /** | ||
343 | - * @title 查看审核状态 | ||
344 | - * @description 查看审核状态 | ||
345 | - * @author XiaoGang Wang | ||
346 | - * @url /index/member_center/status | ||
347 | - * @method GET | ||
348 | - * | ||
349 | - * @header name:XX-Token require:1 default: desc:token | ||
350 | - * | ||
351 | - * @return id:id | ||
352 | - * @return status:状态(1审核中,2审核成功,3审核失败) | ||
353 | - */ | ||
354 | - public function status(){ | ||
355 | - $user_id = $this->getUserId(); | ||
356 | - $volunteerModel = new VolunteerModel(); | ||
357 | - $data = $volunteerModel->findData(array('user_id'=>$user_id)); | ||
358 | - if(empty($data)){ | ||
359 | - $this->success(['code'=>40001,'msg'=>'您还没有提交过申请!']); | ||
360 | - } | ||
361 | - $this->success('获取成功!',$data); | ||
362 | - } | ||
363 | - /** | ||
364 | - * @title 管理员审核 | ||
365 | - * @description 管理员审核 | ||
366 | - * @author XiaoGang Wang | ||
367 | - * @url /index/member_center/admin | ||
368 | - * @method GET | ||
369 | - * | ||
370 | - * @header name:XX-Token require:1 default: desc:token | ||
371 | - * | ||
372 | - * @param name:page type:int require:0 other: desc:志愿者当前页(0为第一页)(默认0) | ||
373 | - * @param name:pageNum type:int require:0 other: desc:活动显示数量(默认10) | ||
374 | - * | ||
375 | - * @return volunteer:志愿者@ | ||
376 | - * @volunteer id:id name:姓名 sex:性别 birthday:生日 nation:民族 politics:政治面貌 education:学历 unit:工作单位 duty:职务 addr:通讯地址 postcode:邮编 school:毕业院校 card_number:身份证号 fixed_phone:固定电话 move_phone:移动电话 email:email urgency_phone:紧急联系电话 qq:qq province:省 city:市 county:区/县 address:详细地址 type:志愿者类型(0医院志愿者,2社会志愿者,3办事处志愿者) record:个人履历@ front_card:身份证正面照 reverse_card:身份证背面照 photo:照片 status:状态(1审核中,2审核成功,3审核失败) user_id:用户id | ||
377 | - * @record record_start_time:开始时间 record_end_time:结束时间 record_unit:单位 record_duty:职务 record_name:证明人 record_phone:证明人电话 | ||
378 | - * @return page:志愿者下一页 | ||
379 | - * @return page:活动下一页 | ||
380 | - */ | ||
381 | - public function admin(){ | ||
382 | - $user_id = $this->getUserId(); | ||
383 | - //判断这个用户是不是管理员 | ||
384 | - $userModel = new UserModel(); | ||
385 | - $user = $userModel->findData(array('id'=>$user_id)); | ||
386 | - if($user['type'] != 2){ | ||
387 | - $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
388 | - } | ||
389 | - $param = $this->request->param(); | ||
390 | - $page = !empty($param['page']) ? $param['page'] : 0;//当前页数下标 | ||
391 | - $pageNum = !empty($param['pageNum']) ? $param['pageNum'] : 10;//每页显示几条数据 | ||
392 | - //获取志愿者 | ||
393 | - $volunteerModel = new VolunteerModel(); | ||
394 | - // $volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>['in','1,2'])); | ||
395 | - $volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>'1')); | ||
396 | - $data['volunteer'] = $volunteer; | ||
397 | - $data['page'] = $page+1; | ||
398 | - $this->success('获取成功!',$data); | ||
399 | - } | ||
400 | - | ||
401 | - /** | ||
402 | - * @title 工时管理列表(new) | ||
403 | - * @description | ||
404 | - * @author XiaoGang Wang | ||
405 | - * @url /index/member_center/addTimeList | ||
406 | - * @method GET | ||
407 | - * | ||
408 | - * @header name:XX-Token require:1 default: desc:token | ||
409 | - * | ||
410 | - * @param name:page type:int require:0 other: desc:志愿者当前页(0为第一页)(默认0) | ||
411 | - * @param name:pageNum type:int require:0 other: desc:活动显示数量(默认10) | ||
412 | - * | ||
413 | - * @return volunteer:志愿者@ | ||
414 | - * @volunteer id:id name:姓名 sex:性别 birthday:生日 nation:民族 politics:政治面貌 education:学历 unit:工作单位 duty:职务 addr:通讯地址 postcode:邮编 school:毕业院校 card_number:身份证号 fixed_phone:固定电话 move_phone:移动电话 email:email urgency_phone:紧急联系电话 qq:qq province:省 city:市 county:区/县 address:详细地址 type:志愿者类型(0医院志愿者,2社会志愿者,3办事处志愿者) record:个人履历@ front_card:身份证正面照 reverse_card:身份证背面照 photo:照片 status:状态(1审核中,2审核成功,3审核失败) user_id:用户id | ||
415 | - * @record record_start_time:开始时间 record_end_time:结束时间 record_unit:单位 record_duty:职务 record_name:证明人 record_phone:证明人电话 | ||
416 | - * @return page:志愿者下一页 | ||
417 | - * @return page:活动下一页 | ||
418 | - * | ||
419 | - */ | ||
420 | - public function addTimeList(){ | ||
421 | - $user_id = $this->getUserId(); | ||
422 | - //判断这个用户是不是管理员 | ||
423 | - $userModel = new UserModel(); | ||
424 | - $user = $userModel->findData(array('id'=>$user_id)); | ||
425 | - if($user['type'] != 2){ | ||
426 | - $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
427 | - } | ||
428 | - $param = $this->request->param(); | ||
429 | - $page = !empty($param['page']) ? $param['page'] : 0;//当前页数下标 | ||
430 | - $pageNum = !empty($param['pageNum']) ? $param['pageNum'] : 10;//每页显示几条数据 | ||
431 | - //获取志愿者 | ||
432 | - $volunteerModel = new VolunteerModel(); | ||
433 | - // $volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>['in','1,2'])); | ||
434 | - $volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>'2')); | ||
435 | - $data['volunteer'] = $volunteer; | ||
436 | - $data['page'] = $page+1; | ||
437 | - $this->success('获取成功!',$data); | ||
438 | - } | ||
439 | - | ||
440 | - | ||
441 | - /** | ||
442 | - * @title 管理员添加时间(new) | ||
443 | - * @description 管理员审核 | ||
444 | - * @author XiaoGang Wang | ||
445 | - * @url /index/member_center/addTime | ||
446 | - * @method GET | ||
447 | - * | ||
448 | - * @header name:XX-Token require:1 default: desc:token | ||
449 | - * | ||
450 | - * @param name:add_time type:int require:0 other: desc:添加时间 | ||
451 | - * @param name:user_id type:int require:0 other: desc:用户id | ||
452 | - * | ||
453 | - */ | ||
454 | - public function addTime(){ | ||
455 | - $user_id = $this->getUserId(); | ||
456 | - //判断这个用户是不是管理员 | ||
457 | - $userModel = new UserModel(); | ||
458 | - $user = $userModel->findData(array('id'=>$user_id)); | ||
459 | - if($user['type'] != 2){ | ||
460 | - $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
461 | - } | ||
462 | - $map['user_id']=input('user_id'); | ||
463 | - $time=input('add_time'); | ||
464 | - // $data['add_time']=['exp','work_time'+$time]; | ||
465 | - $result=db('volunteer')->where($map)->setInc('work_time',$time); | ||
466 | - // echo db('volunteer')->getLastSql(); | ||
467 | - if ($result>0){ | ||
468 | - $this->success('修改成功!'); | ||
469 | - }else{ | ||
470 | - $this->error('此人不是审核通过的志愿者!'); | ||
471 | - } | ||
472 | - } | ||
473 | - /** | ||
474 | - * @title 管理员查看活动申请详情 | ||
475 | - * @description 管理员审核 | ||
476 | - * @author XiaoGang Wang | ||
477 | - * @url /index/member_center/adminGetApplyInfo | ||
478 | - * @method GET | ||
479 | - * | ||
480 | - * @header name:XX-Token require:1 default: desc:token | ||
481 | - * | ||
482 | - * @param name:join_id type:int require:0 other: desc:报名id | ||
483 | - * | ||
484 | - */ | ||
485 | - public function adminGetApplyInfo(){ | ||
486 | - $map['id']=input('join_id'); | ||
487 | - $user_id = $this->getUserId(); | ||
488 | - //判断这个用户是不是管理员 | ||
489 | - $userModel = new UserModel(); | ||
490 | - $user = $userModel->findData(array('id'=>$user_id)); | ||
491 | - if($user['type'] != 2){ | ||
492 | - $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
493 | - } | ||
494 | - | ||
495 | - /*获取*/ | ||
496 | - | ||
497 | - if (!empty($return['time'])){ | ||
498 | - $return['time']= array_reverse($return['time']); | ||
499 | - } | ||
500 | - | ||
501 | - $info=db('join')->field('sgin_time,id,type,user_id,activity_id,select_time,apply_stay,apply_food,work_content')->where($map)->find(); | ||
502 | - $user=db('volunteer')->field('sex,name,birthday,move_phone')->where('user_id',$info['user_id'])->find(); | ||
503 | - if (!empty($user)){ | ||
504 | - $return['name']=$user['name']; | ||
505 | - $return['birthday']=$user['birthday']; | ||
506 | - $return['sex']=$user['sex']==1?'男':'女'; | ||
507 | - $return['tel']=$user['move_phone']; | ||
508 | - } | ||
509 | - if (!empty($info)){ | ||
510 | - $return['work_content']=db('work')->where('id',$info['work_content'])->value('name'); | ||
511 | - $return['work_content']=$info['work_content']; | ||
512 | - $return['select_time']=json_decode($info['select_time'],true); | ||
513 | - $return['apply_stay']=json_decode($info['apply_stay'],true); | ||
514 | - $return['apply_food']=json_decode($info['apply_food'],true); | ||
515 | - $return['id']=$info['id']; | ||
516 | - $return['work_type']=$info['type']; | ||
517 | - $return['is_complete']=$info['sgin_time']==0?'0':'1'; | ||
518 | - /* switch ($info['type']){ | ||
519 | - case 1: | ||
520 | - $return['work_type']='线上'; | ||
521 | - break; | ||
522 | - case 2: | ||
523 | - $return['work_type']='线下'; | ||
524 | - break; | ||
525 | - case 3: | ||
526 | - $return['work_type']='线上及线下'; | ||
527 | - break; | ||
528 | - | ||
529 | - }*/ | ||
530 | - } | ||
531 | - | ||
532 | - $this->success('',$return); | ||
533 | - | ||
534 | - | ||
535 | - } | ||
536 | - | ||
537 | - | ||
538 | - | ||
539 | - /** | ||
540 | - * @title 管理员更新状态 | ||
541 | - * @description 管理员更新状态 | ||
542 | - * @author XiaoGang Wang | ||
543 | - * @url /index/member_center/update_status | ||
544 | - * @method GET | ||
545 | - * | ||
546 | - * @header name:XX-Token require:1 default: desc:token | ||
547 | - * | ||
548 | - * @param name:id type:int require:1 other: desc:志愿者id | ||
549 | - * @param name:status type:int require:1 other: desc:状态(点击审核通过传2,点击审核失败传3) | ||
550 | - * @param name:refund_reason type:int require:1 other: desc:审核不通过原因 | ||
551 | - */ | ||
552 | - public function update_status(){ | ||
553 | - $user_id = $this->getUserId(); | ||
554 | - | ||
555 | - $id = $this->request->param('id'); | ||
556 | - if(empty($id)){ | ||
557 | - $this->error('缺少参数id'); | ||
558 | - } | ||
559 | - $status = $this->request->param('status'); | ||
560 | - if(empty($status)){ | ||
561 | - $this->error('缺少参数status'); | ||
562 | - } | ||
563 | - if($status != 2 && $status != 3){ | ||
564 | - $this->error('status参数错误!'); | ||
565 | - } | ||
566 | - //判断这个用户是不是管理员 | ||
567 | - $userModel = new UserModel(); | ||
568 | - $user = $userModel->findData(array('id'=>$user_id)); | ||
569 | - if($user['type'] != 2){ | ||
570 | - $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
571 | - } | ||
572 | - //获取志愿者 | ||
573 | - $volunteerModel = new VolunteerModel(); | ||
574 | - $data['status']=input('status'); | ||
575 | - | ||
576 | - if ($data['status']==2){ | ||
577 | - $keyword='审核通过'; | ||
578 | - }else{ | ||
579 | - $keyword='审核未通过'; | ||
580 | - } | ||
581 | - $data['refund_reason']=input('refund_reason')??''; | ||
582 | - $result = $volunteerModel->updateData(array('id'=>$id),$data); | ||
583 | - if(empty($result)){ | ||
584 | - $this->success(['code'=>40002,'msg'=>'当前申请可能已被其他管理员审核,请刷新页面!']); | ||
585 | - } | ||
586 | - $userMap['user_id']=$id; | ||
587 | - $openid=db('third_party_user')->where($userMap)->value('openid'); | ||
588 | - $volunteer=db('volunteer')->where('id',$id)->find(); | ||
589 | - $formMap['user_id']=$id; | ||
590 | - $formMap['use_time']=0; | ||
591 | - $formMap['expire_time']=['>',time()]; | ||
592 | - $form_id=\db('form_id')->where($formMap)->find(); | ||
593 | - | ||
594 | - $data['keyword1']= $volunteer['name']; | ||
595 | - $data['keyword2']='志愿者审核'; | ||
596 | - $data['keyword3']=$keyword; | ||
597 | - $data['keyword4']='志愿者审核'; | ||
598 | - $message = [ | ||
599 | - 'touser' => $openid, | ||
600 | - 'template_id' => '1FYkLuMK8LNKO4_nxJ_DuNQhgIjaaJQlAukgt92C-uw', | ||
601 | - 'page' => 'pages/index/index', | ||
602 | - 'form_id' => $form_id['value'], | ||
603 | - 'data' => $data, | ||
604 | - 'emphasis_keyword' =>$data['keyword3']='状态', | ||
605 | - ]; | ||
606 | - $this->wxappNotice($message); | ||
607 | - $this->success(['code'=>20000,'msg'=>'更新成功!']); | ||
608 | - } | ||
609 | - | ||
610 | - | ||
611 | - /** | ||
612 | - * @title 获取人员参与状态 | ||
613 | - * @description 管理员更新状态 | ||
614 | - * @author XiaoGang Wang | ||
615 | - * @url /index/member_center/getJoinPerson | ||
616 | - * @method GET | ||
617 | - * | ||
618 | - * @header name:XX-Token require:1 default: desc:token | ||
619 | - * | ||
620 | - * @param name:id type:int require:1 other: desc:活动id | ||
621 | - * | ||
622 | - * @return photo:摄影(设备自带) | ||
623 | - * @return camera:摄像(设备自带) | ||
624 | - * @return motorcade:爱心车队 | ||
625 | - * @return service:现场服务(签到、指引、礼仪等) | ||
626 | - * @return question:线上答疑 | ||
627 | - * @return ill:门诊服务 | ||
628 | - * @return name:status0,未审核1,已通过2,未通过3,已填写工作汇报(已通过) | ||
629 | - */ | ||
630 | - public function getJoinPerson(){ | ||
631 | - $user_id = $this->getUserId(); | ||
632 | - //判断这个用户是不是管理员 | ||
633 | - $userModel = new UserModel(); | ||
634 | - $user = $userModel->findData(array('id'=>$user_id)); | ||
635 | - if($user['type'] != 2){ | ||
636 | - $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
637 | - } | ||
638 | - //活动id | ||
639 | - $id=input('id'); | ||
640 | - $map['activity_id']=$id; | ||
641 | - $map['j.delete_time']=0; | ||
642 | - | ||
643 | - $info=db('join')->alias('j') | ||
644 | - ->group('j.user_id') | ||
645 | - ->field('v.*,j.*,j.id as join_id,j.status as status') | ||
646 | - ->join('volunteer v','v.user_id=j.user_id') | ||
647 | - ->where($map) | ||
648 | - ->order('j.id','desc') | ||
649 | - ->select() | ||
650 | - ->toArray(); | ||
651 | - | ||
652 | - $return=[]; | ||
653 | - $i0=0; | ||
654 | - $i1=0; | ||
655 | - $i2=0; | ||
656 | - $i3=0; | ||
657 | - $i4=0; | ||
658 | - $i5=0; | ||
659 | - | ||
660 | - foreach($info as $k=>$v){ | ||
661 | - switch ($v['work_content']){ | ||
662 | - case 1: | ||
663 | - $return[0]['title']='摄影(设备自带)'; | ||
664 | - $return[0]['arr'][$i0]['id']=$v['join_id']; | ||
665 | - $return[0]['arr'][$i0]['photo']=$v['photo']; | ||
666 | - $return[0]['arr'][$i0]['name']=$v['name']; | ||
667 | - $return[0]['arr'][$i0]['user_id']=$v['user_id']; | ||
668 | - $return[0]['arr'][$i0]['status']=$this->switchStatus($v['status']); | ||
669 | - $i0++; | ||
670 | - break; | ||
671 | - case 2: | ||
672 | - $return[1]['title']='摄像(设备自带)'; | ||
673 | - $return[1]['arr'][$i1]['id']=$v['join_id']; | ||
674 | - $return[1]['arr'][$i1]['photo']=$v['photo']; | ||
675 | - $return[1]['arr'][$i1]['name']=$v['name']; | ||
676 | - $return[1]['arr'][$i1]['user_id']=$v['user_id']; | ||
677 | - $return[1]['arr'][$i1]['status']=$this->switchStatus($v['status']); | ||
678 | - $i1++; | ||
679 | - break; | ||
680 | - case 3: | ||
681 | - $return[2]['title']='爱心车队'; | ||
682 | - $return[2]['arr'][$i2]['id']=$v['join_id']; | ||
683 | - $return[2]['arr'][$i2]['photo']=$v['photo']; | ||
684 | - $return[2]['arr'][$i2]['name']=$v['name']; | ||
685 | - $return[2]['arr'][$i2]['user_id']=$v['user_id']; | ||
686 | - $return[2]['arr'][$i2]['status']=$this->switchStatus($v['status']); | ||
687 | - $i2++; | ||
688 | - break; | ||
689 | - case 4: | ||
690 | - $return[3]['title']='现场服务(签到、指引、礼仪等)'; | ||
691 | - $return[3]['arr'][$i3]['id']=$v['join_id']; | ||
692 | - $return[3]['arr'][$i3]['photo']=$v['photo']; | ||
693 | - $return[3]['arr'][$i3]['name']=$v['name']; | ||
694 | - $return[3]['arr'][$i3]['user_id']=$v['user_id']; | ||
695 | - $return[3]['arr'][$i3]['status']=$this->switchStatus($v['status']); | ||
696 | - $i3++; | ||
697 | - break; | ||
698 | - case 5: | ||
699 | - $return[4]['title']='线上答疑'; | ||
700 | - $return[4]['arr'][$i4]['id']=$v['join_id']; | ||
701 | - $return[4]['arr'][$i4]['photo']=$v['photo']; | ||
702 | - $return[4]['arr'][$i4]['name']=$v['name']; | ||
703 | - $return[4]['arr'][$i4]['user_id']=$v['user_id']; | ||
704 | - $return[4]['arr'][$i4]['status']=$this->switchStatus($v['status']); | ||
705 | - $i4++; | ||
706 | - break; | ||
707 | - case 6: | ||
708 | - $return[5]['title']='门诊服务'; | ||
709 | - | ||
710 | - /*判断是否有user_id*/ | ||
711 | - $return[5]['arr'][$i5]['id']=$v['join_id']; | ||
712 | - $return[5]['arr'][$i5]['photo']=$v['photo']; | ||
713 | - $return[5]['arr'][$i5]['name']=$v['name']; | ||
714 | - $return[5]['arr'][$i5]['user_id']=$v['user_id']; | ||
715 | - $return[5]['arr'][$i5]['status']=$this->switchStatus($v['status']); | ||
716 | - $i5++; | ||
717 | - break; | ||
718 | - } | ||
719 | - } | ||
720 | - foreach ($return as $k=>$v){ | ||
721 | - foreach($return[$k] as $k1=>$v1){ | ||
722 | - | ||
723 | - } | ||
724 | - } | ||
725 | - | ||
726 | - | ||
727 | - $this->success('',$return); | ||
728 | - } | ||
729 | - /** | ||
730 | - * @title 管理员审核活动申请是否通过(new) | ||
731 | - * @description 管理员更新状态 | ||
732 | - * @author XiaoGang Wang | ||
733 | - * @url /index/member_center/adminApprove | ||
734 | - * @method GET | ||
735 | - * | ||
736 | - * @header name:XX-Token require:1 default: desc:token | ||
737 | - * | ||
738 | - * @param name:id type:int require:1 other: desc:参加id | ||
739 | - * @param name:status type:int require:1 other: desc:1通过2.拒绝 | ||
740 | - * @param name:refund_reason type:int require:1 other: desc:拒绝理由 | ||
741 | - * | ||
742 | - * | ||
743 | - */ | ||
744 | - public function adminApprove(){ | ||
745 | - $user_id = $this->getUserId(); | ||
746 | - //判断这个用户是不是管理员 | ||
747 | - | ||
748 | - $userModel = new UserModel(); | ||
749 | - $user = $userModel->findData(array('id'=>$user_id)); | ||
750 | - if($user['type'] != 2){ | ||
751 | - $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
752 | - } | ||
753 | - $map['id']=input('id'); | ||
754 | - $data['status']=input('status'); | ||
755 | - $refund_reason=input('refund_reason'); | ||
756 | - if (!empty($refund_reason)){ | ||
757 | - $data['refund_reason']=input('refund_reason'); | ||
758 | - } | ||
759 | - $result=db('join')->where($map)->update($data); | ||
760 | - if ($result>0){ | ||
761 | - $join=\db('join')->where($map)->find(); | ||
762 | - $activity=\db('activity')->where('id',$join['activity_id'])->find(); | ||
763 | - $userMap['user_id']=$join['user_id']; | ||
764 | - $openid=db('third_party_user')->where($userMap)->value('openid'); | ||
765 | - $volunteer=\db('volunteer')->where('user_id',$join['user_id'])->find(); | ||
766 | - $formMap['user_id']=$join['user_id']; | ||
767 | - $formMap['use_time']=0; | ||
768 | - $formMap['expire_time']=['>',time()]; | ||
769 | - $form_id=\db('form_id')->where($formMap)->find(); | ||
770 | - | ||
771 | - if ($data['status']==1){ | ||
772 | - if (!empty($form_id)){ | ||
773 | - \db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>time()]); | ||
774 | - $data['keyword1']= $volunteer['name']; | ||
775 | - $data['keyword2']='活动审核'; | ||
776 | - $data['keyword3']='通过'; | ||
777 | - $data['keyword4']=$activity['activity_name']; | ||
778 | - $message = [ | ||
779 | - 'touser' => $openid, | ||
780 | - 'template_id' => '1FYkLuMK8LNKO4_nxJ_DuNQhgIjaaJQlAukgt92C-uw', | ||
781 | - 'page' => 'pages/index/index', | ||
782 | - 'form_id' => $form_id['value'], | ||
783 | - 'data' => $data, | ||
784 | - 'emphasis_keyword' =>$data['keyword3'], | ||
785 | - ]; | ||
786 | - $this->wxappNotice($message); | ||
787 | - } | ||
788 | - }else{ | ||
789 | - if (!empty($form_id)){ | ||
790 | - \db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>time()]); | ||
791 | - $data['keyword1']= $volunteer['name']; | ||
792 | - $data['keyword2']='活动审核'; | ||
793 | - $data['keyword3']='未通过'; | ||
794 | - $data['keyword4']=$activity['activity_name']; | ||
795 | - $message = [ | ||
796 | - 'touser' => $openid, | ||
797 | - 'template_id' => '1FYkLuMK8LNKO4_nxJ_DuNQhgIjaaJQlAukgt92C-uw', | ||
798 | - 'page' => 'pages/index/index', | ||
799 | - 'form_id' => $form_id['value'], | ||
800 | - 'data' => $data, | ||
801 | - 'emphasis_keyword' =>$data['keyword3'], | ||
802 | - ]; | ||
803 | - $this->wxappNotice($message); | ||
804 | - } | ||
805 | - } | ||
806 | - | ||
807 | - | ||
808 | - $this->success('更新成功!'); | ||
809 | - }else{ | ||
810 | - $this->error('操作失败!'); | ||
811 | - } | ||
812 | - } | ||
813 | - | ||
814 | - | ||
815 | - protected function wxappNotice($message){ | ||
816 | - $appId = 'wx7a3bf4e0796c070a'; | ||
817 | - $secret = '755478f064e09a8301345e0c427c6cf3'; | ||
818 | - $config = [ | ||
819 | - 'app_id' => $appId, | ||
820 | - 'secret' => $secret, | ||
821 | - ]; | ||
822 | - | ||
823 | - $wechat=new Application($config); | ||
824 | - $notice=$wechat->mini_program->notice; | ||
825 | - try{ | ||
826 | - $result= $notice->send($message); | ||
827 | - }catch(Exception $e){ | ||
828 | - $e->getMessage(); | ||
829 | - } | ||
830 | - return $result; | ||
831 | - } | ||
832 | - | ||
833 | - | ||
834 | - protected function switchStatus($status){ | ||
835 | - switch ($status){ | ||
836 | - case 0: | ||
837 | - return '0'; | ||
838 | - case 1: | ||
839 | - return '1'; | ||
840 | - case 2: | ||
841 | - return '2'; | ||
842 | - case 3: | ||
843 | - return '3'; | ||
844 | - } | ||
845 | - } | ||
846 | - /** | ||
847 | - * @title 关于我们 | ||
848 | - * @description 关于我们 | ||
849 | - * @author XiaoGang Wang | ||
850 | - * @url /index/member_center/about | ||
851 | - * @method GET | ||
852 | - * | ||
853 | - * @header name:XX-Token require:1 default: desc:token | ||
854 | - */ | ||
855 | - public function about(){ | ||
856 | - $aboutModel = new AboutModel(); | ||
857 | - $data = $aboutModel->findData(array('id'=>1)); | ||
858 | - $this->success('获取成功!',$data); | ||
859 | - } | ||
860 | - /** | ||
861 | - * @title 联系我们 | ||
862 | - * @description 联系我们 | ||
863 | - * @author XiaoGang Wang | ||
864 | - * @url /index/member_center/contact | ||
865 | - * @method GET | ||
866 | - * | ||
867 | - * @header name:XX-Token require:1 default: desc:token | ||
868 | - */ | ||
869 | - public function contact(){ | ||
870 | - $contactModel = new ContactModel(); | ||
871 | - $data = $contactModel->findData(array('id'=>1)); | ||
872 | - $this->success('获取成功!',$data); | ||
873 | - } | ||
874 | - /** | ||
875 | - * @title 我参加的活动 | ||
876 | - * @description 参加过的活动 | ||
877 | - * @author XiaoGang Wang | ||
878 | - * @url /index/member_center/joined | ||
879 | - * @method GET | ||
880 | - * | ||
881 | - * @header name:XX-Token require:1 default: desc:token | ||
882 | - */ | ||
883 | - public function joined(){ | ||
884 | - $userId=$this->getUserId(); | ||
885 | - $Join=new JoinModel(); | ||
886 | - $join=$Join->getUserJoin($userId); | ||
887 | - foreach ($join as $k=>$v){ | ||
888 | - $join[$k]['thumbnail']=cmf_get_image_url($v['thumbnail']); | ||
889 | - $join[$k]['create_time']=date('Y-m-d',$v['create_time']); | ||
890 | - } | ||
891 | - $this->success('',$join); | ||
892 | - } | ||
893 | - | ||
894 | - protected function saveFormId($userId,$formId){ | ||
895 | - if ($formId=='undefined'){ | ||
896 | - return; | ||
897 | - } | ||
898 | - $data['user_id']=$userId; | ||
899 | - $data['add_time']=time(); | ||
900 | - $data['value']=$formId; | ||
901 | - $data['expire_time']=time()+604800; | ||
902 | - db('form_id')->insert($data); | ||
903 | - } | ||
904 | - | ||
905 | - | ||
906 | - | 1 | +<?php |
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: Administrator | ||
5 | + * Date: 2018/12/31 | ||
6 | + * Time: 15:35 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace api\index\controller; | ||
10 | + | ||
11 | + | ||
12 | +use api\index\model\AboutModel; | ||
13 | +use api\index\model\ContactModel; | ||
14 | +use api\index\model\JoinModel; | ||
15 | +use api\index\model\VolunteerModel; | ||
16 | +use api\index\model\UserModel; | ||
17 | +use cmf\controller\RestBaseController; | ||
18 | +use EasyWeChat\Foundation\Application; | ||
19 | +use think\Db; | ||
20 | +use think\Validate; | ||
21 | + | ||
22 | +/** | ||
23 | + * @title 个人中心 | ||
24 | + * @description 个人中心 | ||
25 | + */ | ||
26 | +class MemberCenterController extends RestBaseController | ||
27 | +{ | ||
28 | + public function _initialize() | ||
29 | + { | ||
30 | + $user_id = $this->getUserId(); | ||
31 | + $userModel = new UserModel(); | ||
32 | + $user = $userModel->where(array('id'=>$user_id))->find(); | ||
33 | + if($user['user_status'] == 0){ | ||
34 | + $this->error(['code'=>40005,'msg'=>'您已被列入黑名单,请联系管理员!']); | ||
35 | + } | ||
36 | + } | ||
37 | + /** | ||
38 | + * @title 个人中心 | ||
39 | + * @description 个人中心 | ||
40 | + * @author XiaoGang Wang | ||
41 | + * @url /index/member_center/index | ||
42 | + * @method GET | ||
43 | + * | ||
44 | + * @header name:XX-Token require:1 default: desc:token | ||
45 | + * | ||
46 | + * @return id:id | ||
47 | + * @return user_nickname:用户昵称 | ||
48 | + * @return level:用户星级 | ||
49 | + * @return work_time:工作时长 | ||
50 | + * @return avatar:头像 | ||
51 | + * @return type:类型(1为普通,2为管理员) | ||
52 | + * @return is_submit:0为未提交过,1为已提交过 | ||
53 | + */ | ||
54 | + public function index(){ | ||
55 | + $user_id = $this->getUserId(); | ||
56 | + //判断当前用户是否提交过 | ||
57 | + $volunteerModel = new VolunteerModel(); | ||
58 | + $result = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0)); | ||
59 | + // dump($result->toArray()); | ||
60 | + $userModel = new UserModel(); | ||
61 | + $user = $userModel->findData(array('id'=>$user_id)); | ||
62 | + if(empty($result)){ | ||
63 | + $is_submit = 0; | ||
64 | + }else { | ||
65 | + $user['avatar']=$result['photo']; | ||
66 | + $user['user_nickname']=$result['name']; | ||
67 | + $is_submit = 1; | ||
68 | + } | ||
69 | + | ||
70 | + if (empty($result['level'])){ | ||
71 | + $result['level']=0; | ||
72 | + } | ||
73 | + | ||
74 | + if (empty($result['work_time'])){ | ||
75 | + $result['work_time']=0; | ||
76 | + } | ||
77 | + | ||
78 | + $user['level']=$result['level']; | ||
79 | + $user['work_time']=$result['work_time']; | ||
80 | + $user['is_submit'] = $is_submit; | ||
81 | + $this->success('获取成功!',$user); | ||
82 | + } | ||
83 | + /** | ||
84 | + * @title 判断是否为管理员是否提交过申请 | ||
85 | + * @description 判断是否为管理员是否提交过申请 | ||
86 | + * @author XiaoGang Wang | ||
87 | + * @url /index/member_center/is_submit_admin | ||
88 | + * @method GET | ||
89 | + * | ||
90 | + * @header name:XX-Token require:1 default: desc:token | ||
91 | + * | ||
92 | + * @return id:id | ||
93 | + * @return user_nickname:用户昵称 | ||
94 | + * @return avatar:头像 | ||
95 | + * @return type:类型(1为普通,2为管理员) | ||
96 | + * @return is_submit:0为未提交过,1为已提交过 | ||
97 | + */ | ||
98 | + public function is_submit_admin(){ | ||
99 | + $user_id = $this->getUserId(); | ||
100 | + //判断当前用户是否提交过 | ||
101 | + $volunteerModel = new VolunteerModel(); | ||
102 | + $result = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0)); | ||
103 | + if(empty($result)){ | ||
104 | + $is_submit = 0; | ||
105 | + }else{ | ||
106 | + $is_submit = 1; | ||
107 | + } | ||
108 | + //判断这个用户是不是管理员 | ||
109 | + $userModel = new UserModel(); | ||
110 | + $user = $userModel->findData(array('id'=>$user_id)); | ||
111 | + if($user['type'] != 2){ | ||
112 | + $is_admin = 0; | ||
113 | + }else{ | ||
114 | + $is_admin = 1; | ||
115 | + } | ||
116 | + $data['is_submit'] = $is_submit; | ||
117 | + $data['is_admin'] = $is_admin; | ||
118 | + $this->success('获取成功!',$data); | ||
119 | + } | ||
120 | + /** | ||
121 | + * @title 提交审核 | ||
122 | + * @description 提交审核 | ||
123 | + * @author XiaoGang Wang | ||
124 | + * @url /index/member_center/submit_form | ||
125 | + * @method GET | ||
126 | + * | ||
127 | + * @header name:XX-Token require:1 default: desc:token | ||
128 | + * | ||
129 | + * @param name:form_id type:str require:1 other: desc:表单id | ||
130 | + * @param name:name type:str require:1 other: desc:姓名 | ||
131 | + * @param name:sex type:str require:1 other: desc:性别(1男,2女) | ||
132 | + * @param name:birthday type:str require:1 other: desc:生日 | ||
133 | + * @param name:nation type:str require:1 other: desc:民族 | ||
134 | + * @param name:politics type:str require:1 other: desc:政治面貌 | ||
135 | + * @param name:education type:str require:1 other: desc:学历 | ||
136 | + * @param name:unit type:str require:1 other: desc:工作单位 | ||
137 | + * @param name:duty type:str require:1 other: desc:职务 | ||
138 | + * @param name:addr type:str require:1 other: desc:通讯地址 | ||
139 | + * @param name:postcode type:str require:1 other: desc:邮编 | ||
140 | + * @param name:school type:str require:1 other: desc:毕业院校 | ||
141 | + * @param name:card_number type:str require:1 other: desc:身份证号码 | ||
142 | + * @param name:fixed_phone type:str require:1 other: desc:固定电话 | ||
143 | + * @param name:move_phone type:str require:1 other: desc:移动电话 | ||
144 | + * @param name:email type:str require:1 other: desc:email | ||
145 | + * @param name:urgency_phone type:str require:1 other: desc:紧急联系人电话 | ||
146 | + * @param name:qq type:str require:1 other: desc:qq | ||
147 | + * @param name:province type:str require:1 other: desc:省 | ||
148 | + * @param name:city type:str require:1 other: desc:市 | ||
149 | + * @param name:county type:str require:1 other: desc:区/县 | ||
150 | + * @param name:address type:str require:1 other: desc:详细地址 | ||
151 | + * @param name:type type:int require:1 other: desc:1医院志愿者,2社会志愿者,3办事处志愿者 | ||
152 | + * @param name:record_start_time type:str require:1 other: desc:开始时间 | ||
153 | + * @param name:record_end_time type:str require:1 other: desc:结束时间 | ||
154 | + * @param name:record_unit type:str require:1 other: desc:单位 | ||
155 | + * @param name:record_duty type:str require:1 other: desc:职务 | ||
156 | + * @param name:record_name type:str require:1 other: desc:证明人 | ||
157 | + * @param name:record_phone type:str require:1 other: desc:证明人电话 | ||
158 | + * @param name:front_card type:str require:1 other: desc:身份证正面照 | ||
159 | + * @param name:reverse_card type:str require:1 other: desc:身份证背面照 | ||
160 | + * @param name:photo type:str require:1 other: desc:照片 | ||
161 | + */ | ||
162 | + public function submit_form(){ | ||
163 | + $user_id = $this->getUserId(); | ||
164 | + $param = $this->request->param(); | ||
165 | + $validate = new Validate([ | ||
166 | + 'name' => 'require', | ||
167 | + 'sex' => 'require', | ||
168 | + 'birthday' => 'require', | ||
169 | + 'nation' => 'require', | ||
170 | + 'politics' => 'require', | ||
171 | + 'education' => 'require', | ||
172 | + 'unit' => 'require', | ||
173 | + 'duty' => 'require', | ||
174 | + 'addr' => 'require', | ||
175 | + 'postcode' => 'require', | ||
176 | + 'school' => 'require', | ||
177 | + 'card_number' => 'require', | ||
178 | +// 'fixed_phone' => 'require', | ||
179 | + 'move_phone' => 'require', | ||
180 | + 'email' => 'require', | ||
181 | + 'urgency_phone' => 'require', | ||
182 | + 'qq' => 'require', | ||
183 | + 'province' => 'require', | ||
184 | + 'city' => 'require', | ||
185 | +// 'county' => 'require', | ||
186 | + 'address' => 'require', | ||
187 | + 'record_start_time' => 'require', | ||
188 | + 'record_end_time' => 'require', | ||
189 | + 'record_unit' => 'require', | ||
190 | + 'record_duty' => 'require', | ||
191 | + 'record_name' => 'require', | ||
192 | + 'record_phone' => 'require', | ||
193 | + 'front_card' => 'require', | ||
194 | + 'reverse_card' => 'require', | ||
195 | + 'photo' => 'require', | ||
196 | + ]); | ||
197 | + $validate->message([ | ||
198 | + 'name' => '缺少参数name', | ||
199 | + 'sex' => '缺少参数sex', | ||
200 | + 'birthday' => '缺少参数birthday', | ||
201 | + 'nation' => '缺少参数nation', | ||
202 | + 'politics' => '缺少参数politics', | ||
203 | + 'education' => '缺少参数education', | ||
204 | + 'unit' => '缺少参数unit', | ||
205 | + 'duty' => '缺少参数duty', | ||
206 | + 'addr' => '缺少参数addr', | ||
207 | + 'postcode' => '缺少参数postcode', | ||
208 | + 'school' => '缺少参数school', | ||
209 | + 'card_number' => '缺少参数card_number', | ||
210 | +// 'fixed_phone' => '缺少参数fixed_phone', | ||
211 | + 'move_phone' => '缺少参数move_phone', | ||
212 | + 'email' => '缺少参数email', | ||
213 | + 'urgency_phone' => '缺少参数urgency_phone', | ||
214 | + 'qq' => '缺少参数qq', | ||
215 | + 'province' => '缺少参数province', | ||
216 | + 'city' => '缺少参数city', | ||
217 | +// 'county' => '缺少参数county', | ||
218 | + 'address' => '缺少参数address', | ||
219 | + 'record_start_time' => '缺少参数record_start_time', | ||
220 | + 'record_end_time' => '缺少参数record_end_time', | ||
221 | + 'record_unit' => '缺少参数record_unit', | ||
222 | + 'record_duty' => '缺少参数record_duty', | ||
223 | + 'record_name' => '缺少参数record_name', | ||
224 | + 'record_phone' => '缺少参数record_phone', | ||
225 | + 'front_card' => '缺少参数front_card', | ||
226 | + 'reverse_card' => '缺少参数reverse_card', | ||
227 | + 'photo' => '缺少参数photo', | ||
228 | + ]); | ||
229 | + if (!$validate->check($param)) { | ||
230 | + $this->error($validate->getError()); | ||
231 | + } | ||
232 | + $record_start_time = explode(',',$param['record_start_time']); | ||
233 | + $record_end_time = explode(',',$param['record_end_time']); | ||
234 | + $record_unit = explode(',',$param['record_unit']); | ||
235 | + $record_duty = explode(',',$param['record_duty']); | ||
236 | + $record_name = explode(',',$param['record_name']); | ||
237 | + $record_phone = explode(',',$param['record_phone']); | ||
238 | + $record = []; | ||
239 | + foreach($record_start_time as $key => $r_s_t){ | ||
240 | + $record[$key]['record_start_time'] = !empty($r_s_t) ? $r_s_t : ''; | ||
241 | + $record[$key]['record_end_time'] = !empty($record_end_time[$key]) ? $record_end_time[$key] : ''; | ||
242 | + $record[$key]['record_unit'] = !empty($record_unit[$key]) ? $record_unit[$key] :''; | ||
243 | + $record[$key]['record_duty'] = !empty($record_duty[$key]) ? $record_duty[$key] :''; | ||
244 | + $record[$key]['record_name'] = !empty($record_name[$key]) ? $record_name[$key] :''; | ||
245 | + $record[$key]['record_phone'] = !empty($record_phone[$key]) ? $record_phone[$key] :''; | ||
246 | + } | ||
247 | + if(!empty($record)){ | ||
248 | + $record = json_encode($record); | ||
249 | + }else{ | ||
250 | + $record = null; | ||
251 | + } | ||
252 | + $data = [ | ||
253 | + 'name' => $param['name'], | ||
254 | + 'sex' => $param['sex'], | ||
255 | + 'birthday' => $param['birthday'], | ||
256 | + 'nation' => $param['nation'], | ||
257 | + 'politics' => $param['politics'], | ||
258 | + 'education' => $param['education'], | ||
259 | + 'unit' => $param['unit'], | ||
260 | + 'duty' => $param['duty'], | ||
261 | + 'addr' => $param['addr'], | ||
262 | + 'postcode' => $param['postcode'], | ||
263 | + 'school' => $param['school'], | ||
264 | + 'card_number' => $param['card_number'], | ||
265 | + 'fixed_phone' => $param['fixed_phone'], | ||
266 | + 'move_phone' => $param['move_phone'], | ||
267 | + 'email' => $param['email'], | ||
268 | + 'urgency_phone' => $param['urgency_phone'], | ||
269 | + 'qq' => $param['qq'], | ||
270 | + 'province' => $param['province'], | ||
271 | + 'city' => $param['city'], | ||
272 | + 'county' => !empty($param['county'])?$param['county']:null, | ||
273 | + 'address' => $param['address'], | ||
274 | + /* 'type' => $param['type'],*/ | ||
275 | + 'record' => $record, | ||
276 | + 'front_card' => $param['front_card'], | ||
277 | + 'reverse_card' => $param['reverse_card'], | ||
278 | + 'photo' => $param['photo'], | ||
279 | + 'status' => 1, | ||
280 | + 'user_id' => $user_id, | ||
281 | + ]; | ||
282 | + $form_id=input('form_id'); | ||
283 | + if (!empty($form_id)){ | ||
284 | + $this->saveFormId($user_id,$form_id); | ||
285 | + } | ||
286 | + $volunteerModel = new VolunteerModel(); | ||
287 | + $result1 = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0)); | ||
288 | + //判断该用户是否提交过 | ||
289 | + if(!empty($result1)){ | ||
290 | + $data['update_time'] = time(); | ||
291 | + $volunteerModel->updateData(array('id'=>$result1['id']),$data); | ||
292 | + }else{ | ||
293 | + $data['create_time'] = time(); | ||
294 | + $volunteerModel->insertData($data); | ||
295 | + } | ||
296 | + $this->success('提交成功!'); | ||
297 | + } | ||
298 | + /** | ||
299 | + * @title 进入修改页面 | ||
300 | + * @description 进入修改页面 | ||
301 | + * @author XiaoGang Wang | ||
302 | + * @url /index/member_center/edit | ||
303 | + * @method GET | ||
304 | + * | ||
305 | + * @header name:XX-Token require:1 default: desc:token | ||
306 | + * | ||
307 | + * @return name:姓名 | ||
308 | + * @return sex:性别(1男,2女) | ||
309 | + * @return birthday:生日 | ||
310 | + * @return nation:民族 | ||
311 | + * @return politics:政治面貌 | ||
312 | + * @return education:学历 | ||
313 | + * @return unit:工作单位 | ||
314 | + * @return duty:职务 | ||
315 | + * @return addr:通讯地址 | ||
316 | + * @return postcode:邮编 | ||
317 | + * @return school: desc:毕业院校 | ||
318 | + * @return card_number :身份证号码 | ||
319 | + * @return fixed_phone:固定电话 | ||
320 | + * @return move_phone:移动电话 | ||
321 | + * @return email:email | ||
322 | + * @return urgency_phone:紧急联系人电话 | ||
323 | + * @return qq:qq | ||
324 | + * @return province:省 | ||
325 | + * @return city:市 | ||
326 | + * @return county:区/县 | ||
327 | + * @return address:详细地址 | ||
328 | + * @return type:1医院志愿者,2社会志愿者,3办事处志愿者 | ||
329 | + * @return record_start_time:开始时间 | ||
330 | + * @return record_end_time:结束时间 | ||
331 | + * @return record_unit:单位 | ||
332 | + * @return record_duty:职务 | ||
333 | + * @return record_name:证明人 | ||
334 | + * @return record_phone:证明人电话 | ||
335 | + * @return front_card type:str require:1 other: desc:身份证正面照 | ||
336 | + * @return reverse_card:身份证背面照 | ||
337 | + * @return photo:照片 | ||
338 | + */ | ||
339 | + public function edit(){ | ||
340 | +// $user_id = $this->getUserId(); | ||
341 | + $user_id = $this->request->param('id'); | ||
342 | + //判断当前用户是否提交过 | ||
343 | + $volunteerModel = new VolunteerModel(); | ||
344 | + $result = $volunteerModel->findData(array('user_id'=>$user_id,'delete_time'=>0)); | ||
345 | + $this->success('获取成功!',$result); | ||
346 | + } | ||
347 | + /** | ||
348 | + * @title 查看审核状态 | ||
349 | + * @description 查看审核状态 | ||
350 | + * @author XiaoGang Wang | ||
351 | + * @url /index/member_center/status | ||
352 | + * @method GET | ||
353 | + * | ||
354 | + * @header name:XX-Token require:1 default: desc:token | ||
355 | + * | ||
356 | + * @return id:id | ||
357 | + * @return status:状态(1审核中,2审核成功,3审核失败) | ||
358 | + */ | ||
359 | + public function status(){ | ||
360 | + $user_id = $this->getUserId(); | ||
361 | + $volunteerModel = new VolunteerModel(); | ||
362 | + $data = $volunteerModel->findData(array('user_id'=>$user_id)); | ||
363 | + if(empty($data)){ | ||
364 | + $this->success(['code'=>40001,'msg'=>'您还没有提交过申请!']); | ||
365 | + } | ||
366 | + $this->success('获取成功!',$data); | ||
367 | + } | ||
368 | + /** | ||
369 | + * @title 管理员审核 | ||
370 | + * @description 管理员审核 | ||
371 | + * @author XiaoGang Wang | ||
372 | + * @url /index/member_center/admin | ||
373 | + * @method GET | ||
374 | + * | ||
375 | + * @header name:XX-Token require:1 default: desc:token | ||
376 | + * | ||
377 | + * @param name:page type:int require:0 other: desc:志愿者当前页(0为第一页)(默认0) | ||
378 | + * @param name:pageNum type:int require:0 other: desc:活动显示数量(默认10) | ||
379 | + * | ||
380 | + * @return volunteer:志愿者@ | ||
381 | + * @volunteer id:id name:姓名 sex:性别 birthday:生日 nation:民族 politics:政治面貌 education:学历 unit:工作单位 duty:职务 addr:通讯地址 postcode:邮编 school:毕业院校 card_number:身份证号 fixed_phone:固定电话 move_phone:移动电话 email:email urgency_phone:紧急联系电话 qq:qq province:省 city:市 county:区/县 address:详细地址 type:志愿者类型(0医院志愿者,2社会志愿者,3办事处志愿者) record:个人履历@ front_card:身份证正面照 reverse_card:身份证背面照 photo:照片 status:状态(1审核中,2审核成功,3审核失败) user_id:用户id | ||
382 | + * @record record_start_time:开始时间 record_end_time:结束时间 record_unit:单位 record_duty:职务 record_name:证明人 record_phone:证明人电话 | ||
383 | + * @return page:志愿者下一页 | ||
384 | + * @return page:活动下一页 | ||
385 | + */ | ||
386 | + public function admin(){ | ||
387 | + $user_id = $this->getUserId(); | ||
388 | + //判断这个用户是不是管理员 | ||
389 | + $userModel = new UserModel(); | ||
390 | + $user = $userModel->findData(array('id'=>$user_id)); | ||
391 | + if($user['type'] != 2){ | ||
392 | + $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
393 | + } | ||
394 | + $param = $this->request->param(); | ||
395 | + $page = !empty($param['page']) ? $param['page'] : 0;//当前页数下标 | ||
396 | + $pageNum = !empty($param['pageNum']) ? $param['pageNum'] : 10;//每页显示几条数据 | ||
397 | + //获取志愿者 | ||
398 | + $volunteerModel = new VolunteerModel(); | ||
399 | + // $volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>['in','1,2'])); | ||
400 | + $volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>'1')); | ||
401 | + $data['volunteer'] = $volunteer; | ||
402 | + $data['page'] = $page+1; | ||
403 | + $this->success('获取成功!',$data); | ||
404 | + } | ||
405 | + | ||
406 | + /** | ||
407 | + * @title 工时管理列表(new) | ||
408 | + * @description | ||
409 | + * @author XiaoGang Wang | ||
410 | + * @url /index/member_center/addTimeList | ||
411 | + * @method GET | ||
412 | + * | ||
413 | + * @header name:XX-Token require:1 default: desc:token | ||
414 | + * | ||
415 | + * @param name:page type:int require:0 other: desc:志愿者当前页(0为第一页)(默认0) | ||
416 | + * @param name:pageNum type:int require:0 other: desc:活动显示数量(默认10) | ||
417 | + * | ||
418 | + * @return volunteer:志愿者@ | ||
419 | + * @volunteer id:id name:姓名 sex:性别 birthday:生日 nation:民族 politics:政治面貌 education:学历 unit:工作单位 duty:职务 addr:通讯地址 postcode:邮编 school:毕业院校 card_number:身份证号 fixed_phone:固定电话 move_phone:移动电话 email:email urgency_phone:紧急联系电话 qq:qq province:省 city:市 county:区/县 address:详细地址 type:志愿者类型(0医院志愿者,2社会志愿者,3办事处志愿者) record:个人履历@ front_card:身份证正面照 reverse_card:身份证背面照 photo:照片 status:状态(1审核中,2审核成功,3审核失败) user_id:用户id | ||
420 | + * @record record_start_time:开始时间 record_end_time:结束时间 record_unit:单位 record_duty:职务 record_name:证明人 record_phone:证明人电话 | ||
421 | + * @return page:志愿者下一页 | ||
422 | + * @return page:活动下一页 | ||
423 | + * | ||
424 | + */ | ||
425 | + public function addTimeList(){ | ||
426 | + $user_id = $this->getUserId(); | ||
427 | + //判断这个用户是不是管理员 | ||
428 | + $userModel = new UserModel(); | ||
429 | + $user = $userModel->findData(array('id'=>$user_id)); | ||
430 | + if($user['type'] != 2){ | ||
431 | + $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
432 | + } | ||
433 | + $param = $this->request->param(); | ||
434 | + $page = !empty($param['page']) ? $param['page'] : 0;//当前页数下标 | ||
435 | + $pageNum = !empty($param['pageNum']) ? $param['pageNum'] : 10;//每页显示几条数据 | ||
436 | + //获取志愿者 | ||
437 | + $volunteerModel = new VolunteerModel(); | ||
438 | + // $volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>['in','1,2'])); | ||
439 | + $volunteer = $volunteerModel->selectData($page,$pageNum,array('status'=>'2')); | ||
440 | + $data['volunteer'] = $volunteer; | ||
441 | + $data['page'] = $page+1; | ||
442 | + $this->success('获取成功!',$data); | ||
443 | + } | ||
444 | + | ||
445 | + | ||
446 | + /** | ||
447 | + * @title 管理员添加时间(new) | ||
448 | + * @description 管理员审核 | ||
449 | + * @author XiaoGang Wang | ||
450 | + * @url /index/member_center/addTime | ||
451 | + * @method GET | ||
452 | + * | ||
453 | + * @header name:XX-Token require:1 default: desc:token | ||
454 | + * | ||
455 | + * @param name:join_id type:int require:0 other: desc:参加id | ||
456 | + * | ||
457 | + */ | ||
458 | + public function addTime(){ | ||
459 | + | ||
460 | + | ||
461 | + $user_id = $this->getUserId(); | ||
462 | + //判断这个用户是不是管理员 | ||
463 | + $userModel = new UserModel(); | ||
464 | + $user = $userModel->findData(array('id'=>$user_id)); | ||
465 | + if($user['type'] != 2){ | ||
466 | + $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
467 | + } | ||
468 | + $map['id']=input('join_id'); | ||
469 | + $time=input('add_time'); | ||
470 | + $user_id1=input('user_id'); | ||
471 | + if (empty($user_id1)){ | ||
472 | + $join=\db('join')->where($map)->find(); | ||
473 | + if (empty($join)){ | ||
474 | + $this->error('参数错误'); | ||
475 | + } | ||
476 | + $joinUpdate['work_time']=$time; | ||
477 | + \db('join')->where($map)->update($joinUpdate); | ||
478 | + if ($time>$join['work_time']){ | ||
479 | + $add_time=$time-$join['work_time']; | ||
480 | + $volunteerUpdate['work_time']=$add_time; | ||
481 | + \db('volunteer')->where('user_id',$join['user_id'])->setInc('work_time',$add_time); | ||
482 | + }else{ | ||
483 | + $add_time=$join['work_time']-$time; | ||
484 | + \db('volunteer')->where('user_id',$join['user_id'])->setDec('work_time',$add_time); | ||
485 | + } | ||
486 | + }else{ | ||
487 | + \db('volunteer')->where('user_id',$user_id1)->setInc('work_time',$time); | ||
488 | + } | ||
489 | + $result=1; | ||
490 | + /* // $data['add_time']=['exp','work_time'+$time]; | ||
491 | + $result=db('volunteer')->where($map)->setInc('work_time',$time); | ||
492 | + // echo db('volunteer')->getLastSql();*/ | ||
493 | + if ($result>0){ | ||
494 | + $this->success('修改成功!'); | ||
495 | + }else{ | ||
496 | + $this->error('此人不是审核通过的志愿者!'); | ||
497 | + } | ||
498 | + } | ||
499 | + | ||
500 | + | ||
501 | + | ||
502 | + | ||
503 | + | ||
504 | + | ||
505 | + /** | ||
506 | + * @title 管理员查看活动申请详情 | ||
507 | + * @description 管理员审核 | ||
508 | + * @author XiaoGang Wang | ||
509 | + * @url /index/member_center/adminGetApplyInfo | ||
510 | + * @method GET | ||
511 | + * | ||
512 | + * @header name:XX-Token require:1 default: desc:token | ||
513 | + * | ||
514 | + * @param name:join_id type:int require:0 other: desc:报名id | ||
515 | + * | ||
516 | + */ | ||
517 | + public function adminGetApplyInfo(){ | ||
518 | + $map['id']=input('join_id'); | ||
519 | + $user_id = $this->getUserId(); | ||
520 | + //判断这个用户是不是管理员 | ||
521 | + $userModel = new UserModel(); | ||
522 | + $user = $userModel->findData(array('id'=>$user_id)); | ||
523 | + if($user['type'] != 2){ | ||
524 | + $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
525 | + } | ||
526 | + /*获取*/ | ||
527 | + | ||
528 | + | ||
529 | + | ||
530 | + if (!empty($return['time'])){ | ||
531 | + $return['time']= array_reverse($return['time']); | ||
532 | + } | ||
533 | + | ||
534 | + $info=db('join')->field('card_number,sgin_time,id,type,user_id,activity_id,select_time,apply_stay,apply_food,work_content')->where($map)->find(); | ||
535 | + $user=db('volunteer')->field('card_number,sex,name,birthday,move_phone')->where('user_id',$info['user_id'])->find(); | ||
536 | + if (!empty($user)){ | ||
537 | + $return['name']=$user['name']; | ||
538 | + $return['birthday']=$user['birthday']; | ||
539 | + $return['sex']=$user['sex']==1?'男':'女'; | ||
540 | + $return['tel']=$user['move_phone']; | ||
541 | + } | ||
542 | + if (!empty($info)){ | ||
543 | + $return['work_content']=db('work')->where('id',$info['work_content'])->value('name'); | ||
544 | + $return['work_content']=$info['work_content']; | ||
545 | + $return['select_time']=json_decode($info['select_time'],true); | ||
546 | + $return['apply_stay']=json_decode($info['apply_stay'],true); | ||
547 | + $return['apply_food']=json_decode($info['apply_food'],true); | ||
548 | + $return['id']=$info['id']; | ||
549 | + $return['work_type']=$info['type']; | ||
550 | + $return['card_number']=$user['card_number']; | ||
551 | + $return['is_complete']=$info['sgin_time']==0?'0':'1'; | ||
552 | + /* switch ($info['type']){ | ||
553 | + case 1: | ||
554 | + $return['work_type']='线上'; | ||
555 | + break; | ||
556 | + case 2: | ||
557 | + $return['work_type']='线下'; | ||
558 | + break; | ||
559 | + case 3: | ||
560 | + $return['work_type']='线上及线下'; | ||
561 | + break; | ||
562 | + | ||
563 | + }*/ | ||
564 | + } | ||
565 | + | ||
566 | + $this->success('',$return); | ||
567 | + | ||
568 | + | ||
569 | + } | ||
570 | + | ||
571 | + | ||
572 | + | ||
573 | + /** | ||
574 | + * @title 管理员更新状态 | ||
575 | + * @description 管理员更新状态 | ||
576 | + * @author XiaoGang Wang | ||
577 | + * @url /index/member_center/update_status | ||
578 | + * @method GET | ||
579 | + * | ||
580 | + * @header name:XX-Token require:1 default: desc:token | ||
581 | + * | ||
582 | + * @param name:id type:int require:1 other: desc:志愿者id | ||
583 | + * @param name:status type:int require:1 other: desc:状态(点击审核通过传2,点击审核失败传3) | ||
584 | + * @param name:refund_reason type:int require:1 other: desc:审核不通过原因 | ||
585 | + */ | ||
586 | + public function update_status(){ | ||
587 | + $user_id = $this->getUserId(); | ||
588 | + | ||
589 | + $id = $this->request->param('id'); | ||
590 | + if(empty($id)){ | ||
591 | + $this->error('缺少参数id'); | ||
592 | + } | ||
593 | + $data['refund_reason']=input('refund_reason')??''; | ||
594 | + $status = $this->request->param('status'); | ||
595 | + if(empty($status)){ | ||
596 | + $this->error('缺少参数status'); | ||
597 | + } | ||
598 | + if($status != 2 && $status != 3){ | ||
599 | + $this->error('status参数错误!'); | ||
600 | + } | ||
601 | + //判断这个用户是不是管理员 | ||
602 | + $userModel = new UserModel(); | ||
603 | + $user = $userModel->findData(array('id'=>$user_id)); | ||
604 | + if($user['type'] != 2){ | ||
605 | + $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
606 | + } | ||
607 | + //获取志愿者 | ||
608 | + $volunteerModel = new VolunteerModel(); | ||
609 | + $data['status']=input('status'); | ||
610 | + | ||
611 | + if ($data['status']==2){ | ||
612 | + $keyword='审核通过'; | ||
613 | + }else{ | ||
614 | + $keyword="审核未通过 原因:$data[refund_reason]"; | ||
615 | + } | ||
616 | + | ||
617 | + $result = $volunteerModel->updateData(array('id'=>$id),$data); | ||
618 | + if(empty($result)){ | ||
619 | + $this->success(['code'=>40002,'msg'=>'当前申请可能已被其他管理员审核,请刷新页面!']); | ||
620 | + } | ||
621 | + | ||
622 | + $volunteer=db('volunteer')->where('id',$id)->find(); | ||
623 | + $userMap['user_id']=$volunteer['user_id']; | ||
624 | + $openid=db('third_party_user')->where($userMap)->value('openid'); | ||
625 | + $formMap['user_id']=$volunteer['user_id']; | ||
626 | + $formMap['use_time']=0; | ||
627 | + $formMap['expire_time']=['>',time()]; | ||
628 | + $form_id=\db('form_id')->where($formMap)->find(); | ||
629 | + $now=time(); | ||
630 | + \db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>$now]); | ||
631 | + if (!empty($form_id)){ | ||
632 | + $data['keyword1']= $volunteer['name']; | ||
633 | + $data['keyword2']='志愿者审核'; | ||
634 | + $data['keyword3']=$keyword; | ||
635 | + $data['keyword4']='志愿者审核'; | ||
636 | + $message = [ | ||
637 | + 'touser' => $openid, | ||
638 | + 'template_id' => '1FYkLuMK8LNKO4_nxJ_DuNQhgIjaaJQlAukgt92C-uw', | ||
639 | + 'page' => 'pages/index/index', | ||
640 | + 'form_id' => $form_id['value'], | ||
641 | + 'data' => $data, | ||
642 | + 'emphasis_keyword' =>$data['keyword3']='状态', | ||
643 | + ]; | ||
644 | + $this->wxappNotice($message); | ||
645 | + } | ||
646 | + $this->success(['code'=>20000,'msg'=>'更新成功!']); | ||
647 | + } | ||
648 | + | ||
649 | + | ||
650 | + /** | ||
651 | + * @title 获取人员参与状态 | ||
652 | + * @description 管理员更新状态 | ||
653 | + * @author XiaoGang Wang | ||
654 | + * @url /index/member_center/getJoinPerson | ||
655 | + * @method GET | ||
656 | + * | ||
657 | + * @header name:XX-Token require:1 default: desc:token | ||
658 | + * | ||
659 | + * @param name:id type:int require:1 other: desc:活动id | ||
660 | + * | ||
661 | + * @return photo:摄影(设备自带) | ||
662 | + * @return camera:摄像(设备自带) | ||
663 | + * @return motorcade:爱心车队 | ||
664 | + * @return service:现场服务(签到、指引、礼仪等) | ||
665 | + * @return question:线上答疑 | ||
666 | + * @return ill:门诊服务 | ||
667 | + * @return name:status0,未审核1,已通过2,未通过3,已填写工作汇报(已通过) | ||
668 | + */ | ||
669 | + public function getJoinPerson(){ | ||
670 | + $user_id = $this->getUserId(); | ||
671 | + //判断这个用户是不是管理员 | ||
672 | + $userModel = new UserModel(); | ||
673 | + $user = $userModel->findData(array('id'=>$user_id)); | ||
674 | + if($user['type'] != 2){ | ||
675 | + $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
676 | + } | ||
677 | + //活动id | ||
678 | + $id=input('id'); | ||
679 | + $map['activity_id']=$id; | ||
680 | + $map['j.delete_time']=0; | ||
681 | + | ||
682 | + /* $info=db('join')->alias('j') | ||
683 | + ->group('j.user_id') | ||
684 | + ->field('v.*,j.*,j.id as join_id,j.status as status') | ||
685 | + ->join('volunteer v','v.user_id=j.user_id') | ||
686 | + ->where($map) | ||
687 | + ->order('j.id','asc') | ||
688 | + ->select() | ||
689 | + ->toArray();*/ | ||
690 | + /* $subQuery = db('join')->alias('j') | ||
691 | + ->field('j.user_id,v.name,v.photo,j.id as join_id,j.status as status,j.delete_time,j.activity_id,j.work_content') | ||
692 | + ->join('volunteer v','v.user_id=j.user_id') | ||
693 | + ->where($map) | ||
694 | + ->order('j.id','desc') | ||
695 | + ->buildSql(); | ||
696 | + dump($subQuery); | ||
697 | + $info= Db::table($subQuery.'a') | ||
698 | + ->group('a.user_id') | ||
699 | + ->select() | ||
700 | + ->toArray();*/ | ||
701 | + $new_map=[]; | ||
702 | + $subQuery = db('join')->alias('j') | ||
703 | + ->field('max(j.id)') | ||
704 | + ->join('volunteer v','v.user_id=j.user_id') | ||
705 | + ->where($map) | ||
706 | + ->group('j.user_id') | ||
707 | + ->select() | ||
708 | + ->toArray(); | ||
709 | + if (!empty($subQuery)){ | ||
710 | + foreach ($subQuery as $k=>$v){ | ||
711 | + $new_map[]=$v["max(j.id)"]; | ||
712 | + } | ||
713 | + } | ||
714 | + $map1['j.id']=['in',implode(',',$new_map)]; | ||
715 | + | ||
716 | + | ||
717 | + $info=db('join')->alias('j') | ||
718 | + ->group('j.user_id') | ||
719 | + ->field('v.*,j.*,j.id as join_id,j.status as status') | ||
720 | + ->join('volunteer v','v.user_id=j.user_id') | ||
721 | + ->where($map1) | ||
722 | + ->order('j.id','asc') | ||
723 | + ->select() | ||
724 | + ->toArray(); | ||
725 | + | ||
726 | + /*$info=db('join_view') | ||
727 | + ->group('user_id') | ||
728 | + ->where($map) | ||
729 | + ->select() | ||
730 | + ->toArray();*/ | ||
731 | + | ||
732 | + // echo db('join')->getLastSql(); | ||
733 | + | ||
734 | + $return=[]; | ||
735 | + $i0=0; | ||
736 | + $i1=0; | ||
737 | + $i2=0; | ||
738 | + $i3=0; | ||
739 | + $i4=0; | ||
740 | + $i5=0; | ||
741 | + | ||
742 | + foreach($info as $k=>$v){ | ||
743 | + switch ($v['work_content']){ | ||
744 | + case 1: | ||
745 | + $return[0]['title']='摄影(设备自带)'; | ||
746 | + $return[0]['arr'][$i0]['id']=$v['join_id']; | ||
747 | + $return[0]['arr'][$i0]['photo']=$v['photo']; | ||
748 | + $return[0]['arr'][$i0]['name']=$v['name']; | ||
749 | + $return[0]['arr'][$i0]['user_id']=$v['user_id']; | ||
750 | + $return[0]['arr'][$i0]['status']=$this->switchStatus($v['status']); | ||
751 | + $i0++; | ||
752 | + break; | ||
753 | + case 2: | ||
754 | + $return[1]['title']='摄像(设备自带)'; | ||
755 | + $return[1]['arr'][$i1]['id']=$v['join_id']; | ||
756 | + $return[1]['arr'][$i1]['photo']=$v['photo']; | ||
757 | + $return[1]['arr'][$i1]['name']=$v['name']; | ||
758 | + $return[1]['arr'][$i1]['user_id']=$v['user_id']; | ||
759 | + $return[1]['arr'][$i1]['status']=$this->switchStatus($v['status']); | ||
760 | + $i1++; | ||
761 | + break; | ||
762 | + case 3: | ||
763 | + $return[2]['title']='爱心车队'; | ||
764 | + $return[2]['arr'][$i2]['id']=$v['join_id']; | ||
765 | + $return[2]['arr'][$i2]['photo']=$v['photo']; | ||
766 | + $return[2]['arr'][$i2]['name']=$v['name']; | ||
767 | + $return[2]['arr'][$i2]['user_id']=$v['user_id']; | ||
768 | + $return[2]['arr'][$i2]['status']=$this->switchStatus($v['status']); | ||
769 | + $i2++; | ||
770 | + break; | ||
771 | + case 4: | ||
772 | + $return[3]['title']='现场服务(签到、指引、礼仪等)'; | ||
773 | + $return[3]['arr'][$i3]['id']=$v['join_id']; | ||
774 | + $return[3]['arr'][$i3]['photo']=$v['photo']; | ||
775 | + $return[3]['arr'][$i3]['name']=$v['name']; | ||
776 | + $return[3]['arr'][$i3]['user_id']=$v['user_id']; | ||
777 | + $return[3]['arr'][$i3]['status']=$this->switchStatus($v['status']); | ||
778 | + $i3++; | ||
779 | + break; | ||
780 | + case 5: | ||
781 | + $return[4]['title']='线上答疑'; | ||
782 | + $return[4]['arr'][$i4]['id']=$v['join_id']; | ||
783 | + $return[4]['arr'][$i4]['photo']=$v['photo']; | ||
784 | + $return[4]['arr'][$i4]['name']=$v['name']; | ||
785 | + $return[4]['arr'][$i4]['user_id']=$v['user_id']; | ||
786 | + $return[4]['arr'][$i4]['status']=$this->switchStatus($v['status']); | ||
787 | + $i4++; | ||
788 | + break; | ||
789 | + case 6: | ||
790 | + $return[5]['title']='门诊服务'; | ||
791 | + | ||
792 | + /*判断是否有user_id*/ | ||
793 | + $return[5]['arr'][$i5]['id']=$v['join_id']; | ||
794 | + $return[5]['arr'][$i5]['photo']=$v['photo']; | ||
795 | + $return[5]['arr'][$i5]['name']=$v['name']; | ||
796 | + $return[5]['arr'][$i5]['user_id']=$v['user_id']; | ||
797 | + $return[5]['arr'][$i5]['status']=$this->switchStatus($v['status']); | ||
798 | + $i5++; | ||
799 | + break; | ||
800 | + } | ||
801 | + } | ||
802 | + foreach ($return as $k=>$v){ | ||
803 | + foreach($return[$k] as $k1=>$v1){ | ||
804 | + | ||
805 | + } | ||
806 | + } | ||
807 | + | ||
808 | + | ||
809 | + $this->success('',$return); | ||
810 | + } | ||
811 | + /** | ||
812 | + * @title 管理员审核活动申请是否通过(new) | ||
813 | + * @description 管理员更新状态 | ||
814 | + * @author XiaoGang Wang | ||
815 | + * @url /index/member_center/adminApprove | ||
816 | + * @method GET | ||
817 | + * | ||
818 | + * @header name:XX-Token require:1 default: desc:token | ||
819 | + * | ||
820 | + * @param name:id type:int require:1 other: desc:参加id | ||
821 | + * @param name:status type:int require:1 other: desc:1通过2.拒绝 | ||
822 | + * @param name:refund_reason type:int require:1 other: desc:拒绝理由 | ||
823 | + * | ||
824 | + * | ||
825 | + */ | ||
826 | + public function adminApprove(){ | ||
827 | + $user_id = $this->getUserId(); | ||
828 | + //判断这个用户是不是管理员 | ||
829 | + | ||
830 | + $userModel = new UserModel(); | ||
831 | + $user = $userModel->findData(array('id'=>$user_id)); | ||
832 | + if($user['type'] != 2){ | ||
833 | + $this->success(['code'=>40001,'msg'=>'查无此人!']); | ||
834 | + } | ||
835 | + $map['id']=input('id'); | ||
836 | + $data['status']=input('status'); | ||
837 | + $refund_reason=input('refund_reason'); | ||
838 | + if (!empty($refund_reason)){ | ||
839 | + $data['refund_reason']=input('refund_reason'); | ||
840 | + } | ||
841 | + $result=db('join')->where($map)->update($data); | ||
842 | + if ($result>0){ | ||
843 | + $join=\db('join')->where($map)->find(); | ||
844 | + $activity=\db('activity')->where('id',$join['activity_id'])->find(); | ||
845 | + $userMap['user_id']=$join['user_id']; | ||
846 | + $openid=db('third_party_user')->where($userMap)->value('openid'); | ||
847 | + $volunteer=\db('volunteer')->where('user_id',$join['user_id'])->find(); | ||
848 | + $formMap['user_id']=$join['user_id']; | ||
849 | + $formMap['use_time']=0; | ||
850 | + $formMap['expire_time']=['>',time()]; | ||
851 | + $form_id=\db('form_id')->where($formMap)->find(); | ||
852 | + $now=time(); | ||
853 | + \db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>$now]); | ||
854 | + | ||
855 | + if ($data['status']==1){ | ||
856 | + if (!empty($form_id)){ | ||
857 | + \db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>time()]); | ||
858 | + $data['keyword1']= $volunteer['name']; | ||
859 | + $data['keyword2']='活动审核'; | ||
860 | + $data['keyword3']='通过'; | ||
861 | + $data['keyword4']=$activity['activity_name']; | ||
862 | + $message = [ | ||
863 | + 'touser' => $openid, | ||
864 | + 'template_id' => '1FYkLuMK8LNKO4_nxJ_DuNQhgIjaaJQlAukgt92C-uw', | ||
865 | + 'page' => 'pages/index/index', | ||
866 | + 'form_id' => $form_id['value'], | ||
867 | + 'data' => $data, | ||
868 | + 'emphasis_keyword' =>$data['keyword3'], | ||
869 | + ]; | ||
870 | + $this->wxappNotice($message); | ||
871 | + } | ||
872 | + }else{ | ||
873 | + if (!empty($form_id)){ | ||
874 | + \db('form_id')->where('form_id',$form_id['form_id'])->update(['use_time'=>time()]); | ||
875 | + $data['keyword1']= $volunteer['name']; | ||
876 | + $data['keyword2']='活动审核'; | ||
877 | + $data['keyword3']='未通过 原因:'.$refund_reason; | ||
878 | + $data['keyword4']=$activity['activity_name']; | ||
879 | + $message = [ | ||
880 | + 'touser' => $openid, | ||
881 | + 'template_id' => '1FYkLuMK8LNKO4_nxJ_DuNQhgIjaaJQlAukgt92C-uw', | ||
882 | + 'page' => 'pages/index/index', | ||
883 | + 'form_id' => $form_id['value'], | ||
884 | + 'data' => $data, | ||
885 | + 'emphasis_keyword' =>$data['keyword3'], | ||
886 | + ]; | ||
887 | + $this->wxappNotice($message); | ||
888 | + } | ||
889 | + } | ||
890 | + | ||
891 | + | ||
892 | + $this->success('更新成功!'); | ||
893 | + }else{ | ||
894 | + $this->error('操作失败!'); | ||
895 | + } | ||
896 | + } | ||
897 | + | ||
898 | + protected function wxappNotice($message){ | ||
899 | + $appId = 'wx7a3bf4e0796c070a'; | ||
900 | + $secret = '755478f064e09a8301345e0c427c6cf3'; | ||
901 | + $config = [ | ||
902 | + 'app_id' => $appId, | ||
903 | + 'secret' => $secret, | ||
904 | + ]; | ||
905 | + | ||
906 | + $wechat=new Application($config); | ||
907 | + $notice=$wechat->mini_program->notice; | ||
908 | + try{ | ||
909 | + $result= $notice->send($message); | ||
910 | + }catch(Exception $e){ | ||
911 | + // $e->getMessage(); | ||
912 | + } | ||
913 | + return $result; | ||
914 | + } | ||
915 | + | ||
916 | + | ||
917 | + protected function switchStatus($status){ | ||
918 | + switch ($status){ | ||
919 | + case 0: | ||
920 | + return '0'; | ||
921 | + case 1: | ||
922 | + return '1'; | ||
923 | + case 2: | ||
924 | + return '2'; | ||
925 | + case 3: | ||
926 | + return '3'; | ||
927 | + } | ||
928 | + } | ||
929 | + /** | ||
930 | + * @title 关于我们 | ||
931 | + * @description 关于我们 | ||
932 | + * @author XiaoGang Wang | ||
933 | + * @url /index/member_center/about | ||
934 | + * @method GET | ||
935 | + * | ||
936 | + * @header name:XX-Token require:1 default: desc:token | ||
937 | + */ | ||
938 | + public function about(){ | ||
939 | + $aboutModel = new AboutModel(); | ||
940 | + $data = $aboutModel->findData(array('id'=>1)); | ||
941 | + $this->success('获取成功!',$data); | ||
942 | + } | ||
943 | + /** | ||
944 | + * @title 联系我们 | ||
945 | + * @description 联系我们 | ||
946 | + * @author XiaoGang Wang | ||
947 | + * @url /index/member_center/contact | ||
948 | + * @method GET | ||
949 | + * | ||
950 | + * @header name:XX-Token require:1 default: desc:token | ||
951 | + */ | ||
952 | + public function contact(){ | ||
953 | + $contactModel = new ContactModel(); | ||
954 | + $data = $contactModel->findData(array('id'=>1)); | ||
955 | + $this->success('获取成功!',$data); | ||
956 | + } | ||
957 | + /** | ||
958 | + * @title 我参加的活动 | ||
959 | + * @description 参加过的活动 | ||
960 | + * @author XiaoGang Wang | ||
961 | + * @url /index/member_center/joined | ||
962 | + * @method GET | ||
963 | + * | ||
964 | + * @header name:XX-Token require:1 default: desc:token | ||
965 | + */ | ||
966 | + public function joined(){ | ||
967 | + $userId=$this->getUserId(); | ||
968 | + $Join=new JoinModel(); | ||
969 | + $join=$Join->getUserJoin($userId); | ||
970 | + foreach ($join as $k=>$v){ | ||
971 | + $join[$k]['thumbnail']=cmf_get_image_url($v['thumbnail']); | ||
972 | + $join[$k]['create_time']=date('Y-m-d',$v['create_time']); | ||
973 | + } | ||
974 | + $this->success('',$join); | ||
975 | + } | ||
976 | + | ||
977 | + protected function saveFormId($userId,$formId){ | ||
978 | + if ($formId=='undefined'){ | ||
979 | + return; | ||
980 | + } | ||
981 | + $data['user_id']=$userId; | ||
982 | + $data['add_time']=time(); | ||
983 | + $data['value']=$formId; | ||
984 | + $data['expire_time']=time()+604800; | ||
985 | + db('form_id')->insert($data); | ||
986 | + } | ||
987 | + | ||
988 | + | ||
989 | + | ||
990 | + | ||
907 | } | 991 | } |
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * User: Administrator | ||
5 | - * Date: 2018/12/31 | ||
6 | - * Time: 13:47 | ||
7 | - */ | ||
8 | - | ||
9 | -namespace api\index\model; | ||
10 | - | ||
11 | - | ||
12 | -use think\Model; | ||
13 | - | ||
14 | -class ActivityModel extends Model | ||
15 | -{ | ||
16 | - /** | ||
17 | - * thumbnail 自动转化 | ||
18 | - * @param $value | ||
19 | - * @return array | ||
20 | - */ | ||
21 | - public function getThumbnailAttr($value) | ||
22 | - { | ||
23 | - return cmf_get_image_url($value); | ||
24 | - } | ||
25 | - /** | ||
26 | - * time 自动转化 | ||
27 | - * @param $value | ||
28 | - * @return array | ||
29 | - */ | ||
30 | - public function getTimeAttr($value) | ||
31 | - { | ||
32 | - return date('Y-m-d',$value); | ||
33 | - } | ||
34 | - /** | ||
35 | - * content 自动转化 | ||
36 | - * @param $value | ||
37 | - * @return array | ||
38 | - */ | ||
39 | - public function getContentAttr($value) | ||
40 | - { | ||
41 | - return cmf_replace_content_file_url(htmlspecialchars_decode($value)); | ||
42 | - } | ||
43 | - | ||
44 | - public function selectData($page,$pageNum){ | ||
45 | - $order = "create_time desc"; | ||
46 | - $where['a.delete_time'] = ['eq',0]; | ||
47 | - $where['is_up'] = ['eq',1]; | ||
48 | - $data = $this->alias('a') | ||
49 | - ->field('a.*,p.province_name,act.type_name') | ||
50 | - ->join('activity_type act','act.id=a.activity_type','LEFT') | ||
51 | - ->join('position_province p','p.id=a.position_id','LEFT') | ||
52 | - ->where($where) | ||
53 | - ->limit(($page * $pageNum),$pageNum) | ||
54 | - ->order($order) | ||
55 | - ->select() | ||
56 | - ->toArray(); | ||
57 | - return $data; | ||
58 | - } | ||
59 | - public function selectCityData($city_id){ | ||
60 | - $order = "create_time desc"; | ||
61 | - $where['a.delete_time'] = ['eq',0]; | ||
62 | - $where['a.is_up']=1; | ||
63 | - if (!empty($city_id)){ | ||
64 | - $where['a.position_id'] = $city_id; | ||
65 | - } | ||
66 | - $data = $this->alias('a') | ||
67 | - ->field('a.*,p.province_name,act.type_name') | ||
68 | - ->join('activity_type act','act.id=a.activity_type','LEFT') | ||
69 | - ->join('position_province p','p.id=a.position_id','LEFT') | ||
70 | - ->where($where) | ||
71 | - ->order($order) | ||
72 | - ->select() | ||
73 | - ->toArray(); | ||
74 | - return $data; | ||
75 | - } | ||
76 | - public function selectTypeData($type_id){ | ||
77 | - $order = "create_time desc"; | ||
78 | - $where['a.delete_time'] = ['eq',0]; | ||
79 | - $where['a.is_up']=1; | ||
80 | - if (!empty($type_id)){ | ||
81 | - $where['a.activity_type'] = $type_id; | ||
82 | - } | ||
83 | - $data = $this->alias('a') | ||
84 | - ->field('a.*,p.province_name,act.type_name') | ||
85 | - ->join('activity_type act','act.id=a.activity_type','LEFT') | ||
86 | - ->join('position_province p','p.id=a.position_id','LEFT') | ||
87 | - ->where($where) | ||
88 | - ->order($order) | ||
89 | - ->select() | ||
90 | - ->toArray(); | ||
91 | - return $data; | ||
92 | - } | ||
93 | - | ||
94 | - public function findData($where){ | ||
95 | - $data = $this->where($where)->find(); | ||
96 | - return $data; | ||
97 | - } | ||
98 | - | ||
99 | - /** | ||
100 | - * 即将开始的活动 | ||
101 | - * @param $page | ||
102 | - * @return array | ||
103 | - * @throws \think\db\exception\DataNotFoundException | ||
104 | - * @throws \think\db\exception\ModelNotFoundException | ||
105 | - * @throws \think\exception\DbException | ||
106 | - */ | ||
107 | - public function beginAtOnce($page,$pageNum){ | ||
108 | - $now=time(); | ||
109 | - $map['a.create_time']=['<',$now]; | ||
110 | - $map['a.delete_time'] = ['eq',0]; | ||
111 | - if ($page<=0){ | ||
112 | - $data=$this->alias('a') | ||
113 | - ->field('a.*,p.province_name,act.type_name') | ||
114 | - ->join('activity_type act','act.id=a.activity_type','LEFT') | ||
115 | - ->join('position_province p','p.id=a.position_id','LEFT') | ||
116 | - ->where($map) | ||
117 | - ->order("create_time desc") | ||
118 | - ->limit('2') | ||
119 | - ->select()->toArray(); | ||
120 | - }else{ | ||
121 | - $data=$this->alias('a') | ||
122 | - ->field('a.*,p.province_name,act.type_name') | ||
123 | - ->join('activity_type act','act.id=a.activity_type','LEFT') | ||
124 | - ->join('position_province p','p.id=a.position_id','LEFT') | ||
125 | - ->where($map) | ||
126 | - ->order("create_time desc") | ||
127 | - ->limit(($page * $pageNum),$pageNum) | ||
128 | - ->select()->toArray(); | ||
129 | - } | ||
130 | - return $data; | ||
131 | - } | ||
132 | - | 1 | +<?php |
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: Administrator | ||
5 | + * Date: 2018/12/31 | ||
6 | + * Time: 13:47 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace api\index\model; | ||
10 | + | ||
11 | + | ||
12 | +use think\Model; | ||
13 | + | ||
14 | +class ActivityModel extends Model | ||
15 | +{ | ||
16 | + /** | ||
17 | + * thumbnail 自动转化 | ||
18 | + * @param $value | ||
19 | + * @return array | ||
20 | + */ | ||
21 | + public function getThumbnailAttr($value) | ||
22 | + { | ||
23 | + return cmf_get_image_url($value); | ||
24 | + } | ||
25 | + /** | ||
26 | + * time 自动转化 | ||
27 | + * @param $value | ||
28 | + * @return array | ||
29 | + */ | ||
30 | + public function getTimeAttr($value) | ||
31 | + { | ||
32 | + return date('Y-m-d',$value); | ||
33 | + } | ||
34 | + /** | ||
35 | + * content 自动转化 | ||
36 | + * @param $value | ||
37 | + * @return array | ||
38 | + */ | ||
39 | + public function getContentAttr($value) | ||
40 | + { | ||
41 | + return cmf_replace_content_file_url(htmlspecialchars_decode($value)); | ||
42 | + } | ||
43 | + | ||
44 | + public function selectData($page,$pageNum){ | ||
45 | + $order = "create_time desc"; | ||
46 | + $where['a.delete_time'] = ['eq',0]; | ||
47 | + $where['is_up'] = ['eq',1]; | ||
48 | + $data = $this->alias('a') | ||
49 | + ->field('a.*,p.province_name,act.type_name') | ||
50 | + ->join('activity_type act','act.id=a.activity_type','LEFT') | ||
51 | + ->join('position_province p','p.id=a.position_id','LEFT') | ||
52 | + ->where($where) | ||
53 | + ->limit(($page * $pageNum),$pageNum) | ||
54 | + ->order($order) | ||
55 | + ->select() | ||
56 | + ->toArray(); | ||
57 | + return $data; | ||
58 | + } | ||
59 | + | ||
60 | + public function selectDataByTime($page,$pageNum,$type=0){ | ||
61 | + $order = "create_time desc"; | ||
62 | + $where['a.delete_time'] = ['eq',0]; | ||
63 | + if ($type==0){ | ||
64 | + $where['a.end_time']=['>',time()]; | ||
65 | + }else{ | ||
66 | + $where['a.end_time']=['<',time()]; | ||
67 | + } | ||
68 | + $where['is_up'] = ['eq',1]; | ||
69 | + $data = $this->alias('a') | ||
70 | + ->field('a.*,p.province_name,act.type_name') | ||
71 | + ->join('activity_type act','act.id=a.activity_type','LEFT') | ||
72 | + ->join('position_province p','p.id=a.position_id','LEFT') | ||
73 | + ->where($where) | ||
74 | + ->limit(($page * $pageNum),$pageNum) | ||
75 | + ->order($order) | ||
76 | + ->select() | ||
77 | + ->toArray(); | ||
78 | + return $data; | ||
79 | + } | ||
80 | + | ||
81 | + public function selectCityData($city_id,$type=">="){ | ||
82 | + $order = "create_time desc"; | ||
83 | + $where['a.delete_time'] = ['eq',0]; | ||
84 | + $where['a.is_up']=1; | ||
85 | + $where['a.end_time']=[$type,time()]; | ||
86 | + if (!empty($city_id)){ | ||
87 | + $where['a.position_id'] = $city_id; | ||
88 | + } | ||
89 | + | ||
90 | + $data = $this->alias('a') | ||
91 | + ->field('a.*,p.province_name,act.type_name') | ||
92 | + ->join('activity_type act','act.id=a.activity_type','LEFT') | ||
93 | + ->join('position_province p','p.id=a.position_id','LEFT') | ||
94 | + ->where($where) | ||
95 | + ->order($order) | ||
96 | + ->select() | ||
97 | + ->toArray(); | ||
98 | + // echo $this->getLastSql(); | ||
99 | + return $data; | ||
100 | + } | ||
101 | + | ||
102 | + | ||
103 | + public function selectTypeData($type_id,$type="<="){ | ||
104 | + $order = "create_time desc"; | ||
105 | + $where['a.delete_time'] = ['eq',0]; | ||
106 | + $where['a.is_up']=1; | ||
107 | + | ||
108 | + $where['a.end_time']=[$type,time()]; | ||
109 | + if (!empty($type_id)){ | ||
110 | + $where['a.activity_type'] = $type_id; | ||
111 | + } | ||
112 | + $data = $this->alias('a') | ||
113 | + ->field('a.*,p.province_name,act.type_name') | ||
114 | + ->join('activity_type act','act.id=a.activity_type','LEFT') | ||
115 | + ->join('position_province p','p.id=a.position_id','LEFT') | ||
116 | + ->where($where) | ||
117 | + ->order($order) | ||
118 | + ->select() | ||
119 | + ->toArray(); | ||
120 | + return $data; | ||
121 | + } | ||
122 | + | ||
123 | + public function findData($where){ | ||
124 | + $data = $this->where($where)->find(); | ||
125 | + return $data; | ||
126 | + } | ||
127 | + | ||
128 | + /** | ||
129 | + * 即将开始的活动 | ||
130 | + * @param $page | ||
131 | + * @return array | ||
132 | + * @throws \think\db\exception\DataNotFoundException | ||
133 | + * @throws \think\db\exception\ModelNotFoundException | ||
134 | + * @throws \think\exception\DbException | ||
135 | + */ | ||
136 | + public function beginAtOnce($page,$pageNum){ | ||
137 | + $now=time(); | ||
138 | + $map['a.create_time']=['<',$now]; | ||
139 | + $map['a.delete_time'] = ['eq',0]; | ||
140 | + if ($page<=0){ | ||
141 | + $data=$this->alias('a') | ||
142 | + ->field('a.*,p.province_name,act.type_name') | ||
143 | + ->join('activity_type act','act.id=a.activity_type','LEFT') | ||
144 | + ->join('position_province p','p.id=a.position_id','LEFT') | ||
145 | + ->where($map) | ||
146 | + ->order("create_time desc") | ||
147 | + ->limit('2') | ||
148 | + ->select()->toArray(); | ||
149 | + }else{ | ||
150 | + $data=$this->alias('a') | ||
151 | + ->field('a.*,p.province_name,act.type_name') | ||
152 | + ->join('activity_type act','act.id=a.activity_type','LEFT') | ||
153 | + ->join('position_province p','p.id=a.position_id','LEFT') | ||
154 | + ->where($map) | ||
155 | + ->order("create_time desc") | ||
156 | + ->limit(($page * $pageNum),$pageNum) | ||
157 | + ->select()->toArray(); | ||
158 | + } | ||
159 | + return $data; | ||
160 | + } | ||
161 | + | ||
133 | } | 162 | } |
1 | -<?php | ||
2 | -/** | ||
3 | - * Created by PhpStorm. | ||
4 | - * auther: sgj | ||
5 | - * Date: 2019/2/28 | ||
6 | - * Time: 18:29 | ||
7 | - */ | ||
8 | - | ||
9 | -namespace api\index\model; | ||
10 | - | ||
11 | - | ||
12 | -use think\Model; | ||
13 | - | ||
14 | -class JoinModel extends Model | ||
15 | -{ | ||
16 | - public function findData($where){ | ||
17 | - $data=$this->where($where)->order('id','desc')->find(); | ||
18 | - return $data; | ||
19 | - } | ||
20 | - | ||
21 | - /** | ||
22 | - * 查询多条 | ||
23 | - * @param $where | ||
24 | - * @return array | ||
25 | - * @throws \think\db\exception\DataNotFoundException | ||
26 | - * @throws \think\db\exception\ModelNotFoundException | ||
27 | - * @throws \think\exception\DbException | ||
28 | - */ | ||
29 | - public function selectData($where){ | ||
30 | - $data=$this->where($where)->select()->toArray(); | ||
31 | - return $data; | ||
32 | - } | ||
33 | - | ||
34 | - public function getJoinData($activity_id){ | ||
35 | - $where['j.activity_id']=$activity_id; | ||
36 | - $where['j.status']=['in','1,3']; | ||
37 | - $where['j.delete_time']=0; | ||
38 | - $info=$this->alias('j') | ||
39 | - ->join('cmf_volunteer v','v.user_id=j.user_id') | ||
40 | - ->where($where) | ||
41 | - //->fetchSql() | ||
42 | - ->select() | ||
43 | - ->toArray(); | ||
44 | - //->toArray(); | ||
45 | - //dump($info); | ||
46 | - return $info; | ||
47 | - } | ||
48 | - | ||
49 | - /** | ||
50 | - * @param $userId 用户参加活动id | ||
51 | - * @return array | ||
52 | - * @throws \think\db\exception\DataNotFoundException | ||
53 | - * @throws \think\db\exception\ModelNotFoundException | ||
54 | - * @throws \think\exception\DbException | ||
55 | - */ | ||
56 | - public function getUserJoin($userId){ | ||
57 | - $where['j.user_id']=$userId; | ||
58 | - $where['j.status']=['>',1]; | ||
59 | - $info=$this->alias('j') | ||
60 | - ->field('a.*,at.type_name,pp.*,a.id as id') | ||
61 | - ->join('cmf_activity a','a.id=j.activity_id') | ||
62 | - ->join('cmf_activity_type at','a.activity_type=at.id') | ||
63 | - ->join('cmf_position_province pp','a.position_id=pp.id') | ||
64 | - ->where($where) | ||
65 | - ->select() | ||
66 | - ->toArray(); | ||
67 | - return $info; | ||
68 | - } | 1 | +<?php |
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * auther: sgj | ||
5 | + * Date: 2019/2/28 | ||
6 | + * Time: 18:29 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace api\index\model; | ||
10 | + | ||
11 | + | ||
12 | +use think\Model; | ||
13 | + | ||
14 | +class JoinModel extends Model | ||
15 | +{ | ||
16 | + public function findData($where){ | ||
17 | + $data=$this->where($where)->order('id','desc')->find(); | ||
18 | + return $data; | ||
19 | + } | ||
20 | + | ||
21 | + /** | ||
22 | + * 查询多条 | ||
23 | + * @param $where | ||
24 | + * @return array | ||
25 | + * @throws \think\db\exception\DataNotFoundException | ||
26 | + * @throws \think\db\exception\ModelNotFoundException | ||
27 | + * @throws \think\exception\DbException | ||
28 | + */ | ||
29 | + public function selectData($where){ | ||
30 | + $data=$this->where($where)->select()->toArray(); | ||
31 | + return $data; | ||
32 | + } | ||
33 | + | ||
34 | + public function getJoinData($activity_id){ | ||
35 | + $where['j.activity_id']=$activity_id; | ||
36 | + $where['j.status']=['in','1,3']; | ||
37 | + $where['j.delete_time']=0; | ||
38 | + $info=$this->alias('j') | ||
39 | + ->join('cmf_volunteer v','v.user_id=j.user_id') | ||
40 | + ->where($where) | ||
41 | + //->fetchSql() | ||
42 | + ->select() | ||
43 | + ->toArray(); | ||
44 | + //->toArray(); | ||
45 | + //dump($info); | ||
46 | + return $info; | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * @param $userId 用户参加活动id | ||
51 | + * @return array | ||
52 | + * @throws \think\db\exception\DataNotFoundException | ||
53 | + * @throws \think\db\exception\ModelNotFoundException | ||
54 | + * @throws \think\exception\DbException | ||
55 | + */ | ||
56 | + public function getUserJoin($userId){ | ||
57 | + $where['j.user_id']=$userId; | ||
58 | + $where['j.status']=['in','1,3']; | ||
59 | + $where['j.delete_time']=0; | ||
60 | + $info=$this->alias('j') | ||
61 | + ->field('a.*,at.type_name,pp.*,a.id as id') | ||
62 | + ->join('cmf_activity a','a.id=j.activity_id') | ||
63 | + ->join('cmf_activity_type at','a.activity_type=at.id','LEFT') | ||
64 | + ->join('cmf_position_province pp','a.position_id=pp.id','LEFT') | ||
65 | + ->where($where) | ||
66 | + ->order('a.start_time','desc') | ||
67 | + ->group('a.id') | ||
68 | + ->select() | ||
69 | + ->toArray(); | ||
70 | + // echo $this->getLastSql(); | ||
71 | + return $info; | ||
72 | + } | ||
69 | } | 73 | } |
1 | -<?php | ||
2 | -// +---------------------------------------------------------------------- | ||
3 | -// | bronet [ 以客户为中心 以奋斗者为本 ] | ||
4 | -// +---------------------------------------------------------------------- | ||
5 | -// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved. | ||
6 | -// +---------------------------------------------------------------------- | ||
7 | -namespace api\wxapp\controller; | ||
8 | - | ||
9 | -use think\Db; | ||
10 | -use cmf\controller\RestBaseController; | ||
11 | -use wxapp\aes\WXBizDataCrypt; | ||
12 | -use think\Validate; | ||
13 | - | ||
14 | -/** | ||
15 | - * @title 公共模块 | ||
16 | - * @description 公共模块 | ||
17 | - * @package api\wxapp\controller | ||
18 | - */ | ||
19 | -class PublicController extends RestBaseController | ||
20 | -{ | ||
21 | - /** | ||
22 | - * @title 获取sessionKey和openid | ||
23 | - * @description 小程序登录注册 | ||
24 | - * @author Tiger Yang | ||
25 | - * @url /wxapp/public/getSessionKey | ||
26 | - * @method POST | ||
27 | - * | ||
28 | - * @param name:code type:string require:1 other: desc:code | ||
29 | - * | ||
30 | - * @return session_key:session_key | ||
31 | - * @return openid:openid | ||
32 | - */ | ||
33 | - public function getSessionKey(){ | ||
34 | - $validate = new Validate([ | ||
35 | - 'code' => 'require', | ||
36 | - ]); | ||
37 | - | ||
38 | - $validate->message([ | ||
39 | - 'code.require' => '缺少参数code!', | ||
40 | - ]); | ||
41 | - | ||
42 | - $data = $this->request->param(); | ||
43 | - if (!$validate->check($data)) { | ||
44 | - $this->error(['code'=>'40003','msg'=>$validate->getError()]); | ||
45 | - } | ||
46 | - | ||
47 | - $code = $data['code']; | ||
48 | - $appId = config('app_id'); | ||
49 | - $appSecret = config('app_secret'); | ||
50 | - | ||
51 | - $response = cmf_curl_get("https://api.weixin.qq.com/sns/jscode2session?appid=$appId&secret=$appSecret&js_code=$code&grant_type=authorization_code"); | ||
52 | - | ||
53 | - $response = json_decode($response, true); | ||
54 | - if (!empty($response['errcode'])) { | ||
55 | - $this->error(['code'=>'41001','msg'=>'操作失败:'.$response['errcode']]); | ||
56 | - } | ||
57 | - $this->success('获取成功',$response); | ||
58 | - } | ||
59 | - | ||
60 | - /** | ||
61 | - * @title 小程序登录注册 | ||
62 | - * @description 小程序登录注册 | ||
63 | - * @author Tiger Yang | ||
64 | - * @url /wxapp/public/login | ||
65 | - * @method POST | ||
66 | - * | ||
67 | - * @param name:openid type:string require:1 other: desc:openid | ||
68 | - * @param name:session_key type:string require:1 other: desc:session_key | ||
69 | - * @param name:encrypted_data type:string require:1 other: desc:encrypted_data | ||
70 | - * @param name:iv type:string require:1 other: desc:iv | ||
71 | - * | ||
72 | - * @return token:登录唯一标识 | ||
73 | - */ | ||
74 | - public function login() | ||
75 | - { | ||
76 | - $validate = new Validate([ | ||
77 | - 'openid' => 'require', | ||
78 | - 'session_key' => 'require', | ||
79 | - 'encrypted_data' => 'require', | ||
80 | - 'iv' => 'require', | ||
81 | - ]); | ||
82 | - | ||
83 | - $validate->message([ | ||
84 | - 'openid.require' => '缺少参数openid!', | ||
85 | - 'session_key.require' => '缺少参数session_key!', | ||
86 | - 'encrypted_data.require' => '缺少参数encrypted_data!', | ||
87 | - 'iv.require' => '缺少参数iv!', | ||
88 | - ]); | ||
89 | - | ||
90 | - $data = $this->request->param(); | ||
91 | - if (!$validate->check($data)) { | ||
92 | - $this->error(['code'=>'40003','msg'=>$validate->getError()]); | ||
93 | - } | ||
94 | - | ||
95 | - $appId = config('app_id'); | ||
96 | - | ||
97 | - $openid = $data['openid']; | ||
98 | - $sessionKey = $data['session_key']; | ||
99 | - | ||
100 | - $pc = new WXBizDataCrypt($appId, $sessionKey); | ||
101 | - $errCode = $pc->decryptData($data['encrypted_data'], $data['iv'], $wxUserData); | ||
102 | - | ||
103 | - if ($errCode != 0) { | ||
104 | - $this->error(['code'=>'41002','msg'=>'检验数据失败!'],['errCode'=>$errCode,'param'=>$data]); | ||
105 | - } | ||
106 | - | ||
107 | - $findThirdPartyUser = Db::name("third_party_user") | ||
108 | - ->where('openid', $openid) | ||
109 | - ->where('app_id', $appId) | ||
110 | - ->find(); | ||
111 | - | ||
112 | - $currentTime = time(); | ||
113 | - $ip = $this->request->ip(0, true); | ||
114 | - | ||
115 | - $wxUserData['sessionKey'] = $sessionKey; | ||
116 | - unset($wxUserData['watermark']); | ||
117 | - | ||
118 | - if ($findThirdPartyUser) { | ||
119 | - $token = cmf_generate_user_token($findThirdPartyUser['user_id'], 'wxapp'); | ||
120 | - | ||
121 | - $userData = [ | ||
122 | - 'last_login_ip' => $ip, | ||
123 | - 'last_login_time' => $currentTime, | ||
124 | - 'login_times' => ['exp', 'login_times+1'], | ||
125 | - 'more' => json_encode($wxUserData) | ||
126 | - ]; | ||
127 | - | ||
128 | - if (isset($wxUserData['unionId'])) { | ||
129 | - $userData['union_id'] = $wxUserData['unionId']; | ||
130 | - } | ||
131 | - | ||
132 | - Db::name("third_party_user") | ||
133 | - ->where('openid', $openid) | ||
134 | - ->where('app_id', $appId) | ||
135 | - ->update($userData); | ||
136 | - $this->success("登录成功!", ['token' => $token]); | ||
137 | - } else { | ||
138 | - | ||
139 | - Db::startTrans(); | ||
140 | - $userId = Db::name("user")->insertGetId([ | ||
141 | - 'create_time' => $currentTime, | ||
142 | - 'user_status' => 1, | ||
143 | - 'user_type' => 2, | ||
144 | - 'sex' => $wxUserData['gender'], | ||
145 | - 'user_nickname' => $wxUserData['nickName'], | ||
146 | - 'avatar' => $wxUserData['avatarUrl'], | ||
147 | - 'last_login_ip' => $ip, | ||
148 | - 'last_login_time' => $currentTime | ||
149 | - ]); | ||
150 | - | ||
151 | - $row=Db::name("third_party_user")->insert([ | ||
152 | - 'openid' => $openid, | ||
153 | - 'user_id' => $userId, | ||
154 | - 'third_party' => 'wxapp', | ||
155 | - 'app_id' => $appId, | ||
156 | - 'last_login_ip' => $ip, | ||
157 | - 'union_id' => isset($wxUserData['unionId']) ? $wxUserData['unionId'] : '', | ||
158 | - 'last_login_time' => $currentTime, | ||
159 | - 'create_time' => $currentTime, | ||
160 | - 'login_times' => 1, | ||
161 | - 'status' => 1, | ||
162 | - 'more' => json_encode($wxUserData) | ||
163 | - ]); | ||
164 | - | ||
165 | - if($userId && $row){ | ||
166 | - Db::commit(); | ||
167 | - $token = cmf_generate_user_token($userId, 'wxapp'); | ||
168 | - $this->success("登录成功!", ['token' => $token]); | ||
169 | - }else{ | ||
170 | - Db::rollback(); | ||
171 | - $this->error(['code'=>'40004','msg'=>'登录失败']); | ||
172 | - } | ||
173 | - | ||
174 | - } | ||
175 | - | ||
176 | - } | ||
177 | - /** | ||
178 | - * @title 获取token | ||
179 | - * @description 获取token | ||
180 | - * @author Tiger Yang | ||
181 | - * @url /wxapp/public/get_token | ||
182 | - * @method POST | ||
183 | - * | ||
184 | - * @param name:openid type:string require:1 other: desc:openid | ||
185 | - * | ||
186 | - * @return token:登录唯一标识 | ||
187 | - */ | ||
188 | - public function get_token(){ | ||
189 | - $openid = $this->request->param('openid'); | ||
190 | - $third_party_user = Db::name('third_party_user')->where(array('openid'=>$openid))->find(); | ||
191 | - if(empty($third_party_user)){ | ||
192 | - $this->success('查无此人!',['code'=>20000,'msg'=>'查无此人!']); | ||
193 | - } | ||
194 | - $data = Db::name('user_token')->where(array('user_id'=>$third_party_user['user_id']))->find(); | ||
195 | - if($data['expire_time']<time()){ | ||
196 | - $this->success('token过期了',['code'=>20000,'msg'=>'token过期了']); | ||
197 | - }else{ | ||
198 | - $this->success('ok',['code'=>20000,'msg'=>'ok','data'=>$data['token']]); | ||
199 | - } | ||
200 | - } | ||
201 | - | ||
202 | -} | 1 | +<?php |
2 | +// +---------------------------------------------------------------------- | ||
3 | +// | bronet [ 以客户为中心 以奋斗者为本 ] | ||
4 | +// +---------------------------------------------------------------------- | ||
5 | +// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved. | ||
6 | +// +---------------------------------------------------------------------- | ||
7 | +namespace api\wxapp\controller; | ||
8 | + | ||
9 | +use think\Db; | ||
10 | +use cmf\controller\RestBaseController; | ||
11 | +use wxapp\aes\WXBizDataCrypt; | ||
12 | +use think\Validate; | ||
13 | + | ||
14 | +/** | ||
15 | + * @title 公共模块 | ||
16 | + * @description 公共模块 | ||
17 | + * @package api\wxapp\controller | ||
18 | + */ | ||
19 | +class PublicController extends RestBaseController | ||
20 | +{ | ||
21 | + /** | ||
22 | + * @title 获取sessionKey和openid | ||
23 | + * @description 小程序登录注册 | ||
24 | + * @author Tiger Yang | ||
25 | + * @url /wxapp/public/getSessionKey | ||
26 | + * @method POST | ||
27 | + * | ||
28 | + * @param name:code type:string require:1 other: desc:code | ||
29 | + * | ||
30 | + * @return session_key:session_key | ||
31 | + * @return openid:openid | ||
32 | + */ | ||
33 | + public function getSessionKey(){ | ||
34 | + $validate = new Validate([ | ||
35 | + 'code' => 'require', | ||
36 | + ]); | ||
37 | + | ||
38 | + $validate->message([ | ||
39 | + 'code.require' => '缺少参数code!', | ||
40 | + ]); | ||
41 | + | ||
42 | + $data = $this->request->param(); | ||
43 | + if (!$validate->check($data)) { | ||
44 | + $this->error(['code'=>'40003','msg'=>$validate->getError()]); | ||
45 | + } | ||
46 | + | ||
47 | + $code = $data['code']; | ||
48 | + $appId = config('app_id'); | ||
49 | + $appSecret = config('app_secret'); | ||
50 | + | ||
51 | + $response = cmf_curl_get("https://api.weixin.qq.com/sns/jscode2session?appid=$appId&secret=$appSecret&js_code=$code&grant_type=authorization_code"); | ||
52 | + | ||
53 | + $response = json_decode($response, true); | ||
54 | + if (!empty($response['errcode'])) { | ||
55 | + $this->error(['code'=>'41001','msg'=>'操作失败:'.$response['errcode']]); | ||
56 | + } | ||
57 | + $this->success('获取成功',$response); | ||
58 | + } | ||
59 | + | ||
60 | + /** | ||
61 | + * @title 小程序登录注册 | ||
62 | + * @description 小程序登录注册 | ||
63 | + * @author Tiger Yang | ||
64 | + * @url /wxapp/public/login | ||
65 | + * @method POST | ||
66 | + * | ||
67 | + * @param name:openid type:string require:1 other: desc:openid | ||
68 | + * @param name:session_key type:string require:1 other: desc:session_key | ||
69 | + * @param name:encrypted_data type:string require:1 other: desc:encrypted_data | ||
70 | + * @param name:iv type:string require:1 other: desc:iv | ||
71 | + * | ||
72 | + * @return token:登录唯一标识 | ||
73 | + */ | ||
74 | + public function login() | ||
75 | + { | ||
76 | + $validate = new Validate([ | ||
77 | + 'openid' => 'require', | ||
78 | + 'session_key' => 'require', | ||
79 | + 'encrypted_data' => 'require', | ||
80 | + 'iv' => 'require', | ||
81 | + ]); | ||
82 | + | ||
83 | + $validate->message([ | ||
84 | + 'openid.require' => '缺少参数openid!', | ||
85 | + 'session_key.require' => '缺少参数session_key!', | ||
86 | + 'encrypted_data.require' => '缺少参数encrypted_data!', | ||
87 | + 'iv.require' => '缺少参数iv!', | ||
88 | + ]); | ||
89 | + | ||
90 | + $data = $this->request->param(); | ||
91 | + if (!$validate->check($data)) { | ||
92 | + $this->error(['code'=>'40003','msg'=>$validate->getError()]); | ||
93 | + } | ||
94 | + | ||
95 | + $appId = config('app_id'); | ||
96 | + | ||
97 | + $openid = $data['openid']; | ||
98 | + $sessionKey = $data['session_key']; | ||
99 | + | ||
100 | + $pc = new WXBizDataCrypt($appId, $sessionKey); | ||
101 | + $errCode = $pc->decryptData($data['encrypted_data'], $data['iv'], $wxUserData); | ||
102 | + | ||
103 | + if ($errCode != 0) { | ||
104 | + $this->error(['code'=>'41002','msg'=>'检验数据失败!'],['errCode'=>$errCode,'param'=>$data]); | ||
105 | + } | ||
106 | + | ||
107 | + $findThirdPartyUser = Db::name("third_party_user") | ||
108 | + ->where('openid', $openid) | ||
109 | + ->where('app_id', $appId) | ||
110 | + ->find(); | ||
111 | + | ||
112 | + $currentTime = time(); | ||
113 | + $ip = $this->request->ip(0, true); | ||
114 | + | ||
115 | + $wxUserData['sessionKey'] = $sessionKey; | ||
116 | + unset($wxUserData['watermark']); | ||
117 | + | ||
118 | + if ($findThirdPartyUser) { | ||
119 | + $token = cmf_generate_user_token($findThirdPartyUser['user_id'], 'wxapp'); | ||
120 | + | ||
121 | + $userData = [ | ||
122 | + 'last_login_ip' => $ip, | ||
123 | + 'last_login_time' => $currentTime, | ||
124 | + 'login_times' => ['exp', 'login_times+1'], | ||
125 | + 'more' => json_encode($wxUserData) | ||
126 | + ]; | ||
127 | + | ||
128 | + if (isset($wxUserData['unionId'])) { | ||
129 | + $userData['union_id'] = $wxUserData['unionId']; | ||
130 | + } | ||
131 | + | ||
132 | + Db::name("third_party_user") | ||
133 | + ->where('openid', $openid) | ||
134 | + ->where('app_id', $appId) | ||
135 | + ->update($userData); | ||
136 | + $this->success("登录成功!", ['token' => $token]); | ||
137 | + } else { | ||
138 | + | ||
139 | + Db::startTrans(); | ||
140 | + $userId = Db::name("user")->insertGetId([ | ||
141 | + 'create_time' => $currentTime, | ||
142 | + 'user_status' => 1, | ||
143 | + 'user_type' => 2, | ||
144 | + 'sex' => $wxUserData['gender'], | ||
145 | + 'user_nickname' => $wxUserData['nickName'], | ||
146 | + 'avatar' => $wxUserData['avatarUrl'], | ||
147 | + 'last_login_ip' => $ip, | ||
148 | + 'last_login_time' => $currentTime | ||
149 | + ]); | ||
150 | + | ||
151 | + $row=Db::name("third_party_user")->insert([ | ||
152 | + 'openid' => $openid, | ||
153 | + 'user_id' => $userId, | ||
154 | + 'third_party' => 'wxapp', | ||
155 | + 'app_id' => $appId, | ||
156 | + 'last_login_ip' => $ip, | ||
157 | + 'union_id' => isset($wxUserData['unionId']) ? $wxUserData['unionId'] : '', | ||
158 | + 'last_login_time' => $currentTime, | ||
159 | + 'create_time' => $currentTime, | ||
160 | + 'login_times' => 1, | ||
161 | + 'status' => 1, | ||
162 | + 'more' => json_encode($wxUserData) | ||
163 | + ]); | ||
164 | + | ||
165 | + if($userId && $row){ | ||
166 | + Db::commit(); | ||
167 | + $token = cmf_generate_user_token($userId, 'wxapp'); | ||
168 | + $this->success("登录成功!", ['token' => $token]); | ||
169 | + }else{ | ||
170 | + Db::rollback(); | ||
171 | + $this->error(['code'=>'40004','msg'=>'登录失败']); | ||
172 | + } | ||
173 | + | ||
174 | + } | ||
175 | + | ||
176 | + } | ||
177 | + /** | ||
178 | + * @title 获取token | ||
179 | + * @description 获取token | ||
180 | + * @author Tiger Yang | ||
181 | + * @url /wxapp/public/get_token | ||
182 | + * @method POST | ||
183 | + * | ||
184 | + * @param name:openid type:string require:1 other: desc:openid | ||
185 | + * | ||
186 | + * @return token:登录唯一标识 | ||
187 | + */ | ||
188 | + public function get_token(){ | ||
189 | + $openid = $this->request->param('openid'); | ||
190 | + $third_party_user = Db::name('third_party_user')->where(array('openid'=>$openid))->find(); | ||
191 | + if(empty($third_party_user)){ | ||
192 | + /*没有相关用户 添加用户到数据库 分配token*/ | ||
193 | + $ip = $this->request->ip(0, true); | ||
194 | + $currentTime=time(); | ||
195 | + Db::startTrans(); | ||
196 | + $appId = config('app_id'); | ||
197 | + $userId = Db::name("user")->insertGetId([ | ||
198 | + 'create_time' => $currentTime, | ||
199 | + 'user_status' => 1, | ||
200 | + 'user_type' => 2, | ||
201 | + 'sex' => 0, | ||
202 | + 'user_nickname' => '用户', | ||
203 | + 'avatar' => '', | ||
204 | + 'last_login_ip' => $ip, | ||
205 | + 'last_login_time' => $currentTime | ||
206 | + ]); | ||
207 | + | ||
208 | + $row=Db::name("third_party_user")->insert([ | ||
209 | + 'openid' => $openid, | ||
210 | + 'user_id' => $userId, | ||
211 | + 'third_party' => 'wxapp', | ||
212 | + 'app_id' => $appId, | ||
213 | + 'last_login_ip' => $ip, | ||
214 | + 'union_id' => '', | ||
215 | + 'last_login_time' => $currentTime, | ||
216 | + 'create_time' => $currentTime, | ||
217 | + 'login_times' => 1, | ||
218 | + 'status' => 1 | ||
219 | + ]); | ||
220 | + if($userId && $row){ | ||
221 | + Db::commit(); | ||
222 | + $token = cmf_generate_user_token($userId, 'wxapp'); | ||
223 | + $this->success("登录成功!", ['token' => $token]); | ||
224 | + }else{ | ||
225 | + Db::rollback(); | ||
226 | + $this->error(['code'=>'40004','msg'=>'登录失败']); | ||
227 | + } | ||
228 | + // $this->success('查无此人!',['code'=>20000,'msg'=>'查无此人!']); | ||
229 | + } | ||
230 | + $data = Db::name('user_token')->where(array('user_id'=>$third_party_user['user_id']))->find(); | ||
231 | + | ||
232 | + if($data['expire_time']<time()){ | ||
233 | + $token = cmf_generate_user_token($third_party_user['user_id'], 'wxapp'); | ||
234 | + $this->success('ok',['code'=>20000,'msg'=>'ok','token'=>$token]); | ||
235 | + }else{ | ||
236 | + $this->success('ok',['code'=>20000,'msg'=>'ok','token'=>$data['token']]); | ||
237 | + } | ||
238 | + } | ||
239 | + | ||
240 | +} |
-
请 注册 或 登录 后发表评论