[]]); } public function lamp(){ $orderSn = request()->get('order_sn'); return DevicesService::make()->catchLamp($orderSn); } public function lamp1(){ $colors = ['黄色','红色','绿色','白色']; shuffle($colors); $data = [ 'CommandType'=> 'OpenLed', // 执行命令方式:OpenLed-开灯,CloseLed-关灯,QuitStatus-查询状态 'MD'=> 1, // 机器号设备号 'MDPORT'=> 1, // 设备端口:暂与设备号一致 'LEDID'=> 4, // 亮灯灯号1-498对应1号设备,498后为设备2 'Color'=> urlencode($colors[0]), // 颜色 'OrderNo'=> 'G202107152132315', // 订单号 ]; $dataStr = []; foreach($data as $k => $v){ $dataStr[] = $k.'='.$v; } // 调用亮灯接口处理 $dataStr = implode('&', $dataStr); var_dump($dataStr); $headers = ["Content-Type: application/x-www-form-urlencoded; charset=UTF-8"]; $apiUrl = ConfigService::make()->getConfigByCode('gd_api_url').'/LEDControl.ashx'; $result = httpHeaderRequest($apiUrl, $dataStr,'post',$headers,'text'); var_dump($result); return $result; } /** * 支付回调 */ public function pay($scene){ $postData = request()->all(); $sign = request()->headers->get('Wechatpay-Signature'); $nonce = request()->headers->get('Wechatpay-Nonce'); $timestamp = request()->headers->get('Wechatpay-Timestamp'); $body = file_get_contents('php://input'); $id = isset($postData['id'])? '_'.$postData['id'] : ''; RedisService::set('caches:payments:'.$scene.':result'.$id.'_'.date('YmdHis'), ['result'=> $postData,'sign'=> $sign,'date'=> date('Y-m-d H:i:s')], 7200); $postData = isset($postData['resource'])? $postData['resource'] : []; if(empty($scene) || empty($postData)){ return NotifyService::make()->rebackMsg('回调参数错误'); } // 解密 $signStr = "{$timestamp}\n{$nonce}\n{$body}\n"; $ciphertext = isset($postData['ciphertext'])? $postData['ciphertext'] : ''; RedisService::set('caches:payments:'.$scene.':result'.$id.'_ciphertext', ['result'=> $postData,'date'=> date('Y-m-d H:i:s')], 7200); if(empty($ciphertext)){ return NotifyService::make()->rebackMsg('解密数据不存在'); } $postData = WechatService::decryptNotifyData($postData); $postData = $postData? json_decode($postData, true) : []; // var_dump($postData); $outTradeNo = isset($postData['out_trade_no']) ? $postData['out_trade_no'] : ''; if(empty($postData) || empty($outTradeNo)){ return NotifyService::make()->rebackMsg('获取解密数据失败'); } RedisService::set('caches:payments:'.$scene.':result'.$id.'_'.$outTradeNo, ['result'=> $postData], 7200); RedisService::set('caches:payments:'.$scene.':check'.$id.'_'.$outTradeNo, ['data'=> $postData,'signStr'=> $signStr,'sign'=> $sign], 3600); if (WechatService::checkJsapiNotifyV3($signStr, $sign, $postData)) { switch($scene){ case 'index': // 供灯订单 return NotifyService::make()->notifyGongdeng($postData, $outTradeNo); case 'recharge': // 充值 break; default: break; } } return 'fail'; } public function baward(){ $id = request('id', ''); $api = request('code',''); $apiUrl = 'http://18.166.54.98'; $webApiUrl = 'http://18.166.54.98:5666'; $sdate = request('sdate', '2021-07-14'); if(empty($id) || empty($api) || empty($sdate)){ return false; } $url = $webApiUrl.'/home/get_history?fdate='.$sdate.'&id='.$api; $results = file_get_contents($url); $datas = $results? json_decode($results, true) : []; $datas = isset($datas[0]['data'])? $datas[0]['data'] : []; $awards = []; //var_dump($datas); if($datas){ foreach ($datas as $v) { $cycleid = isset($v['qihao'])? $v['qihao'] : ''; $balls = isset($v['jg'])? $v['jg'] : ''; $stime = isset($v['time'])? $v['time'] : ''; //if(!AwardModel::where(['Number'=> $cycleid])->value('id')){ $awards[$cycleid] = [ 'Sid'=> $id, 'DateTIme'=> $stime, 'Number'=> $cycleid, 'Data'=> $balls, ]; // } } } ksort($awards); $awards = array_values($awards); //AwardModel::insert($awards); echo '
';
        var_dump($awards);
    }

    public function award(){
       /*$lotterys = LotteryModel::where(['State'=> 1])
           ->where('Pid','>', 0)
           ->select(['id','title','api','model'])
           ->get()
           ->toArray();*/

        $id = request('id', '');
        $api = request('code','');
        $type = request('type',0);
        $apiUrl = 'http://18.166.54.98';
        $webApiUrl = 'http://18.166.54.98:5666';
        $sdate = request('sdate', '2021-07-14');
        if(empty($id) || empty($api) || empty($sdate)){
            return false;
        }
        
        $baseUrl = "https://168api.vip/index.php?controller=Apiac_Lotrs&action=findLotRs&uid=61258&mkey=96396ae0d51ef0740236fb7256e4e8f7&code=".$api.'&pt=nav';
        /*if($id==76){
            $url = $baseUrl.'&sdate='.$sdate;
        }else if($id==91) {
            $url = $baseUrl.'&sdate='.$sdate;
        }else if($id==75) {
            $url = $baseUrl.'&sdate=' . $sdate;
        }else if($id==104) {
            $url = $baseUrl.'&sdate='. $sdate;
        }else if($id==105) {
            $url = $baseUrl.'&sdate=' . $sdate;
        }else if($id==92){
            $url = $apiUrl.'/api/award/index.php?mkey=DfhHGF7USHGVFDKJNX3454AHDc&code='.$api;
        }else if($id>=78 && $id<=120){
            $url = $baseUrl;
        }else if($id == 48 || $id == 75 || $id == 76 || $id == 78){
            $url = $baseUrl.'?date='.date('Y', time());
        }else if ($id == 8){
            $url = $baseUrl.'&sdate='.$sdate;
        }else if ($id == 77){
            $Date = date('Y',time());
            $url = "{$webApiUrl}/home/six_history?year=".$Date.'>ype=1';
        }else{
            $url = $webApiUrl.'/home/get_today?id='.$id;
        }*/

        $url = $baseUrl.'&sdate='.$sdate;

       // echo $url."
"; $results = httpRequest($url,'','get'); $datas = isset($results['data'])?$results['data'] : []; $awards = []; if($datas){ foreach ($datas as $v) { $cycleid = isset($v['cycleid'])? $v['cycleid'] : ''; $balls = isset($v['balls'])? $v['balls'] : ''; $stime = isset($v['stime'])? $v['stime'] : ''; if($type == 1){ $d = explode('-', $cycleid); $cycleid = isset($d[1])? $d[1] : $cycleid; }else if($type == 2){ $cycleid = str_replace('-','', $cycleid); } //if(!AwardModel::where(['Number'=> $cycleid])->value('id')){ $awards[$cycleid] = [ 'Sid'=> $id, 'DateTIme'=> $stime, 'Number'=> $cycleid, 'Data'=> $balls, ]; // } } } ksort($awards); $awards = array_values($awards); //AwardModel::insert($awards); echo '
';
        var_dump($awards);


    }

}