MemberCenterController.php
12.7 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
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/12/31
* Time: 15:35
*/
namespace api\index\controller;
use api\index\model\VolunteerModel;
use api\index\model\UserModel;
use cmf\controller\RestBaseController;
use think\Validate;
/**
* @title 个人中心
* @description 个人中心
*/
class MemberCenterController extends RestBaseController
{
/**
* @title 个人中心
* @description 个人中心
* @author XiaoGang Wang
* @url /index/member_center/index
* @method GET
*
* @header name:XX-Token require:1 default: desc:token
*
* @return id:id
* @return user_nickname:用户昵称
* @return avatar:头像
* @return type:类型(1为普通,2为管理员)
*/
public function index(){
$user_id = $this->getUserId();
$userModel = new UserModel();
$user = $userModel->findData(array('id'=>$user_id));
$this->success('获取成功!',$user);
}
/**
* @title 提交审核
* @description 提交审核
* @author XiaoGang Wang
* @url /index/member_center/submit_form
* @method GET
*
* @header name:XX-Token require:1 default: desc:token
*
* @param name:name type:str require:1 other: desc:姓名
* @param name:sex type:str require:1 other: desc:性别(1男,2女)
* @param name:birthday type:str require:1 other: desc:生日
* @param name:nation type:str require:1 other: desc:民族
* @param name:politics type:str require:1 other: desc:政治面貌
* @param name:education type:str require:1 other: desc:学历
* @param name:unit type:str require:1 other: desc:工作单位
* @param name:duty type:str require:1 other: desc:职务
* @param name:addr type:str require:1 other: desc:通讯地址
* @param name:postcode type:str require:1 other: desc:邮编
* @param name:school type:str require:1 other: desc:毕业院校
* @param name:card_number type:str require:1 other: desc:身份证号码
* @param name:fixed_phone type:str require:1 other: desc:固定电话
* @param name:move_phone type:str require:1 other: desc:移动电话
* @param name:email type:str require:1 other: desc:email
* @param name:urgency_phone type:str require:1 other: desc:紧急联系人电话
* @param name:qq type:str require:1 other: desc:qq
* @param name:province type:str require:1 other: desc:省
* @param name:city type:str require:1 other: desc:市
* @param name:county type:str require:1 other: desc:区/县
* @param name:address type:str require:1 other: desc:详细地址
* @param name:type type:int require:1 other: desc:1医院志愿者,2社会志愿者,3办事处志愿者
* @param name:record_start_time type:str require:1 other: desc:开始时间
* @param name:record_end_time type:str require:1 other: desc:结束时间
* @param name:record_unit type:str require:1 other: desc:单位
* @param name:record_duty type:str require:1 other: desc:职务
* @param name:record_name type:str require:1 other: desc:证明人
* @param name:record_phone type:str require:1 other: desc:证明人电话
* @param name:front_card type:str require:1 other: desc:身份证正面照
* @param name:reverse_card type:str require:1 other: desc:身份证背面照
* @param name:photo type:str require:1 other: desc:照片
*/
public function submit_form(){
$user_id = $this->getUserId();
$param = $this->request->param();
$validate = new Validate([
'name' => 'require',
'sex' => 'require',
'birthday' => 'require',
'nation' => 'require',
'politics' => 'require',
'education' => 'require',
'unit' => 'require',
'duty' => 'require',
'addr' => 'require',
'postcode' => 'require',
'school' => 'require',
'card_number' => 'require',
'fixed_phone' => 'require',
'move_phone' => 'require',
'email' => 'require',
'urgency_phone' => 'require',
'qq' => 'require',
'province' => 'require',
'city' => 'require',
'county' => 'require',
'address' => 'require',
'type' => 'require',
'record_start_time' => 'require',
'record_end_time' => 'require',
'record_unit' => 'require',
'record_duty' => 'require',
'record_name' => 'require',
'record_phone' => 'require',
'front_card' => 'require',
'reverse_card' => 'require',
'photo' => 'require',
]);
$validate->message([
'name' => '缺少参数name',
'sex' => '缺少参数sex',
'birthday' => '缺少参数birthday',
'nation' => '缺少参数nation',
'politics' => '缺少参数politics',
'education' => '缺少参数education',
'unit' => '缺少参数unit',
'duty' => '缺少参数duty',
'addr' => '缺少参数postcode',
'postcode' => '缺少参数',
'school' => '缺少参数school',
'card_number' => '缺少参数card_number',
'fixed_phone' => '缺少参数fixed_phone',
'move_phone' => '缺少参数move_phone',
'email' => '缺少参数email',
'urgency_phone' => '缺少参数urgency_phone',
'qq' => '缺少参数qq',
'province' => '缺少参数province',
'city' => '缺少参数city',
'county' => '缺少参数county',
'address' => '缺少参数address',
'type' => '缺少参数type',
'record_start_time' => '缺少参数record_start_time',
'record_end_time' => '缺少参数record_end_time',
'record_unit' => '缺少参数record_unit',
'record_duty' => '缺少参数record_duty',
'record_name' => '缺少参数record_name',
'record_phone' => '缺少参数record_phone',
'front_card' => '缺少参数front_card',
'reverse_card' => '缺少参数reverse_card',
'photo' => '缺少参数photo',
]);
if (!$validate->check($param)) {
$this->error($validate->getError());
}
$record_start_time = explode(',',$param['record_start_time']);
$record_end_time = explode(',',$param['record_end_time']);
$record_unit = explode(',',$param['record_unit']);
$record_duty = explode(',',$param['record_duty']);
$record_name = explode(',',$param['record_name']);
$record_phone = explode(',',$param['record_phone']);
$record = [];
foreach($record_start_time as $key => $r_s_t){
$record[$key]['record_start_time'] = !empty($r_s_t) ? $r_s_t : '';
$record[$key]['record_end_time'] = !empty($record_end_time[$key]) ? $record_end_time[$key] : '';
$record[$key]['record_unit'] = !empty($record_unit[$key]) ? $record_unit[$key] :'';
$record[$key]['record_duty'] = !empty($record_duty[$key]) ? $record_duty[$key] :'';
$record[$key]['record_name'] = !empty($record_name[$key]) ? $record_name[$key] :'';
$record[$key]['record_phone'] = !empty($record_phone[$key]) ? $record_phone[$key] :'';
}
if(!empty($record)){
$record = json_encode($record);
}else{
$record = null;
}
$data = [
'name' => $param['name'],
'sex' => $param['sex'],
'birthday' => $param['birthday'],
'nation' => $param['nation'],
'politics' => $param['politics'],
'education' => $param['education'],
'unit' => $param['unit'],
'duty' => $param['duty'],
'addr' => $param['addr'],
'postcode' => $param['postcode'],
'school' => $param['school'],
'card_number' => $param['card_number'],
'fixed_phone' => $param['fixed_phone'],
'move_phone' => $param['move_phone'],
'email' => $param['email'],
'urgency_phone' => $param['urgency_phone'],
'qq' => $param['qq'],
'province' => $param['province'],
'city' => $param['city'],
'county' => $param['county'],
'address' => $param['address'],
'type' => $param['type'],
'record' => $record,
'front_card' => $param['front_card'],
'reverse_card' => $param['reverse_card'],
'photo' => $param['photo'],
'status' => 1,
'user_id' => $user_id,
];
$volunteerModel = new VolunteerModel();
$result1 = $volunteerModel->findData(array('user_id'=>$user_id));
//判断该用户是否提交过
if(!empty($result1)){
$data['update_time'] = time();
$volunteerModel->updateData(array('user_id'=>$user_id),$data);
}else{
$data['create_time'] = time();
$volunteerModel->insertData($data);
}
$this->success('提交成功!');
}
/**
* @title 查看审核状态
* @description 查看审核状态
* @author XiaoGang Wang
* @url /index/member_center/status
* @method GET
*
* @header name:XX-Token require:1 default: desc:token
*
* @return id:id
* @return status:状态(1审核中,2审核成功,3审核失败)
*/
public function status(){
$user_id = $this->getUserId();
$volunteerModel = new VolunteerModel();
$data = $volunteerModel->findData(array('user_id'=>$user_id));
if(empty($data)){
$this->success(['code'=>40001,'msg'=>'您还没有提交过申请!']);
}
$this->success('获取成功!',$data);
}
/**
* @title 管理员审核
* @description 管理员审核
* @author XiaoGang Wang
* @url /index/member_center/admin
* @method GET
*
* @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:性别 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 admin(){
$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'=>1));
$data['volunteer'] = $volunteer;
$data['page'] = $page+1;
$this->success('获取成功!',$data);
}
/**
* @title 管理员更新状态
* @description 管理员更新状态
* @author XiaoGang Wang
* @url /index/member_center/update_status
* @method GET
*
* @param name:id type:int require:1 other: desc:志愿者id
* @param name:status type:int require:1 other: desc:状态(点击审核通过传2,点击审核失败传3)
*/
public function update_status(){
$id = $this->request->param('id');
if(empty($id)){
$this->error('缺少参数id');
}
$status = $this->request->param('status');
if(empty($status)){
$this->error('缺少参数status');
}
if($status != 2 or $status != 3){
$this->error('status参数错误!');
}
//获取志愿者
$volunteerModel = new VolunteerModel();
$result = $volunteerModel->updateData(array('id'=>1),array('status'=>$status));
if(empty($result)){
$this->success(['code'=>40002,'msg'=>'当前申请可能已被其他管理员审核,请刷新页面!']);
}
$this->success('更新成功!');
}
}