UserAudit.php
14.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
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
<?php
namespace app\api\controller;
use app\api\validate\UserAuditA;
use app\api\validate\UserAuditB;
use app\common\controller\Api;
/**
* 微信审核
* @package app\api\controller
*/
class UserAudit extends BaseApi
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
/**
* 判断用户是否什么身份都没有
* @ApiTitle (判断用户是否什么身份都没有)
* @ApiSummary (判断用户是否什么身份都没有:{用于增加文章部分})
* @ApiMethod (POST)
* @ApiRoute (/api/user_audit/is_auth_all)
* @ApiBody (无内容)
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
"code": 1,
"msg": "有权限",
"time": "1608605278",
"data": null
})
*/
public function is_auth_all(){
//2.获取用户数据
$user = model('user')->where('id',$this->auth->id)->find();
//3.判断用户是否有权限
if (!$user['authlist']){
$this->error('无权限');
}
//4.返回
$this->success('有权限');
}
/**
* 判断用户权限
* @ApiTitle (判断用户权限)
* @ApiSummary (判断用户是不是有已经有此种身份)
* @ApiMethod (POST)
* @ApiRoute (/api/user_audit/is_auth)
* @ApiParams (name="status", type="integer", required=true, description="身份:1=实名认证,2=书家,3=书协,4=企业")
* @ApiBody (无内容)
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
"code": 0,
"msg": "身份必须必填",
"time": "1608280579",
"data": {
"stu": "0=审核中,1=审核成功,2=审核失败,3=没有提交"
}
})
*/
public function is_auth(){
//1.获取用户信息
$status = $this->get_data('status','身份必须必填');
//2.获取用户数据
$user = model('user')->where('id',$this->auth->id)->find();
//3.判断用户是否有权限
$data = [
'stu'=>3
];
if (!in_array($status,Turn_an_array($user['authlist']))){
$this->error('无权限',$data);
}
//4.查询身份
if(in_array($status,[1,2])){
$res = model('user_audit_a')
->where('user_id',$this->auth->id)
->where('status',$status)
->find();
//审核状态:0=审核中,1=审核成功,2=审核失败
if ($res){
$data['stu'] = $res['is_stu'];
}
}
if(in_array($status,[3,4])){
$res = model('user_audit_b')
->where('user_id',$this->auth->id)
->where('status',$status-2)
->find();
//审核状态:0=审核中,1=审核成功,2=审核失败
if ($res){
$data['stu'] = $res['is_stu'];
}
}
//4.返回
$this->success('有权限',$data);
}
/**
* 用户实名认证/书家申请
* @ApiTitle (用户实名认证/书家申请)
* @ApiSummary (用户实名认证/书家申请 调用前请先调用{判断用户权限}接口)
* @ApiMethod (POST)
* @ApiRoute (/api/user_audit/user_audit_a)
* @ApiParams (name="name", type="string", required=true, description="用户姓名")
* @ApiParams (name="sex_data", type="integer", required=true, description="性别:1=男,0=女")
* @ApiParams (name="id_number", type="integer", required=true, description="身份证号码")
* @ApiParams (name="auth_true_image", type="string", required=true, description="身份证正面")
* @ApiParams (name="auth_false_image", type="string", required=true, description="身份证反面")
* @ApiParams (name="auth_xiehui_image", type="string", required=true, description="书协会员证")
* @ApiParams (name="status", type="integer", required=true, description="类别:1=实名认证审核,2=书家审核")
* @ApiParams (name="user_audit_a_id", type="integer", required=false, description="审核id:如果存在,则代表更新,用于用户审核失败时候重新审核")
* @ApiBody (无内容)
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
"code": 1,
"msg": "提交成功",
"time": "1608284784",
"data": {
"name": "用户姓名",
"sex_data": "性别:1=男,0=女",
"id_number": "身份证号码",
"auth_true_image": "身份证号码",
"auth_false_image": "身份证反面",
"auth_xiehui_image": "书协会员证",
"status": "类别:1=实名认证审核,2=书家审核",
"user_id": "用户id",
"is_stu": "审核状态:0=审核中,1=审核成功,2=审核失败",
"createtime": "2020-12-18 17:46:24",
"updatetime": "2020-12-18 17:46:24",
"id": "19"
}
})
*/
public function user_audit_a(){
//1.表单验证
(new UserAuditA())->goCheck();
//2.获取数据
$data = g();
//3.用户验证
$res = model('user_audit_a')
->where('user_id',$this->auth->id)
->where('status',$data['status'])
->find();
if ($res){
if(!isset($data['user_audit_a_id']) && empty($data['user_audit_a_id'])){
$this->error('您已经提交认证申请,如果修改请填写user_audit_a_id');
}
}
//4.验证数据
$data['user_id'] = $this->auth->id;
$data['auth_xiehui_image'] = input('param.auth_xiehui_image');
if($data['status'] == 2){
$data['auth_xiehui_image'] = $this->get_data('auth_xiehui_image','书协会员证不能为空');
}
//5.更新或者增加
if (isset($data['user_audit_a_id']) || !empty($data['user_audit_a_id'])){
//5.更新数据
$user_audit_a = model('user_audit_a')
->where('user_id',$this->auth->id)
->where('id',$data['user_audit_a_id'])
->find();
if (!$user_audit_a){
$this->error('user_audit_a_id 参数错误,未查询到审核内容!');
}
if ($user_audit_a['is_stu'] == 1){
$this->error('您已经审核成功');
}
$user_audit_a->name = $data['name'];
$user_audit_a->sex_data = $data['sex_data'];
$user_audit_a->id_number = $data['id_number'];
$user_audit_a->auth_true_image = $data['auth_true_image'];
$user_audit_a->auth_false_image = $data['auth_false_image'];
$user_audit_a->auth_xiehui_image = $data['auth_xiehui_image'];
$user_audit_a->status = $data['status'];
$user_audit_a->is_stu = 0;
$user_audit_a->message = '';
$user_audit_a->save();
//6.返回成功
$this->success('重新审核中',$user_audit_a);
}else{
//5.增加数据
$res = model('user_audit_a')->create($data);
//6.返回成功
$this->success('提交成功',$res);
}
}
/**
* @ApiTitle (获取 用户实名认证/书家申请)
* @ApiSummary (用户实名认证/书家申请 如果有code返回1 没有返回0)
* @ApiMethod (POST)
* @ApiRoute (/api/user_audit/get_user_audit_a)
* @ApiParams (name="status", type="integer", required=true, description="类别:1=实名认证审核,2=书家审核")
* @ApiBody (无内容)
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
"code": 1,
"msg": {
"id": 19,
"user_id": "用户ID",
"name": "用户姓名",
"sex_data": "性别:1=男,0=女",
"id_number": "身份证号码",
"auth_true_image": "身份证正面",
"auth_false_image": "身份证反面",
"auth_xiehui_image": "书协会员证",
"status": "类别:1=实名认证审核,2=书家审核",
"is_stu": "审核状态:0=审核中,1=审核成功,2=审核失败",
"message": "提示",
"createtime": "2020-12-18 17:46:24",
"updatetime": "2020-12-18 17:46:24"
},
"time": "1608519985",
"data": null
})
*/
public function get_user_audit_a(){
//1.获取数据
$data = g();
//2.查询数据
$res = model('user_audit_a')
->where('user_id',$this->auth->id)
->where('status',$data['status'])
->find();
if ($res){
$this->success($res);
}
$this->error('没有查询出任何提交');
}
/**
* 用户 书协认证/企业认证接口
* @ApiTitle (书协认证/企业认证接口)
* @ApiSummary (书协认证/企业认证接口 调用前请先调用{判断用户权限}接口)
* @ApiMethod (POST)
* @ApiRoute (/api/user_audit/user_audit_b)
* @ApiParams (name="name", type="string", required=true, description="用户姓名")
* @ApiParams (name="auth_true_image", type="string", required=true, description="营业执照正面")
* @ApiParams (name="auth_false_image", type="string", required=true, description="营业执照反面")
* @ApiParams (name="status", type="integer", required=true, description="类别:1=书协审核,2=企业审核")
* @ApiParams (name="user_audit_b_id", type="integer", required=false, description="审核id:如果存在,则代表更新,用于用户审核失败时候重新审核")
* @ApiBody (无内容)
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
"code": 1,
"msg": "提交成功",
"time": "1608284784",
"data": {
"name": "用户姓名",
"auth_true_image": "营业执照正面",
"auth_false_image": "营业执照反面",
"status": "类别:1=书协审核,2=企业审核",
"user_id": "用户id",
"createtime": "2020-12-18 17:46:24",
"updatetime": "2020-12-18 17:46:24",
"id": "19"
}
})
*/
public function user_audit_b(){
//1.表单验证
(new UserAuditB())->goCheck();
//2.获取数据
$data = g();
//3.用户验证
$res = model('user_audit_b')
->where('user_id',$this->auth->id)
->where('status',$data['status'])
->find();
if ($res){
if(!isset($data['user_audit_b_id']) || empty($data['user_audit_b_id'])){
$this->error('您已经提交认证申请,如果修改请填写user_audit_b_id');
}
}
//4.验证数据
$data['user_id'] = $this->auth->id;
//5.更新或者增加
if (isset($data['user_audit_b_id']) && !empty($data['user_audit_b_id'])){
//5.更新数据
$user_audit_b = model('user_audit_b')
->where('id',$data['user_audit_b_id'])
->where('user_id',$this->auth->id)
->find();
if (!$user_audit_b){
$this->error('user_audit_b_id 参数错误,未查询到审核内容!');
}
if ($user_audit_b['is_stu'] == 1){
$this->error('您已经审核成功');
}
$user_audit_b->name = $data['name'];
$user_audit_b->auth_true_image = $data['auth_true_image'];
$user_audit_b->auth_false_image = $data['auth_false_image'];
$user_audit_b->status = $data['status'];
$user_audit_b->is_stu = 0;
$user_audit_b->message = '';
$user_audit_b->save();
//6.返回成功
$this->success('重新审核中',$user_audit_b);
}else{
//5.增加数据
if (isset($data['user_audit_b_id'])){
unset($data['user_audit_b_id']);
}
$res = model('user_audit_b')->create($data);
//6.返回成功
$this->success('提交成功',$res);
}
}
/**
* @ApiTitle (获取 书协认证/企业认证)
* @ApiSummary (书协认证/企业认证 如果有code返回1 没有返回0)
* @ApiMethod (POST)
* @ApiRoute (/api/user_audit/get_user_audit_b)
* @ApiParams (name="status", type="integer", required=true, description="类别:1=书协审核,2=企业审核")
* @ApiBody (无内容)
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
"code": 1,
"msg": {
"id": 19,
"user_id": "用户ID",
"name": "用户姓名",
"auth_true_image": "营业执照正面",
"auth_false_image": "营业执照反面",
"status": "类别:1=书协审核,2=企业审核",
"is_stu": "审核状态:0=审核中,1=审核成功,2=审核失败",
"message": "提示",
"createtime": "2020-12-18 17:46:24",
"updatetime": "2020-12-18 17:46:24"
},
"time": "1608519985",
"data": null
})
*/
public function get_user_audit_b(){
//1.获取数据
$data = g();
//2.查询数据
$res = model('user_audit_b')
->where('user_id',$this->auth->id)
->where('status',$data['status'])
->find();
if ($res){
$this->success($res);
}
$this->error('没有查询出任何提交');
}
}