UsersController.php 2.0 KB
<?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,'用户尚未使用设备');
        }
    }



}