Teacher.php
27.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
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
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/1/9
* Time: 17:14
*/
namespace app\api\controller;
use app\common\controller\Api;
use function Qiniu\entry;
use think\Db;
use think\Log;
use think\Validate;
/**
* 老师接口
*/
class Teacher extends Api
{
/**
* @ApiTitle (成为老师表单提交)
* @ApiSummary (成为老师表单提交)
* @ApiMethod (POST)
* @ApiRoute (/api/teacher/become)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="name", type="string", required=true, description="真实姓名")
* @ApiParams (name="sex", type="int", required=true, description="性别(1男2女)")
* @ApiParams (name="birth", type="string", required=true, description="出生日期")
* @ApiParams (name="idcard", type="string", required=true, description="身份证号")
* @ApiParams (name="before", type="string", required=true, description="身份证正面")
* @ApiParams (name="behind", type="string", required=true, description="身份证反面")
* @ApiParams (name="phone", type="string", required=true, description="手机号")
* @ApiParams (name="thumbnail", type="string", required=true, description="头像")
* @ApiParams (name="address", type="string", required=true, description="常住地")
* @ApiParams (name="honor", type="string", required=true, description="头衔")
* @ApiParams (name="content", type="string", required=true, description="个人履历")
* @ApiParams (name="show", type="string", required=true, description="展示在最前")
* @ApiParams (name="online", type="string", required=true, description="在线时段")
* @ApiParams (name="territory_id", type="string", required=true, description="擅长领域ID")
*
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
}
})
*/
public function become()
{
$param = $this->request->param();
$param['user_id'] = $this->getUserId();
$validate = new Validate([
'name' => 'require',
'sex' => 'require',
'birth' => 'require',
'idcard' => 'require',
'before' => 'require',
'behind' => 'require',
'phone' => 'require',
'thumbnail' => 'require',
'address' => 'require',
'honor' => 'require',
'content' => 'require',
'show' => 'require',
'online' => 'require'
]);
if (!$validate->check($param)) {
$this->error($validate->getError());
}
if(!empty($param['territory_id'])){
//接收所传入的擅长领域ID
$territory_id = explode(',',$param['territory_id']);
$count = count($territory_id);
if($count>4){
$this->error('最多添加4个擅长领域');
}
unset($param['territory_id']);
}
$qiniu = get_addon_config('qiniu');
$http = $qiniu['cdnurl'];
$param['before'] = str_replace($http, '', $param['before']);
$param['behind'] = str_replace($http, '', $param['behind']);
$param['thumbnail'] = str_replace($http, '', $param['thumbnail']);
$param['createtime'] = time();
$data = Db::name('teacher')->insertGetId($param);
if (empty($data)) {
$this->error('提交失败');
} else {
Db::name('user')->where('id',$param['user_id'])->update(['identity'=>2]);
$this->success('提交成功');
}
}
/**
* @ApiTitle (成为老师表单详情)
* @ApiSummary (成为老师表单详情)
* @ApiMethod (POST)
* @ApiRoute (/api/teacher/tea_detail)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id"://老师ID
"name"://真实姓名
"sex"://性别(1男2女
"birth"://出生日期
"idcard"://身份证号
"before"://身份证正面照
"behind"://身份证反面照
"phone"://手机号
"thumbnail"://大头照
"address"://常住地
"honor"://头衔
"content"://个人履历
"show"://展示在最前
"online"://在线时段
"status"://状态(0待审核1审核通过2未通过
"nopass"://未通过的理由
"territory_id"://擅长领域ID
}
})
*/
public function tea_detail()
{
$user_id = $this->getUserId();
$data = Db::name('teacher')
->where('user_id',$user_id)
->find();
if(empty($data)){
$this->error('数据错误');
}
$qiniu = get_addon_config('qiniu')['cdnurl'];
$data['before'] = $qiniu.$data['before'];
$data['behind'] = $qiniu.$data['behind'];
$data['thumbnail'] = $qiniu.$data['thumbnail'];
$data['show'] = explode(',',$data['show']);
if(!empty($data['territory_id'])){
$data['territory_id'] = explode(',',$data['territory_id']);
}else{
$data['territory_id'] = '';
}
$this->success('success',$data);
}
/**
* @ApiTitle (修改成为老师表单提交)
* @ApiSummary (修改成为老师表单提交)
* @ApiMethod (POST)
* @ApiRoute (/api/teacher/update)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="id", type="int", required=true, description="老师ID")
* @ApiParams (name="name", type="string", required=true, description="真实姓名")
* @ApiParams (name="sex", type="int", required=true, description="性别(1男2女)")
* @ApiParams (name="birth", type="string", required=true, description="出生日期")
* @ApiParams (name="idcard", type="string", required=true, description="身份证号")
* @ApiParams (name="before", type="string", required=true, description="身份证正面")
* @ApiParams (name="behind", type="string", required=true, description="身份证反面")
* @ApiParams (name="phone", type="string", required=true, description="手机号")
* @ApiParams (name="thumbnail", type="string", required=true, description="头像")
* @ApiParams (name="address", type="string", required=true, description="常住地")
* @ApiParams (name="honor", type="string", required=true, description="头衔")
* @ApiParams (name="content", type="string", required=true, description="个人履历")
* @ApiParams (name="show", type="string", required=true, description="展示在最前")
* @ApiParams (name="online", type="string", required=true, description="在线时段")
* @ApiParams (name="territory_id", type="string", required=true, description="擅长领域ID")
*
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
}
})
*/
public function update()
{
$user_id = $this->getUserId();
$param = $this->request->param();
if(empty($param['id'])){
$this->error('缺少必要参数');
}
$validate = new Validate([
'name' => 'require',
'sex' => 'require',
'birth' => 'require',
'idcard' => 'require',
'before' => 'require',
'behind' => 'require',
'phone' => 'require',
'thumbnail' => 'require',
'address' => 'require',
'honor' => 'require',
'content' => 'require',
'show' => 'require',
'online' => 'require',
]);
if (!$validate->check($param)) {
$this->error($validate->getError());
}
if(!empty($param['territory_id'])){
$count = count(explode(',',$param['territory_id']));
if($count>4){
$this->error('最多添加4个擅长领域');
}
}
$qiniu = get_addon_config('qiniu');
$http = $qiniu['cdnurl'];
$param['before'] = str_replace($http, '', $param['before']);
$param['behind'] = str_replace($http, '', $param['behind']);
$param['thumbnail'] = str_replace($http, '', $param['thumbnail']);
// $is_true = Db::name('teacher')->where('id',$param['id'])->find();
$param['status'] = 0;
$param['updatetime'] = time();
$data = Db::name('teacher')->where('id',$param['id'])->update($param);
if (empty($data)) {
$this->error('提交失败');
} else {
$this->success('提交成功');
}
}
/**
* @ApiTitle (我的擅长领域)
* @ApiSummary (我的擅长领域)
* @ApiMethod (POST)
* @ApiRoute (/api/teacher/shanList)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id": //id,
"title"://标题,
"is_check"://是否选中(0未点亮1点亮
"money"://价格
"content"://领域优势
}
})
*/
public function shanList()
{
$user_id = $this->getUserId();
$data = Db::name('territory')
->alias('a')
->join('contype b','a.contype_id = b.id')
->where('a.user_id',$user_id)
->field('a.*,b.title')
->select();
$this->success('success',$data);
}
/**
* @ApiTitle (点亮标签/取消点亮)
* @ApiSummary (点亮标签/取消点亮)
* @ApiMethod (POST)
* @ApiRoute (/api/teacher/cancle)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="id", type="int", required=true, description="擅长领域ID")
*
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
}
})
*/
public function cancle()
{
$user_id = $this->getUserId();
$id = $this->request->param('id');
if(empty($id)){
$this->error('缺少必要参数');
}
$data = Db::name('territory')
->where('id',$id)
->find();
if($data['is_check'] == 0){
Db::startTrans();
$res = Db::name('territory')->where('id',$id)->update(['is_check'=>1]);
$teacher = Db::name('teacher')
->where('user_id',$user_id)
->field('id,territory_id')
->find();
if(empty($teacher['territory_id'])){
$teacher_territory = [];
}else{
$teacher_territory = explode(',',$teacher['territory_id']);
}
array_push($teacher_territory,$id);
if(count($teacher_territory) >4){
$this->error('最多添加4个擅长领域');
}
$upd_territory = implode(',',$teacher_territory);
$upd_teacher = Db::name('teacher')
->where('user_id',$user_id)
->update(['territory_id'=>$upd_territory,'status'=>0]);
if($res && $upd_teacher){
Db::commit();
$this->success('点亮成功');
}else{
Db::rollback();
$this->error('点亮失败');
}
}else{
Db::startTrans();
$res = Db::name('territory')->where('id',$id)->update(['is_check'=>0]);
$teacher = Db::name('teacher')
->where('user_id',$user_id)
->field('id,territory_id')
->find();
$teacher_territory = explode(',',$teacher['territory_id']);
foreach ($teacher_territory as $k =>$v){
if($v == $id){
unset($teacher_territory[$k]);
}
}
if(!empty($teacher_territory)){
$upd_territory = implode(',',$teacher_territory);
$upd_teacher = Db::name('teacher')
->where('user_id',$user_id)
->update(['territory_id'=>$upd_territory]);
if($res && $upd_teacher){
Db::commit();
$this->success('取消点亮成功');
}else{
Db::rollback();
$this->error('取消点亮失败');
}
}else{
$this->error('至少留一个点亮的标签');
}
}
}
/**
* @ApiTitle (新赠擅长领域)
* @ApiSummary (新赠擅长领域)
* @ApiMethod (POST)
* @ApiRoute (/api/teacher/index)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="contype_id", type="int", required=true, description="咨询分类ID")
* @ApiParams (name="money", type="string", required=true, description="资讯价格")
* @ApiParams (name="content", type="string", required=true, description="领域优势内容")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
'id':擅长领域ID
}
})
*/
public function index()
{
$param = $this->request->param();
$param['user_id'] = $this->getUserId();
$validate = new Validate([
'contype_id' => 'require',
'money' => 'require',
'content' => 'require',
]);
if (!$validate->check($param)) {
$this->error($validate->getError());
}
$info = Db::name('territory')
->where('user_id',$param['user_id'])
->where('contype_id',$param['contype_id'])
->find();
if(!empty($info)){
$this->error('该标签您已经添加过了');
}
$param['createtime'] = time();
$param['updatetime'] = time();
$data = Db::name('territory')->insertGetId($param);
$res['id'] = $data;
if(!empty($data)){
$this->success('success',$res);
}else{
$this->error('sql执行失败');
}
}
/**
* @ApiTitle (擅长领域详情)
* @ApiSummary (擅长领域详情)
* @ApiMethod (POST)
* @ApiRoute (/api/teacher/info)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="int", required=true, description="擅长领域ID")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
'id'://擅长领域ID
'contype_id'://资讯分类ID
'money'://金额
'content'://简介
}
})
*/
public function info()
{
$user_id = $this->getUserId();
$id = $this->request->param('id');
if(empty($id)){
$this->error('缺少必要参数');
}
$data = Db::name('territory')
->alias('a')
->join('contype b','a.contype_id = b.id')
->field('a.id,a.money,a.content,b.title')
->where('a.id',$id)
->find();
$this->success('success',$data);
}
/**
* @ApiTitle (编辑擅长领域)
* @ApiSummary (编辑擅长领域)
* @ApiMethod (POST)
* @ApiRoute (/api/teacher/upd)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="id", type="int", required=true, description="擅长领域ID")
* @ApiParams (name="contype_id", type="int", required=true, description="咨询分类ID")
* @ApiParams (name="money", type="string", required=true, description="资讯价格")
* @ApiParams (name="content", type="string", required=true, description="领域优势内容")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
'id':擅长领域ID
}
})
*/
public function upd()
{
$user_id = $this->getUserId();
$param = $this->request->param();
if(empty($param['id'])){
$this->error('缺少必要参数');
}
$validate = new Validate([
'contype_id' => 'require',
'money' => 'require',
'content' => 'require',
]);
if (!$validate->check($param)) {
$this->error($validate->getError());
}
$param['updatetime'] = time();
$res = Db::name('territory')
->where('id',$param['id'])
->find();
if($res['is_check'] == 1){
$this->error('请先取消点亮再编辑');
// $info = Db::name('territory')
// ->where('id',$param['id'])
// ->update($param);
// if(empty($info)){
// $this->error('sql执行错误');
// }else{
// $a = Db::name('territory')->where('id',$param['id'])->find();
// Db::name('teacher')->where('user_id',$a['user_id'])->update(['status'=>0]);
// $this->success('SUCCESS');
// }
}else{
$info = Db::name('territory')
->where('id',$param['id'])
->update($param);
if(empty($info)){
$this->error('sql执行错误');
}else{
$this->success('SUCCESS');
}
}
}
/**
* @ApiTitle (删除擅长领域)
* @ApiSummary (删除擅长领域)
* @ApiMethod (POST)
* @ApiRoute (/api/teacher/del)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="id", type="int", required=true, description="擅长领域ID")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
}
})
*/
public function del()
{
$user_id = $this->getUserId();
$id = $this->request->param('id');
if(empty($id)){
$this->error('缺少必要参数');
}
$res = Db::name('territory')
->where('id',$id)
->find();
if($res['is_check'] == 1){
$data = Db::name('teacher')->where('user_id',$user_id)->find();
$territory_id = explode(',',$data['territory_id']);
foreach ($territory_id as $k =>$v){
if($v == $id){
unset($territory_id[$k]);
}
}
$upd_territory = implode(',',$territory_id);
$upd_teacher = Db::name('teacher')
->where('user_id',$user_id)
->update(['territory_id'=>$upd_territory]);
$data = Db::name('territory')
->where('id',$id)
->delete();
if(empty($upd_teacher) && empty($data)){
$this->error('sql运行失败');
}else{
$this->success('success');
}
}else{
$data = Db::name('territory')
->where('id',$id)
->delete();
if(empty($data)){
$this->error('sql运行失败');
}else{
$this->success('success');
}
}
}
/**
* @ApiTitle (评价老师)
* @ApiSummary (评价老师)
* @ApiMethod (POST)
* @ApiRoute (/api/teacher/comment)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="order_id", type="int", required=true, description="订单ID")
* @ApiParams (name="teacher_id", type="int", required=true, description="老师ID")
* @ApiParams (name="service", type="int", required=true, description="服务态度评分")
* @ApiParams (name="ability", type="int", required=true, description="专业能力评分")
* @ApiParams (name="effect", type="int", required=true, description="解决效果评分")
* @ApiParams (name="content", type="string", required=true, description="评价内容")
* @ApiParams (name="desc", type="string", required=false, description="平台建议")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
'id':评价ID
}
})
*/
public function comment()
{
$param = $this->request->param();
$param['user_id'] = $this->getUserId();
$validate = new Validate([
'order_id' => 'require',
'teacher_id'=>'require',
'service' => 'require',
'ability'=>'require',
'effect'=>'require',
'content' => 'require',
]);
if (!$validate->check($param)) {
$this->error($validate->getError());
}
$param['level'] = ceil(($param['service'] + $param['ability'] + $param['effect'])/3);
$param['createtime'] = time();
$data = Db::name('comment')
->insertGetId($param);
if(empty($data)){
$this->error('失败');
}else{
$this->success('成功');
}
}
/**
* @ApiTitle (评价详情)
* @ApiSummary (评价详情)
* @ApiMethod (POST)
* @ApiRoute (/api/teacher/pingDetail)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="order_id", type="int", required=true, description="订单ID")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id": //评价id,
"user_id"://用户ID
"teacher_id"://老师ID
"order_id"://订单ID
"service"://服务态度评分
"ability"://专业能力评分
"effect"://解决效果评分
"content"://评论内容
"desc"://平台建议
"createtime"://评价时间
}
})
*/
public function pingDetail()
{
$user_id = $this->getUserId();
$id = $this->request->param('order_id');
if(empty($id)){
$this->error('缺少必要参数');
}
$data = Db::name('comment')
->where('order_id',$id)
->find();
$data['createtime'] = date('Y-m-d H:i:s',$data['createtime']);
$this->success('success',$data);
}
/**
* @ApiTitle (投诉老师)
* @ApiSummary (投诉老师)
* @ApiMethod (POST)
* @ApiRoute (/api/teacher/complaint)
*
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="teacher_id", type="int", required=true, description="老师ID")
* @ApiParams (name="order_id", type="int", required=true, description="订单ID")
* @ApiParams (name="phone", type="string", required=true, description="手机号")
* @ApiParams (name="wxnum", type="string", required=false, description="微信号")
* @ApiParams (name="content", type="string", required=true, description="评价内容")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
'id'://投诉ID
}
})
*/
public function complaint()
{
$param = $this->request->param();
$param['user_id'] = $this->getUserId();
$validate = new Validate([
'teacher_id' => 'require',
'order_id' =>'require',
'phone' => 'require',
'content' => 'require',
]);
if (!$validate->check($param)) {
$this->error($validate->getError());
}
$param['createtime'] = time();
$data = Db::name('complaint')->insertGetId($param);
if(empty($data)){
$this->error('失败');
}else{
Db::name('order')
->where('id',$param['order_id'])
->update(['is_complaint'=>1,'finish_status'=>4]);
$res = Db::name('order')
->where('id',$param['order_id'])
->find();
// 群组禁言
$return = rongyun_ban($res);
Log::write(date('Y-m-d H:i') . '添加指定群组全部禁言成功,返回结果:' . $res['chat_id'] . json_encode($return, JSON_UNESCAPED_UNICODE), 'rongyun_log');
$this->success('投诉成功',['id'=>$data]);
}
}
/**
* @ApiTitle (投诉详情)
* @ApiSummary (投诉详情)
* @ApiMethod (POST)
* @ApiRoute (/api/teacher/detail)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="order_id", type="int", required=true, description="订单ID")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
"id": //投诉id,
"user_id"://用户ID
"teacher_id"://老师ID
"order_id"://订单ID
"wxnum"://微信号
"createtime"://创建时间
"content"://投诉理由
"phone"://手机号
}
})
*/
public function detail()
{
$user_id = $this->getUserId();
$order_id = $this->request->param('order_id');
if(empty($order_id)){
$this->error('缺少必要参数');
}
$data = Db::name('complaint')
->where('order_id',$order_id)
->find();
$this->success('success',$data);
}
/**
* @ApiTitle (老师总结)
* @ApiSummary (老师总结)
* @ApiMethod (POST)
* @ApiRoute (/api/teacher/summarize)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiParams (name="order_id", type="int", required=true, description="订单ID")
* @ApiParams (name="background", type="string", required=true, description="背景")
* @ApiParams (name="questions", type="string", required=false, description="问题")
* @ApiParams (name="Research", type="string", required=true, description="调研")
* @ApiParams (name="analyze", type="string", required=true, description="分析")
* @ApiParams (name="conclusion", type="string", required=true, description="结论")
* @ApiParams (name="plana", type="string", required=true, description="方案一")
* @ApiParams (name="planb", type="string", required=true, description="方案二")
* @ApiParams (name="planc", type="string", required=false, description="方案三")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1571492001",
"data": {
'id'://总结ID
}
})
*/
public function summarize()
{
$param = $this->request->param();
// $param['user_id'] = $this->getUserId();
$validate = new Validate([
'order_id'=>'require',
'background' => 'require',
'questions' => 'require',
'Research' => 'require',
'analyze'=>'require',
'conclusion'=>'require',
'plana'=>'require',
]);
if (!$validate->check($param)) {
$this->error($validate->getError());
}
$param['createtime'] = time();
$data = Db::name('summarize')->insertGetId($param);
if(empty($data)){
$this->error('失败');
}else{
Db::name('order')->where('id',$param['order_id'])->update(['finish_status'=>3]);
$this->success('success',['id'=>$data]);
}
}
}