UsersController.php
2.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
<?php
/**
* Created by PhpStorm.
* User: ruidiudiu
* Date: 2018/11/23
* Time: 18:26
*/
namespace app\portal\controller;
use cmf\controller\HomeBaseController;
use think\Db;
/**
* @title 用户相关接口
* @description 用户相关接口
* @group 用户相关接口
*/
class UsersController extends HomeBaseController{
/**
* @title 状态验证
* @description 开锁前判断是否有未支付订单与是否提交押金
* @author 董瑞恩
* @url /portal/users/lock_check
* @method GET
*
* @param name:users_id type:String require:1 default:无 other: desc:用户id
*/
public function lock_check(){
$users_id=$this->request->param('users_id');
//获取提交押金的状态
$users=Db::name('users')->where('id',$users_id)->find();
if ($users['is_deposit']===1){
if ($users['is_use']==1){
$this->apiResponse(303,'用户正在使用设备');
}else{
$order=Db::name('order')->where(['users_id'=>$users_id,'state'=>2])->find();
if (empty($order)){
$this->apiResponse(200,'验证通过');
}else{
$this->apiResponse(302,'有未支付订单');
}
}
}else{
$this->apiResponse(301,'未支付押金');
}
}
/**
* @title 用户使用状态验证
* @description 判断用户当前是否在使用设备
* @author 董瑞恩
* @url /portal/users/isUse
* @method GET
*
* @param name:users_id type:String require:1 default:无 other: desc:用户id
*/
public function isUse(){
$users_id=$this->request->param('users_id');
$users=Db::name('users')->where('id',$users_id)->find();
if ($users['is_use']==1){
$this->apiResponse(200,'用户正在使用设备');
}else{
$this->apiResponse(301,'用户尚未使用设备');
}
}
}