<?php
namespace app\task\controller;
use think\facade\Cache;
use app\shared\model\Electricity;
//门锁回调
class Index
{

    public function index(){
        $data = input();
        Cache::set('qingqiu','请求'.date('Y-m-d H:i:s'));
        if($data){
            if(isset($data['DEVICEID'])){
                 $lockid=$data['DEVICEID'];
                 Cache::set('suoshuju','数据'.json_encode($data));
                 Cache::set('jieshoudeshuju','接收'.date('Y-m-d H:i:s'));
                 $form=Electricity::where(['lockid'=>$lockid])->where('start_time','<',time())->where('end_time','>',time())->find();
                 if($form){
                     Cache::set('renwuid','任务ID'.date('Y-m-d H:i:s').'--'.$form->id);
                    $task=new \app\shared\controller\Task();
                    $task->handle($form->id);
                    
                 }else{
                     Cache::set('shebeiid','设备'.date('Y-m-d H:i:s').'--'.$lockid);
                 }
            }
        }
        exit(json_encode(['result'=>0]));
    }
    public function test(){
         
    }
}