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