IndexController.php
24.5 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
<?php
namespace api\home\controller;
use api\home\model\ToolsModel;
use api\home\service\ToolsService;
use cmf\controller\RestBaseController;
use think\Db;
/**
* @title 会员端-瑜伽房
*/
class IndexController extends RestBaseController
{
/**
* @title 首页
* @description 瑜伽房-首页接口
* @author Pan Haowen
* @url /home/index/index
* @method POST
* @header name:XX-Token require:1 default: desc:token
* @param name:city type:varchar require:0 desc:搜索条件
* @param name:jing type:varchar require:0 desc:经度
* @param name:wei type:varchar require:0 desc:纬度
* @return jieshao:首页介绍
* @return room:场所列表
*/
public function index()
{
$userId = $this->getUserId();
$param = $this->request->param();
$where['delete_time'] = null;
$where['city'] = '北京';
if (!empty($param['jing']) && !empty($param['wei'])) {
Db::name('user')->where('id', $userId)->update(['jing' => $param['jing'], 'wei' => $param['wei']]);
}
if (!empty($param['city'])) {
$where['city'] = $param['city'];
}
$data['jieshao'] = Db::name('config')->where('id', 1)->find()['jieshao'];
$data['thumbnail'] = cmf_get_image_preview_url(Db::name('config')->where('id', 1)->find()['thumbnail']);
$data['room'] = Db::name('room')->where($where)->order('create_time', 'desc')->select()->toArray();
//距离计算
$user = Db::name('user')->where('id', $userId)->find();
foreach ($data['room'] as $k => $v) {
$distance=new ToolsService();
$dis=$distance->distance($user['jing'],$user['wei'],$data['room'][$k]['lng'],$data['room'][$k]['lat']);
if($dis<1000){
$dis=floor($dis).'m';
}else{
$dis=round(($dis/1000),1).'km';
}
$data['room'][$k]['distance'] = $dis;
//图片处理
$data['room'][$k]['thumbnail'] = cmf_get_image_preview_url($data['room'][$k]['thumbnail']);
}
$this->success("获取数据成功", $data);
}
/**
* @title 场所详情
* @description 场所详情接口
* @author Pan Haowen
* @url /home/index/room
* @method POST
* @header name:XX-Token require:1 default: desc:token
* @param name:room_id type:int require:1 desc:场所id
* @param name:time type:int require:0 desc:筛选课程时间戳
* @return room:场所详情
* @return class:该场所课程
*/
public function room()
{
$userId = $this->getUserId();
$param = $this->request->param();
$data['room'] = Db::name('room')->where('id', $param['room_id'])->find();
//图片处理
$data['room']['thumbnail'] = cmf_get_image_preview_url($data['room']['thumbnail']);
//距离计算
$distance=new ToolsService();
$user = Db::name('user')->where('id', $userId)->find();
$dis=$distance->distance($user['jing'],$user['wei'],$data['room']['lng'],$data['room']['lat']);
if($dis<1000){
$dis=floor($dis).'m';
}else{
$dis=round(($dis/1000),1).'km';
}
$data['room']['distance'] = $dis;
//根据时间计算课程
$where['c.delete_time'] = null;
$where['c.status']=1;
$where['p.delete_time'] = null;
$where['c.room_id'] = $param['room_id'];
if (!empty($param['time'])) {
$time1=$param['time'];
$time2=strtotime('+1 month',$param['time']);
$where['c.start_time'] = [['>= time',intval($time1) ], ['< time',$time2]];
}
else {
$where['c.start_time'] = [['>= time', strtotime('+1 month', strtotime(date('Y-m', time())))], ['< time', strtotime('+2 month', strtotime(date('Y-m', time())))]];
}
$data['class'] = Db::name('class')
->alias('c')
->join('product p', 'c.product_id=p.id')
->where($where)
// ->where(['c.start_time'=>[['>= time',intval($param['time'])], ['<= time',$time2]]])
->group('c.product_id')
->field('p.*,c.room_id,count(*) as count')
->select()
->each(function ($item) {
$item['thumbnail'] = cmf_get_image_preview_url($item['thumbnail']);
return $item;
});
$this->success("获取数据成功", $data);
}
/**
* @title 教室列表
* @description 教室列表接口
* @author Pan Haowen
* @url /home/index/ClassRoom
* @method POST
* @header name:XX-Token require:1 default: desc:token
* @param name:room_id type:int require:1 desc:场所id
* @return data:教室列表
*/
public function ClassRoom()
{
$this->getUserId();
$param = $this->request->param();
$data = Db::name('class_room')->where('room_id', $param['room_id'])->select()->each(function ($item) {
$item['thumbnail'] = cmf_get_image_preview_url($item['thumbnail']);
return $item;
});
$this->success("获取数据成功", $data);
}
/**
* @title 计划产品
* @description 计划产品
* @author Pan Haowen
* @url /home/index/Class
* @method POST
* @header name:XX-Token require:1 default: desc:token
* @param name:product_id type:int require:1 desc:产品id
* @param name:room_id type:int require:1 desc:场所id
* @param name:time type:int require:0 desc:筛选课程时间戳
* @return room:场所信息
* @return product:产品信息
* @return tuan:团课教程
* @return si:私课教程
*/
public function Class()
{
$userId = $this->getUserId();
$param = $this->request->param();
//场所信息
$data['room'] = Db::name('room')->where('id', $param['room_id'])->field('id,name,lat,lng,location')->find();
$distance=new ToolsService();
$user = Db::name('user')->where('id', $userId)->find();
$dis=$distance->distance($user['jing'],$user['wei'],$data['room']['lng'],$data['room']['lat']);
if($dis<1000){
$dis=floor($dis).'m';
}else{
$dis=round(($dis/1000),1).'km';
}
$data['room']['distance'] = $dis;
//产品信息
$data['product'] = Db::name('product')->where('id', $param['product_id'])->find();
$data['product']['thumbnail'] = cmf_get_image_preview_url($data['product']['thumbnail']);
//根据时间计算课程
$where['delete_time'] = null;
$where['room_id'] = $param['room_id'];
$where['product_id'] = $param['product_id'];
if (!empty($param['time'])) {
$where['start_time'] = [['>= time', intval($param['time'])], ['< time', strtotime('+1 month', $param['time'])]];
} else {
$where['start_time'] = [['>= time', strtotime('+1 month', strtotime(date('Y-m', time())))], ['< time', strtotime('+2 month', strtotime(date('Y-m', time())))]];
}
//团教课程
$data['tuan'] = Db::name('class')
->where($where)
->where(['type'=>1,'status'=>1])
->limit(2)
->select()
->each(function ($item) {
$item['avatar'] = Db::name('user_class_apply')->where(['class_id' => $item['id'], 'status' => 1])->limit(4)->select()->each(function ($item2) {
$user = Db::name('user')->where('id', $item2['user_id'])->find();
$item2['avatar'] = cmf_get_image_preview_url($user['avatar']);
$item2['user_name'] = $user['user_nickname'];
return $item2;
});
return $item;
});
//私教课程
$data['si'] = Db::name('class')
->where($where)
->where(['type'=>2,'status'=>1])
->limit(2)
->select()
->each(function ($item) {
$coach_id = Db::name('coach_class_apply')->where(['class_id' => $item['id'], 'status' => 1])->find()['coach_id'];
$coach = Db::name('coach')->where('id', $coach_id)->find();
$item['avatar'] = cmf_get_image_preview_url($coach['avatar']);
$item['coach_name'] = $coach['name'];
return $item;
});
$this->success("获取数据成功", $data);
}
/**
* @title 课程详情
* @description 课程详情
* @author Pan Haowen
* @url /home/index/ClassDetail
* @method POST
* @header name:XX-Token require:1 default: desc:token
* @param name:class_id type:int require:1 desc:课程id
* @param name:room_id type:int require:1 desc:场所id
* @param name:product_id type:int require:1 desc:产品id
* @return room:场所信息
* @return product:产品信息
* @return config:教学内容与激励政策
* @return coach:教练信息
* @return user:用户信息
* @return class:课程详情
*/
public function ClassDetail()
{
$userId = $this->getUserId();
$param = $this->request->param();
//场所信息
$data['room'] = Db::name('room')->where('id', $param['room_id'])->field('id,name,lat,lng,location')->find();
$distance=new ToolsService();
$user = Db::name('user')->where('id', $userId)->find();
$dis=$distance->distance($user['jing'],$user['wei'],$data['room']['lng'],$data['room']['lat']);
if($dis<1000){
$dis=floor($dis).'m';
}else{
$dis=round(($dis/1000),1).'km';
}
$data['room']['distance'] = $dis;
//产品信息
$data['product'] = Db::name('product')->where('id', $param['product_id'])->find();
$data['product']['thumbnail'] = cmf_get_image_preview_url($data['product']['thumbnail']);
//教学内容与激励信息
$data['config'] = Db::name('config')->where('id', 1)->field('jiaoxue,jili,tuanke,sike')->find();
$data['config']['tuanke']=cmf_replace_content_file_url(htmlspecialchars_decode($data['config']['tuanke']));
$data['config']['sike']=cmf_replace_content_file_url(htmlspecialchars_decode($data['config']['sike']));
$data['config']['jiaoxue']=cmf_replace_content_file_url(htmlspecialchars_decode($data['config']['jiaoxue']));
$data['config']['jili']=cmf_replace_content_file_url(htmlspecialchars_decode($data['config']['jili']));
//教练信息
$data['coach'] = Db::name('coach_class_apply')
->alias('cca')
->join('coach c', 'cca.coach_id=c.id')
->where(['cca.status' => 1, 'cca.class_id' => $param['class_id']])
->field('c.id,c.avatar,c.create_time,c.name,c.mobile')
->select()
->each(function ($item) {
$item['star'] = Db::name('user_coach_class')
->alias('ucc')
->join('coach_class cc', 'ucc.coach_class_id=cc.id')
->where(['ucc.status' => 1, 'cc.coach_id' => $item['id']])
->avg('ucc.star');
$item['create_time'] = date('Y/m/d', $item['create_time']);
$item['avatar'] = cmf_get_image_preview_url($item['avatar']);
return $item;
});
//课程详情
$data['class'] = Db::name('class')->where('id', $param['class_id'])->find();
$data['class']['people'] = Db::name('user_class_apply')->where(['class_id' => $param['class_id'], 'status' => 1])->count();
$data['class']['money']=Db::name('coach_class')->where(['class_id' => $param['class_id'], 'status' => 0])->count()*$data['class']['price'];
if ($data['class']['people'] < $data['class']['min_people']) {
$data['class']['need_people'] = $data['class']['min_people'] - $data['class']['people'];
}
if ($data['class']['type']==1) {
//课表
$date=Db::name('coach_class')
->alias('cc')
->join('coach c','cc.coach_id=c.id')
->where(['cc.status'=>0,'cc.class_id'=>$param['class_id']])
->field('cc.start_time')
->select()->each(function ($item3) {
$item3['choose']=date('j',$item3['start_time']);
return $item3;
})->toArray();
//日历渲染
$j = date("t",$data['class']['start_time']); //获取当前月份天数
$array = array();
for($i=0;$i<$j;$i++){
$choose = 0;
$plan='';
foreach ($date as $k=>$v){
if ($date[$k]['choose']==($i+1)){
$choose = 1;
$plan=$k;
}
}
$array[]=['day'=>$i+1,'choose'=>$choose,'plan'=>$plan];
}
$data['time']=date('Y年m月',$data['class']['start_time']);
$data['date']=$array;
//日期计划
$data['plan']=Db::name('coach_class')
->alias('cc')
->join('coach c','cc.coach_id=c.id')
->where(['cc.status'=>0,'cc.class_id'=>$param['class_id']])
->field('cc.*,c.name')
->select()->each(function ($item2) {
$item2['time']=date('H:i',$item2['start_time']).'-'.date('H:i',$item2['end_time']);
return $item2;
});
// $data['plan'] = Db::name('coach_class')
// ->alias('cc')
// ->join('coach c', 'cc.coach_id=c.id')
// ->where(['cc.class_id' => $param['class_id'], 'cc.status' => 0])
// ->field('cc.start_time,cc.end_time,cc.id,c.name')
// ->select()
// ->each(function ($item) {
// $item['start_time'] = date('Y-m-d H:i:s',$item['start_time']);
// $item['end_time'] = date('Y-m-d H:i:s',$item['end_time']);
// return $item;
// });
}elseif ($data['class']['type']==2){
//用户
$data['user']=Db::name('user_class_apply')
->alias('ucc')
->join('user u','ucc.user_id=u.id')
->where(['ucc.class_id' => $param['class_id'], 'ucc.status' => 1])
->field('u.avatar,u.user_nickname')
->select()
->each(function ($item) {
$item['avatar'] = cmf_get_image_preview_url($item['avatar']);
return $item;
});
}
$this->success("获取数据成功", $data);
}
/**
* @title 已加入会员
* @description 获取已加入课程的会员
* @author Pan Haowen
* @url /home/index/ClassUser
* @method POST
* @header name:XX-Token require:1 default: desc:token
* @param name:class_id type:int require:1 desc:课程id
*/
public function ClassUser(){
$this->getUserId();
$param=$this->request->param();
$data=Db::name('user_class_apply')
->alias('ucc')
->join('user u','ucc.user_id=u.id')
->where(['ucc.class_id' => $param['class_id'], 'ucc.status' => 1])
->field('u.avatar,u.user_nickname')
->select()
->each(function ($item) {
$item['avatar'] = cmf_get_image_preview_url($item['avatar']);
return $item;
});
$this->success('操作成功',$data);
}
/**
* @title 加入课程
* @description 加入课程操作
* @author Pan Haowen
* @url /home/index/ClassApply
* @method POST
* @header name:XX-Token require:1 default: desc:token
* @param name:class_id type:int require:1 desc:课程id
*/
public function ClassApply(){
$userId=$this->getUserId();
$param=$this->request->param();
$user=Db::name('user')->where('id',$userId)->find();
if (empty($user['name'])||empty($user['mobile'])||empty($user['number'])){
$this->error(['code'=>40001,'msg'=>'请完善个人信息']);
}
if (Db::name('user_class_apply')->where(['user_id'=>$userId,'status'=>0,'class_id'=>$param['class_id']])->find()){
$this->error(['code'=>40002,'msg'=>'申请审核中']);
}
Db::name('user_class_apply')->insert(['user_id'=>$userId,'create_time'=>time(),'class_id'=>$param['class_id']]);
$this->success('操作成功');
}
/**
* @title 计划订单
* @description 计划订单页面1
* @author Pan Haowen
* @url /home/index/ClassPlan
* @method POST
* @header name:XX-Token require:1 default: desc:token
* @param name:time type:int require:0 desc:时间搜索条件
* @return data:计划订单信息
*/
public function ClassPlan(){
$userId=$this->getUserId();
$param=$this->request->param();
$where=[];
// if (!empty($param['time'])) {
$where['c.start_time'] = [['>= time', intval($param['time'])], ['< time', strtotime('+1 month', $param['time'])]];
// } else {
// $where['c.start_time'] = [['>= time', strtotime('+1 month', strtotime(date('Y-m', time())))], ['<= time', strtotime('+2 month', strtotime(date('Y-m', time())))]];
// }
$data=Db::name('user_class_apply')
->alias('uca')
->join('class c','uca.class_id=c.id')
->join('product p','c.product_id=p.id')
->join('room r','c.room_id=r.id')
->where(['c.delete_time'=>null,'uca.user_id'=>$userId])
->where($where)
->field('p.name as pname,c.*,uca.status,r.name as rname')
->select()
->each(function ($item) {
$item['rname']=$item['rname'].'/'.$item['pname'];
if ($item['type']==1) {
$item['avatar'] = Db::name('coach_class_apply')
->alias('cca')
->join('coach c', 'cca.coach_id=c.id')
->where(['cca.status' => 1, 'cca.class_id' => $item['id']])
->field('c.id,c.avatar,c.name,c.mobile')
->limit(4)
->select()->each(function ($item2) {
$item2['avatar']=cmf_get_image_preview_url($item2['avatar']);
return $item2;
});
}elseif ($item['type']==2){
$item['avatar'] = Db::name('coach_class_apply')
->alias('cca')
->join('coach c', 'cca.coach_id=c.id')
->where(['cca.status' => 1, 'cca.class_id' => $item['id']])
->field('c.id,c.avatar,c.name,c.mobile')
->find();
$item['avatar']['avatar'] = cmf_get_image_preview_url($item['avatar']['avatar']);
}
return $item;
});
$new_arr=array();
$re=array();
foreach($data as $k=>$v ){
$new_arr[$v['rname']][] = $v;
}
foreach($new_arr as $k=>$v ){
$re[]=['name'=>$k,'data'=>$v];
}
$this->success('获取数据成功',$re);
}
/**
* @title 独立获取时间
* @description 独立获取时间
* @author Pan Haowen
* @url /home/index/getTime
* @method POST
* @return data:时间信息
*/
public function getTime(){
$date=date('Y-m',time());
$timestamp=strtotime($date);
$arr=getdate($timestamp);
$firstday=date('Y-n-01',strtotime(date('Y',$timestamp).'-'.(date('m',$timestamp)+1).'-01'));
$firstday1=date('Y年n月',strtotime(date('Y',$timestamp).'-'.(date('m',$timestamp)+1).'-01'));
$secondday=date('Y-n-01',strtotime(date('Y',$timestamp).'-'.(date('m',$timestamp)+2).'-01'));
$secondday1=date('Y年n月',strtotime(date('Y',$timestamp).'-'.(date('m',$timestamp)+2).'-01'));
$thirdday=date('Y-n-01',strtotime(date('Y',$timestamp).'-'.(date('m',$timestamp)+3).'-01'));
$thirdday1=date('Y年n月',strtotime(date('Y',$timestamp).'-'.(date('m',$timestamp)+3).'-01'));
if($arr['mon'] == 12){
$year=$arr['year'] +1;
$firstday=$year.'-01-01';
$firstday1=$year.'年1月';
$secondday=$year.'-02-01';;
$secondday1=$year.'年2月';
$thirdday=$year.'-03-01';;
$thirdday1=$year.'年3月';
}elseif($arr['mon'] == 11){
$year=$arr['year'] +1;
$secondday=$year.'-01-01';;
$secondday1=$year.'年1月';
$thirdday=$year.'-02-01';;
$thirdday1=$year.'年2月';
}
elseif($arr['mon'] == 10){
$year=$arr['year'] +1;
$thirdday=$year.'-01-01';;
$thirdday1=$year.'年1月';
}
$data1['date']=$firstday1;
$data1['time']=strtotime($firstday);
$data2['date']=$secondday1;
$data2['time']=strtotime($secondday);
$data3['date']=$thirdday1;
$data3['time']=strtotime($thirdday);
$data[]=$data1;
$data[]=$data2;
$data[]=$data3;
$this->success('获取数据成功',$data);
}
/**
* @title 独立获取时间(包含本月的后三个月)
* @description 独立获取时间
* @author Pan Haowen
* @url /home/index/getTime2
* @method POST
* @return data:时间信息
*/
public function getTime2(){
$date=date('Y-m',time());
$timestamp=strtotime($date);
$arr=getdate($timestamp);
$firstday=date('Y-n-01',strtotime(date('Y',$timestamp).'-'.date('m',$timestamp).'-01'));
$firstday1=date('Y年n月',strtotime(date('Y',$timestamp).'-'.date('m',$timestamp).'-01'));
$secondday=date('Y-n-01',strtotime(date('Y',$timestamp).'-'.(date('m',$timestamp)+1).'-01'));
$secondday1=date('Y年n月',strtotime(date('Y',$timestamp).'-'.(date('m',$timestamp)+1).'-01'));
$thirdday=date('Y-n-01',strtotime(date('Y',$timestamp).'-'.(date('m',$timestamp)+2).'-01'));
$thirdday1=date('Y年n月',strtotime(date('Y',$timestamp).'-'.(date('m',$timestamp)+2).'-01'));
if($arr['mon'] == 12){
$year=$arr['year'] +1;
$secondday=$year.'-01-01';;
$secondday1=$year.'年1月';
$thirdday=$year.'-02-01';;
$thirdday1=$year.'年2月';
}elseif($arr['mon'] == 11){
$year=$arr['year'] +1;
$thirdday=$year.'-01-01';;
$thirdday1=$year.'年1月';
}
$data[]=['date'=>$firstday1,'time'=>strtotime($firstday)];
$data[]=['date'=>$secondday1,'time'=>strtotime($secondday)];
$data[]=['date'=>$thirdday1,'time'=>strtotime($thirdday)];
$this->success('获取数据成功',$data);
}
/**
* @title 独立获取时间(包含本月的前三个月)
* @description 独立获取时间
* @author Pan Haowen
* @url /home/index/getTime3
* @method POST
* @return data:时间信息
*/
public function getTime3(){
$thismonth = date('n');
$thisyear = date('Y');
$lastmonth1 = $thismonth - 1;
$lastmonth2 = $thismonth - 2;
$lastyear1 = $thisyear;
$lastyear2 = $thisyear;
if ($thismonth == 1) {
$lastmonth1 = 12;
$lastmonth2 = 11;
$lastyear1 = $thisyear - 1;
$lastyear2 = $thisyear - 1;
}elseif ($thismonth == 2){
$lastmonth1 = 1;
$lastmonth2 = 12;
$lastyear2 = $thisyear - 1;
}
$lastStartDay = $thisyear . '-' . $thismonth . '-1';
$lastStartDay1 = $lastyear1 . '-' . $lastmonth1 . '-1';
$lastStartDay2 = $lastyear2 . '-' . $lastmonth2 . '-1';
$data[]=['date'=>$lastyear2.'年'.$lastmonth2.'月','time'=>strtotime($lastStartDay2)];
$data[]=['date'=>$lastyear1.'年'.$lastmonth1.'月','time'=>strtotime($lastStartDay1)];
$data[]=['date'=>$thisyear.'年'.$thismonth.'月','time'=>strtotime($lastStartDay)];
$this->success('获取数据成功',$data);
}
/**
* @title 判断用户身份(新)
* @description 判断用户身份(新)
* @author Pan Haowen
* @url /home/index/userType
* @method POST
* @header name:XX-Token require:1 default: desc:token
* @return data:用户身份(1=》会员,2=》教练)
*/
public function userType(){
$userId=$this->getUserId();
$re=Db::name('coach')->where(['user_id'=>$userId,'status'=>1])->find();
if($re){
$type=2;
}else{
$type=1;
}
$this->success('获取数据成功',$type);
}
}